feat(scanner): match bypasses and merge findings across advisory aliases

Scanners report one advisory under different ids, such as a GHSA id from
OSV and the CVE id from Trivy. Findings now carry an aliases list.
The merge folds findings that share any id into one finding. A bypass
for any id of a finding now covers it. Stored findings without aliases
still load and match by their own id.
This commit is contained in:
2026-11-24 01:39:51 +00:00
parent 64793f9c7e
commit 43e075baf3
20 changed files with 617 additions and 66 deletions
+1
View File
@@ -419,6 +419,7 @@ func (s *Scanner) convertResult(advisories []GHSAAdvisory, registry, packageName
Description: advisory.Description,
References: refs,
FixedIn: fixedIn,
Aliases: metadata.NormalizeAliases(advisory.GHSAID, advisory.CVEID),
})
}
+9
View File
@@ -158,3 +158,12 @@ func TestFilterAffectedAdvisoriesFiltersByRange(t *testing.T) {
t.Fatalf("expected only MATCH, got %+v", out)
}
}
func TestFindingsCarryTheCVEOfTheAdvisory(t *testing.T) {
s := &Scanner{}
res := s.convertResult([]GHSAAdvisory{{GHSAID: "GHSA-xvch-5gv4-984h", CVEID: "CVE-2021-44906", Severity: "critical"}}, "npm", "minimist", "0.0.8")
if got := res.Vulnerabilities[0].Aliases; len(got) != 1 || got[0] != "CVE-2021-44906" {
t.Errorf("aliases = %v, want [CVE-2021-44906]", got)
}
}