Repository navigation
Conversation
) A heredoc with a quoted delimiter is never expanded, so a body read by git commit -F -, gh --body-file - or a bare cat is now masked for every check, as a commit message already is, and a python program read from stdin that starts no process is masked for the shell-statement scan. Shell, ssh, eval and SQL readers, unquoted delimiters, pipes and every command outside the body are still checked. Reported-by: Nima Ghorbani (@nghorbani) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
… list change as non-behavioral Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=red-team Review-Finding: p1/specialist-batched#2 reader=red-team Review-Finding: p1/specialist-batched#3 reader=testing Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p2/specialist-batched#1 reader=security Review-Finding: p2/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: ship2-p1/specialist-batched#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Parking this draft. Each review round found one more bash feature the text check does not model. The latest: unquoted brace expansion such as |
|
Closing this draft unmerged. Across four review passes, modelling bash command lines in awk kept exposing new syntax bypasses (editor flags, function/ |
Commit messages sent with
git commit -F - <<'EOF',ghbodies sent with--body-file -and a barecat <<'EOF'no longer trigger an approval prompt because their text mentionsrm -rforgit push -f.Bash never expands a body with a quoted delimiter, so it is text; a body read by a shell,
ssh,eval,pythonor a SQL client, an editor or exec option, an unquoted delimiter, a pipe, and every command outside the body are still checked. Fixes #4843, reported by @nghorbani.Nothing to do after merging.
What changed
careful/bin/mask-heredoc.awk, run bycheck-careful.shonly when a Bash command contains<<. It follows bash's quoting, comments and heredoc rules, and blanks only the body lines of a heredoc whose delimiter is quoted (<<'EOF',<<"EOF",<<\EOF, and the<<-forms). The header line and closing delimiter are kept, so anything chained on them is still read. The hook change is 23 added lines; every existing check reads the masked command, as it already does forgit commit -mmessages (/careful hook triggers false positives on patterns inside commit messages #1060).git [-C dir] commit -F -/--file -with only-a,-q,-s,--allow-empty,--amend,--no-editor--cleanup=beside it;gh issue|pr create|comment|edit -F -/--body-file -with title, base, head, repo, label, assignee, reviewer, milestone and draft options only; and a barecat.$( ),${ }, backticks, a pipe, an output redirect to a file, process substitution, a command named by a path or variable, or a shell or interpreter name inside any word (sh,bash,ssh,eval,xargs,python,nodeand others, so-c core.editor=bashand--exec 'bash m'count). PowerShell commands are never masked.python - <<'EOF'still asks when its body mentions a destructive command: python runs its program, and no text check can show a program never starts a process. The first repro in /careful: heredoc bodies are scanned as shell commands #4843 therefore still asks; the commit-message repro no longer does.test/hook-scripts.test.tsrecorded the bug (git commit -F - <<'EOF'\ndocs: rm -rf src\nEOFasks). It now expects no prompt, and its place in the "stays unmasked" table is taken by the unquoted twin, which still asks.%TEMP%spelling mentioned at the end of /careful: heredoc bodies are scanned as shell commands #4843 is not part of this change: Windows has minimal support, and/tmpalready covers Git Bash's scratch folder.Tests
test/careful-replay.test.ts: 68 new rows. 12 fix rows (each asked or denied on main) and 56 controls that keep main's decision:bash/sh/sh -s/zsh/dash/sudo bash/env bash/ssh host sh/ssh hostreading the body,source/.of stdin,eval, a read loop, here-strings,git -c core.editor=bash,git commit -e,GIT_EDITOR=bash, a later amend orrebase --exec,gh --editor, unquoted and unclosed delimiters, an indented delimiter without<<-, a CRLF delimiter, deletes chained with&&,;,||and|on the header line or after the closing line, a heredoc marker in a comment or in quotes, several heredocs on one line, every python heredoc, cat writing a script that a later command runs, andpsql. Plus a 200 KB message timing test.Agent notes
Agent notes
Replay counts and review results are added by /gstack-ship.