check cve_contents init (#725)

check cve_contents init to avoid nil pointer
This commit is contained in:
sadayuki-matsuno
2018-10-29 16:27:54 +09:00
committed by Kota Kanbe
parent b2d913cc21
commit ec41899089

View File

@@ -108,7 +108,15 @@ func (red RedHat) fillUnfixed(driver db.DB, r *models.ScanResult) (nCVEs int, er
cveCont := red.ConvertToModel(&cve)
v, ok := r.ScannedCves[cve.Name]
if ok {
v.CveContents[models.RedHatAPI] = *cveCont
if _, ok := v.CveContents[models.RedHatAPI]; ok {
v.CveContents[models.RedHatAPI] = *cveCont
} else {
v = models.VulnInfo{
CveID: cveCont.CveID,
CveContents: models.NewCveContents(*cveCont),
Confidences: models.Confidences{models.RedHatAPIMatch},
}
}
} else {
v = models.VulnInfo{
CveID: cveCont.CveID,
@@ -138,7 +146,15 @@ func (red RedHat) fillUnfixed(driver db.DB, r *models.ScanResult) (nCVEs int, er
cveCont := red.ConvertToModel(&cve)
v, ok := r.ScannedCves[cve.Name]
if ok {
v.CveContents[models.RedHatAPI] = *cveCont
if _, ok := v.CveContents[models.RedHatAPI]; ok {
v.CveContents[models.RedHatAPI] = *cveCont
} else {
v = models.VulnInfo{
CveID: cveCont.CveID,
CveContents: models.NewCveContents(*cveCont),
Confidences: models.Confidences{models.RedHatAPIMatch},
}
}
} else {
v = models.VulnInfo{
CveID: cveCont.CveID,