Repository navigation
fix(global-settings): a hard deny beats every prompt; git aliases that push need the phrase (v2.7.3) - #813
Merged
Conversation
…t push need the phrase (v2.7.3) ask() printed its prompt and exited, so every hard deny placed below an ask guard was never reached for a chained command. One approval of the first part also ran `date -s`, `--legacy-peer-deps`, a link to a ~/.claude config file, a script that writes one, or a step out of WSL: `gh pr create … && date -s 2020-01-01` only prompted for gh. ask() now records the first reason and the prompt is raised at the end of the hook, after every guard; the order of the parts no longer matters. git push in more forms: - a git alias that resolves to push (`git config --get alias.<name>` in the -C directory or the session cwd, alias chains followed, aliases that shadow a git command ignored); - defining one: `git config alias.p push`, `git -c alias.p=push p`, an [alias] section written into a git config file; - `push` must end the word, so `git push-notes` is no longer denied as a push. Tests: every prompting guard chained with every hard-denied command in three orders, ask-reason checks, push-word, alias definition and alias resolution against a fixture git config. 651 of 8672 checks fail against v2.7.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 5 tasks
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.
Problem
ask()inblock-write-commands.shprinted its prompt and exited. Every hard deny placed lower in the file was never reached for a chained command, so one approval of the first part also ran the rest:gh pr create … && date -s 2020-01-01ghdate -s)rm build.log && npm ci --legacy-peer-depsrm--legacy-peer-deps)curl -X POST … && ln -s /tmp/x ~/.claude/settings.jsoncurldocker compose up -d && bash /tmp/writes-claude-config.shdockergit -C repo commit -m x && cd /mnt/c/powershell.exe/wslgit -Cdate -s … && gh pr create …(deny first)gh(file order, not command order)v2.7.2 fixed this for
git pushonly, by moving that one check up. This fixes the cause.Fix
ask()only records its reason. Every guard runs, a hard deny anywhere wins, and the prompt is raised once at the end, with the first guard's reason, which is the one users saw before.git pushin more forms, without the phrase:git config --get alias.<name>in the-Cdirectory or the session cwd (cwdfrom the payload) and follows alias chains. Aliases that shadow a git command are ignored, as git ignores them.git config alias.p push,git -c alias.p=push p, or an[alias]section written into.gitconfig/.git/config(heredoc included).pushmust end the word, sogit push-notesis no longer denied as a push.Not covered, and documented in the README: config set via
GIT_CONFIG_*env vars or--config-env, and a push inside a script an alias runs.Tests
test-block-write-commands.shtest-block-config-tool-writes.shtest-block-polling.shtest-check-settings-version.shThe new checks:
&&,;and deny-first.push-notes,push;,(git push),$(git push).GIT_CONFIG_GLOBAL, with and without the phrase. This covers chains, shell aliases, options inside an alias, a shadowed name, a repo-local alias and-C.ShellCheck is not installed locally; CI runs it.
Version
VERSION2.7.2 → 2.7.3. The README has a new section, A hard deny always beats a prompt (v2.7.3), and the push section covers aliases.docs/claude/global-claude-settings.mdis updated to match.🤖 Generated with Claude Code