heredoc-guard
Deny command substitution in unquoted shell heredocs before execution.
- License 许可
- Apache-2.0
- 所属仓库
- EtanHey/golems
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- heredoc-guard
- description
- Deny command substitution in unquoted shell heredocs before execution.
02 资源文件 3
- 脚本hooks/heredoc_parser.py8.0 KB
- 脚本hooks/heredoc-guard-pretooluse.py3.7 KB
- 脚本tests/test_heredoc_guard.py10.5 KB
03 SKILL.md 正文
Heredoc guard
Unquoted heredocs (<<EOF, <<-EOF) expand backticks and $(command) in
their bodies. A backticked command in generated Markdown can run on the host.
Quote the delimiter: <<'EOF', <<"EOF", <<\EOF, or <<E"OF".
If a value must expand, compute it first: put v=$(cmd) on its own line before
the heredoc, then use $v in the unquoted body. Quoting preserves literal text;
precomputing preserves the intended computed value.
Escaped backticks/dollars, variable expansion and arithmetic alone are allowed.
There is no environment bypass. Commands without a heredoc operator return allow
before shell inspection; << split by escaped newlines still counts. Invalid or
unsupported syntax and inspection limits in heredoc-bearing commands deny with
a plain refusal; the ledger keeps the stage and short cause. ANSI-C escapes in
delimiters require a plain quoted rewrite; ordinary ANSI-C quoted arguments are
treated as strings.
Scope: inspect the outer shell command, including executable substitutions.
Quoted interpreter payloads such as bash -c '…' are strings and are not
recursively interpreted. Quotes inside an unquoted heredoc body do not protect it.
This is a heredoc guard, not a full shell syntax validator.
Claude uses the fail-closed launcher; Codex uses codex-policy-hook.py.
Codex uses the standard ^(Bash|apply_patch)$ matcher. The gate immediately
allows non-Bash events; native patch content is never parsed as shell.
Each denial appends one JSONL record to the heredoc guard ledger in the user's
Claude logs directory, following tmp-block's durable logs convention. Override
the destination with HEREDOC_GUARD_LEDGER; tests and probes use isolated ledgers.
Records contain ts,
command_sha256, rule, and a short static reason, never raw command text.
Missing or invalid commands use the SHA-256 of the empty string. An unwritable
ledger still denies with the same plain refusal.
Source wiring does not prove installed/native enforcement. Installation and
native acceptance belong to the lead after merge; this change installs nothing.
04 同仓库更多 Skills
yash
Push dependency bugs upstream. Triggers: dependency bug, workaround, monkey-patch, fork/fix. NOT app bugs.
whats-new
Diff Claude/Codex/Cursor/Wispr/agy changelogs vs local setup. Triggers: whats new, changelog, version bump.
weave
Orchestrator convergence: mine JSONLs, cite findings, route actions. Triggers: weave, run weave.
unslop
Cut AI tells while keeping every receipt, number, path, and hedge intact. Triggers: unslop, cut the slop, wall of text, too verbose, rambly, make this readable. NOT for delivery cadence (see i-have-adhd), channel choice, or artifact length governance.
tmp-block
Guard denying durable writes to /tmp, /private/tmp, /var/folders, $TMPDIR; enforces <repo>/.worktrees/<name>. Triggers: tmp guard, TMP-BLOCK deny, WORKTREE-CONVENTION deny, bypass ledger. NOT for storage policy.
t3-visuals
Show/visualize/chart/diagram/compare/status board in T3 with compact interactive HTML. Not standalone dashboards.