Development record
guard check and guard hook disagree on a candidate whose last line opens a here-document. tokenize resolves a pending here-document only when it crosses a newline, so a candidate that ends at the redirection (`cat <<EOF`, no trailing newline) drops the pending document silently and reads allow, while the same command with its newline intact takes the fail-closed heredoc-unterminated block. guard check trims the trailing newline off stdin (guardCandidate, internal/surface/cli/guard.go), so the two front doors return different verdicts for the same command: the hook blocks, check clears. Evidence symbol: tokenize's final flushSegment, which returns with pending non-empty. The fix must give a here-document still pending at the END OF INPUT the same verdict as one whose delimiter line never came, so both front doors answer identically whether or not the candidate ends in a newline.
guard check and guard hook disagree on a candidate whose last line opens a here-document. tokenize resolves a pending here-document only when it crosses a newline, so a candidate that ends at the redirection (cat <<EOF, no trailing newline) drops the pending document silently and reads allow, while the same command with its newline intact takes the fail-closed heredoc-unterminated block. guard check trims the trailing newline off stdin (guardCandidate, internal/surface/cli/guard.go), so the two front doors return different verdicts for the same command: the hook blocks, check clears. Evidence symbol: tokenize's final flushSegment, which returns with pending non-empty. The fix must give a here-document still pending at the END OF INPUT the same verdict as one whose delimiter line never came, so both front doors answer identically whether or not the candidate ends in a newline.
Grounds
- pursued: the divergence is an allow-direction one on the surface a script queries, and fixing it in the core rather than by untrimming stdin makes every channel agree at once — the trim is a reasonable thing for a front door to do, and no front door should be able to change a verdict by doing it
Frontmatter
| id | iss-2609020450405136 |
|---|---|
| type | issue |
| lifecycle | resolved |
| severity | major |
.abcd/work/issues/resolved/iss-2609020450405136-guard-check-and-guard-hook-disagree-on-a.md
open on GitHub ↗ · commit history ↗