Repository navigation
feat(hooks): judge heredocs, substitutions, loops, and redirections structurally - #175
Merged
Merged
Conversation
…tructurally Every command inside a substitution, clause, or shell heredoc is now judged on its own. Quoted heredocs are standard input, and rules match command words, so redirections no longer ask. Interpreters take any argument; only scripts a shell computes at run time still ask. Closes #174 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 17, 2026
furedea
added a commit
that referenced
this pull request
Oct 17, 2026
Replaying the 151 Bash commands run after #175 gave 58 non-allow verdicts. 56 of them were prompts for local commands that used a shell variable or a form the precise allowlist did not list. This PR keeps prompts for effects the sandbox cannot undo. - **Local commands pass in any form.** The allowed guard now governs only `gh`, `curl`, and `wget`, listed per rule under `programs`. Every other command passes unless a forbidden rule or the dangerous-Git guard denies it. This covers `git commit -S`, `git -C $W add`, `sed -i ''`, `cat > $D/pr.md`, and unlisted subcommands of approved tools. - **Run-time words in governed programs.** A run-time word counts as a placeholder, so it passes only where any value would. `gh pr view $N` and `gh api repos/o/$r/... --jq` (reads) pass. `gh api $E --method DELETE` asks. - **The Git guard asks about a run-time word only when it can hide a denial.** That means a dynamic program or subcommand, an argument of a verb judged by its options (push, reset, branch, switch, checkout, restore, rm, mv, gc, `worktree remove`), or the repository an implicit push reads its branch from. `git -C $W push origin topic`, `git -C $R worktree add ... $W`, and `git commit -m "$MSG"` pass. - **Parser fixes.** - A lone `[` is no longer a glob, so `[ -d "$W" ]` is not a run-time program. - Parameter operations such as `${c:0:7}` parse. A substitution inside `${x:-$(rm -rf y)}` is still denied. - **Permissions.** `ln -s` moves to allow. `git stash drop` and `git stash clear` stay ask, because recovering a dropped stash needs dangling-commit archaeology. The plan had listed them as recoverable; that was wrong. - **ADR-0036** supersedes ADR-0034. Closes #177 ## Verification - `uv run --frozen pytest tests`: 1459 passed. The 3 errors in `tests/hermes/test_hermes_gateway.py` also occur on main. - Replayed every Bash command from today's sessions (284) through the new hooks: 273 allow and 7 deny. The 4 remaining asks are: - a run-time program (`$P -c ...`); - zsh-only `${(@f)...}`; - `git worktree remove $R-$w`; - `curl` to a remote host. - The existing denials stay green: substitutions, clauses, shell heredocs, force pushes, pushes to main, `--no-verify`, and `git add -A`. - ruff, ty, and lefthook pre-commit passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 task done
furedea
added a commit
that referenced
this pull request
Nov 12, 2026
agent-config 0.1.2(`3b3d9c5`)を取り込みます.#74 のモデル判定まわりの残りがすべて入ります. | 取り込む変更(furedea/agent-config) | 中身 | | --- | --- | | #172 | 「ルールの見本のフォルダ」の判定を 1 か所にまとめる | | #173 | jev-lint の子プロセスに `GIT_LITERAL_PATHSPECS=1` を渡す(#159) | | #174 | 時間に頼らないタイムアウトのテスト(#171) | | #175,#178 | Go と Rust のルールの穴と,境目の見本(#164) | | #180 | 読み取り専用の GraphQL の問い合わせのあとに `jq` を付けてよくする | | #177 | Stop のテストの行を,ランナーごとに 1 つの件数にまとめる(Rust は `312 passed` のように合計する) | - [x] `darwin-rebuild switch` で反映済み ほかのセッションが main の古い `flake.lock` で反映すると,これらが取り消されます.早めにマージします. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since ADR-0034 deployed, 313 of 354 hook escalations were syntax: quoted heredocs fed to python3, command substitution, for loops, and redirections. All of these are contained by the sandbox.
echo "$(rm -rf x)"is denied, and a force push inside a loop is denied. A substituted word is a run-time word.evalorsh -cof a computed script, and dollar-quoted words still ask.python,python3, andnodeare sandbox-contained programs that take any argument;uv run pythonanduv run --frozen pythontake any arguments.python -m pipstays denied.Known gap, left for a follow-up: the forbidden patterns are unanchored, so a quoted argument that merely contains text such as a bulk staging command (for example a PR body passed with
--body) is still denied. This PR body is passed with--body-filefor that reason.Closes #174
Verification
uv run --frozen pytest tests/agents: 1537 passed. New tests cover exposed inner commands, run-time substituted words, heredocs as standard input, shell heredocs parsed as scripts, computed scripts still asking, and denials inside substitutions, clauses, and shell heredocs.ruff check,ruff format,ty check, and lefthook pre-commit passed.🤖 Generated with Claude Code