Repository navigation
fix: strip scoped allow rules for guarded tools so they reach can_use_tool - #247
Open
shubhranillayek wants to merge 3 commits into
Open
shubhranillayek wants to merge 3 commits into
shubhranillayek wants to merge 3 commits into
Conversation
…_tool The strip added for overwirehq#219 compared allow rules by exact name, so a scoped rule like Bash(git:*) never matched Bash in the strip set and was passed to the CLI, which pre-approved matching calls and skipped the can_use_tool boundary checks (and the interactive approval prompt). Match rules by the tool they name -- the part before the scope -- instead. Refs overwirehq#244
|
No blocking findings at this head. |
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.
Description
ClaudeSDKManager.execute_commandstrips guarded tools (and tools gated behind interactive approval) fromallowed_toolsso the CLI routes those calls throughcan_use_toolinstead of pre-approving them (#219). The strip compared entries by exact name, so a scoped allow rule such asBash(git:*)orRead(//etc/**)never matchedBash/Readin the strip set and was passed through to the CLI. The CLI pre-approved every call the rule matched, and the boundary checks (and the Telegram approval prompt) never ran -- a rule written to narrow what Claude may do silently removed a security layer.This change matches allow rules by the tool they name -- the part before
(-- when deciding what to strip, via a small_allow_rule_base_namehelper. Stripping a scoped rule does not loosen anything: matching calls now reach the callback, which allows them only if they pass validation, the same treatment bare tool names already get since #219.Related issue
Closes #244
Type of change
How it was tested
make testandmake lintpass locallytests/unit/test_claude/test_scoped_allow_rules.pycover scoped rules for guarded tools (stripped), scoped rules for approval-gated tools (stripped), and scoped rules for unguarded tools (kept). Full unit suite: 692 passed. black, isort and flake8 clean on the changed files.Checklist
CHANGELOG.mdhas an entry under[Unreleased]pyproject.tomldependencies changed,poetry lockwas run and the updatedpoetry.lockis committed (no dependency changes in this PR)README.md,docs/,.env.example,CLAUDE.md) where settings or commands changed (no settings or commands changed)