Skip to content

Fix pre_tool_use.py hook to not falsely blocks safe rm#29

Open
cmer wants to merge 1 commit intodisler:mainfrom
cmer:patch-1
Open

Fix pre_tool_use.py hook to not falsely blocks safe rm#29
cmer wants to merge 1 commit intodisler:mainfrom
cmer:patch-1

Conversation

@cmer
Copy link
Copy Markdown

@cmer cmer commented Dec 12, 2025

Fixes #28

Quick sanity check tests

1) Test an allowed rm (should exit 0)

printf '%s' '{"tool_name":"Bash","tool_input":{"command":"rm /Users/me/project/soft-hold-enrollment/db/migrate/a.rb /Users/me/project/soft-hold-enrollment/db/migrate/b.rb"}}' \
  | uv run ~/.claude/hooks/pre_tool_use.py ; echo "exit=$?"

2) Test a blocked dangerous rm (should exit 2 + print BLOCKED)

printf '%s' '{"tool_name":"Bash","tool_input":{"command":"rm -rf /"}}' \
  | uv run ~/.claude/hooks/pre_tool_use.py ; echo "exit=$?"

3) Test .env access blocking (should exit 2)

printf '%s' '{"tool_name":"Bash","tool_input":{"command":"cat .env"}}' \
  | uv run ~/.claude/hooks/pre_tool_use.py ; echo "exit=$?"


if parsing_options and t.startswith("--"):
if t == "--recursive":
has_recursive = True
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( parenthesis) do matter

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.

pre_tool_use.py hook falsely blocks safe rm due to pathname matching -...r...

2 participants