Repository navigation
fix: root github auth probe を --active --hostname github.com に限定する - #2413
Conversation
…2404) _github_auth_probe が呼び出す `gh auth status` に `--active --hostname github.com` を付与し、github.com の active account の認証状態のみを 検査するようにする。無関係な host や inactive account の認証不整合で workflow preflight を誤って block しないようにするため。 test_capability_preflight_review_fixes.py の test_root_to_producer_transports_deadline_with_fake_external_clis が 検証する exact fake-gh argv trace の先頭要素も同じ引数に合わせて更新する。 fake gh fixture は args[:2] == ["auth", "status"] で受理するため変更不要。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2413/ The preview will be removed when this PR is closed. |
impl-review-loop PR レビュー結果Mergeability
Evidence Check
Blockersなし Non-blockersなし verdict: APPROVE
reviewed_head_sha: c18818c0f89059d5cb814436db98f308b8990850
blockers: []
warnings: [] |
敵対的レビュー結果PR #2413 の中心変更は妥当です。差分は production の また、前回 Issue #2404 をレビューした際の主要 finding は既にかなり適切に取り込まれています。現在の Issue は exact root→producer test を AC にし、GitHub CLI 2.57.0 以上を runtime precondition とし、version parser・fallback・新規 harness を明示的に不要としています。 PR 上の既存 impl-review-loop も head ただし、まだ1点、今回の目的そのものに刺さる host-scope の穴があります。 ID | 重要度 | Finding | 推奨 -- | -- | -- | -- P1-1 | P1 / merge blocker | auth probe は github.com に固定された一方、直後の repo-read probe は ambient default host のまま | _github_repo_read_probe も github.com に固定 P2-1 | P2 | 現テストは argv を正しく固定するが、fake gh 自身は auth の追加引数を意味論的には検証しない | 現状維持でよい。公式実装照合で十分P1-1: |
| ID | 重要度 | Finding | 推奨 |
|---|---|---|---|
| P1-1 | P1 / merge blocker | auth probe は github.com に固定された一方、直後の repo-read probe は ambient default host のまま |
_github_repo_read_probe も github.com に固定 |
| P2-1 | P2 | 現テストは argv を正しく固定するが、fake gh 自身は auth の追加引数を意味論的には検証しない |
現状維持でよい。公式実装照合で十分 |
P1-1: root_github_read の2つの probe が別 host を見る可能性がある
PR 後の root GitHub 判定は実質的にこうなります。
github_auth:
gh auth status --active --hostname github.com
github_repo_read:
gh repo view squne121/loop-protocol --json name
production コードも、auth 側だけを github.com 固定し、repo-read 側には host 指定がありません。
ここで GitHub CLI の実装が重要です。gh repo view owner/repo は owner/repo に host が含まれていない場合、ghrepo.FromFullName() → defaultHost() を通して default host を補完します。公式実装は HOST/OWNER/REPO や full URL なら host を明示できますが、現在の squne121/loop-protocol 形式はそうではありません。
さらに GitHub CLI では、コマンドから host が確定しない場合に GH_HOST が host 選択へ影響します。([cli.github.com]2) このリポジトリ自身も GH_HOST を credential/host context に影響する値として扱っており、controlled probe では明示的に GH_HOST を環境から除去して --hostname github.com を使うテストがあります。一方、root の auth/repo probes は ambient environment を使う設計です。
したがって、例えばシェルに次が残っているだけで問題になります。
export GH_HOST=github.example.comすると、
gh auth status --active --hostname github.com
→ github.com を検査して PASS
gh repo view squne121/loop-protocol --json name
→ GH_HOST の github.example.com を対象にして FAIL
となり得ます。
しかも root_github_read は repo-read が失敗すると unavailable になり、controlled GitHub probe が正常でも workflow 全体を block する既存契約です。これはテストにも固定されています。
つまり今回の PR は、
「無関係な host の認証不整合で block しない」
ことを auth probe については達成していますが、同じ composite capability の repo-read 側から無関係な host が再侵入できます。
これはセキュリティ強化の話ではありません。むしろ、ユーザーが避けたい 不要な workflow block そのものです。
修正はかなり小さくできます
新しい env sanitizer、host abstraction、version layer、live GitHub test は不要です。
私なら _github_repo_read_probe を次のようにします。
def _github_repo_read_probe(repo: str, deadline_ns: int) -> ProbeOutcome:
return _run_probe_with_deadline(
"github_repo_read",
["gh", "repo", "view", f"github.com/{repo}", "--json", "name"],
deadline_ns=deadline_ns,
cap_seconds=_GITHUB_REPO_READ_PROBE_CAP_SECONDS,
)GitHub CLI の parser は HOST/OWNER/REPO を正式に受け付けます。
既存の exact trace も2番目だけ合わせます。
assert gh_calls == [
["auth", "status", "--active", "--hostname", "github.com"],
["repo", "view", f"github.com/{_REPO}", "--json", "name"],
["api", "--hostname", "github.com", f"repos/{_REPO}", "--jq", "{name}"],
]追加テストは要求しません。 既存の root→producer exact-argv test で十分です。これならハーネスを増やさず、「auth・root repo read・controlled repo read の3つが全部 github.com」という単純な契約になります。
問題は Issue #2404 が現在 _github_repo_read_probe の変更を Out of Scope にしている点です。 個人趣味開発で品質と作業効率を優先するなら、別 Issue に分割して往復を増やすより、#2404 の scope をこの1行だけ controlled reframe して PR #2413 で終わらせる方を推します。
P2-1: fake gh が --active の意味論を検証しないことは blocker ではない
共有 fake gh は auth invocation を
if args[:2] == ["auth", "status"]:で受理するため、--active --hostname github.com の挙動そのものは再現しません。
ただし今回は別の exact-argv trace がフルの引数列を照合しており、GitHub CLI の公式 manual と現行 source でも --active / --hostname の意味論を確認できています。したがってここを理由に fake CLI を精密化したり、live-account test を新設したりするのは過剰です。
GitHub CLI 2.57.0 未満への production fallback も不要です。PR evidence では実利用環境が 2.98.0 と確認済みで、Issue も runtime precondition として処理しています。 個人環境なら「古くなったら gh を更新」で十分です。
最終判断
gh auth status --active --hostname github.com への変更自体には賛成です。 前回レビューで問題にした Allowed Paths、exact verification、GitHub CLI version precondition も解消されています。
しかし、今回の目的が「無関係な host による誤 block をなくす」である以上、auth だけを pin して gh repo view owner/repo を ambient default host のまま残すのは中途半端です。既存 APPROVE はこの gh repo view の host resolution まで見ていません。
したがって 現 head は REQUEST_CHANGES とします。
必要な追加作業は、実質的には production 1行 + exact expected 1行、および Issue #2404 の _github_repo_read_probe Out of Scope を狭く解除することだけです。セキュリティ harness、sandbox、version compatibility framework、追加 live test は入れない方がよいです。
OWNER REQUEST_CHANGES (PR #2413, P1-1) を反映。auth probe のみを github.com に固定しても、composite capability の repo-read probe が ambient default host(GH_HOST 環境変数の影響を含む)のままでは、 無関係な host による認証不整合の誤 block を防ぐという本 Issue の 目的が未達成だったため、_github_repo_read_probe の gh repo view 呼び出し引数を f"github.com/{repo}" に固定する。 - scripts/claude-gpt/workflow_capability_preflight.py: _github_repo_read_probe の対象引数を github.com host 固定に変更 - scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py: test_root_to_producer_transports_deadline_with_fake_external_clis の exact fake-gh trace 期待値の2番目の要素を更新 Refs #2404
|
fix_delta 適用完了(OWNER REQUEST_CHANGES P1-1 対応、iteration 1)。 変更内容
新規 head: 検証結果(Issue #2404 Verification Commands)標準品質ゲート
Scope
|
impl-review-loop PR レビュー結果(iteration 2、fix_delta 後の最終確認)Mergeability
Evidence Check
経緯(このレビューで解消した blocker)直前のレビューで Blockersなし Non-blockersなし verdict: APPROVE
reviewed_head_sha: ebe972a525f89da55dc693e64e2878f66f395821
blockers: []
warnings:
- "直前レビューで検出した python-test failure は同一head上の並行CI runによる race(旧runのcancelled job起因)であり、新runの完走によりSUCCESSで再確定済み。コード自体の問題ではない。" |
Summary
_github_auth_probeが実行するgh auth status呼び出しに--active --hostname github.comを追加し、github.com の active account の認証状態のみを検査するようにした。無関係な host や inactive account の認証不整合で workflow preflight を誤って block しないようにするための修正。test_root_to_producer_transports_deadline_with_fake_external_clis)の期待値を新しい argv に合わせて更新した。fake gh fixture はargs[:2] == ["auth", "status"]で受理する実装のため、fixture 自体の変更は不要だった。_github_repo_read_probeが実行するgh repo view呼び出しの対象引数をrepoからf"github.com/{repo}"へ変更し、ambient default host(GH_HOST環境変数の影響を含む)ではなく github.com に明示的に固定した。auth probe のみを github.com に固定しても、同一 composite capability の repo-read probe が ambient host のままでは無関係な host の再侵入を防げないという OWNER 指摘(https://github.com/squne121/loop-protocol/pull/2413#issuecomment-5465790972)に対応。同じ exact-argv trace テストの2番目の期待要素も合わせて更新した。Issue 実装: root GitHub auth probe を対象host限定(--active --hostname github.com)に変更する #2404 の契約(AC5・Out of Scope)は本 fix_delta 前に OWNER trusted anchor reframe として更新済み。Checks
pnpm typecheckpnpm lintpnpm testpnpm buildSchema Change Applicability
not_schema_changeSchema Consumer Inventory
N/A(
not_schema_changeのため)。Visual Impact Declaration(視覚影響申告)
UI(DOM/CSS)変更を含まないため省略する。
Safety Claim Matrix
_github_auth_probe)はgh auth status --active --hostname github.comを実行し、github.com の active account の認証状態のみを検査する(他 host / inactive account の状態は本 probe の判定に影響しない)。--activeフラグは実行環境の GitHub CLI が 2.57.0 以上であることを前提とし、production への互換 fallback は追加しないgh version 2.98.0(要件 >= 2.57.0 を満たす)_github_repo_read_probe(gh repo view)は対象引数をf"github.com/{repo}"に変更し github.com host に明示的に固定した(GitHub CLI が正式サポートするHOST/OWNER/REPO形式)。それ以外(actor-scoped / controlled_github_read の各 probe、env sanitizer、host abstraction layer の新設)は本 PR で変更していないgit diffで_github_repo_read_probe以外の probe 関数に diff がないことを確認記載ルール確認:
Not controlledは GitHub CLI 側実装の外部前提のみであり、無限定のsafe/read-only/sandboxed/isolated/completeは本文中で使用していない。Not controlledに対応する Follow-up は該当なし(gh --versionによるバージョン要件確認で閉じており、追加の恒久対応は不要)。検証コマンド結果(Issue #2404 Verification Commands)
Notes
implement-issueskill 手順に従う)scripts/claude-gpt/workflow_capability_preflight.py,scripts/claude-gpt/tests/test_capability_preflight_review_fixes.py)の範囲内のみを変更。docstring(17/29/327 行目付近のgh auth status記述)は generic な capability 説明であり exact argv を主張していないため変更していない(Issue In Scope の「必要な場合」の判断として据え置いた)。_github_repo_read_probeの host 固定を追加した。