Skip to content

fix(guardrails): stop judging gh --attach source paths as posted machine paths #15979

Closed

Description

@kyle-sexton

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
    --attach operand included, goes to GHPOST_TEXTS
    (plugins/guardrails/lib/github-post/github-post-body.sh:417) and is emitted as a word body
    (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 a word
    only when it names one of GHPOST_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 contains CLAUDE_PROJECT_DIR and 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 '![x](/home/<user>/wt/a.png)' --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.

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 labeled attach ...: 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 an evidence/ directory; run the scan-root quiet
    cases with CLAUDE_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 one deny case with the project root in the alt text.
  • deny (path): AC5 spaced form, AC5 adjacent form labeled attach adjacent alt ..., AC7's three
    shapes, AC8's PowerShell alt case, AC14, AC15's four shapes.
  • deny (secret): AC6 ($TOK after #; $TOK in 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

  1. Consumer check before editing: git grep -n -e GHPOST_TEXTS -e GHPOST_BODY_KIND -- plugins scripts shows no reader outside github-post-body.sh except the kind case at
    plugins/guardrails/hooks/block-github-post-content.sh:156 (true at 999cb91c1b). Stop on any
    other hit.
  2. 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,
      when GHPOST_TOOL is PowerShell, no ,, ( or @.
    • ghpost::segment word loop (plugins/guardrails/lib/github-post/github-post-body.sh:383-418):
      add attach=0 to the local line that declares skip=0 (line 383), so a pending --attach
      never crosses into the next segment. The function re-enters itself for bash -c, script
      wrappers and eval (plugins/guardrails/lib/github-post/github-post-body.sh:296-298,320-331,337-339).
      After the -H skip block and before GHPOST_TEXTS+=("$w"), for a form matching gh-pr-* or
      gh-issue-*: when attach is set, clear it, and if the word is literal append it to
      GHPOST_ATTACH and continue; a bare --attach sets attach; an --attach=<v> word whose
      <v> is literal appends <v> and continues. Everything else falls through to GHPOST_TEXTS,
      the --attach flag word included. The $ and $(cat checks above still see every word.
    • ghpost::bodies (plugins/guardrails/lib/github-post/github-post-body.sh:466-476): after each
      branch's word loop, add every GHPOST_ATTACH entry with ghpost::_add attach "" "$c", so
      whole-command mode and PowerShell get it too.
    • Header comments: add attach to 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 a word; 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.
  3. plugins/guardrails/hooks/block-github-post-content.sh: in the path pass case
    (plugins/guardrails/hooks/block-github-post-content.sh:156-182) add an attach) 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.
  4. plugins/guardrails/README.md:99: after "a --body-file operand is not judged", say an
    --attach operand 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.
  5. Changelog: bash scripts/new-changelog-fragment.sh guardrails patch, then a ### Fixed entry
    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 no plugin.json bump. No shared-copy sync: neither
    touched file is in scripts/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 --body value byte-identical to the operand, so a posted home path would pass
    (AC7, third shape). The library already skips curl -H values by position
    (plugins/guardrails/lib/github-post/github-post-body.sh:399-416).
  • Literal operands only: capturing every operand lets a brace, $IFS or 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|issue posting forms, pr review included: gh rejects --attach on review, so nothing
    posts either way, and no per-subcommand list is needed.
  • --body --attach <word>: pflag takes --attach as 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 --attach and gh release upload labels: 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 (![x](<home>/x.png) 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 --body value ('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' ';')"
done

Acceptance 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.png exits 0.
  • AC2: --attach '/home/<user>/.../x.png#Banner before resize' exits 0, and --attach=/home/<user>/.../x.png exits 0.
  • AC3: two --attach operands with home paths on one gh issue create exit 0.
  • AC4: an --attach operand under CLAUDE_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.png exits 0; on PowerShell, a single-quoted <win home>\...\x.png operand exits 0, and the same operand with a home path after # exits 2.
  • AC9: bash plugins/guardrails/hooks/block-fix-request-post.test.sh gives the same result on the branch as on origin/main in the same environment, and block-fix-request-post.sh and 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: attach cases and the adjacent AC5 case; on the branch head bash plugins/guardrails/hooks/block-github-post-content.test.sh exits 0.
  • AC11: the library header (body kinds, WHAT IS READ), the guard header (MACHINE PATHS, KNOWN GAPS) and plugins/guardrails/README.md row 99 describe the attach reading and its fail-closed exceptions.
  • AC12: a .changes/guardrails/ fragment with bump: patch and a ### Fixed entry exists; plugins/guardrails/.claude-plugin/plugin.json is unchanged; bash scripts/check-changelog-fragments.sh exits 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=5 and 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 --attach does 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-gate code and security modes report no unresolved blocking finding.

Required stages for the implementer

  1. The fix with the regression test written first: /testing:write for the Phase 1 cases (commit
    them red), then /implementation:implement for Phase 2.
  2. /toolchain:check and /toolchain:lint; /testing:audit on the new test cases.
  3. A performance and waste pass: rerun the Baseline script and compare with the Baseline table;
    /code-metrics:audit complexity and /code-metrics:audit-duplication on 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.
  4. /review:quality-gate code mode, plus security mode, because the change alters a guard's block
    decision.
  5. /verification:confirm against these acceptance criteria, line by line.
  6. 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.sh is 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 $(cat checks in the word loop, so GHPOST_SUBST still sees
    every word.
  • Emit attach bodies in both ghpost::bodies branches. 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 attach a local of ghpost::segment; the function re-enters itself, and a global flag
    would carry a pending --attach into 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 deny case that fails on main; the Phase 1 check expects it.
  • block-fix-request-post.test.sh depends 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/main in 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=value prefix, export or 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 word bodies 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 time loop 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.yml runs the Windows suites a change selects.

Activity

  1. added
    agent-ready
    on Nov 13, 2026
  2. added
    needs-triage
    on Nov 13, 2026
  3. github-actions commented on Nov 13, 2026

    @github-actions
    Contributor

    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 --attach operands 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.

  4. removed
    needs-triage
    on Nov 13, 2026
  5. added
    agent-ready
    and removed
    agent-ready
    on Nov 13, 2026
  6. added
    host-run
    on Nov 13, 2026
  7. melodic-automation-lanes commented on Nov 13, 2026

    @melodic-automation-lanes
    Contributor

    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).

  8. kyle-sexton commented on Nov 15, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded.

    Owner, 2026-11-15, asked how to finish this issue (close as delivered for the Bash tool, PowerShell --attach stays blocked, the AC16 and AC17 passes run first): "go w/ recommendations".

    Outcome

    AC13 and AC16 (performance and waste), on the merged code of #16066

    • The issue's Baseline script, rerun on Linux with the pre-change and merged code in one session: launch counts c0 5 = 5, a1 10 (bound 21), r1 8 (bound 24); every merged median is at or below the pre-change slowest run of the same arm.
    • Waste read: three advisory findings, none adding a process launch. The per-word tool and form test (fixed in fix(guardrails): block a home path in attach alt text after a non-boundary character #16347), two builtin assignments that run for forms that never read them, and one duplicated loop pair in ghpost::bodies.
    • Not run: /code-metrics:audit complexity, /code-metrics:audit-duplication and /simplify, so AC16 is partly met as the issue defines it.

    AC17 (/review:quality-gate code and security modes)

    Closing as delivered for the Bash tool.

  9. removed
    host-run
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-ready

    Type

    Fields

    Work status

    confirmed

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions