Skip to content

seatbelt provider - #333

Closed
drscrewdriver wants to merge 8 commits into
AgentEra:mainfrom
drscrewdriver:adapt/seatbelt-provider
Closed

seatbelt provider#333
drscrewdriver wants to merge 8 commits into
AgentEra:mainfrom
drscrewdriver:adapt/seatbelt-provider

Conversation

@drscrewdriver

Copy link
Copy Markdown
Contributor

rewite with supported_kinds = ("code_execution",)

test-bot and others added 8 commits July 29, 2026 21:05
- 新增 SeatbeltExecutionResourceProvider (kind='seatbelt')
- SBPL profile 生成器,支持网络/路径读写隔离
- is_macos() + inspect_seatbelt_availability() 平台检测
- ActionResourceRegistrar._normalize_code_sandbox 支持 'seatbelt'
- 新增 register_seatbelt_sandbox_action() 注册入口
- __init__.py 注册 Seatbelt provider
SBPL Profile 设计改进:
- 基础能力: process-exec*, process-fork, signal, mach(*), ipc-posix*
- 文件读取: 全局允许 (allow file-read*) — AI agent 需要读系统库
- 文件写入: 白名单模式 (writable_paths + temp dirs)
- 受保护路径: protected_paths 禁止写入 (last-match-wins, 覆盖 allow)
- 禁止读取: deny_read_paths 同时禁止读写 (保护 secrets)
- 设备文件: /dev/null, /dev/ptmx, pseudo-tty
- 网络: network-outbound 开关
- realpath 防符号链接绕过

接口变更:
- 移除 read_paths (全局可读)
- 新增 writable_paths (白名单可写)
- 新增 protected_paths (禁止写入, 覆盖 writable_paths)
- 新增 deny_read_paths (禁止读写)
- 移除不存在的 ExecutionResourceProvider 基类继承,改为 duck-typing
- 将 create_handle 重写为 async_ensure/async_health_check/async_release
- 清理文件拼接残留(659→394行)
- TYPE_CHECKING 导入替代运行时导入
- BUG-1: sandbox-exec -f - 不支持 stdin,改用临时文件 + -f
- BUG-2: SBPL 语法 (allow mach(*)) 无效,改为 (allow mach*)
- BUG-3: SBPL 语法 (deny network) 无效,改为 (deny network-outbound)

修复后沙箱可正常执行,6 项可配置限制全部验证通过。
添加 .gitignore 规则忽略本地 TDD 验证资产。
- 恢复 .gitignore 到 main 分支状态
- 添加 tests/test_seatbelt_bugs.py (11 项 TDD 测试)
@Maplemx

Maplemx commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Superseded by #351, merged as 71b111120f94310818a1f6256601702ce330b48d.

The accepted integration branch started from this PR and retains all eight original commits and authors. Maintainer commits then merged current dev, restricted SBPL writes to TaskWorkspace grants, reported the broad-read limitation truthfully, added lifecycle hardening, consolidated docs, and added passing real macOS Seatbelt CI.

Closing because the contribution-preserving integration has landed, not because the contribution lacked value.

@Maplemx Maplemx closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants