fix: scope terminal approval exemptions - #69152
Open
trac3r00 wants to merge 1 commit into
Open
Conversation
teknium1
reviewed
Jul 30, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for narrowing the proposed command shapes and adding negative cases. The recursive-cleanup exemption needs one safety boundary before it can be salvaged.
Problems
tools/approval.py:2009treats every descendant ofHERMES_KANBAN_WORKSPACEas disposable. Kanban explicitly supports preserveddir:andworktreeworkspaces (website/docs/user-guide/features/kanban.md:66-68), so this would auto-allow recursive deletion inside a user source tree. Existing Kanban cleanup deliberately refuses paths outside managed scratch roots (tests/hermes_cli/test_kanban_db.py:2535-2563).- The new cleanup tests exercise
detect_dangerous_command, not the terminal gate that executes the full policy ordering (tools/approval.py:3335).
Suggested changes
- Gate the exemption on verified managed-scratch containment/workspace kind, rather than the task workspace environment variable alone.
- Add
check_all_command_guardscoverage for scratch versus preserved workspaces and for a matchingapprovals.denyrule.
Automated hermes-sweeper review.
| try: | ||
| return os.path.commonpath((workspace, target)) == workspace | ||
| except ValueError: | ||
| return False |
Contributor
There was a problem hiding this comment.
HERMES_KANBAN_WORKSPACE is also used for preserved dir: and worktree tasks, not just disposable scratch tasks (website/docs/user-guide/features/kanban.md:66-68). A descendant-only check would auto-allow rm -rf inside a user source tree. Please require the same managed-scratch containment/workspace-kind proof used by Kanban's automatic cleanup.
This was referenced Aug 1, 2026
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.
Summary
Verification
python -m pytest tests/tools/test_approval.py -q -o "addopts=" -k "KanbanWorkspaceRecursiveCleanup or ReadOnlyProfileConfigInspection or ApprovalTimeoutIsNotConsent"python -m pytest tests/tools/test_tirith_security.py -q -o "addopts="python -m pytest tests/agent/test_tool_guardrails.py -q -o "addopts="python -m py_compile tools/approval.pyKnown baseline: the full
tests/tools/test_approval.pyrun has one pre-existing macOS tempdir canonicalization failure intest_nonrecursive_verification_artifact_cleanup; this PR does not touch that path.