Repository navigation
fix(#570): pre-tool.sh regexes skip gh issue/pr body content for destructive/deployment/reset/workflow commands - #578
Merged
admarble merged 2 commits intoMay 6, 2026
Conversation
…ructive/deployment/reset/workflow commands Wraps four additional regex sites in pre-tool.sh with the same `^gh (issue|pr) ` exclusion idiom introduced in #564 / #566: - Destructive system commands site (line ~95) - Deployment commands site (line ~101) - git reset outer guard (inner BLOCK_REASONS accumulator unchanged) - gh workflow run site Applied across all three mirrored hook copies: - templates/hooks/pre-tool.sh - hooks/pre-tool.sh - .claude/hooks/pre-tool.sh Real destructive commands are still blocked at the bash command-string level; only `gh issue|pr create|comment` payloads referencing these tokens in body text are allowed through. Adds 24 parametrized test cases (8 new tests x 3 hook copies) to __tests__/pre-tool-hook.integration.test.ts covering allow-on-gh-body and block-on-real-command for each of the four sites. Closes #570
7 tasks
Per feedback_motivating_example_regression — examples quoted verbatim in an issue body are mandatory test fixtures, not paraphrases. The existing AC-1..AC-4 tests covered the spirit of each "Affected regex sites" table row but used reworded fixtures (e.g. "never run rm -rf / on production" vs the issue's verbatim "WARNING: never run `rm -rf /` ..."). This commit adds the EXACT strings from the #570 issue body: - Row 1 destructive: cleanup-doc explainer payload - Row 2 deployment: release-notes payload - Row 3 git reset: tutorial payload (with dirty-repo fixture so the outer guard is actually exercised, not silently skipped via empty BLOCK_REASONS) - Row 4 gh workflow: workflow-doc payload - "Repro pattern" section: gh issue create with `rm -rf /` body Each fixture parametrized over the 3 hook copies via the existing describe.each(HOOK_COPIES) block = 15 net new test runs. Test count: 72 -> 87, all passing.
admarble
deleted the
feature/570-bug-hooks-pre-tool-sh-regexes-for-destructive-depl
branch
May 6, 2026 18:31
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
Direct follow-up to #564 / #566. Wraps four additional regex sites in
pre-tool.shwith the same^gh (issue|pr)exclusion idiom, eliminating false-positive blocks when agh issue|pr create|commentbody merely references destructive tokens.rm -rfpatterns) — line ~95git reset --hardouter guard — line ~130 (innerBLOCK_REASONSaccumulator left untouched)gh workflow run— line ~170Applied across all three mirrored hook copies (
templates/hooks/,hooks/,.claude/hooks/). Real destructive commands are still blocked at the bash command-string level — onlygh issue|prbody content gets the pass.Acceptance Criteria
sudo,rm -rf /,rm -rf ~,rm -rf $HOME)vercel deploy,terraform apply,kubectl apply)git reset --hard,git reset origin)gh workflow run)[Unreleased] / Fixedreferencing bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 and bug(hooks): pre-tool.sh regexes match inside quoted gh issue/pr body content (line 108 force-push, line 248 git-commit) #564Test plan
npx vitest run __tests__/pre-tool-hook.integration.test.ts— 72/72 passingnpm run build— TypeScript clean#570comment) present across 3 hook filesSelf-dogfood
The hook fix self-validated during this PR's lifecycle: the prior QA pass was unable to post issue comments referencing the destructive tokens until
.claude/hooks/pre-tool.shwas patched. Posting now works via standardgh issue comment --body.Closes #570