跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

environment_storage_windows_test.go

47 行 · 1.8 KB历史下载
1package workbench
2
3import (
4 "encoding/json"
5 "net/url"
6 "os"
7 "os/exec"
8 "path/filepath"
9 "testing"
10
11 "github.com/sylvinus/agent-vm/internal/mounts"
12)
13
14// NTFS junctions are available to ordinary users. Exercise the same private
15// directory through an unrelated DOS path in both sharing entry points.
16func TestWindowsJunctionCannotExposePrivateDirectory(t *testing.T) {
17 s := testServer(t)
18 parent := t.TempDir()
19 alias := filepath.Join(parent, "环境别名")
20 cmd := exec.Command("cmd.exe", "/d", "/v:off", "/c", "mklink", "/J", alias, s.profile)
21 if out, err := cmd.CombinedOutput(); err != nil {
22 t.Fatalf("create directory junction: %v, %s", err, out)
23 }
24 if err := os.Mkdir(filepath.Join(s.profile, "stored-data"), 0700); err != nil {
25 t.Fatal(err)
26 }
27 for _, dir := range []string{alias, filepath.Join(alias, "stored-data")} {
28 if _, err := validateWorkspace(dir, s.profile); err == nil {
29 t.Fatal("private alias accepted as a workbench project", dir)
30 }
31 if _, denied := mounts.UnsafeProject(dir, mounts.Refs("", "", s.profile)); !denied {
32 t.Fatal("private alias accepted as a CLI share", dir)
33 }
34 if w := request(s, "GET", "/api/projects/directories?path="+url.QueryEscape(dir), "", "", true); w.Code != 403 {
35 t.Fatal("private alias browsable", w.Code)
36 }
37 }
38 visible := filepath.Join(parent, "public")
39 if err := os.Mkdir(visible, 0700); err != nil {
40 t.Fatal(err)
41 }
42 w := request(s, "GET", "/api/projects/directories?path="+url.QueryEscape(parent), "", "", true)
43 var listing struct{ Directories []struct{ Name string } }
44 if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &listing) != nil || len(listing.Directories) != 1 || listing.Directories[0].Name != "public" {
45 t.Fatal("directory picker exposed the private alias or hid the safe sibling", w.Code, w.Body.String())
46 }
47}