refactor: ScopedFs to avoid escaping symlinks

This commit is contained in:
Henrique Dias committed 2026-06-07 18:16:46 +02:00
1 parent 3406d3d7f9
commit 7c2c0a11b3
15 files changed
+277 -210

No files matched your search

+3 -2
View File
@@ -5,6 +5,7 @@ import (
"path/filepath"
"testing"
"github.com/filebrowser/filebrowser/v2/files"
"github.com/spf13/afero"
)
@@ -31,7 +32,7 @@ func TestCopyDoesNotDereferenceEscapingSymlink(t *testing.T) {
t.Skipf("cannot create symlink: %v", err)
}
afs := afero.NewBasePathFs(afero.NewOsFs(), scope)
afs := files.NewScopedFs(afero.NewOsFs(), scope)
err := Copy(afs, "/srcdir", "/dstdir", 0o644, 0o755)
if err == nil {
@@ -58,7 +59,7 @@ func TestCopyAllowsInScopeSymlink(t *testing.T) {
t.Skipf("cannot create symlink: %v", err)
}
afs := afero.NewBasePathFs(afero.NewOsFs(), scope)
afs := files.NewScopedFs(afero.NewOsFs(), scope)
if err := Copy(afs, "/srcdir", "/dstdir", 0o644, 0o755); err != nil {
t.Fatalf("expected copy of an in-scope symlink to succeed, got: %v", err)