mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
s3_objectlock: scan names that contain a backslash
With backslashes allowed in object keys, a key such as a\b is stored under that name. The scan skipped it, and every key below such a prefix, as if the name were a path separator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
62b393e13c
commit
f889ccc40a
2 files changed
+17
-1
No files matched your search
@@ -95,7 +95,7 @@ func paginateEntries(ctx context.Context, client filer_pb.SeaweedFilerClient, di
|
||||
for _, entry := range page {
|
||||
// Skip invalid entry names to prevent path traversal
|
||||
if entry.Name == "" || entry.Name == "." || entry.Name == ".." ||
|
||||
strings.ContainsAny(entry.Name, "/\\") {
|
||||
strings.Contains(entry.Name, "/") {
|
||||
glog.V(2).Infof("Skipping invalid entry name: %q in %s", entry.Name, dir)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -137,3 +137,19 @@ func TestHasObjectsWithActiveLocksReadsEachPageBeforeSubdirectories(t *testing.T
|
||||
t.Fatalf("expected the held object in the subdirectory to be reported")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasObjectsWithActiveLocksNamesWithBackslashes(t *testing.T) {
|
||||
held := map[string][]byte{s3_constants.ExtLegalHoldKey: []byte(s3_constants.LegalHoldOn)}
|
||||
for name, dirs := range map[string]map[string][]*filer_pb.Entry{
|
||||
"object": {"/buckets/b": {{Name: `a\b`, Extended: held}}},
|
||||
"prefix": {"/buckets/b": {{Name: `a\b`, IsDirectory: true}}, `/buckets/b/a\b`: {{Name: "c", Extended: held}}},
|
||||
} {
|
||||
has, err := HasObjectsWithActiveLocks(context.Background(), &fakeFilerClient{dirs: dirs}, "/buckets/b")
|
||||
if err != nil {
|
||||
t.Fatalf("%s: unexpected error: %v", name, err)
|
||||
}
|
||||
if !has {
|
||||
t.Fatalf("%s: expected the held object with a backslash in its key to be reported", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user