@@ -65,27 +65,30 @@ func (o SUSE) FillWithOval(r *models.ScanResult) (nCVEs int, err error) {
65
65
}
66
66
67
67
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
+ }
69
72
ovalContent .Type = models .NewCveContentType (o .family )
70
- vinfo , ok := r .ScannedCves [defpacks . def . Title ]
73
+ vinfo , ok := r .ScannedCves [ovalContent . CveID ]
71
74
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 )
73
76
vinfo = models.VulnInfo {
74
- CveID : defpacks . def . Title ,
77
+ CveID : ovalContent . CveID ,
75
78
Confidences : models.Confidences {models .OvalMatch },
76
- CveContents : models .NewCveContents (ovalContent ),
79
+ CveContents : models .NewCveContents (* ovalContent ),
77
80
}
78
81
} else {
79
82
cveContents := vinfo .CveContents
80
83
ctype := models .NewCveContentType (o .family )
81
84
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 )
83
86
} 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 )
85
88
cveContents = models.CveContents {}
86
89
}
87
90
vinfo .Confidences .AppendIfMissing (models .OvalMatch )
88
- cveContents [ctype ] = []models.CveContent {ovalContent }
91
+ cveContents [ctype ] = []models.CveContent {* ovalContent }
89
92
vinfo .CveContents = cveContents
90
93
}
91
94
@@ -105,10 +108,15 @@ func (o SUSE) update(r *models.ScanResult, defpacks defPacks) {
105
108
}
106
109
vinfo .AffectedPackages = collectBinpkgFixstat .toPackStatuses ()
107
110
vinfo .AffectedPackages .Sort ()
108
- r .ScannedCves [defpacks . def . Title ] = vinfo
111
+ r .ScannedCves [ovalContent . CveID ] = vinfo
109
112
}
110
113
111
114
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
+
112
120
refs := []models.Reference {}
113
121
for _ , r := range def .References {
114
122
refs = append (refs , models.Reference {
@@ -117,23 +125,15 @@ func (o SUSE) convertToModel(def *ovalmodels.Definition) *models.CveContent {
117
125
RefID : r .RefID ,
118
126
})
119
127
}
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 ,
137
138
}
138
- return & cveCont
139
139
}
0 commit comments