bash gate: a quoted heredoc inside "$(...)" is tokenized as shell source, so Markdown bodies trip Confirm
Summary
The bash risk gate blocks the common idiom of passing a multiline body through a quoted heredoc inside a double-quoted command substitution:
gh api repos/o/r/pulls -f body="$(cat <<'EOF'
Ran `tool resume X "<pointer>"` ok.
EOF
)"
The gate returns Confirm with target is computed at runtime (variable or command substitution), so its value cannot be checked in advance, quoting heredoc prose as the "target". The same body passes when the heredoc is not wrapped in "$(...)".
Minimal reproduction
Blocked (Confirm):
echo "$(cat <<'EOF'
`"p>"` y
EOF
)"
Runs (Safe):
cat <<'EOF'
`"p>"` y
EOF
Checked against master at a61c38e with jcode_command_risk::assess:
| Command | Result |
|---|---|
echo "$(cat <<'EOF'\n"p>" y\nEOF\n)" |
Confirm |
gh api x -f body="$(cat <<'EOF'\nran aside resume X " ok\nEOF\n)" |
Confirm |
cat <<'EOF'\n"p>" y\nEOF |
Safe |
It reaches users through gh pr create --body "$(cat <<'EOF' ...)" and git commit -m "$(cat <<'EOF' ...)", which agents use constantly. Any Markdown body that contains an inline code span with a " and a > or similar trips it.
Cause
without_heredoc_bodies relies on heredoc_delimiters, which tracks a single quote state for the whole line. In body="$(cat <<'EOF', the " before $( opens a double-quote context. The scanner then treats <<'EOF' as quoted text and never records the heredoc. The body is tokenized as shell source, a backtick span with an inner " and > becomes a redirect with a non-literal target, and the gate asks for confirmation.
In the shell, $( starts a new quoting context even inside double quotes, so the heredoc is real and its quoted body is inert data, the case #922 already strips.
Expected
A quoted heredoc declared inside "$(...)" is treated like any other quoted heredoc: its body is data. Commands outside the substitution, and the $(...) contents themselves, stay assessed as before.
Environment
jcode v0.90.4-dev (macOS, Apple Silicon). The logic is unchanged on master a61c38e.
Related: #922 (heredoc payload stripping), #751 and #932 (other gate false positives).
Thanks! Your PR #1752 has the fix, and it's queued for maintainer review. FYI, #1764 (for #1753) adds substitution scanning on top. It only ever makes verdicts stricter and leaves this quoted-heredoc case alone.
--- — Jcode agent (automated triage), on behalf of @1jehuang
Fixed on master in dea8a4ad0 (from #1752). Quoted heredocs inside "$(...)" are treated as data again. --- Jcode agent, on behalf of @1jehuang