Repository navigation
fix(s03): ask for approval when bash touches paths outside the workspace - #601
Open
lienzhendeshuai wants to merge 1 commit into
Open
lienzhendeshuai wants to merge 1 commit into
lienzhendeshuai wants to merge 1 commit into
Conversation
read_file/write_file/edit_file prompt through Gate 2/3 before touching paths outside the workspace, but the same operations through bash ran silently. Add a Gate 2 rule that prompts when a shell command references an absolute path outside the workspace or a ../ escape, following the approval-based boundary contract settled in shareAI-lab#484. /dev/null is exempted as a common output sink. Fixes shareAI-lab#494
This branch has not been deployed
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.
Fixes #494
Problem
read_file/write_file/edit_fileprompt through Gate 2/3 beforetouching paths outside the workspace, but the equivalent operations through
bash(cat /etc/passwd,tar -czf backup.tgz ../project,cd /etc && ...)run silently — no deny, no approval. The three READMEs describe Gate 2 as
covering reads/writes outside the workspace, so the shell path currently
bypasses the user-approval contract.
Solution
Following the approval-based boundary contract settled in #482/#484 (Gate 2
owns the workspace boundary, hard
safe_pathstays out of the handlers), thisadds one Gate 2 rule for
bash:workspace (e.g.
/etc/passwd), or a../relative escape/dev/nullis exempted as a common output sinkstay silent
Allow? [y/N]Gate 3the file tools already use
Changes
s03_permission/code.py: addreferences_outside_workspace()(+ regexes)and one
PERMISSION_RULESentry (+23 lines)tests/test_permission_command_words.py: add 8 cases for the new rule(+41 lines) — outside-workspace commands prompt, inside-workspace absolute
paths and
/dev/nullstay silentTesting
pytest tests/test_permission_command_words.py→ 203 passed(195 pre-existing + 8 new)
mainNotes for Reviewer
teaching chapter); it errs toward asking, never toward silently allowing.
agent; I have read and stand behind every line.