fix golint warnings in scribevulnpolicy

This commit is contained in:
Aaron Meihm 2017-07-19 11:29:48 -05:00
Родитель 29c5f68bb4
Коммит 7179958654
3 изменённых файлов: 14 добавлений и 14 удалений

Просмотреть файл

@ -19,11 +19,11 @@ type centosRelease struct {
filematch string
}
const centos_expression = ".*CentOS.*(release \\d+)\\..*"
const centosExpression = ".*CentOS.*(release \\d+)\\..*"
var centosReleases = []centosRelease{
{PLATFORM_CENTOS_7, "release 7", centos_expression, "^centos-release$"},
{PLATFORM_CENTOS_6, "release 6", centos_expression, "^centos-release$"},
{platformCentos7, "release 7", centosExpression, "^centos-release$"},
{platformCentos6, "release 6", centosExpression, "^centos-release$"},
}
// The list of packages for this platform we will only consider the newest version for in the
@ -80,7 +80,7 @@ func centosReleaseTest(platform supportedPlatform, doc *scribe.Document) (tid st
// Set our match value on the test to the release string
found := false
for _, x := range centosReleases {
if x.identifier == platform.platformId {
if x.identifier == platform.platformID {
found = true
release = x
break

Просмотреть файл

@ -25,7 +25,7 @@ func dbGetSupportedPlatforms() (ret []supportedPlatform, err error) {
}
platform, err = getPlatform(nsname)
if err == nil {
platform.clairNamespaceId = nsid
platform.clairNamespaceID = nsid
ret = append(ret, platform)
}
}
@ -40,7 +40,7 @@ func dbVulnsForPlatform(platform supportedPlatform) (ret []vuln, err error) {
JOIN vulnerability_fixedin_feature vff ON (vff.feature_id = f.id)
JOIN vulnerability v ON (v.id = vff.vulnerability_id)
WHERE f.namespace_id = $1
ORDER BY f.name`, platform.clairNamespaceId)
ORDER BY f.name`, platform.clairNamespaceID)
if err != nil {
return
}

Просмотреть файл

@ -19,24 +19,24 @@ import (
)
const (
PLATFORM_CENTOS_6 = iota
PLATFORM_CENTOS_7
platformCentos6 = iota
platformCentos7
)
// Our list of platforms we will support policy generation for, this maps the
// platform constants to clair namespace identifiers
type supportedPlatform struct {
platformId int
platformID int
name string
clairNamespace string
clairNamespaceId int // Populated upon query of the database
clairNamespaceID int // Populated upon query of the database
releaseTest func(supportedPlatform, *scribe.Document) (string, error)
pkgNewest func(string) bool
}
var supportedPlatforms = []supportedPlatform{
{PLATFORM_CENTOS_6, "centos6", "centos:6", 0, centosReleaseTest, centosOnlyNewest},
{PLATFORM_CENTOS_7, "centos7", "centos:7", 0, centosReleaseTest, centosOnlyNewest},
{platformCentos6, "centos6", "centos:6", 0, centosReleaseTest, centosOnlyNewest},
{platformCentos7, "centos7", "centos:7", 0, centosReleaseTest, centosOnlyNewest},
}
// Given a clair namespace, return the supportedPlatform entry for it if it is
@ -111,7 +111,7 @@ func dbInit() (err error) {
// Generate a test identifier; this needs to be unique in the document. Here we
// just use a few elements from the vulnerability and platform and return an MD5
// digest.
func generateTestId(v vuln, p supportedPlatform) (string, error) {
func generateTestID(v vuln, p supportedPlatform) (string, error) {
h := md5.New()
h.Write([]byte(v.name))
h.Write([]byte(p.name))
@ -185,7 +185,7 @@ func generatePolicy(p string) error {
newtest.EVR.Value = x.fixedInVersion
newtest.EVR.Operation = "<"
newtest.If = append(newtest.If, reltestid)
newtest.TestID, err = generateTestId(x, platform)
newtest.TestID, err = generateTestID(x, platform)
if err != nil {
return err
}