Repository navigation
refactor(guardrails): read the hook payload through one fail-closed helper - #15611
Conversation
Six blocking guards refuse a payload jq cannot read and one carrying a NUL byte, and let any other failed field read through. No suite reached the unparsable branch: the "not JSON" cases stop in the stdin read first. These cases send JSON whose fields jq cannot index, a NUL in a harmless command where none was covered, and, through a stub of hook::jq_fields on a copy of the plugin, statuses 1 and 3, which no payload produces. Each case fails when its branch in the hook is broken. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
…elper Six blocking guards repeated the same checks after hook::jq_fields: refuse a payload jq rejected, let any other failed read through, refuse a NUL byte in a read field. guard::payload_verdict in abort-boundary.sh now decides and returns, as that file's other shared refusals do; each guard keeps its own exit in one form, `|| exit $(($? == 3 ? 0 : 2))`, which blocks on every status but 0 and 3, so a missing or broken helper denies the call. abort-boundary.test.sh unit-tests the helper and fails on any call not in that form. The hook::jq_fields call stays in each guard, where run-guards.test.sh reads its filters. The three guards that share only the NUL refusal keep their own handling of an unparsable payload, which differs from these six, so they are unchanged. No guard's output or exit code changes for any payload. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #15611 at
|
|
claude-review reviewed Incremental code review: PR #15611 (
|
The caller count matched the usage line in abort-boundary.sh's doc comment, so it passed with every call removed. It now counts non-comment call lines only and asserts each of the six guards by name, so one guard dropping out fails. Refs: #15610 Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
The caller scan piped grep into `grep -q`, which the pipefail-grep-q hygiene check refuses: the early exit can kill the producer. The scan now reads the producer through process substitution; same result. Refs: #15610 Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
Closes #15610
Summary
Six guardrails hooks repeated the same three checks after their
hook::jq_fieldscall: refuse and exit 2 on a payload jq rejects, exit 0 on any other failed read, refuse and exit 2 on a NUL byte in a read field. They now shareguard::payload_verdictinplugins/guardrails/hooks/abort-boundary.sh. Part of restructuring pass #14622 (R5).Built in a session, tests first, because it changes safety guards; the owner decided the route.
session: Simplify Planning
Fix
guard::payload_verdict <jq_fields status>returns 0 to read on, 2 after writing the refusal, 3 for a read the guard lets through silently. It never exits, as the otherguard::refusals do not.guard::payload_verdict "$jq_rc" || exit $(($? == 3 ? 0 : 2)). Every status but 0 and 3 blocks, so a missing or misbehaving helper denies the call.abort-boundary.test.shfails on any other call form.block-credential-read.sh,block-exported-msys-pathconv.sh,block-github-post-content.sh,block-no-verify.sh,block-root-delete-target.sh,block-windows-drive-tmp.sh. One comment inblock-windows-drive-tmp.shnow says "any of these fields" (the read takes four).block-convention-violation.sh,block-dangerous-git.shandblock-noncanonical-commit.shrepeat only the NUL refusal and handle status 2 differently, so the helper would change their output.Verification
abort-boundary.test.sh(no payload produces them). Each passed on the unchanged hooks, and 18 of 18 single-line breakages of those hooks failed a test.scripts/sync-shared-copies.sh --check(812 copies) and the cross-plugin drift check pass; changelog fragment andtyposchecks pass.merge.diff-check.floor-pathsrow.Related
Follow-ups
plugins/guardrails/hooks/block-fix-request-post.sh:112-124holds a seventh copy of this check in_bfr_settle_fields, which exits inside its helper.plugins/guardrails/hooks/block-convention-violation.sh:108andplugins/guardrails/hooks/block-noncanonical-commit.sh:144exit 0 on a payload jq rejects (status 2), and their comments name "rc 1". Refusing it would change what those guards allow, which is the owner's decision.plugins/guardrails/hooks/block-root-delete-target.test.sh:1001said section 5 held a NUL-in-command test; none existed until this change added one to the-esuite.🤖 Generated with Claude Code
https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH