diff options
| author | Mohamed Hegazy <mhegazy@anthropic.com> | 2026-10-12 17:36:29 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-10-12 17:36:29 +0000 |
| commit | ed2ae7cd72fb60b4b3e58d622745870072cfd2aa (patch) | |
| tree | 155384ce450ed6dd08ce6012f1e9a2538b4e33bb /plugins/security-guidance/hooks/security_reminder_hook.py | |
| parent | ccdb984025c4115b7d534a41a9fdad43a5283f74 (diff) | |
security-guidance: count diff headers the parser could not readmhegazy/sg-diff-parsing
A file whose header cannot be parsed is left out of the review without a trace. The Stop hook now reports diff_hdr_unparsed (a count, only when nonzero) so a header shape the parser misses shows up in metrics.
Diffstat (limited to 'plugins/security-guidance/hooks/security_reminder_hook.py')
| -rwxr-xr-x | plugins/security-guidance/hooks/security_reminder_hook.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/security-guidance/hooks/security_reminder_hook.py b/plugins/security-guidance/hooks/security_reminder_hook.py index e8df7a1c..3516a5a7 100755 --- a/plugins/security-guidance/hooks/security_reminder_hook.py +++ b/plugins/security-guidance/hooks/security_reminder_hook.py @@ -125,6 +125,7 @@ from reporesolve import ( # noqa: E402,F401 toplevel_from_command, repo_containing_commit, scan_roots, resolve_repo_root, save_repo_hint, load_repo_hint, ) +import gitutil # noqa: E402 module ref for per-run counters import llm # noqa: E402 module ref for reassignable globals (_last_call_claude_http_error etc.) from llm import ( # noqa: E402,F401 ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, HAS_API_CREDENTIALS, @@ -1959,6 +1960,8 @@ def handle_stop_hook(input_data): "skipped": True, "skip_reason": reason, "fire_index": fire_count + 1, "diff_strategy_v2": True, **v2_metrics, **extra, **sweep, + **({"diff_hdr_unparsed": len(gitutil._unparsed_diff_headers)} + if gitutil._unparsed_diff_headers else {}), }) sys.exit(0) @@ -2174,6 +2177,8 @@ def handle_stop_hook(input_data): if llm._last_review_truncated_bytes else {}), **({"repo_resolution": repo_res} if res_metrics else {}), **sweep_trimmed, + **({"diff_hdr_unparsed": len(gitutil._unparsed_diff_headers)} + if gitutil._unparsed_diff_headers else {}), }, rewake_summary=_format_vulns_summary(vulns), additional_context=(PROVENANCE_BANNER + "\n\n" + concrete_guidance + CONTINUATION_SUFFIX + "\n"), @@ -2204,6 +2209,8 @@ def handle_stop_hook(input_data): **({"diff_truncated": llm._last_review_truncated_bytes} if llm._last_review_truncated_bytes else {}), **v2_metrics, + **({"diff_hdr_unparsed": len(gitutil._unparsed_diff_headers)} + if gitutil._unparsed_diff_headers else {}), }) sys.exit(0) |
