Skip to content

Commit 7750347

Browse files
authored
fix(oval/suse): use def.Advisory.Cves[0].CveID instead of def.Title (future-architect#1397)
1 parent 9bcffcd commit 7750347

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

oval/suse.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,30 @@ func (o SUSE) FillWithOval(r *models.ScanResult) (nCVEs int, err error) {
6565
}
6666

6767
func (o SUSE) update(r *models.ScanResult, defpacks defPacks) {
68-
ovalContent := *o.convertToModel(&defpacks.def)
68+
ovalContent := o.convertToModel(&defpacks.def)
69+
if ovalContent == nil {
70+
return
71+
}
6972
ovalContent.Type = models.NewCveContentType(o.family)
70-
vinfo, ok := r.ScannedCves[defpacks.def.Title]
73+
vinfo, ok := r.ScannedCves[ovalContent.CveID]
7174
if !ok {
72-
logging.Log.Debugf("%s is newly detected by OVAL", defpacks.def.Title)
75+
logging.Log.Debugf("%s is newly detected by OVAL", ovalContent.CveID)
7376
vinfo = models.VulnInfo{
74-
CveID: defpacks.def.Title,
77+
CveID: ovalContent.CveID,
7578
Confidences: models.Confidences{models.OvalMatch},
76-
CveContents: models.NewCveContents(ovalContent),
79+
CveContents: models.NewCveContents(*ovalContent),
7780
}
7881
} else {
7982
cveContents := vinfo.CveContents
8083
ctype := models.NewCveContentType(o.family)
8184
if _, ok := vinfo.CveContents[ctype]; ok {
82-
logging.Log.Debugf("%s OVAL will be overwritten", defpacks.def.Title)
85+
logging.Log.Debugf("%s OVAL will be overwritten", ovalContent.CveID)
8386
} else {
84-
logging.Log.Debugf("%s is also detected by OVAL", defpacks.def.Title)
87+
logging.Log.Debugf("%s is also detected by OVAL", ovalContent.CveID)
8588
cveContents = models.CveContents{}
8689
}
8790
vinfo.Confidences.AppendIfMissing(models.OvalMatch)
88-
cveContents[ctype] = []models.CveContent{ovalContent}
91+
cveContents[ctype] = []models.CveContent{*ovalContent}
8992
vinfo.CveContents = cveContents
9093
}
9194

@@ -105,10 +108,15 @@ func (o SUSE) update(r *models.ScanResult, defpacks defPacks) {
105108
}
106109
vinfo.AffectedPackages = collectBinpkgFixstat.toPackStatuses()
107110
vinfo.AffectedPackages.Sort()
108-
r.ScannedCves[defpacks.def.Title] = vinfo
111+
r.ScannedCves[ovalContent.CveID] = vinfo
109112
}
110113

111114
func (o SUSE) convertToModel(def *ovalmodels.Definition) *models.CveContent {
115+
if len(def.Advisory.Cves) != 1 {
116+
logging.Log.Warnf("Unknown Oval format. Please register the issue as it needs to be investigated. https://github.com/vulsio/goval-dictionary/issues family: %s, defID: %s", o.family, def.DefinitionID)
117+
return nil
118+
}
119+
112120
refs := []models.Reference{}
113121
for _, r := range def.References {
114122
refs = append(refs, models.Reference{
@@ -117,23 +125,15 @@ func (o SUSE) convertToModel(def *ovalmodels.Definition) *models.CveContent {
117125
RefID: r.RefID,
118126
})
119127
}
120-
cveCont := models.CveContent{
121-
CveID: def.Title,
122-
Title: def.Title,
123-
Summary: def.Description,
124-
References: refs,
125-
}
126-
127-
if 0 < len(def.Advisory.Cves) {
128-
if len(def.Advisory.Cves) == 1 {
129-
cve := def.Advisory.Cves[0]
130-
score3, vec3 := parseCvss3(cve.Cvss3)
131-
cveCont.Cvss3Score = score3
132-
cveCont.Cvss3Vector = vec3
133-
cveCont.Cvss3Severity = cve.Impact
134-
} else {
135-
logging.Log.Warnf("Unknown Oval format. Please register the issue as it needs to be investigated. https://github.com/future-architect/vuls/issues family: %s, defID: %s", o.family, def.DefinitionID)
136-
}
128+
cve := def.Advisory.Cves[0]
129+
score3, vec3 := parseCvss3(cve.Cvss3)
130+
return &models.CveContent{
131+
Title: def.Title,
132+
Summary: def.Description,
133+
CveID: cve.CveID,
134+
Cvss3Score: score3,
135+
Cvss3Vector: vec3,
136+
Cvss3Severity: cve.Impact,
137+
References: refs,
137138
}
138-
return &cveCont
139139
}

0 commit comments

Comments
 (0)