Merge pull request #7 from ameihm0912/master

add release test for amazon linux
This commit is contained in:
Aaron Meihm 2016-01-21 13:41:41 -06:00
Родитель 440cf277d9 11254081a4
Коммит ccdc782bb6
3 изменённых файлов: 54 добавлений и 0 удалений

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

@ -0,0 +1,51 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Contributor:
// - Aaron Meihm ameihm@mozilla.com
package vulnpolicy
import (
"fmt"
"scribe"
)
const amazon_expression = "^(Amazon Linux AMI.*)$"
func amazonGetReleaseTest(doc *scribe.Document, vuln Vulnerability) (string, error) {
reltestname := fmt.Sprintf("test-release-%v-%v", vuln.OS, vuln.Release)
relobjname := "obj-release-amazonsystemrelease"
// See if we have a release definition for this already, if not
// add it
for _, x := range doc.Tests {
if x.TestID == reltestname {
return reltestname, nil
}
}
found := false
for _, x := range doc.Objects {
if x.Object == relobjname {
found = true
break
}
}
if !found {
obj := scribe.Object{}
obj.Object = relobjname
obj.FileContent.Path = "/etc"
obj.FileContent.File = "^system-release$"
obj.FileContent.Expression = amazon_expression
doc.Objects = append(doc.Objects, obj)
}
test := scribe.Test{}
test.TestID = reltestname
test.Object = relobjname
test.Regexp.Value = "Amazon Linux AMI release"
doc.Tests = append(doc.Tests, test)
return test.TestID, nil
}

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

@ -16,4 +16,5 @@ var OSList = []OS{
{"redhat"},
{"centos"},
{"debian"},
{"amazon"},
}

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

@ -47,6 +47,8 @@ func getReleaseTest(doc *scribe.Document, vuln Vulnerability) (string, error) {
return ubuntuGetReleaseTest(doc, vuln)
} else if (vuln.OS == "redhat") || (vuln.OS == "centos") {
return redhatGetReleaseTest(doc, vuln)
} else if vuln.OS == "amazon" {
return amazonGetReleaseTest(doc, vuln)
}
return "", fmt.Errorf("unable to create release definition")
}