Repository navigation
Description
Problem
block-github-post-content blocks gh pr|issue create|comment|edit calls that upload a local file
with --attach <path>, reporting the source path as a machine path that "would be posted". gh
uploads the file and posts only the alt text after a # (or, without one, a name derived from the
file's base name) and the asset URL; the directory path never reaches GitHub. So the block is a false
positive. When the attached file sits under the session's project root, the same word also trips
the "Machine-specific repo path detected" check, which is the second message in the original report.
The $HOME/... and variable workarounds pass only because the guard reads unexpanded text.
Mechanism on main (999cb91c1b, guardrails 3.1.5):
ghpost::gh_body(plugins/guardrails/lib/github-post/github-post-body.sh:121-133) records only
-F,--body-file,--body-file=and-F<path>operands. Every other posting word, the
--attachoperand included, goes toGHPOST_TEXTS
(plugins/guardrails/lib/github-post/github-post-body.sh:417) and is emitted as awordbody
(plugins/guardrails/lib/github-post/github-post-body.sh:470,474).- The path pass (
plugins/guardrails/hooks/block-github-post-content.sh:150-224) drops aword
only when it names one ofGHPOST_FILES, so the operand is scanned and blocks at
plugins/guardrails/hooks/block-github-post-content.sh:211-223. The secret pass
(plugins/guardrails/hooks/block-github-post-content.sh:136-148) scans every body text. - "Machine-specific repo path detected" comes from the scan-root branch
(plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh:298-313), which fires when the
text containsCLAUDE_PROJECT_DIRand that directory sits in a git checkout whose top level is
not home (plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh:339-355).
Evidence
Verified this pass (origin/main 999cb91c1b) by piping a PreToolUse JSON payload on stdin to the
guard extracted into a scratch directory, direct and through run-guards.sh block-fix-request-post.sh block-github-post-content.sh. No payload command was executed. Home
paths are written /home/<user>/... here; the repro builds them split (/ho""me/alice).
<win home> is a C: user-profile path, also split in the repro.
| Case | Command (Bash unless noted) | main | prototype |
|---|---|---|---|
| a1 | gh pr edit 5340 --repo octo/repo --body-file body.md --attach /home/<user>/wt/evidence/figma/built-banner-resized.png |
2, "Linux user path detected" | 0 |
| a2 | gh pr comment 5340 --body 'see shot' --attach '/home/<user>/wt/evidence/a.png#Banner before resize' |
2 | 0 |
| a2c | ... --attach '/home/<user>/wt/a.png#Banner, before resize' (comma in alt, Bash) |
2 | 0 |
| j1 | ... --attach=/home/<user>/wt/evidence/a.png |
2 | 0 |
| m1 | gh issue create --title t --body ok --attach /home/<user>/wt/a.png --attach /home/<user>/wt/b.png |
2 | 0 |
| w1 | gh pr comment 5340 --body "$X" --attach /home/<user>/wt/a.png (whole-command mode) |
2 | 0 |
| wr | bash ./gate.sh run k -- gh pr comment 1 --body ok --attach /home/<user>/wt/a.png |
2 | 0 |
| bc | bash -c 'gh pr comment 1 --body ok --attach /home/<user>/wt/a.png' |
2 | 0 |
| p2 | PowerShell: gh pr edit 5340 --body 'ok' --attach '<win home>\wt\a.png' |
2, "Windows user path detected" | 0 |
| p2a | PowerShell: ... --attach '<win home>\wt\a.png#shot' |
2 | 0 |
| rv | gh pr review 5340 --body ok --attach /home/<user>/wt/a.png (gh rejects the flag) |
2 | 0 |
| a3 | --attach '/home/<user>/wt/evidence/a.png#built at /home/<user>/wt' |
2 | 2 |
| adj | --attach './x.png#/home/<user>/wt/alt' |
0 | 2 |
| p4 | PowerShell: --attach '<win home>\wt\a.png#built in <win home>\wt' |
2 | 2 |
| ws | --body "$X" --attach '/home/<user>/wt/a.png#at /home/<user>/wt' |
2 | 2 |
| s1 | --attach '/home/<user>/wt/a.png#alt <ghp_ token>' |
2, "GitHub PAT" | 2 |
| s2 | --attach '/home/<user>/wt/<ghp_ token>.png' |
2, "GitHub PAT" | 2 |
| b1 | gh pr comment 5340 --body-file pathbody.md --attach /home/<user>/wt/a.png (file holds a home path) |
2 | 2 |
| b2 | --body '' --attach /home/<user>/wt/a.png |
2 | 2 |
| x1 | --body /home/<user>/wt/a.png --attach /home/<user>/wt/a.png |
2 | 2 |
| h1b | gh pr comment 1 --attach {./x.png,--body=/home/<user>/wt/log} |
2 | 2 |
| h1i | gh pr comment 1 --attach ./x.png$IFS--body=/home/<user>/wt/log |
2 | 2 |
| h1j | gh pr comment 1 --attach=./x.png$IFS--body=/home/<user>/wt/log |
2 | 2 |
| h1p | PowerShell: gh pr comment 1 --attach './x.png','--body=<win home>\wt\log' |
2 | 2 |
| trailing | gh pr comment 1 --body ok --attach && gh pr comment 2 --body 'see /home/<user>/x/log.txt' |
2 | 2 |
| t1 | gh issue create --title t --template /home/<user>/wt/tpl.md --body ok |
2 | 2 (out of scope) |
| hv | gh pr comment 1 --body ok --attach "$HOME/a.png" |
0 | 0 |
| p1 | PowerShell: --attach <win home>\wt\a.png, unquoted |
0 (tokenizer strips the backslashes) | 0 |
| c0 | gh pr comment 5340 --body 'clean' |
0 | 0 |
Cases a2c, p2a, adj, h1b, h1i, h1j, h1p, trailing and hv ran direct only; every other case ran
direct and dispatched with the same exit code.
Scan-root half: with CLAUDE_PROJECT_DIR set to a throwaway git init repo and
--attach <repo>/evidence/a.png (with or without #shot), main exits 2 and reports both
"Windows user path detected" and "Machine-specific repo path detected" (the scratch repo sat under a
Windows home); the prototype exits 0, and --body 'built in <repo>' with the same attach still
exits 2 on both.
The "prototype" column is the Plan's Phase 2 applied to a second scratch extract, not committed
anywhere. On it, block-github-post-content.test.sh passes (79 PASS, 0 FAIL, as on main), and
block-fix-request-post.test.sh gives exactly main's result in the same extract (310 PASS, and the
same 6 "allow mode" failures on both, which need a git checkout the extract is not).
Inferred, not re-verified: the original WSL report (guardrails 2.0.1, 2026-11-06), where the
$HOME/... form and 16 operands passed through "${args[@]}" were not blocked. Both stay as they
are: an operand holding $ is not captured (see Plan), and the guard reads unexpanded text.
Research
Read from gh's own source at the latest release, v2.104.0 (2026-11-12), plus local gh 2.102.0
help. The links are the source files read.
- Which commands take
--attach:attachments.AddFlagis called inpr create|comment|edit,
issue create|comment|editandissue artifact create|edit;pkg/cmd/pr/review/review.gonever
mentions attach, so gh rejects--attachthere. No short flag
(https://raw.githubusercontent.com/cli/cli/v2.104.0/internal/attachments/flags.go,StringArrayVar). - How
<file>#<alt>splits:SplitFileArgtakes the whole argument as the path, with empty alt,
when it exists as a file; else the longest existing prefix before a#, the rest being alt; else
it splits at the last#. Any alt text gh uses therefore starts after some#, and the text after
the first#contains every candidate. Same rule since v2.99.0, the first release with--attach
(https://raw.githubusercontent.com/cli/cli/v2.104.0/internal/attachments/flags.go). - What posts: an image with no alt text gets the base name without its extension, dots replaced by
spaces, and renders as; a video refuses alt text and renders as the bare URL
(https://raw.githubusercontent.com/cli/cli/v2.104.0/internal/attachments/userasset.go). The upload
request sends onlyfilepath.Base(path)as itsname
(https://raw.githubusercontent.com/cli/cli/v2.104.0/internal/attachments/client.go). - Partial failure: uploads stop at the first failure, existing references point only at URLs of files
that uploaded, and callers write the markdown whenever any upload succeeded, so a body reference
to a failed file keeps its local path
(https://raw.githubusercontent.com/cli/cli/v2.104.0/internal/attachments/attach.go). References
are matched throughfilepath.Abs, so an absolute-path reference is rewritten on success
(https://raw.githubusercontent.com/cli/cli/v2.104.0/internal/attachments/references.go). --template:pr createrefuses it with--body/--body-file, passes it into the browser compare
URL in web mode, and in the editor and interactive flows matches it against repository template
names, failing withtemplate "..." not foundotherwise. It is never body text
(https://raw.githubusercontent.com/cli/cli/v2.104.0/pkg/cmd/pr/create/create.go).gh release upload <tag> <file>#<label>sends the base name as the asset name and the text after
the first#as its label
(https://raw.githubusercontent.com/cli/cli/v2.104.0/pkg/cmd/release/shared/upload.go). The guard
does not parsegh release.- Release notes (
gh api repos/cli/cli/releases): v2.99.0 introduced--attach; v2.103.0 added
gh issue artifactwith--attach; the v2.104.0 notes name no--attachchange.
Verification: a fresh-context research verifier failed the first wording (claims phrased as runtime
behavior rather than as what the source says, plus two over-broad clauses). The claims were reworded
to what each file says and the clauses cut; that rewording was not re-verified. A separate
devils-advocate pass re-read client.go, userasset.go and flags.go at v2.104.0 and confirmed the
upload-name, default-alt and split claims.
Plan
Size: Small. Four files in one plugin plus a changelog fragment, two commits; within the issue
lane's one-run size, so no split.
Design: capture each literal --attach operand by position in the parser library and emit it as a
new body kind, attach. The secret pass and block-fix-request-post keep reading the whole operand:
both read every GHPOST_BODY text and neither reads the kind
(plugins/guardrails/hooks/block-fix-request-post.sh:285-288). Only the path pass narrows an
attach text, to the text after its first #, or with no # to its base name. "Literal" means
the shell passes the operand on unchanged: no $, backtick or {, and on PowerShell no ,, (
or @. Any other operand stays a word and is judged whole, as today, because the hook's
tokenizer does no brace or IFS expansion and an operand like {./x.png,--body=<home>/log} or
./x.png$IFS--body=<home>/log really posts a --body.
Phase 1: tests first (commit them red)
In plugins/guardrails/hooks/block-github-post-content.test.sh, add an attach block after the
stay-quiet section (after line 121), using the file's quiet/deny helpers
(plugins/guardrails/hooks/block-github-post-content.test.sh:36-68), its split-literal home paths
(/ho""me/alice, Use""rs) and $TOK:
quiet, each labeledattach ...: AC1, AC2 (both forms), AC3, AC8 (--body "$X"plus an attach;
PowerShell with a single-quoted'C:\Use""rs\alice\x.png').- AC4:
git init -q "$TEST_TMPDIR/proj"with anevidence/directory; run the scan-rootquiet
cases withCLAUDE_PROJECT_DIR="$TEST_TMPDIR/proj"prefixed on those calls only (the file unsets
it globally at line 21; a prefix on a bash function call reaches the hook subprocess, checked on
bash 5.3), plus onedenycase with the project root in the alt text. deny(path): AC5 spaced form, AC5 adjacent form labeledattach adjacent alt ..., AC7's three
shapes, AC8's PowerShell alt case, AC14, AC15's four shapes.deny(secret): AC6 ($TOKafter#;$TOKin the base name).
Check on the unmodified hook: bash plugins/guardrails/hooks/block-github-post-content.test.sh 2>&1 | grep '^FAIL: ' prints only lines starting FAIL: quiet: attach or
FAIL: deny: attach adjacent alt . Every other new deny case already passes on main. Commit.
Phase 2: the fix
- Consumer check before editing:
git grep -n -e GHPOST_TEXTS -e GHPOST_BODY_KIND -- plugins scriptsshows no reader outsidegithub-post-body.shexcept the kindcaseat
plugins/guardrails/hooks/block-github-post-content.sh:156(true at999cb91c1b). Stop on any
other hit. plugins/guardrails/lib/github-post/github-post-body.sh:ghpost::reset(plugins/guardrails/lib/github-post/github-post-body.sh:64-79): add
GHPOST_ATTACH=().- Add
ghpost::_literal_operand <word>: true when the word holds no$, backtick or{, and,
whenGHPOST_TOOLis PowerShell, no,,(or@. ghpost::segmentword loop (plugins/guardrails/lib/github-post/github-post-body.sh:383-418):
addattach=0to thelocalline that declaresskip=0(line 383), so a pending--attach
never crosses into the next segment. The function re-enters itself forbash -c, script
wrappers andeval(plugins/guardrails/lib/github-post/github-post-body.sh:296-298,320-331,337-339).
After the-Hskip block and beforeGHPOST_TEXTS+=("$w"), for a form matchinggh-pr-*or
gh-issue-*: whenattachis set, clear it, and if the word is literal append it to
GHPOST_ATTACHandcontinue; a bare--attachsetsattach; an--attach=<v>word whose
<v>is literal appends<v>and continues. Everything else falls through toGHPOST_TEXTS,
the--attachflag word included. The$and$(catchecks above still see every word.ghpost::bodies(plugins/guardrails/lib/github-post/github-post-body.sh:466-476): after each
branch'swordloop, add everyGHPOST_ATTACHentry withghpost::_add attach "" "$c", so
whole-command mode and PowerShell get it too.- Header comments: add
attachto the body-kind list
(plugins/guardrails/lib/github-post/github-post-body.sh:16-23), saying its text is posted
in part and must be judged like aword; say in WHAT IS READ
(plugins/guardrails/lib/github-post/github-post-body.sh:25-37) that a literal--attach
operand is its own kind.
plugins/guardrails/hooks/block-github-post-content.sh: in the path passcase
(plugins/guardrails/hooks/block-github-post-content.sh:156-182) add anattach)branch: with a
#, keep${_bgpc_t#*#}; without, keep the text after the last/or\. Comment what gh
posts. Update the MACHINE PATHS header
(plugins/guardrails/hooks/block-github-post-content.sh:22-29) and add to KNOWN GAPS
(plugins/guardrails/hooks/block-github-post-content.sh:39-47) that a markdown reference to an
attached file's absolute path still blocks, by design. Leave the secret pass untouched: a token in
the base name is posted as default alt text, and one in a directory segment blocking is the
conservative side.plugins/guardrails/README.md:99: after "a--body-fileoperand is not judged", say an
--attachoperand is judged for paths by what gh can post from it (its alt text or base name),
except an operand the shell would expand, which is judged whole.- Changelog:
bash scripts/new-changelog-fragment.sh guardrails patch, then a### Fixedentry
naming the false positive, that alt text and secrets still block, and that a home path starting
right after#now blocks too. guardrails is in fragment mode
(scripts/fragment-plugins.txt:51), so noplugin.jsonbump. No shared-copy sync: neither
touched file is inscripts/shared-copies.txt.
Commit.
Decisions
- Position-aware capture in the library, not the original string match in the guard: string match
would also narrow a--bodyvalue byte-identical to the operand, so a posted home path would pass
(AC7, third shape). The library already skips curl-Hvalues by position
(plugins/guardrails/lib/github-post/github-post-body.sh:399-416). - Literal operands only: capturing every operand lets a brace,
$IFSor PowerShell array operand
carry a posted--body=<home path>past the path pass (AC15). - The first
#, not the last: gh picks a#by which files exist at run time; the text after the
first one covers every choice. With no#, the base name, which is what gh posts. - All
gh pr|issueposting forms,pr reviewincluded: gh rejects--attachon review, so nothing
posts either way, and no per-subcommand list is needed. --body --attach <word>: pflag takes--attachas the body value and the capture treats<word>
as an operand; gh then rejects the extra argument or uses it as the PR or issue selector, and
neither posts it. Say so in a code comment; do not special-case it.
Alternatives rejected: adding operands to GHPOST_FILES (reads an image as text and drops posted
alt text); reading only --body/--body-file/--title (reverses the library's read-every-word
design and misses other posted flags); a userConfig opt-out (see Configurability).
Out of scope
--template: gh never posts its value (Research); a home-path value blocking refuses a call that
would fail anyway.gh issue artifact create|edit --attachandgh release uploadlabels: the guard never parses
these forms, so no false positive; they are unread publishing forms (known gaps).- An unquoted PowerShell backslash operand already exits 0 on main because the bash tokenizer strips
unquoted backslashes; that tokenizer gap is separate. - A markdown reference to the attached file by its absolute path (
beside
--attach <home>/x.png) still blocks. gh rewrites it when the upload succeeds but writes the body
with it unchanged when that upload fails. Kept as an intended remaining false positive; no test
locks it in either way. - An operand whose alt text holds
$, a backtick or{(on PowerShell also,,(,@) keeps
today's false positive when its directory is a home path; it is judged whole, which fails closed. - The same
#-adjacency gap in a--bodyvalue ('x#/home/<user>/...'exits 0 on main): a
path-pattern boundary change, separate from this fix. GHPOST_PATHS(plugins/guardrails/lib/github-post/github-post-body.sh:454) has no reader outside
the library; not touched.
Configurability
Fix, not a setting. The guard blocks correct input (a local upload path gh never posts), and a guard
that blocks correct input gets fixed rather than given an opt-out. No userConfig option is added;
block_github_post_content_enabled, secret_pattern_detection_enabled and
hardcoded_path_check_enabled are unchanged.
Baseline
Host: Windows 11, Git Bash (GNU bash 5.3.15, Cygwin build), hyperfine 1.20.0; guardrails extracted
from origin/main 999cb91c1b; 9 runs after 1 warm-up per arm. Run-to-run spread on this host is
10-35% of the median, so medians are reported, not gated; the launch counts are the gate.
| Arm | Exit | Median ms | Mean ms | Std dev ms | External launches |
|---|---|---|---|---|---|
a1 direct: body file plus --attach <home>/...png |
2 | 5621 | 5622 | 722 | 21 (15 grep, 4 head, 1 jq, 1 tr) |
c0 direct: clean --body |
0 | 1681 | 1700 | 172 | 5 (4 grep, 1 jq) |
| a1 dispatched (with block-fix-request-post) | 2 | 6093 | 6425 | 816 | not counted |
| c0 dispatched | 0 | 1797 | 1916 | 688 | not counted |
r1 direct: attach under CLAUDE_PROJECT_DIR |
2 | 5707 | 5966 | 952 | 24 (1 git, 15 grep, 6 head, 1 jq, 1 tr) |
The blocking arms cost about 4 s more than a clean pass, nearly all in the path scanner's grep
pipelines. After the fix a1 and r1 exit 0 and should cost about what c0 costs; c0 should not move.
Launch counts come from PATH shims around each external tool and do not count $(...) forks.
Rerun: save the script below as <scratch>/baseline.sh and run
bash <scratch>/baseline.sh <checkout root> <scratch>/out 9 on origin/main and on the branch, on
one host (needs hyperfine and jq; payloads reach the hook on stdin only).
#!/usr/bin/env bash
# Usage: bash baseline.sh <root holding plugins/guardrails> <out dir> [runs]
set -uo pipefail
ROOT="$1"; OUT="$2"; RUNS="${3:-9}"
H="$ROOT/plugins/guardrails/hooks"
mkdir -p "$OUT"
WD="$(mktemp -d)"; echo "work dir (left in place): $WD"
unset CLAUDE_PLUGIN_OPTION_BLOCK_GITHUB_POST_CONTENT_ENABLED
HP="/ho""me/alice/worktrees/octo/repo-x"
REPO="$WD/repo"; mkdir -p "$REPO/evidence"; git -C "$REPO" init -q
printf 'body ok\n' >"$WD/body.md"
mk() { jq -n --arg c "$2" --arg d "$3" '{tool_name:"Bash",cwd:$d,tool_input:{command:$c}}' >"$WD/$1.json"; }
mk a1 "gh pr edit 5340 --repo octo/repo --body-file body.md --attach $HP/evidence/figma/built-banner-resized.png" "$WD"
mk c0 "gh pr comment 5340 --body 'clean'" "$WD"
mk r1 "gh pr edit 1 --body ok --attach $REPO/evidence/a.png" "$REPO"
arm() { # name payload project-dir dispatched(0|1)
local cmd="env CLAUDE_PROJECT_DIR=$3 bash $H/block-github-post-content.sh"
(($4)) && cmd="env CLAUDE_PROJECT_DIR=$3 bash $H/run-guards.sh block-fix-request-post.sh block-github-post-content.sh"
hyperfine -N -i --style basic --warmup 1 --runs "$RUNS" --input "$WD/$2.json" \
--export-json "$OUT/$1.json" -n "$1" "$cmd" >/dev/null 2>&1
jq -r '.results[0] | "\(.command)\tmedian_ms=\(.median*1000|floor)\tmean_ms=\(.mean*1000|floor)\tstddev_ms=\(.stddev*1000|floor)\texit=\(.exit_codes|unique)"' "$OUT/$1.json"
}
arm a1-direct a1 "" 0
arm c0-direct c0 "" 0
arm a1-dispatched a1 "" 1
arm c0-dispatched c0 "" 1
arm r1-direct-scanroot r1 "$REPO" 0
SHIM="$WD/shim"; mkdir -p "$SHIM"; LOG="$WD/launches.log"
for t in jq git grep head tr cut sed awk cat date mktemp sort uniq wc tail basename dirname realpath cygpath; do
real=$(command -v "$t") || continue
printf '#!/usr/bin/env bash\nprintf "%%s\\n" %s >>"%s"\nexec "%s" "$@"\n' "$t" "$LOG" "$real" >"$SHIM/$t"
chmod +x "$SHIM/$t"
done
for p in a1 c0 r1; do
pd=""; [[ "$p" == r1 ]] && pd="$REPO"
: >"$LOG"
PATH="$SHIM:$PATH" CLAUDE_PROJECT_DIR="$pd" bash "$H/block-github-post-content.sh" <"$WD/$p.json" >/dev/null 2>&1
printf 'launches %s total=%s %s\n' "$p" "$(wc -l <"$LOG")" "$(sort "$LOG" | uniq -c | tr -s ' ' | tr '\n' ';')"
doneAcceptance criteria
Each case runs direct and through run-guards.sh block-fix-request-post.sh block-github-post-content.sh, with the same exit code.
- AC1:
gh pr edit <n> --repo o/r --body-file <file> --attach /home/<user>/.../x.pngexits 0. - AC2:
--attach '/home/<user>/.../x.png#Banner before resize'exits 0, and--attach=/home/<user>/.../x.pngexits 0. - AC3: two
--attachoperands with home paths on onegh issue createexit 0. - AC4: an
--attachoperand underCLAUDE_PROJECT_DIR(a git checkout) exits 0, with and without#alt. - AC5: a home path or the project root in the alt text exits 2, spaced (
#built at /home/<user>/...) and adjacent (#/home/<user>/..., which exits 0 on main and now blocks). - AC6: a secret pattern after
#, and one in the file's base name, exit 2. - AC7: each still exits 2: a body file holding a home path beside an
--attach; a prose--body 'see /home/<user>/.../x.png'beside the same attach;--body /home/<user>/.../x.png --attach /home/<user>/.../x.png. - AC8:
--body "$X" --attach /home/<user>/.../x.pngexits 0; on PowerShell, a single-quoted<win home>\...\x.pngoperand exits 0, and the same operand with a home path after#exits 2. - AC9:
bash plugins/guardrails/hooks/block-fix-request-post.test.shgives the same result on the branch as onorigin/mainin the same environment, andblock-fix-request-post.shand its test file are unchanged. - AC10: the regression cases fail on main and pass on the branch: on the Phase 1 commit the test file fails only on the new
quiet: attachcases and the adjacent AC5 case; on the branch headbash plugins/guardrails/hooks/block-github-post-content.test.shexits 0. - AC11: the library header (body kinds, WHAT IS READ), the guard header (MACHINE PATHS, KNOWN GAPS) and
plugins/guardrails/README.mdrow 99 describe the attach reading and its fail-closed exceptions. - AC12: a
.changes/guardrails/fragment withbump: patchand a### Fixedentry exists;plugins/guardrails/.claude-plugin/plugin.jsonis unchanged;bash scripts/check-changelog-fragments.shexits 0. - AC13: timing no worse than Baseline (a local check; CI does not run it): on one host, the Baseline script prints
launches c0 total=5and a1, r1 totals no higher than 21 and 24; before and after medians go in the PR body. - AC14: a segment ending in a bare
--attachdoes not swallow the next segment:gh pr comment 1 --body ok --attach && gh pr comment 2 --body 'see /home/<user>/x/log.txt'exits 2. - AC15: an operand the shell would expand still exits 2 when it carries a home path:
--attach {./x.png,--body=/home/<user>/log},--attach ./x.png$IFS--body=/home/<user>/log,--attach=./x.png$IFS--body=/home/<user>/log, and on PowerShell--attach './x.png','--body=<win home>\log'. - AC16: the performance and waste pass is done; its findings are fixed or listed in the PR body.
- AC17:
/review:quality-gatecode and security modes report no unresolved blocking finding.
Required stages for the implementer
- The fix with the regression test written first:
/testing:writefor the Phase 1 cases (commit
them red), then/implementation:implementfor Phase 2. /toolchain:checkand/toolchain:lint;/testing:auditon the new test cases.- A performance and waste pass: rerun the Baseline script and compare with the Baseline table;
/code-metrics:auditcomplexity and/code-metrics:audit-duplicationon the touched files;
/simplify; and a check for repeated process launches, slow loops, repeated git calls, and unclear
block or error messages. Make in-scope fixes; list the rest in the PR body. /review:quality-gatecode mode, plus security mode, because the change alters a guard's block
decision./verification:confirmagainst these acceptance criteria, line by line.- The PR, with the before/after Baseline numbers in its body.
Constraints and gotchas
- Do not exempt a body reference to the attached path: on a partial upload failure gh writes the
body with the failed file's local reference unchanged. github-post-body.shis shared with block-fix-request-post. Keep every attach operand in
GHPOST_BODY; only its kind changes. That guard reads texts, not kinds.- Place the capture after the
$and$(catchecks in the word loop, soGHPOST_SUBSTstill sees
every word. - Emit
attachbodies in bothghpost::bodiesbranches. Whole-command mode ($, stdin, a written
body file) and PowerShell take the first branch; missing it there leaves the false positive in
those modes. - Keep
attachalocalofghpost::segment; the function re-enters itself, and a global flag
would carry a pending--attachinto the next segment (AC14). - Test fixtures split home paths (
/ho""me/alice,Use""rs) so the repository's own scanners do
not flag the test file; build tokens at run time from$TOK. - The AC5 adjacent case is the one
denycase that fails on main; the Phase 1 check expects it. block-fix-request-post.test.shdepends on its environment: in a plain extract outside a git
checkout, its "allow mode" cases fail on main too. Compare its result on the branch with
origin/mainin the same checkout rather than expecting a clean pass anywhere.- Hook-precision discipline: a false-positive fix lands with a stay-quiet test that fails before the
fix (docs/contracts/hook-precision/README.md:78-90; AGENTS.md links the moved stub at
docs/conventions/hook-precision/README.md). - On a Windows Git Bash host the existing test file takes about 3 minutes (79 cases); budget for it.
- No
cd,VAR=valueprefix,exportor redirect in agent-run shell commands (AGENTS.md team
standards); the AC4 variable is set inside the test file, not on the command line.
Context
- Source: local handoff item
20261106-025554-guardrails-github-post-content-blocks-gh-attach-source-path.md
(retired into this issue), raised from a work-domain session on WSL. - Related: fix(guardrails): scan Bash-posted GitHub bodies for secrets and machine paths #12093 introduced the Bash-posted body scan
(fix(guardrails): scan Bash-posted GitHub bodies for secrets and machine paths). - This body replaces the original proposal (record operands and narrow matching
wordbodies by
string comparison in the guard, leaving the secret pass alone): the string match and the
expansion-shaped operands both let a posted path through (see Decisions). The original facts kept
here: the mechanism lines, cases a1 to a3, the subcommand list, the partial-failure constraint,
the shared-library constraint, the split-literal fixture rule, and the fragment release rule.
Runner portability (overrides the timing criteria above where they conflict)
The Baseline numbers above were measured on Windows 11 with Git Bash, where these hooks run far slower than on Linux. The issue lane (.github/workflows/work-resolve-issue.yml) runs on ubuntu-24.04 and installs no shfmt, typos or hyperfine; only the PR checks install a pinned shfmt (.github/actions/setup-pinned-shfmt). Windows seconds are context, not a pass bar.
- Binding timing gate: counts. The process-launch or call counts the Baseline commands report are measured on origin/main and on the branch in the same run on the same host. The branch meets the count target stated above (or does not exceed main where none is stated). Counts go in the PR body.
- Wall time, same host only. If the Baseline commands can run on the host, time origin/main and the branch in the same run (median of 5; a plain
timeloop is fine, hyperfine is not required). The branch median is at most main's slowest run. Seconds from a different host are never compared. - Missing tool. Where a test or timing needs a tool the host lacks, use the stub approach the plan gives if it has one. Otherwise do not install an unpinned tool: name the missing tool in the PR body, report the count evidence, and leave the wall-time check for a maintainer to rerun with the Baseline commands (on Windows where the symptom is Windows-only). That is not a failed stop.
- Windows-only symptoms (command-line length, Git Bash process cost) are proved on Linux by the deterministic test the plan names (for example a stub that fails when paths arrive on argv).
pr-test-platforms.ymlruns the Windows suites a change selects.
Metadata
Metadata
Assignees
Labels
Type
Fields
Work status
Priority
Activity
github-actions commentedon Nov 13, 2026
Size: Small
Complexity: Medium
Uncertainty: Known
Flags: none
Blocked by: none
Understood: block-github-post-content wrongly blocks
gh pr|issue create|comment|edit ... --attach <local path>, because gh posts only the alt text or base name, never the directory. The issue proposes capturing literal--attachoperands as their own body kind and judging only the alt text or base name for paths. It keeps secret scanning on the whole operand and fails closed for operands the shell would expand. The plan, tests and acceptance criteria are specific, so I found nothing missing. I found no duplicate among open issues and no merged PR that already fixes this.Automated triage. A maintainer reviews it.
melodic-automation-lanes commentedon Nov 13, 2026
Not admitted to the issue lane: its body or a criterion names .github/workflows/pr-test-platforms.yml, .github/workflows/work-resolve-issue.yml, which the issue lane cannot push (patch-protected-path); a builder session takes it. Admission takes the issue once each of those is met, when intake triages it again (
.github/actions/resolve-config/admission-rules.json).fix(guardrails): stop judging gh --attach source paths as posted mach…
kyle-sexton commentedon Nov 15, 2026
Decision recorded.
Owner, 2026-11-15, asked how to finish this issue (close as delivered for the Bash tool, PowerShell
--attachstays blocked, the AC16 and AC17 passes run first): "go w/ recommendations".Outcome
--attachoperand is still judged whole. AC8's PowerShell half is not delivered, by this decision.AC13 and AC16 (performance and waste), on the merged code of #16066
ghpost::bodies./code-metrics:auditcomplexity,/code-metrics:audit-duplicationand/simplify, so AC16 is partly met as the issue defines it.AC17 (
/review:quality-gatecode and security modes)--attachalt text passed the guard when it followed a character the path patterns do not take as a left boundary (a second#,,,;,|,<,-or a letter), for example--attach '<home>/x.png#log,<home>/log'. Nine such shapes exited 2 before fix(guardrails): stop judging gh --attach source paths as posted machine paths under Bash #16066 and 0 after it. gh posts the alt text, so the path would have reached GitHub./or\is judged with the whole operand. All nine shapes exit 2 again; the test file went from 186 to 199 passing cases. Cost, failing closed: an alt text holding a slash beside a home-directory source blocks again.?,*,[,{or$in an operand counts as "could expand", so the operand is judged whole; the README says "one the shell would expand". It fails closed.block-fix-request-postreading the whole attach operand has one test (a token in the base name); a token in a directory segment and a fix-request phrase in alt text are untested.--attachonpr review, a flag gh does not have there.--bodyvalue and in an attach whose source is relative. Its fix belongs in the path patterns' boundary class.Closing as delivered for the Bash tool.