mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
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:
@@ -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),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user