`guard_git`・`guard_command`・`guard_file` が,シェルの書き方しだいで破壊的操作や秘密情報の扱いを見逃す. いずれも dotfiles から取り込んだ既存の挙動で,今の環境でも起きる.失敗するテストを先に書いて直す. | 入力 | 現在 | 期待 | |---|---|---| | `echo "git reset --hard" \| sh`,here-string で `sh` に渡す | 通る | 拒否または確認 | | `git reset --har`(省略した長いオプション) | 破壊的と判定されない | `--hard` と同じ扱い | | `cat .en*`(glob を含む秘密ファイルの指定) | 検出されない | 秘密ファイルとして扱う | | `cd x && git commit`,`git -C x commit` | 秘密情報のコミット検査が掛からない | 検査が掛かる | ## 受け入れ条件 - [ ] 上の 4 種類それぞれに,修正前に失敗するテストがある - [ ] `echo ... \| sh` と here-string 経由のコマンドが `guard_git` と `guard_command` で評価される(`agents/hooks/lib/shell_syntax.py`) - [ ] git の長いオプションの一意な省略形が,正式名と同じく判定される(`git_safety.py`) - [ ] glob を含むパスが秘密ファイルのパターンと照合される(`provider_adapter.py`) - [ ] `cd` を挟んだ commit と `git -C` の commit に secret commit 検査が掛かる(`guard_file.py`) - [ ] 既存のテストがすべて通る <details> <summary>出典と前提</summary> - furedea/agent-config#2 のコードレビューで見つかった指摘.1〜3 は再現済み,4 は未再現 - 取り込み PR は履歴の移送に限るため,そこでは直さなかった(furedea/dotfiles#314) - 修正後は dotfiles 側の flake input を上げて反映する </details>
Activity
furedea-agent commentedon Oct 24, 2026
実装計画
4 種類のすり抜けを,それぞれ失敗するテストから直す.1 レーン・1 PR で進め,修正の種類ごとにコミットを分ける.
4 と 3 は判定方針がこの計画で決まるので,承認時に方針も合わせて確認してほしい.
fix/guard-shell-bypassagents/hooks/lib/shell_syntax.py,git_safety.py,provider_adapter.py,agents/hooks/guard_file.py,対応するtests/echo "git reset --hard" \| shと here-string(sh <<< "...")でsh/bash/zshに渡した文字列を,入れ子のコマンドとしてguard_git・guard_commandに評価させる.中身が静的に決まらない場合(変数展開など)は確認を求める--har→--hard)を正式名に正規化してから判定する.曖昧な省略は git 自体がエラーにするので扱わないcat .en*)は,パターンが秘密ファイルの名前に一致しうるかで判定する(例:.envが.en*に一致する).実在ファイルへの展開には頼らないcd x && git commitとgit -C x commitに secret commit 検査が掛かるかを,まずテストで再現する.再現すれば,検査対象のディレクトリをcd/-Cの後に解決するよう直す.再現しなければ,そのテストを残して理由を書くall-green)とレビューを通す.マージはユーザーが行うnix flake update agent-configの PR を出す前提と未決事項
cat *.mdのような無害な glob まで止まる.秘密ファイルのパターンに対してfnmatchで照合する範囲に限るfix(hooks): check every repository a commit may reach
fix(hooks): match globbed directories and bare names against secret p…
fix(hooks): judge git switch --force-create like -C
fix(hooks): inspect scripts run by dash and ksh
fix(hooks): block commits whose repository a git variable picks
fix(hooks): expand braces before matching secret paths
fix(hooks): judge scripts a shell reads from a file or process substi…
fix(hooks): treat a forced branch deletion like git branch -D
fix(hooks): ask about commits the shell parser cannot place
refactor(hooks): share the directories a cd may reach through shell_s…
fix(hooks): judge globs by the files they expand to
fix(hooks): ask when a shell gets several input redirections
fix(hooks): follow env -C and quoted git variables in the commit check
fix(hooks): expand $HOME in globs and refuse unbounded brace expansion
fix(hooks): read only standard input, where the shell may run
fix(hooks): skip env option values and line continuations in the comm…
fix(hooks): expand ** across directories in secret path globs
fix(hooks): judge git restore by the last -S and -W toggle
fix(hooks): judge inherited and per-file shell input separately
fix(hooks): find git variables inside scripts a shell reads
fix(hooks): bound glob expansion in the secret path check
fix(hooks): walk every non-hidden directory a recursive glob reaches
fix(hooks): read 00<, repeated env -C, and += as the shell does
docs(adr): judge only statically determinable shell text in the guards
docs(adr): renumber the guard contract ADR to 0015
fix(hooks): list every file a trailing ** matches
fix(hooks): ask when a piped echo word expands
fix(hooks): close shell-syntax bypasses of the guard hooks (#11)