Repository navigation
fix: check_session_recording_runtime_safety.py の ghs_ redaction を新形式トークンに対応 - #2789
Conversation
…ークンに対応 (#2734) 新形式 GitHub App installation token (ghs_<APP_ID>_<JWT-header>.<payload>.<signature>) は、既存の legacy ghs_[0-9A-Za-z]+ matcher だと APP_ID 直後の最初の "_" で 部分マッチが終了し、残りの "_" と JWT 全体("." 区切りの header/payload/signature)が redact 後の診断出力に断片として 残存していた。 _SECRET_PATTERNS に新形式トークンを完全にマッチする broad matcher (ghs_[A-Za-z0-9._-]{36,}) を、既存の legacy matcher より前に追加 する(specific-before-legacy)。legacy matcher 自体および他の GitHub prefix matcher(gho_/ghu_/ghr_/ghp_/github_pat_)は変更しない。 _self_check_redaction() の "if raw in redact(raw): return False" という判定は、部分マッチで 文字列の一部だけが [REDACTED] に置換され断片が残るケース (partial redaction)を成功として見逃す false-green だった。 新形式 standalone token について redact 結果が exactly "[REDACTED]" になることを検証する exact whole-token behavioral check を追加した。 tests/session-recording/test_runtime_safety_redaction.py に、 新形式トークンの完全 redaction(AC2)、legacy-only matcher set に monkeypatch した場合の _self_check_redaction() の false 検知 (AC3、production code は書き換えない)、既存 short-form ghs_ の 回帰確認(AC4)を検証する focused pytest を追加した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2789 closed). |
impl-review-loop: pr-review-judge Verdict
Blockersなし Warningsなし(Draft 状態は情報として記録するのみ) verdict: APPROVE
reviewed_head_sha: "e88daaa0d4efeea42a82b9eab21c99ddbf9e9292"
blockers: []
warnings: [] |
判定REQUEST_CHANGES。 コアの production regex 自体は妥当ですが、今回の主目的の一つである 対象は [PR #2789](https://github.com/squne121/loop-protocol/pull/2789?utm_source=chatgpt.com)、契約元は [Issue #2734](https://github.com/squne121/loop-protocol/issues/2734?utm_source=chatgpt.com)。先行実装として [PR #2722](https://github.com/squne121/loop-protocol/pull/2722?utm_source=chatgpt.com) と Issue #2725 も照合しました。 Findings
production 実装の評価
GitHubの2026年5月15日の案内は、新旧installation token双方を扱う推奨regexとしてほぼ同一の リポジトリ・CI確認PR #2789 は head 関連履歴では PR #2722 が同じ新形式 CI run マージ前に直す最小差分P1とP2だけで十分です。self-check fixture に それ以外の production regex、Allowed Paths、CI plan、他 GitHub prefix matcher は触らない方がよいです。 |
P1: `_self_check_redaction()` が使う新形式 ghs_ トークンの synthetic
サンプルに `-` を含めていなかったため、broad matcher
`ghs_[A-Za-z0-9._-]{36,}` から `-` を落とす regression を検知できない
false-green があった。サンプルに `-` を追加し、既存の broad matcher
の性質(`.` を exactly 2個・`_` と `-` を含む・実トークンを代表する
長さ)を独立して備えるよう修正した。加えて、この regression を固定する
mutation-style test
(test_self_check_redaction_detects_dash_dropped_from_broad_matcher)を
tests/session-recording/test_runtime_safety_redaction.py に追加し、
monkeypatch で `-` を欠落させた broad matcher に差し替えた状態で
`_self_check_redaction()` が False を返すことを検証する。
P2: 既存 negative-path test が broad matcher の識別に
`"{36,}" not in pattern.pattern` という偶然一致しうるセレクタを使って
いたため、将来別 prefix が正当に `{36,}` を採用しただけで無関係に
テストが壊れる懸念があった。canonical string
`r"ghs_[A-Za-z0-9._-]{36,}"` との exact identity 比較に変更し、
production `_SECRET_PATTERNS` にこの matcher が exactly 1件だけ
存在することを事前に assert した上でその1件のみを除外・置換する
ロジックに修正した。
Co-Authored-By: Claude Sonnet 5 <[email protected]>
impl-review-loop 再開: fix_delta 適用結果(対応先: #issuecomment-5847955926)対象 REQUEST_CHANGES(P1/P2)を解消しました。P3(over-redaction)は non-blocking として受容済みのため対応していません。 変更内容P1: P2: negative-path test の broad matcher 特定を production regex( 検証結果(current head)
Note過去の APPROVE コメント(#issuecomment-5847713114、旧head PR body 内 merge はこのループでは実行していません。人間の最終判断をお願いします。 |
Summary
.claude/scripts/check_session_recording_runtime_safety.pyの_SECRET_PATTERNSに、新形式 GitHub App installation token(ghs_<APP_ID>_<JWT-header>.<payload>.<signature>)を完全にマッチする broad matcher(ghs_[A-Za-z0-9._-]{36,})を、既存の legacy matcher(ghs_[0-9A-Za-z]+)より前に追加した(specific-before-legacy)。既存 legacy matcher と他の GitHub prefix matcher(gho_/ghu_/ghr_/ghp_/github_pat_)は変更していない。_self_check_redaction()の判定を、partial redaction(文字列の一部だけが[REDACTED]に置換され断片が残るケース)を成功として見逃すif raw in redact(raw)から、新形式 standalone token について redact 結果が exactly[REDACTED]になることを検証する exact whole-token behavioral check に修正した。tests/session-recording/test_runtime_safety_redaction.pyを新規追加し、AC2(新形式トークンの完全 redaction)、AC3(_self_check_redaction()が legacy-only matcher set では partial redaction を検知してFalseを返す)、AC4(既存 short-formghs_の回帰確認)を検証する focused pytest を実装した。Acceptance Criteria
_SECRET_PATTERNSに、新形式ghs_<APP_ID>_<JWT-header>.<payload>.<signature>を完全にマッチする新しい broad/current matcher(ghs_[A-Za-z0-9._-]{36,}相当)が、既存のghs_[0-9A-Za-z]+legacy matcher より前の位置に追加されている。既存 legacy matcher および他の GitHub prefix matcher(gho_/ghu_/ghr_/ghp_/github_pat_)は変更されていない.を exactly 2個、_と-を含む deterministic synthetic な新形式ghs_installation token について、redact(f"before {token} after") == "before [REDACTED] after"が成立する_self_check_redaction()が partial redaction を成功として扱わない。new-format standalone token を exactly[REDACTED]に置換できない場合(意図的に旧実装相当へ戻した場合)に_self_check_redaction()が False を返す(fail を検知する)ことをテストで検証するghs_トークン(例:"ghs_abc123XYZ")の既存 redaction behavior が本変更後も維持されているtests/session-recording/配下の新規 focused pytest(test_runtime_safety_redaction.py)が pass するVerification Commands(実行結果)
Checks
pnpm typecheck— N/A(Python のみの変更、対象ファイルは TypeScript ではない)pnpm lint— N/A(対象ファイルは ESLint 対象外の Python スクリプト)pnpm test— N/A(Vitest 対象外。上記 pytest で代替検証済み)pnpm build— N/A(ビルド成果物に影響しない Python/pytest 変更).claude/scripts/*.pyとtests/session-recording/*.pyのみを変更する Python 専用変更のため、上記 pnpm 系コマンドの代わりにuv run --locked pytestによる Verification Commands を正本として実行・記録した。Schema Change Applicability
not_schema_change_SECRET_PATTERNSは producer-consumer 境界をまたぐ machine-readable contract ではなく、単一ファイル内部の正規表現リストである。追加した matcher は同ファイル内redact()の内部実装詳細であり、外部 consumer が参照する schema フィールドではない。Schema Consumer Inventory
N/A(
not_schema_changeのため)。Visual Impact Declaration(視覚影響申告)
該当なし(UI/DOM/CSS 変更を含まない)。
Safety Claim Matrix
.claude/scripts/check_session_recording_runtime_safety.py内で、新形式 GitHub App installation token(ghs_<APP_ID>_<JWT>)が診断出力で断片を残さず完全に[REDACTED]へ置換されるtest_redact_fully_redacts_new_installation_tokenPASS(上記 Verification Commands 参照).claude/scripts/check_session_recording_runtime_safety.py内の_self_check_redaction()が partial redaction(断片残存)を false-green として見逃さないtest_self_check_redaction_detects_partial_redactionPASS記載ルール遵守: 上表の各主張は「
.claude/scripts/check_session_recording_runtime_safety.py単体ファイル内」に射程を明示的に限定しており、Not controlledは空(-)である。.claude/scripts/check_session_recording_runtime_safety.py以外の redactor / secret detector ファイルへの同種拡張は Issue #2734 本文の Out of Scope として明記済みのスコープ境界であり(Not controlled ではなくスコープ定義)、PR title / summary / docs で無限定のsafe/read-only/sandboxed/isolated/completeは使用していない。Notes
.claude/scripts/check_session_recording_runtime_safety.py単体に限定)。他 redactor ファイルへの拡張は Out of Scope(別途 follow-up 起票対象)。.claude/scripts/check_session_recording_runtime_safety.py、tests/session-recording/test_runtime_safety_redaction.pygit diff --name-only main...HEAD):.claude/scripts/check_session_recording_runtime_safety.py、tests/session-recording/test_runtime_safety_redaction.py.github/ci/python-test-plan.jsonは変更していない(tests/session-recording/は既存 required pytest target に含まれているため不要)。git diff再計算による): trueimplement-issueskill 手順)による実装。人間承認前に worktree 作成・実装・push・Draft PR 起票まで自律実行。ghs_installation token redaction の先行実装)