Skip to content

Commit 5758c09

Browse files
authored
ROX-18363: Fix RHEL CVSS equals 0 even after update (#1258)
1 parent 66c9bc6 commit 5758c09

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

database/pgsql/rhelv2_vulnerability.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"context"
1111
"crypto/md5"
1212
"database/sql"
13+
"sort"
1314
"time"
1415

1516
"github.com/lib/pq"
@@ -216,6 +217,11 @@ func (pgSQL *pgSQL) GetRHELv2Vulnerabilities(records []*database.RHELv2Record) (
216217

217218
addedVulns := uniqueVulns[recordID]
218219

220+
// Order the vulns in terms of updated first so that if we have multiple of the same vulns
221+
// the ones with the latest update time will be used
222+
sort.SliceStable(matchedVulns, func(i, j int) bool {
223+
return matchedVulns[i].Updated.After(matchedVulns[j].Updated)
224+
})
219225
for _, matched := range matchedVulns {
220226
if addedVulns.Add(matched.Name) {
221227
vulnMap[recordID] = append(vulnMap[recordID], matched)

0 commit comments

Comments
 (0)