security: harden WebDAV overwrite and multi-root routing

This commit is contained in:
OpenClaw Agent
2026-09-21 21:15:36 +08:00
parent cf62b944f7
commit a9c1ab031b
4 changed files with 122 additions and 9 deletions
@@ -0,0 +1,26 @@
package storage
import (
"os"
"path/filepath"
"testing"
)
func TestNewMultiKeepsDuplicateBasenames(t *testing.T) {
root := t.TempDir()
first := filepath.Join(root, "same")
second := filepath.Join(root, "other", "same")
if err := os.MkdirAll(first, 0o755); err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(second, 0o755); err != nil {
t.Fatal(err)
}
m := NewMulti([]string{first, second})
if len(m.Roots) != 2 || len(m.Names) != 2 {
t.Fatalf("duplicate basename dropped: roots=%d names=%v", len(m.Roots), m.Names)
}
if m.Names[0] != "same" || m.Names[1] != "same-2" {
t.Fatalf("unexpected virtual names: %v", m.Names)
}
}