mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-27 06:46:01 +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:
@@ -233,6 +233,7 @@ func (s *Scanner) convertResult(auditResult *NpmAuditResult, registry, packageNa
|
||||
Title: adv.Title,
|
||||
Description: fmt.Sprintf("%s: %s (affected %s)", adv.Name, adv.Title, adv.Range),
|
||||
References: refs,
|
||||
Aliases: metadata.NormalizeAliases(advisoryID(adv), metadata.ExtractAdvisoryIDs(refs...)...),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,3 +202,15 @@ func TestScanSkipsOtherRegistries(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusClean, res.Status)
|
||||
}
|
||||
|
||||
func TestFindingsKeepOnlyTheIDOfTheirAdvisoryLink(t *testing.T) {
|
||||
audit := &NpmAuditResult{Vulnerabilities: map[string]NpmVulnerability{"minimist": {Via: []NpmVia{{Advisory: &NpmAdvisory{
|
||||
Source: 1, Name: "minimist", Severity: "critical", URL: "https://github.com/advisories/GHSA-xvch-5gv4-984h",
|
||||
}}}}}}
|
||||
|
||||
res := New(config.NpmAuditConfig{}).convertResult(audit, "npm", "minimist", "0.0.8")
|
||||
|
||||
if res.Vulnerabilities[0].ID != "GHSA-xvch-5gv4-984h" || len(res.Vulnerabilities[0].Aliases) != 0 {
|
||||
t.Errorf("id %q aliases %v, want the GHSA id and no aliases", res.Vulnerabilities[0].ID, res.Vulnerabilities[0].Aliases)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user