refactor(exec,io): 文件沙箱单入口收进 io 工具、删 exec.FileSandbox(裁决 13.4.4)+ 修一条假阳性安全断言

- 删除未接线的 exec.FileSandbox(含 5 个用例):文件沙箱从此只有 plugins/tools/io/file.go 一处实现
- io 侧取更严一侧:NUL 拒绝(原 io 缺)、写前按最深存在祖先判定落点(避免越界建目录)、roots 归化到真实路径(修 roots 自身是 symlink 时的全误拒)
- exec/sandbox.go 保留并注释说明:那是**终端工作目录守卫**的原语(terminal.go 在用),不是文件沙箱
- 修假阳性:原 NUL 用例断言错误文本含 "NUL",而 t.TempDir() 目录名自带测试函数名 "…RejectsNULBytePath…"、错误又内嵌整条临时路径 ⇒ 删掉安全检查用例照样绿。改为哨兵错误 ErrNullByte + errors.Is(错误文本逐字节不变),修复后同一变异必红
- 同类排查:file_test.go 三处文本断言判定无风险(含空格的串不可能出现在临时目录名里),保留
This commit is contained in:
AskaEth committed 2026-10-04 12:29:39 +08:00
1 parent 95f97f5df3
commit 09ee561aa7
6 files changed
+344 -222

No files matched your search

+5 -3
View File
@@ -2,13 +2,15 @@
// Cyrene agent runtime (DevDocs/design/04-运行时.md §8 and design/02-会话与上下文模型.md §4).
//
// A Provider is the grant-based, sandboxed entry point through which the agent
// may run code on its own host. This milestone ships two concrete pieces:
// may run code on its own host. This milestone ships one concrete piece:
//
// - [TerminalExecutor], the default command provider, which runs allowlisted
// commands inside a locked-down terminal sandbox (command allowlist, working
// directory confinement, environment allowlist, timeout, output truncation).
// - [FileSandbox], which confines file read/write/list access to a set of
// allowed root directories.
//
// 文件读写的路径沙箱不在本包:按裁决 13.4.4(design/04 §4),文件访问的 roots
// 收敛、symlink 逃逸与 NUL 拒绝统一由 plugins/tools/io 文件工具承载;本包内
// sandbox.go 的收敛原语只服务于终端沙箱的工作目录 / roots 守卫。
//
// GUI operations and a real virtual machine are reserved for later milestones;
// they surface only through the [Provider] interface and are not implemented