From 8661d544066b217ca5f6aca9e0e852aa658a4413 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Thu, 12 Feb 2026 21:58:40 +0800 Subject: [PATCH] * Delete unused file --- pkg/tools/filesystem_test.go | 92 ------------------------------------ 1 file changed, 92 deletions(-) delete mode 100644 pkg/tools/filesystem_test.go diff --git a/pkg/tools/filesystem_test.go b/pkg/tools/filesystem_test.go deleted file mode 100644 index a4eacc1..0000000 --- a/pkg/tools/filesystem_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package tools - -import ( - "os" - "path/filepath" - "testing" -) - -func TestValidatePath(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "picoclaw-test-*") - if err != nil { - t.Fatalf("failed to create temp dir: %v", err) - } - defer os.RemoveAll(tmpDir) - - workspace := filepath.Join(tmpDir, "workspace") - os.MkdirAll(workspace, 0755) - - tests := []struct { - name string - path string - workspace string - restrict bool - wantErr bool - }{ - { - name: "Valid relative path", - path: "test.txt", - workspace: workspace, - restrict: true, - wantErr: false, - }, - { - name: "Valid nested path", - path: "dir/test.txt", - workspace: workspace, - restrict: true, - wantErr: false, - }, - { - name: "Path traversal attempt (restricted)", - path: "../test.txt", - workspace: workspace, - restrict: true, - wantErr: true, - }, - { - name: "Path traversal attempt (unrestricted)", - path: "../test.txt", - workspace: workspace, - restrict: false, - wantErr: false, - }, - { - name: "Absolute path inside workspace", - path: filepath.Join(workspace, "test.txt"), - workspace: workspace, - restrict: true, - wantErr: false, - }, - { - name: "Absolute path outside workspace (restricted)", - path: "/etc/passwd", - workspace: workspace, - restrict: true, - wantErr: true, - }, - { - name: "Absolute path outside workspace (unrestricted)", - path: "/etc/passwd", - workspace: workspace, - restrict: false, - wantErr: false, - }, - { - name: "Empty workspace (no restriction)", - path: "/etc/passwd", - workspace: "", - restrict: true, - wantErr: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _, err := validatePath(tt.path, tt.workspace, tt.restrict) - if (err != nil) != tt.wantErr { - t.Errorf("validatePath() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -}