summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMohamed Hegazy <mhegazy@anthropic.com>2026-10-20 22:43:59 +0000
committerClaude <noreply@anthropic.com>2026-10-20 22:43:59 +0000
commitb541fcab7df839cf90de95fdc0c039cb83544a95 (patch)
treef5b9a00499fc9985db4bd2a7ece2670822504ae2 /plugins
parent6a331ec8ced0a1ae66dbb927e9909bc37acb26c3 (diff)
security-guidance: test the mask order, not that the masks come lastmhegazy/sg-pattern-fired-telemetry
Other tail metrics are now added after the two warning masks, so the masks are no longer the last keys on the Stop row. What matters is that the fired mask comes after the unresolved one, so a row cut at the key cap loses the fired mask first. Test that, and say so in the comment.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/security-guidance/hooks/security_reminder_hook.py7
-rw-r--r--plugins/security-guidance/tests/test_pattern_fired_metrics.py5
2 files changed, 7 insertions, 5 deletions
diff --git a/plugins/security-guidance/hooks/security_reminder_hook.py b/plugins/security-guidance/hooks/security_reminder_hook.py
index 93a545b4..e2f40a8b 100755
--- a/plugins/security-guidance/hooks/security_reminder_hook.py
+++ b/plugins/security-guidance/hooks/security_reminder_hook.py
@@ -2377,9 +2377,10 @@ def handle_stop_hook(input_data):
# The two masks also ride the tail, so the reviewed rows below, which
# leave `sweep` or its mask out, carry them when there is room under the
# key cap. Per rule they give how often it fired and how often the
- # flagged code was still there at Stop. warn_fired_mask goes last: a row
- # cut at the cap loses it first, and a row without it is left out of the
- # per-rule read instead of counting its rules as fixed.
+ # flagged code was still there at Stop. warn_fired_mask goes after
+ # warn_unresolved_mask: a row cut at the cap loses it first, and a row
+ # without it is left out of the per-rule read instead of counting its
+ # rules as fixed.
if warn_unresolved_mask:
_TAIL_METRICS["warn_unresolved_mask"] = warn_unresolved_mask
if warn_fired_mask:
diff --git a/plugins/security-guidance/tests/test_pattern_fired_metrics.py b/plugins/security-guidance/tests/test_pattern_fired_metrics.py
index 256cbf73..c1e31300 100644
--- a/plugins/security-guidance/tests/test_pattern_fired_metrics.py
+++ b/plugins/security-guidance/tests/test_pattern_fired_metrics.py
@@ -34,13 +34,14 @@ class TestFiredRulesReachTheStopRow:
assert m["warn_unresolved_mask"] == EVAL
assert list(m).index("warn_fired_mask") < 20
- def test_fired_mask_is_the_last_key(self, env, gateway, workspace):
+ def test_fired_mask_follows_the_unresolved_mask(self, env, gateway, workspace):
"""A row cut at the key cap loses the fired mask before the
unresolved one."""
_, repo = workspace
gateway.vulns = [STUB_VULN]
m = _turn(repo, env, {"calc.js": "const v = eval(src)\n"})
- assert list(m)[-2:] == ["warn_unresolved_mask", "warn_fired_mask"]
+ keys = list(m)
+ assert keys.index("warn_unresolved_mask") < keys.index("warn_fired_mask")
assert m["warn_fixed"] == 0 and m["warn_unresolved"] == 1
def test_review_with_findings(self, env, gateway, workspace):