You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consolidate the Write Guard's Shell Context Scanners Into One Walker #3354
A design finding from the local review of the backslash-newline narrowing (branch feature/guard-backslash-newline-quoting), declined there because consolidating means changing shared helpers on every tokenizer path of a security hook inside a narrowing change.
Finding
gh-write-guard.py holds several hand-written scanners of bash's quoting and nesting contexts, and the narrowing adds one more, _line_break_contexts. Its inner readers repeat existing ones:
its double-quote reader repeats _skip_quote_body
its command reader repeats _skip_group with comments=True: paren depth, case counting, a # at a word start, and pending heredocs from _HEREDOC_IN_GROUP
its heredoc reader repeats _skip_heredoc_lines and _heredoc_body_end, and adds a rule those lack, that a line ending in an unescaped backslash in an unquoted heredoc joins the next, so the next is not its delimiter
its quoted-delimiter test repeats the one in _unquoted_heredoc_bodies
Each copy is a place for the same bash rule to be read two ways, as the heredoc continuation rule already is.
Possible Direction
One context walker over _skip_group and _skip_quote_body, taking an optional visitor that records the context at each index it passes. The skippers keep their return contract, _line_break_contexts becomes a visitor, and the heredoc readers share one body-end rule.
This issue now also carries the fourth finding of #3358, which #3368 left out on purpose: a quoted span naming git or gh that holds an apostrophe, double quote, backquote, or << is still read as develop reads it, so a pull request body that mentions git in a code span and holds a Markdown hard line break is still denied. Letting such a body through needs a reading of a quoted span that is sound across a further quoting level, which is the single context walker's job. #3358 closes with the promotion of its other three findings.
Closed as out of the write guard's scope under the maintainer's decision (ptr727, 2026-10-23) on #3391, item 1. The guard bounds a good-faith agent's mistake rather than an adversary, so a parse gap reached only by a command shape no agent plausibly types in a coding session is closed rather than fixed, and the guard's own growth is a cost each later review pays again. The scope statement lands in the guard's docstring and README under #3391. Reopen only with a command a session actually produced.
Activity
Read a Backslash-Newline by Its Quoting in the Write Guard (#3357)
Keep Escaped Backslash Pairs Before a Line Break in the Write Guard (#…
ptr727 commentedon Oct 22, 2026
This issue now also carries the fourth finding of #3358, which #3368 left out on purpose: a quoted span naming git or gh that holds an apostrophe, double quote, backquote, or
<<is still read as develop reads it, so a pull request body that mentionsgitin a code span and holds a Markdown hard line break is still denied. Letting such a body through needs a reading of a quoted span that is sound across a further quoting level, which is the single context walker's job. #3358 closes with the promotion of its other three findings.Promote the Write Guard Line-Continuation and Escaped-Pair Reads, Win…
ptr727 commentedon Oct 23, 2026
Closed as out of the write guard's scope under the maintainer's decision (ptr727, 2026-10-23) on #3391, item 1. The guard bounds a good-faith agent's mistake rather than an adversary, so a parse gap reached only by a command shape no agent plausibly types in a coding session is closed rather than fixed, and the guard's own growth is a cost each later review pays again. The scope statement lands in the guard's docstring and README under #3391. Reopen only with a command a session actually produced.