From ec41899089e43761b0ca2ba488b7db547afa6728 Mon Sep 17 00:00:00 2001 From: sadayuki-matsuno Date: Mon, 29 Oct 2018 16:27:54 +0900 Subject: [PATCH] check cve_contents init (#725) check cve_contents init to avoid nil pointer --- gost/redhat.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gost/redhat.go b/gost/redhat.go index 40f73207..17bd1d84 100644 --- a/gost/redhat.go +++ b/gost/redhat.go @@ -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,