Repository navigation
feat(#970): secret_boundary_guard を MultiEdit 対応に拡張する - #989
Conversation
- SENSITIVE_TOOLS に MultiEdit を追加 - settings.json の secret boundary guard matcher に MultiEdit を追加 - hook-boundaries.md の secret_boundary_guard matcher を更新 - MultiEdit pathless fail-closed ロジックを追加 (AC8) - test_secret_boundary_multiedit.py を新規作成 (AC3/AC5/AC8/AC9/AC10) - test_secret_boundary_contract.py に MultiEdit 回帰テストを追加 (AC4)
Preview URLPreview removed (PR #989 closed). |
#960 が書いた assert MultiEdit not in secret_matcher は follow-up Issue (#970) 完了後に assert MultiEdit in secret_matcher に反転する前提のものだった。#970 実装完了により更新。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
schema: LOOP_VERDICT_V2
verdict: APPROVE
pr_number: 989
reviewed_head_sha: d6e8e045078777140da908ab6d3bcd3a734967e1
issue_number: 970
contract_snapshot_url: "https://github.com/squne121/loop-protocol/issues/970#issuecomment-4742206654"
expected_contract_fingerprint: "sha256:383d511e2baa1e7cfb8284e2a721b94f70ec4b19f76706b6eebd1400e23baf00"
contract_source_kind: issue_comment
contract_source_id: "4742206654"
allowed_paths_gate:
result: PASS
schema: ALLOWED_PATHS_GATE_RESULT_V1
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files:
- ".claude/hooks/secret_boundary_guard.sh"
- ".claude/hooks/tests/test_secret_boundary_contract.py"
- ".claude/hooks/tests/test_secret_boundary_multiedit.py"
- ".claude/hooks/tests/test_worktree_scope_guard.py"
- ".claude/settings.json"
- "docs/dev/hook-boundaries.md"
allowed_paths_from_contract:
- ".claude/hooks/secret_boundary_guard.sh"
- ".claude/settings.json"
- ".claude/hooks/tests/test_secret_boundary_contract.py"
- ".claude/hooks/tests/test_secret_boundary_multiedit.py"
- "docs/dev/hook-boundaries.md"
- ".claude/hooks/tests/test_worktree_scope_guard.py"
violations: []
determination: all_changed_files_within_allowed_paths
ac_results:
- ac: AC1
status: PASS
evidence: "SENSITIVE_TOOLS=\"Read Write Edit Grep Glob MultiEdit\" confirmed in secret_boundary_guard.sh diff (line 128)"
- ac: AC2
status: PASS
evidence: "settings.json PreToolUse[0] matcher updated to \"Bash|Read|Write|Edit|Grep|Glob|MultiEdit\""
- ac: AC3
status: PASS
evidence: "test_multiedit_secret_block() asserts exit 2 for MultiEdit on /home/user/.env; behavioral test via subprocess"
- ac: AC4
status: PASS
evidence: "test_existing_tools_no_regression parametrized over Read/Write/Edit/Grep/Glob (block) and MultiEdit safe path (allow); CI python-test PASS"
- ac: AC5
status: PASS
evidence: "test_guard_order_secret_before_worktree() verifies secret_guard_index < worktree_guard_index; settings.json structure: index 0 = secret_boundary_guard (matcher includes MultiEdit), index 1 = worktree_scope_guard"
- ac: AC6
status: PASS
evidence: "CI: python-test/test/typecheck/lint/build/e2e all PASS per gh pr checks output"
- ac: AC7
status: PASS
evidence: "docs/dev/hook-boundaries.md manifest matcher = \"Bash|Read|Write|Edit|Grep|Glob|MultiEdit\" matches settings.json PreToolUse[0] matcher exactly"
- ac: AC8
status: PASS
evidence: "Guard code: [ \"$TOOL_NAME\" = \"MultiEdit\" ] && [ -z \"$PATH_INPUT\" ] → exit 2. jq PATH_INPUT extraction: empty file_path (\"\") produces empty string; -z check fires. Tests test_multiedit_pathless_fail_closed_missing and test_multiedit_pathless_fail_closed_empty confirm exit 2 with no raw payload leak in stderr"
- ac: AC9
status: PASS
evidence: "test_multiedit_sensitive_paths_parametrize covers 9 paths: .env, .env.local, secrets/api_key.txt, settings.local.json, .netrc, .npmrc, .pypirc, .aws/credentials, .kube/config"
- ac: AC10
status: PASS
evidence: "test_multiedit_first_in_pretooluse_group() verifies first MultiEdit-matching entry has secret_boundary_guard as hooks[0]; settings.json structure independently confirmed"
stop_conditions: []
ci_status:
python-test: pass
test: pass
typecheck: pass
lint: pass
build: pass
e2e: pass
PR Body Japanese Check: pass
notes:
- "AC8 jq behavior: in jq, empty string (\"\") is not falsy for // operator (only null/false are), so file_path:\"\" correctly produces empty PATH_INPUT, and -z check fires correctly."
- "test_worktree_scope_guard.py change is within Scope Delta (旧 assertion 更新 for #960 compatibility) and within Allowed Paths."
- "All CI required jobs PASS. No stop conditions detected."レビュー判定: APPROVE
全 AC が差分と CI 証跡で確認できた。Allowed Paths 逸脱なし。stop_condition 該当なし。
確認ポイント:
- AC1/AC2:
SENSITIVE_TOOLSと settings.json matcher の両方にMultiEditが追加されており、一致している。 - AC3/AC9: MultiEdit で secret path を block するテストが subprocess harness で実装され、9 種の sensitive path を parametrize でカバーしている。
- AC4: 既存 tool の block/allow 挙動が parametrized テストで固定されており、CI PASS。
- AC5/AC10: settings.json の PreToolUse 配列で index 0 =
secret_boundary_guard(matcher:Bash|Read|Write|Edit|Grep|Glob|MultiEdit)、index 1 =worktree_scope_guardの順序が確認でき、テストで固定されている。 - AC7:
docs/dev/hook-boundaries.mdの manifest matcher と settings.json が"Bash|Read|Write|Edit|Grep|Glob|MultiEdit"で一致。 - AC8: file_path 欠落/空文字 → exit 2 のロジックが実装されており、stderr への raw payload 漏洩なしを確認するアサーションもある。
- AC6: 全 CI ジョブ(python-test/test/typecheck/lint/build/e2e)が PASS。
判定: REQUEST_CHANGESPR #989 の方向性は正しいです。 ただし、AC8 の fail-closed 要件をすり抜ける実装穴があるため、このままマージは不可です。 Blocker 1:
|
…2 Grep テスト payload を runtime shape に修正
- secret_boundary_guard.sh: MultiEdit の file_path 検証を fallback 禁止の明示型チェックに置換
(path/pattern/glob fallback 経由の迂回を防ぐ; file_path が string 型でない場合はすべて exit 2)
- test_secret_boundary_multiedit.py: path/pattern/glob/null/array/object/number の 7 種類の
fallback payload をすべて exit 2 にするパラメータを test_multiedit_pathless_fail_closed_fallback_variants として追加
- test_secret_boundary_contract.py: test_existing_tools_no_regression の Grep payload を
{"file_path": path} から {"pattern": path} に変更(runtime shape に合わせる)
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
schema: LOOP_VERDICT_V2
verdict: APPROVE
pr_number: 989
reviewed_head_sha: 6fb51c2a6395d9dfb9669d848e8593947e2cac72
issue_number: 970
contract_snapshot_url: "https://github.com/squne121/loop-protocol/issues/970#issuecomment-4742206654"
expected_contract_fingerprint: "sha256:383d511e2baa1e7cfb8284e2a721b94f70ec4b19f76706b6eebd1400e23baf00"
contract_source_kind: issue_comment
contract_source_id: "4742206654"
allowed_paths_gate:
schema: ALLOWED_PATHS_GATE_RESULT_V1
result: PASS
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files:
- ".claude/hooks/secret_boundary_guard.sh"
- ".claude/hooks/tests/test_secret_boundary_contract.py"
- ".claude/hooks/tests/test_secret_boundary_multiedit.py"
- ".claude/hooks/tests/test_worktree_scope_guard.py"
- ".claude/settings.json"
- "docs/dev/hook-boundaries.md"
allowed_paths_from_contract:
- ".claude/hooks/secret_boundary_guard.sh"
- ".claude/settings.json"
- ".claude/hooks/tests/test_secret_boundary_contract.py"
- ".claude/hooks/tests/test_secret_boundary_multiedit.py"
- "docs/dev/hook-boundaries.md"
- ".claude/hooks/tests/test_worktree_scope_guard.py"
violations: []
determination: all_changed_files_within_allowed_paths
ac_results:
- ac: AC1
status: PASS
evidence: "SENSITIVE_TOOLS=\"Read Write Edit Grep Glob MultiEdit\" at line 128 of secret_boundary_guard.sh"
- ac: AC2
status: PASS
evidence: "settings.json PreToolUse[0] matcher = \"Bash|Read|Write|Edit|Grep|Glob|MultiEdit\""
- ac: AC3
status: PASS
evidence: "test_multiedit_secret_block() asserts exit 2 for MultiEdit on /home/user/.env via subprocess harness"
- ac: AC4
status: PASS
evidence: "test_existing_tools_no_regression parametrized over Read/Write/Edit (file_path), Grep/Glob (pattern), MultiEdit safe path; CI python-test PASS"
- ac: AC5
status: PASS
evidence: "test_guard_order_secret_before_worktree() verifies secret_guard_index < worktree_guard_index for MultiEdit-matching entries"
- ac: AC6
status: PASS
evidence: "All CI required jobs PASS: python-test/test/typecheck/lint/build/e2e/PR Body Japanese Check/actionlint/validate-generated-artifact"
- ac: AC7
status: PASS
evidence: "docs/dev/hook-boundaries.md secret_boundary_guard matcher = \"Bash|Read|Write|Edit|Grep|Glob|MultiEdit\" matches settings.json exactly"
- ac: AC8
status: PASS
evidence: |
MultiEdit-specific block at lines 130-141: independently re-extracts file_path via
jq -r '.tool_input.file_path | type' (null/array/object/number all return non-"string")
and jq -r '.tool_input.file_path // empty' (empty string gives -z true).
Covers: missing key → FILE_PATH_TYPE="null"; file_path:null → "null"; file_path:[] → "array";
file_path:{} → "object"; file_path:123 → "number"; file_path:"" → type="string" but -z fires.
The earlier PATH_INPUT fallback (line 27) is overridden or bypassed by the MultiEdit block exiting early.
test_multiedit_pathless_fail_closed_fallback_variants covers 7 variants (path/pattern/glob/null/array/object/number).
- ac: AC9
status: PASS
evidence: "test_multiedit_sensitive_paths_parametrize covers 9 paths: .env, .env.local, secrets/api_key.txt, settings.local.json, .netrc, .npmrc, .pypirc, .aws/credentials, .kube/config"
- ac: AC10
status: PASS
evidence: "test_multiedit_first_in_pretooluse_group() verifies first MultiEdit-matching PreToolUse entry's hooks[0] contains secret_boundary_guard"
stop_conditions: []
ci_status:
python-test: pass
test: pass
typecheck: pass
lint: pass
build: pass
e2e: pass
actionlint: pass
validate-generated-artifact: pass
PR Body Japanese Check: pass
notes:
- "B1 fix verified: MultiEdit block (lines 133-141) runs for TOOL_NAME=MultiEdit and either exits 2 (invalid file_path) or overwrites PATH_INPUT with strictly-validated file_path only. The earlier PATH_INPUT fallback at line 27 is irrelevant for MultiEdit because the dedicated block exits before reaching line 143, or replaces PATH_INPUT."
- "B2 fix verified: Grep/Glob now use pattern key in test_existing_tools_no_regression, matching actual PreToolUse input shape per official docs."
- "test_worktree_scope_guard.py change is within Allowed Paths (Scope Delta) and corrects the old assertion that secret guard must NOT include MultiEdit, which is now outdated."
- "iteration 1 head SHA: 6fb51c2a6395d9dfb9669d848e8593947e2cac72"判定: APPROVE
全 AC が現 HEAD 6fb51c2a... の差分と CI 証跡で確認できた。Allowed Paths 逸脱なし。stop_condition 該当なし。
B1 検証
前回 Blocker 1 の根本は PATH_INPUT=$(... jq -r '.tool_input.file_path // .tool_input.path // .tool_input.pattern // empty') による fallback で MultiEdit の pathless 判定を迂回できた点。
現 HEAD の修正は、line 133-141 に MultiEdit 専用ブロックを追加し、jq -r '.tool_input.file_path | type' で型を独立検証している。type が "string" でない場合(null/array/object/number/missing いずれも "string" にはならない)、または type が "string" でも値が空文字の場合、即 exit 2 する。PATH_INPUT の fallback 値は line 143 に到達する前に制御が exit 2 で抜けるか、もしくは line 140 で上書きされるため、fallback 迂回は不可能になっている。
B2 検証
test_existing_tools_no_regression の Grep/Glob payload が {"file_path": path} から {"pattern": path} に修正されており、公式 PreToolUse input の実 shape に一致している。
CI 全 PASS 確認
全 required ジョブ(python-test/test/typecheck/lint/build/e2e/actionlint/validate-generated-artifact/PR Body Japanese Check)が現 HEAD で PASS している。
squne121
left a comment
There was a problem hiding this comment.
test comment to verify posting works
概要
Issue #970 の実装。
secret_boundary_guard.shと関連ファイルをMultiEditツール対応に拡張する。Closes #970(Issue #970 を解決)
変更内容
.claude/hooks/secret_boundary_guard.sh:SENSITIVE_TOOLSにMultiEditを追加、MultiEditでfile_pathが欠落/空文字の場合の pathless fail-closed ロジックを追加(exit 2).claude/settings.json: secret boundary guard の PreToolUse matcher をBash|Read|Write|Edit|Grep|Glob|MultiEditに更新docs/dev/hook-boundaries.md:secret_boundary_guardの manifest matcher をsettings.jsonと一致させる(MultiEdit追加).claude/hooks/tests/test_secret_boundary_multiedit.py: 新規テストファイル(14 件: AC3/AC5/AC8/AC9/AC10).claude/hooks/tests/test_secret_boundary_contract.py: MultiEdit 回帰テストを追加(7 件: AC1/AC2/AC4)検証結果
AC 対応表
🤖 Claude Code で生成 (Claude Code)