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:
@@ -212,6 +212,7 @@ func (s *Scanner) convertTrivyResult(trivyResult *TrivyResult, registry, package
|
||||
Description: vuln.Description,
|
||||
References: vuln.References,
|
||||
FixedIn: vuln.FixedVersion,
|
||||
Aliases: metadata.NormalizeAliases(vuln.VulnerabilityID, metadata.ExtractAdvisoryIDs(append([]string{vuln.PrimaryURL}, vuln.References...)...)...),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,3 +149,18 @@ func TestExtractEnforcesSizeCap(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 10, n)
|
||||
}
|
||||
|
||||
func TestFindingsNameTheGHSAOfTheirAdvisoryLinks(t *testing.T) {
|
||||
res := New(config.TrivyConfig{}).convertTrivyResult(&TrivyResult{Results: []TrivyVulnResult{{Vulnerabilities: []TrivyVulnerability{{
|
||||
VulnerabilityID: "CVE-2021-44906",
|
||||
Severity: "CRITICAL",
|
||||
PrimaryURL: "https://avd.aquasec.com/nvd/cve-2021-44906",
|
||||
References: []string{
|
||||
"https://github.com/advisories/GHSA-xvch-5gv4-984h",
|
||||
"https://nvd.nist.gov/vuln/detail/CVE-2021-44906",
|
||||
"https://github.com/minimistjs/minimist/issues/CVE-2020-0001",
|
||||
},
|
||||
}}}}}, "npm", "minimist", "0.0.8")
|
||||
|
||||
assert.Equal(t, []string{"GHSA-xvch-5gv4-984h"}, res.Vulnerabilities[0].Aliases)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user