grouper.Group misses transitive alias relations when the linking record comes last
grouper.Group (internal/grouper/grouper.go) merges two records that share an alias by writing groups[i] = min(groups[i], groups[j]) against the two indices, not against the groups those indices already belong to. When the record that links two existing groups comes after both of them, only the later index is re-pointed and the earlier group's other members stay behind, so records that describe one vulnerability are reported as two groups.
Reproduction against main at f0e28d36, in internal/grouper:
func TestGroupTransitive(t *testing.T) {
got := grouper.Group([]grouper.IDAliases{
{ID: "GHSA-aaaa", Aliases: []string{"CVE-1"}},
{ID: "GHSA-bbbb", Aliases: []string{"CVE-3"}},
{ID: "GHSA-cccc", Aliases: []string{"CVE-2", "CVE-3"}},
{ID: "GHSA-dddd", Aliases: []string{"CVE-1", "CVE-2"}},
})
if len(got) != 1 {
t.Fatalf("want 1 group, got %d: %v", len(got), got)
}
}Expected: one group holding all four IDs, since aaaa and dddd share CVE-1, cccc and dddd share CVE-2, and bbbb and cccc share CVE-3.
Actual: two groups, [GHSA-aaaa GHSA-cccc GHSA-dddd] and [GHSA-bbbb].
Where it shows: pkg/osvscanner/vulnerability_result.go builds pkg.Groups from this function, so every output that reads Groups reports one vulnerability as two groups whenever the alias sets overlap in a chain rather than pairwise, which is the shape distribution advisories produce once their upstream CVEs are folded into aliases (#2027). It is order dependent: the same four records in a different order group correctly.
Source: google/osv-scanner