inform new release on diff option (#614)
inform new release on diff option (#614)
This commit is contained in:
@@ -344,14 +344,14 @@ func getDiffCves(previous, current models.ScanResult) models.VulnInfos {
|
||||
updated := models.VulnInfos{}
|
||||
for _, v := range current.ScannedCves {
|
||||
if previousCveIDsSet[v.CveID] {
|
||||
if isCveInfoUpdated(v.CveID, previous, current) {
|
||||
if isCveInfoUpdated(v.CveID, previous, current) || isCveFixed(v, previous) {
|
||||
updated[v.CveID] = v
|
||||
util.Log.Debugf("updated: %s", v.CveID)
|
||||
util.Log.Debugf("updated or new release: %s", v.CveID)
|
||||
} else {
|
||||
util.Log.Debugf("same: %s", v.CveID)
|
||||
util.Log.Debugf("same and not new Release: %s", v.CveID)
|
||||
}
|
||||
} else {
|
||||
util.Log.Debugf("newsame: %s", v.CveID)
|
||||
util.Log.Debugf("new: %s", v.CveID)
|
||||
new[v.CveID] = v
|
||||
}
|
||||
}
|
||||
@@ -362,6 +362,21 @@ func getDiffCves(previous, current models.ScanResult) models.VulnInfos {
|
||||
return updated
|
||||
}
|
||||
|
||||
func isCveFixed(current models.VulnInfo, previous models.ScanResult) bool {
|
||||
preVinfo, _ := previous.ScannedCves[current.CveID]
|
||||
pre := map[string]bool{}
|
||||
for _, h := range preVinfo.AffectedPackages {
|
||||
pre[h.Name] = h.NotFixedYet
|
||||
}
|
||||
|
||||
cur := map[string]bool{}
|
||||
for _, h := range current.AffectedPackages {
|
||||
cur[h.Name] = h.NotFixedYet
|
||||
}
|
||||
|
||||
return !reflect.DeepEqual(pre, cur)
|
||||
}
|
||||
|
||||
func isCveInfoUpdated(cveID string, previous, current models.ScanResult) bool {
|
||||
cTypes := []models.CveContentType{
|
||||
models.NVD,
|
||||
|
||||
Reference in New Issue
Block a user