Skip to content

Commit 3fa208d

Browse files
dongsuparkCopilot
andcommitted
Fix discovery recommendation counts
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: Dongsu Park <dongsu@dpark.io>
1 parent 0a9ce33 commit 3fa208d

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎src/security_triage/review.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ def unknown_checked_action_ids(
629629
"update_existing_issue": DISCOVERY_KIND_UPDATE,
630630
"ignore": DISCOVERY_KIND_IGNORE,
631631
"kernel_regular_update_flow": DISCOVERY_KIND_KERNEL,
632+
"needs_manual_review": DISCOVERY_KIND_MANUAL,
632633
}
633634
_CLEANUP_KIND_BY_ACTION = {
634635
"comment_only": CLEANUP_KIND_COMMENT_ONLY,
@@ -1357,12 +1358,17 @@ def _group_severity(group: DecisionGroup) -> str:
13571358
return label.replace("cvss/", "") if label else "n/a"
13581359

13591360

1361+
def _group_recommendation(group: DecisionGroup) -> str:
1362+
if group.source == "discovery":
1363+
action = (group.record.get("decision") or {}).get("action")
1364+
return _DISCOVERY_KIND_BY_ACTION.get(action or "", "unknown")
1365+
return group.candidates[0].kind if group.candidates else "unknown"
1366+
1367+
13601368
def _render_counts_table(groups: list[DecisionGroup]) -> list[str]:
13611369
if not groups:
13621370
return ["", "(no decision groups)"]
1363-
kind_counts = Counter(
1364-
group.candidates[0].kind if group.candidates else "unknown" for group in groups
1365-
)
1371+
kind_counts = Counter(_group_recommendation(group) for group in groups)
13661372
confidence_counts = Counter(_group_confidence(group) for group in groups)
13671373
severity_counts = Counter(_group_severity(group) for group in groups)
13681374
lines = ["", "| Recommendation | Count |", "| --- | --- |"]

‎tests/test_review.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ def test_discovery_ignore_and_kernel_groups_are_single_checkbox_no_payload():
610610
assert len({candidate.action_id for candidate in ignore_groups[0].candidates}) == 3
611611
assert len({candidate.group_id for candidate in ignore_groups[0].candidates}) == 1
612612

613+
counts = review._render_counts_table(ignore_groups)
614+
assert "| discovery_ignore | 1 |" in counts
615+
assert "| discovery_create_issue | 1 |" not in counts
616+
613617
assert kernel_groups[0].candidates[0].kind == review.DISCOVERY_KIND_KERNEL
614618
assert kernel_groups[0].candidates[0].payload == {}
615619

0 commit comments

Comments
 (0)