Change ScanResult.Packages structure to Map

This commit is contained in:
Kota Kanbe
2017-05-08 22:15:12 +09:00
committed by kota kanbe
parent f36671784e
commit 210e3dc990
15 changed files with 209 additions and 284 deletions

View File

@@ -11,15 +11,11 @@ type Client interface {
}
func getPackages(r *models.ScanResult, d *ovalmodels.Definition) models.Packages {
var packages models.Packages
for _, pack := range d.AffectedPacks {
for _, p := range r.Packages {
if pack.Name == p.Name {
p.Changelog = models.Changelog{}
packages = append(packages, p)
break
}
}
packages := models.Packages{}
for _, affectedPack := range d.AffectedPacks {
pack, _ := r.Packages[affectedPack.Name]
// pack.Changelog = models.Changelog{}
packages[affectedPack.Name] = pack
}
return packages
}

View File

@@ -61,7 +61,7 @@ func (o Redhat) fillOvalInfo(r *models.ScanResult, definition *ovalmodels.Defini
ovalContent := *o.convertToModel(cve.CveID, definition)
vinfo, ok := r.ScannedCves.Get(cve.CveID)
if !ok {
util.Log.Infof("%s is newly detected by OVAL", definition.Debian.CveID)
util.Log.Infof("%s is newly detected by OVAL", cve.CveID)
vinfo = models.VulnInfo{
CveID: cve.CveID,
Confidence: models.OvalMatch,
@@ -70,9 +70,9 @@ func (o Redhat) fillOvalInfo(r *models.ScanResult, definition *ovalmodels.Defini
}
} else {
if _, ok := vinfo.CveContents.Get(models.RedHat); !ok {
util.Log.Infof("%s is also detected by OVAL", definition.Debian.CveID)
util.Log.Infof("%s is also detected by OVAL", cve.CveID)
} else {
util.Log.Infof("%s will be updated by OVAL", definition.Debian.CveID)
util.Log.Infof("%s will be updated by OVAL", cve.CveID)
}
if vinfo.Confidence.Score < models.OvalMatch.Score {
vinfo.Confidence = models.OvalMatch