Skip to content

fix(vulnhunter-fix): pair cluster annotations by identity, not by name - #36

Merged
schenksj merged 2 commits into
capitalone:mainfrom
AmirF194:fix/cluster-score-duplicate-name-collision
Oct 5, 2026
Merged

schenksj merged 2 commits into
capitalone:mainfrom
AmirF194:fix/cluster-score-duplicate-name-collision

Conversation

@AmirF194

Copy link
Copy Markdown

Pairs each Cluster with its source dict by identity instead of by name, so the annotation step can't cross-wire two clusters that share a name.

sort_clusters returns the same Cluster objects it was given, just reordered, so zip(clusters, raw) at construction time gives an exact id(cluster) -> original mapping that survives the sort. Swapped the post-sort next(r for r in raw if r.get("name") == c.name) for a lookup into that mapping.

Added test_duplicate_names_keep_their_own_members, which builds two "Other clusters" entries (the documented 4th-slot overflow name from parse_issues.md Step 3(c)) with different members and severities. It fails on main: both output entries came back with the first entry's data, and the second entry's two Critical findings never appeared anywhere in the output. pytest -k cluster_score is 31 passed on the branch, same as before this change plus the new one.

Fixes #35

Cluster names are not guaranteed unique: parse_issues.md Step 3(c)
documents the "Other clusters" overflow slot, which two clustering
runs can both legitimately produce. annotate_clusters_json recovered
each sorted cluster's members/severity_breakdown via
next(r for r in raw if r.get("name") == c.name), so two same-named
clusters both resolved to the first match, and the second cluster's
real findings vanished from the output.

Pair each Cluster with its source dict by identity at construction
time instead, since sort_clusters reorders the same objects rather
than copying them.

Adds a regression test that fails on main (both entries return the
first cluster's members; the second's Critical findings disappear)
and passes on this change.
@AmirF194
AmirF194 requested a review from a team as a code owner September 22, 2026 07:23
@CLAassistant

CLAassistant commented Sep 22, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@AmirF194

Copy link
Copy Markdown
Author

Fixes a data-corruption bug: two clusters sharing a display name silently overwrite each other's members in the report (repro and a differential test in the PR body). CI's held pending a first-run workflow approval; the other checks (CLA, Socket Security) all pass.

@schenksj schenksj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: full vulnhunter-fix suite passes (550 passed, 10 skipped, py3.12), and the new test fails against main's cluster_score.py, confirming it reproduces the duplicate-name collision. LGTM.

@schenksj
schenksj merged commit 53be63a into capitalone:main Oct 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

annotate_clusters_json loses real findings when two clusters share a name

3 participants