for Amazon Linux image (#896)

* fit amazon linux image's version to OVAL

* add Arch to SrcPackage

* lint go.mod

* make fmt
This commit is contained in:
Tomoya Amachi
2019-09-06 10:34:14 +09:00
committed by Kota Kanbe
parent b7ca5e5590
commit af58122c91
4 changed files with 18 additions and 6 deletions

10
go.mod
View File

@@ -46,8 +46,8 @@ require (
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
)
replace github.com/genuinetools/reg => github.com/tomoyamachi/reg v0.16.1-0.20190706172545-2a2250fd7c00
replace gopkg.in/mattn/go-colorable.v0 => github.com/mattn/go-colorable v0.1.0
replace gopkg.in/mattn/go-isatty.v0 => github.com/mattn/go-isatty v0.0.6
replace (
github.com/genuinetools/reg => github.com/tomoyamachi/reg v0.16.1-0.20190706172545-2a2250fd7c00
gopkg.in/mattn/go-colorable.v0 => github.com/mattn/go-colorable v0.1.0
gopkg.in/mattn/go-isatty.v0 => github.com/mattn/go-isatty v0.0.6
)

View File

@@ -207,6 +207,7 @@ type NeedRestartProcess struct {
type SrcPackage struct {
Name string `json:"name"`
Version string `json:"version"`
Arch string `json:"arch"`
BinaryNames []string `json:"binaryNames"`
}

View File

@@ -233,6 +233,7 @@ func getDefsByPackNameFromOvalDB(driver db.DB, r *models.ScanResult) (relatedDef
packName: pack.Name,
binaryPackNames: pack.BinaryNames,
versionRelease: pack.Version,
arch: pack.Arch,
isSrcPack: true,
})
}

View File

@@ -20,6 +20,7 @@ package scan
import (
"context"
"fmt"
"strings"
"time"
"github.com/aquasecurity/fanal/analyzer"
@@ -93,8 +94,16 @@ func detectContainerImage(c config.ServerInfo) (itsMe bool, containerImage osTyp
return false, newDummyOS(c), err
}
osName := os.Name
switch os.Family {
case fanalos.Amazon:
osName = "1"
if strings.HasPrefix(os.Family, "2") {
osName = "2"
}
}
p := newContainerImage(c, pkgs, libScanners)
p.setDistro(os.Family, os.Name)
p.setDistro(os.Family, osName)
return true, p, nil
}
@@ -164,6 +173,7 @@ func convertFanalToVulsPkg(pkgs []analyzer.Package) (map[string]models.Package,
modelSrcPkgs[pkg.SrcName] = models.SrcPackage{
Name: pkg.SrcName,
Version: pkg.SrcVersion,
Arch: pkg.Arch,
BinaryNames: []string{pkg.Name},
}
}