Skip to content

Commit

Permalink
fix(csaf): show only first package with unpatched cve
Browse files Browse the repository at this point in the history
RHINENG-10310
  • Loading branch information
psegedy authored and jdobes committed Jun 19, 2024
1 parent 62353ea commit aa8d0f0
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions vmaas/vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,7 @@ func evaluate(c *Cache, opts *options, request *Request) (*VulnerabilitiesCvesDe
definition.evaluate(c, modules, cvesOval, &cves, cves.UnpatchedCves)
}
}
for _, pp := range products {
for _, product := range pp.ProductsUnfixed {
cn := CpeIDNameID{CpeID: product.CpeID, NameID: product.PackageNameID}
csafCves := c.CSAFCVEs[cn][product]
for _, cveID := range csafCves.Unfixed {
cve := c.CveNames[int(cveID)]
cpe := c.CpeID2Label[product.CpeID]
updateCves(cves.UnpatchedCves, cve, pp.Package, nil, cpe)
}
}
}
evaluateUnpatchedCves(c, products, &cves)

// 2. evaluate CVEs from Repositories
// if CVE is already in Unpatched list -> skip it
Expand Down Expand Up @@ -182,6 +172,23 @@ func evaluate(c *Cache, opts *options, request *Request) (*VulnerabilitiesCvesDe
return &cves, nil
}

func evaluateUnpatchedCves(c *Cache, products []ProductsPackage, cves *VulnerabilitiesCvesDetails) {
for _, pp := range products {
for _, product := range pp.ProductsUnfixed {
cn := CpeIDNameID{CpeID: product.CpeID, NameID: product.PackageNameID}
csafCves := c.CSAFCVEs[cn][product]
for _, cveID := range csafCves.Unfixed {
cve := c.CveNames[int(cveID)]
cpe := c.CpeID2Label[product.CpeID]
if _, ok := cves.UnpatchedCves[cve]; !ok {
// show only CVE hit for the first package
updateCves(cves.UnpatchedCves, cve, pp.Package, nil, cpe)
}
}
}
}
}

func evaluateManualCves(c *Cache, products []ProductsPackage, cves *VulnerabilitiesCvesDetails) {
for _, pp := range products {
pp := pp // make copy because &pp is used
Expand Down

0 comments on commit aa8d0f0

Please sign in to comment.