为 Bash 工具引入权限模式,并对齐 C/Go/Rust 实现#33
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
这个 PR 分两部分:
1. Bash 主版本:为 Bash 工具引入权限模式
将 Bash 工具的安全策略从原来的
deny reason规则,重构为BASH_AGENT_BASH_MODE驱动的权限模式。核心模型:
system / external / network / workspaceread=4 / write=2 / execute=1required_moderequired_mode是否被allowed_mode覆盖BASH_AGENT_BASH_MODE统一 fail-closed 为0000同时统一了 Bash 主版本的报错文案:
Error: command blocked by bash safety policy (required=... allowed=...; mode=system/external/network/workspace bits=4:read,2:write,1:execute)2. 多运行时对齐:C / Go / Rust
在 Bash 主版本完成后,将同一套权限模式逻辑同步到:
目标不是“语义接近”,而是:
BASH_AGENT_BASH_MODE04470000required_modeallowed/required得到同一 allow/block 结果具体修改
Bash 主版本
tool_classify_bash_required_modetool_bash_mode_allowsBASH_AGENT_BASH_MODEGo
ToolDenyBashReasonBASH_AGENT_BASH_MODEC
bash_deny_reasonBASH_AGENT_BASH_MODERust
BASH_AGENT_BASH_MODE测试
补强 12-bit 权限测试覆盖,新增对具体 mode 的断言,而不只是检查“是否 blocked”:
required=4000system readrequired=0050network executerequired=0200external writeallowed=0000验证
已验证:
GOCACHE=$PWD/go/.gocache GOMODCACHE=$PWD/go/.gomodcache go -C go test ./...make build-gomake build-c/bin/zsh -lc 'AGENT=./dist/goagent bash tests/test.sh 9902'/bin/zsh -lc 'AGENT=./dist/cagent bash tests/test.sh 9904'结果:
124 passed, 0 failed124 passed, 0 failed补充说明:
make test-rust build-rust test-rust-e2e