Repository navigation
fix(hooks): stop asking for gh calls whose target and arguments are known at hook time - #254
Conversation
…nown at hook time - A read that names its repository with a literal -R or --repo no longer asks because of the working directory's remotes. - On a line that is one gh call, a plain glob that matches no file in the working directory is the argument as written. - On such a line, a body or input file named by environment variables set in the hook's environment is expanded, then scanned like a literal path. Closes #253 Refs #197, #181 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Review summaryI found one issue (P2) and nothing that should block the merge. This was a read-only review. I did not run the test suite. What I checked
Finding
Tests cover the new paths well, both allow and ask cases, including a secret in an expanded file. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: caa18645f0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Any other variable may hold a different value in the sandboxed shell than in the hook, so a path using one keeps asking. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@codex review |
|
Review of #254: I found no P0 or P1 problems, and I didn't post any inline comments. I read the diff and the surrounding code. I did not run the test suite. What I checked:
Optional (P3) test gaps:
Assumptions the PR already lists, which keep me from marking this fully safe:
|
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@codex review |
|
Review of #254 (read-only): no blocking findings. I read the diff for Checked and fine:
Not blocking, for awareness:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc14ea15cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…tory A literal -R only settles the host; another command on the line that may write a git onto PATH still makes the call ask. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@codex review |
|
Review summary (read-only; I ran no tests and did not execute the guard against probe commands). No P0 or P1 findings. I read the three new behaviours against the existing guards:
P3 (inline): P3 (description): The PR body says Tests: Coverage of the new cases looks good. Three unmatched-glob and |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fd52ef38f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
Review summaryI found no P0 or P1 problems. I read the diff and the code around it, but I could not run the test suite in this environment because the commands were not approved. The pass/fail claims in the PR description are therefore unverified by me. What I checked
Findings
Residual risk (a decision already recorded in the PR, not a defect) 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac6d21eef9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🤖 I have created a release *beep* *boop* --- ## [0.3.1](v0.3.0...v0.3.1) (2026-11-20) ### Bug Fixes * **hooks:** do not count a printf whose format holds %n as writing nothing ([#262](#262)) ([f3a4543](f3a4543)) * **hooks:** judge gh beside commands that write nothing as gh alone ([#256](#256)) ([540bbad](540bbad)) * **hooks:** stop asking for gh calls whose target and arguments are known at hook time ([#254](#254)) ([f4aa355](f4aa355)) * **lint:** close the Rust and TypeScript items of [#196](#196) ([#259](#259)) ([1d2a81e](1d2a81e)) * **lint:** select the Go model-rule forms deferred in [#196](#196) ([#257](#257)) ([8c347fe](8c347fe)) * **lint:** widen three Python model-rule selectors deferred in [#196](#196) ([#258](#258)) ([b3fc801](b3fc801)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
概要
hook の時点で確定できる事実がある
gh呼び出しが確認(ask)になり,lane が承認待ちで止まっていた.文字列の解析を深くせず,確定できる 3 種類だけを allow 側に直す.Closes #253
Refs #197, #181
変更
-R owner/repo(--repo)で対象を明示した読み取りは,作業ディレクトリの remote を理由に確認にしない(gh_repository.names_repository_option,gh_invocation._classify_words).host は-Rの値で決まり,host 部分が無ければ github.com.github.com 以外の host,run time の値,別の option の値になりうる-R(直前が option)は従来どおり確認.nocaseglob,走査範囲と指摘が続いた.feat(hooks): judge shell function bodies instead of asking for every function #200 と同じ教訓).未一致 glob の「文字どおり扱い」とそのテストを削除し,glob を含む引数(?ref=など)は従来どおり確認.feat(agent-runtime): build persistent, isolated, provider-neutral agent infrastructure #181 で扱う.-Rの許可は,行にほかのコマンドがあれば従来どおり確認(writable な PATH に git を置きうるコマンドの検査を迂回しない).GhCall.names_repositoryを足し,gh_policy._ungrantedで行全体の検査を残した.$TMPDIR/$HOMEだけで書かれた body / input ファイルの path は展開し,リテラルの path と同じく存在・読み取り・サイズ・秘密のスキャンにかける(gh_options.expand_environment,environment_files).未設定の変数,$TMPDIR/$HOME以外の変数,単独の$f,同じ行で代入した変数,ループ,コマンド置換は従来どおり確認.gh_policy.pyの変更は,-Rの許可に行全体の検査を残す 1 行とコメントだけ.?ref=を含む read は feat(agent-runtime): build persistent, isolated, provider-neutral agent infrastructure #181 まで確認のまま.テスト
tests/hooks/test_gh_known_at_hook_time.py(新規):-Rの 7 つの書き方が remote に関わらず allow,host 違い・run time の値・option に食われうる-R・値なし・後続の別 host の-Rは ask,GH_HOST違いは ask.glob を含む read endpoint(?ref=)と,cp x later/git; gh pr list -R …は ask.tests/hooks/test_gh_run_time_body_files.py:$TMPDIRの body file が allow,ほかの変数・未設定・単独変数・存在しないファイル・コマンド置換・同じ行の代入・ループ・stdin のリダイレクトは ask,秘密を含むファイルは展開後に ask.-Rでも remote を見る,環境変数の body path は ask)を確かめていた既存テストを新しい仕様に合わせた.uv run pytest tests(6135 件),ruff,ty は通過.記録(範囲外・前提)
判定と実行の間の変化(TOCTOU)は範囲外.hook が見たファイルや環境変数が gh の実行時に変わりうる.feat(agent-runtime): build persistent, isolated, provider-neutral agent infrastructure #181 で扱う.
環境変数の展開は,hook の環境の
TMPDIR/HOMEがサンドボックス内のシェルと同じ値を持つことを前提にする(Issue の決定).ほかの変数は値が違いうるので展開せず,確認のまま.セキュリティレビューの指摘(任意の変数を展開するとスキャン対象がずれる)はこの 2 変数への限定で対処した.Issue の実例 4 件目の確認理由(行が変数や環境を設定する)は,この実例だけでは再現できなかった(実際の理由は「run time の file」).同じ行の代入は従来どおり確認.
ループ・関数・同じ行での変数代入・コマンド置換は緩めていない(feat(hooks): judge shell function bodies instead of asking for every function #200,feat(agent-runtime): build persistent, isolated, provider-neutral agent infrastructure #181).
レビュー指摘(範囲外として回答・解決):フラグ直後の
-R,-R=値の形,HOMEのテスト不足.いずれも確認が 1 回増えるだけで誤った allow にはならず,read の option 表(feat(agent-runtime): build persistent, isolated, provider-neutral agent infrastructure #181)が必要.🤖 Generated with Claude Code