Skip to content

fix(output): group vulnerabilities transitively regardless of order - #3114

Merged
G-Rath merged 2 commits into
google:mainfrom
ackama:grouping
Oct 12, 2026
Merged

G-Rath merged 2 commits into
google:mainfrom
ackama:grouping

Conversation

@G-Rath

@G-Rath G-Rath commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Currently when grouping if a pair shares an identifier we only update the group of those two vulnerabilities, leaving any other vulnerabilities in the original group.

This means connected vulnerabilities can end up getting split across multiple groups depending on the order they're encountered, which is incorrect.

For example these should be all one group, but currently GHSA-bbbb ends up on its own:

  • GHSA-aaaa with the alias CVE-1
  • GHSA-bbbb with the alias CVE-3
  • GHSA-cccc with the aliases CVE-2 and CVE-3
  • GHSA-dddd with the aliases CVE-1 and CVE-2

To address this I've rewritten the pairwise comparison to use a union-find, so that connected vulnerabilities are always grouped together regardless of order.

Resolves #3107

@codecov-commenter

codecov-commenter commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.11%. Comparing base (593afad) to head (db2c174).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3114      +/-   ##
==========================================
+ Coverage   82.09%   82.11%   +0.02%     
==========================================
  Files         118      118              
  Lines        7658     7667       +9     
==========================================
+ Hits         6287     6296       +9     
  Misses       1371     1371              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@G-Rath
G-Rath marked this pull request as ready for review September 29, 2026 00:19
@G-Rath
G-Rath requested a review from Ly-Joey September 29, 2026 00:19
another-rex pushed a commit that referenced this pull request Sep 29, 2026
#3116)

This new test shows how our current grouping behaviour is wrong due to
considering the `upstream` as an alias: each of these advisories should
be in their own group as they only share an `upstream`, but our current
logic results in the groups `{DSA-1543-1, DSA-1819-1, DTSA-132-1}` and
`{DTSA-125-1}`.

#3114 will improve this by making the grouping consistent, but we'll
still incorrectly put all the advisories into a single group.

Relates to #3107

@Ly-Joey Ly-Joey 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.

LGTM!
Some minor nits to appease the lint gods (I'm surprised modernize lint isn't already flagging this)

Comment thread internal/grouper/grouper.go Resolved
Comment thread internal/grouper/grouper.go Resolved
@G-Rath

G-Rath commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

@Ly-Joey have done #3146 to move us entirely off sort

@G-Rath
G-Rath merged commit a4d0a04 into google:main Oct 12, 2026
25 checks passed
@G-Rath
G-Rath deleted the grouping branch October 12, 2026 19:48
G-Rath added a commit that referenced this pull request Oct 12, 2026
This reverts part of #2036 as treating the upstream as an alias is
incorrect and may hide vulnerabilities [especially now that our grouping
logic has been fixed](#3114)
G-Rath added a commit that referenced this pull request Oct 12, 2026
…re correct (#3138)

Working on #1275 made me realize the output tests are just too
artificial, which lead me down a bit of a rabbit hole to try and
centralize how we build our groups so that it all lives in one place.

Most of this is diff is just adding tests, with the two main changes
otherwise being moving a bunch of stuff to `grouper.Build` and modifying
the `output` tests to use `grouper.Build`.

There's some follow-up changes I'll do like making `grouper.Group`
private, but I'm going to wait until #3114 is landed to avoid nasty
conflicts
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.

grouper.Group misses transitive alias relations when the linking record comes last

3 participants