database: Rename affected Type to feature type
This commit is contained in:
parent
00eed77b45
commit
7dd989c0f2
@ -199,8 +199,8 @@ type VulnerabilityWithFixedIn struct {
|
|||||||
// by a Vulnerability. Namespace and Feature Name is unique. Affected Feature is
|
// by a Vulnerability. Namespace and Feature Name is unique. Affected Feature is
|
||||||
// bound to vulnerability.
|
// bound to vulnerability.
|
||||||
type AffectedFeature struct {
|
type AffectedFeature struct {
|
||||||
// AffectedType determines which type of package it affects.
|
// FeatureType determines which type of package it affects.
|
||||||
AffectedType AffectedFeatureType
|
FeatureType FeatureType
|
||||||
Namespace Namespace
|
Namespace Namespace
|
||||||
FeatureName string
|
FeatureName string
|
||||||
// FixedInVersion is known next feature version that's not affected by the
|
// FixedInVersion is known next feature version that's not affected by the
|
||||||
|
@ -40,7 +40,7 @@ const (
|
|||||||
nvdURLPrefix = "https://cve.mitre.org/cgi-bin/cvename.cgi?name="
|
nvdURLPrefix = "https://cve.mitre.org/cgi-bin/cvename.cgi?name="
|
||||||
// affected type indicates if the affected feature hint is for binary or
|
// affected type indicates if the affected feature hint is for binary or
|
||||||
// source package.
|
// source package.
|
||||||
affectedType = database.AffectBinaryPackage
|
affectedType = database.BinaryPackage
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -177,7 +177,7 @@ func (file *secDB) Vulnerabilities() (vulns []database.VulnerabilityWithAffected
|
|||||||
|
|
||||||
vuln.Affected = []database.AffectedFeature{
|
vuln.Affected = []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
FeatureName: pkg.Pkg.Name,
|
FeatureName: pkg.Pkg.Name,
|
||||||
AffectedVersion: version,
|
AffectedVersion: version,
|
||||||
FixedInVersion: fixedInVersion,
|
FixedInVersion: fixedInVersion,
|
||||||
|
@ -38,7 +38,7 @@ const (
|
|||||||
url = "https://security-tracker.debian.org/tracker/data/json"
|
url = "https://security-tracker.debian.org/tracker/data/json"
|
||||||
cveURLPrefix = "https://security-tracker.debian.org/tracker"
|
cveURLPrefix = "https://security-tracker.debian.org/tracker"
|
||||||
updaterFlag = "debianUpdater"
|
updaterFlag = "debianUpdater"
|
||||||
affectedType = database.AffectSourcePackage
|
affectedType = database.SourcePackage
|
||||||
)
|
)
|
||||||
|
|
||||||
type jsonData map[string]map[string]jsonVuln
|
type jsonData map[string]map[string]jsonVuln
|
||||||
@ -215,7 +215,7 @@ func parseDebianJSON(data *jsonData) (vulnerabilities []database.VulnerabilityWi
|
|||||||
|
|
||||||
// Create and add the feature version.
|
// Create and add the feature version.
|
||||||
pkg := database.AffectedFeature{
|
pkg := database.AffectedFeature{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
FeatureName: pkgName,
|
FeatureName: pkgName,
|
||||||
AffectedVersion: version,
|
AffectedVersion: version,
|
||||||
FixedInVersion: fixedInVersion,
|
FixedInVersion: fixedInVersion,
|
||||||
|
@ -41,7 +41,7 @@ func TestDebianParser(t *testing.T) {
|
|||||||
|
|
||||||
expectedFeatures := []database.AffectedFeature{
|
expectedFeatures := []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "debian:8",
|
Name: "debian:8",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
@ -50,7 +50,7 @@ func TestDebianParser(t *testing.T) {
|
|||||||
AffectedVersion: versionfmt.MaxVersion,
|
AffectedVersion: versionfmt.MaxVersion,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "debian:unstable",
|
Name: "debian:unstable",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
@ -71,7 +71,7 @@ func TestDebianParser(t *testing.T) {
|
|||||||
|
|
||||||
expectedFeatures := []database.AffectedFeature{
|
expectedFeatures := []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "debian:8",
|
Name: "debian:8",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
@ -81,7 +81,7 @@ func TestDebianParser(t *testing.T) {
|
|||||||
AffectedVersion: "0.7.0",
|
AffectedVersion: "0.7.0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "debian:unstable",
|
Name: "debian:unstable",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
@ -91,7 +91,7 @@ func TestDebianParser(t *testing.T) {
|
|||||||
AffectedVersion: "0.7.0",
|
AffectedVersion: "0.7.0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "debian:8",
|
Name: "debian:8",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
|
@ -41,7 +41,7 @@ const (
|
|||||||
ovalURI = "https://linux.oracle.com/oval/"
|
ovalURI = "https://linux.oracle.com/oval/"
|
||||||
elsaFilePrefix = "com.oracle.elsa-"
|
elsaFilePrefix = "com.oracle.elsa-"
|
||||||
updaterFlag = "oracleUpdater"
|
updaterFlag = "oracleUpdater"
|
||||||
affectedType = database.AffectBinaryPackage
|
affectedType = database.BinaryPackage
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -365,7 +365,7 @@ func toFeatures(criteria criteria) []database.AffectedFeature {
|
|||||||
} else if strings.Contains(c.Comment, " is earlier than ") {
|
} else if strings.Contains(c.Comment, " is earlier than ") {
|
||||||
const prefixLen = len(" is earlier than ")
|
const prefixLen = len(" is earlier than ")
|
||||||
featureVersion.FeatureName = strings.TrimSpace(c.Comment[:strings.Index(c.Comment, " is earlier than ")])
|
featureVersion.FeatureName = strings.TrimSpace(c.Comment[:strings.Index(c.Comment, " is earlier than ")])
|
||||||
featureVersion.AffectedType = affectedType
|
featureVersion.FeatureType = affectedType
|
||||||
version := c.Comment[strings.Index(c.Comment, " is earlier than ")+prefixLen:]
|
version := c.Comment[strings.Index(c.Comment, " is earlier than ")+prefixLen:]
|
||||||
err := versionfmt.Valid(rpm.ParserName, version)
|
err := versionfmt.Valid(rpm.ParserName, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -43,7 +43,7 @@ func TestOracleParserOneCve(t *testing.T) {
|
|||||||
|
|
||||||
expectedFeatures := []database.AffectedFeature{
|
expectedFeatures := []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "oracle:7",
|
Name: "oracle:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
@ -53,7 +53,7 @@ func TestOracleParserOneCve(t *testing.T) {
|
|||||||
AffectedVersion: "0:3.1.1-7.el7_1",
|
AffectedVersion: "0:3.1.1-7.el7_1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "oracle:7",
|
Name: "oracle:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
@ -63,7 +63,7 @@ func TestOracleParserOneCve(t *testing.T) {
|
|||||||
AffectedVersion: "0:3.1.1-7.el7_1",
|
AffectedVersion: "0:3.1.1-7.el7_1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "oracle:7",
|
Name: "oracle:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
|
@ -43,7 +43,7 @@ const (
|
|||||||
ovalURI = "https://www.redhat.com/security/data/oval/"
|
ovalURI = "https://www.redhat.com/security/data/oval/"
|
||||||
rhsaFilePrefix = "com.redhat.rhsa-"
|
rhsaFilePrefix = "com.redhat.rhsa-"
|
||||||
updaterFlag = "rhelUpdater"
|
updaterFlag = "rhelUpdater"
|
||||||
affectedType = database.AffectBinaryPackage
|
affectedType = database.BinaryPackage
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -333,7 +333,7 @@ func toFeatures(criteria criteria) []database.AffectedFeature {
|
|||||||
} else if strings.Contains(c.Comment, " is earlier than ") {
|
} else if strings.Contains(c.Comment, " is earlier than ") {
|
||||||
const prefixLen = len(" is earlier than ")
|
const prefixLen = len(" is earlier than ")
|
||||||
featureVersion.FeatureName = strings.TrimSpace(c.Comment[:strings.Index(c.Comment, " is earlier than ")])
|
featureVersion.FeatureName = strings.TrimSpace(c.Comment[:strings.Index(c.Comment, " is earlier than ")])
|
||||||
featureVersion.AffectedType = affectedType
|
featureVersion.FeatureType = affectedType
|
||||||
version := c.Comment[strings.Index(c.Comment, " is earlier than ")+prefixLen:]
|
version := c.Comment[strings.Index(c.Comment, " is earlier than ")+prefixLen:]
|
||||||
err := versionfmt.Valid(rpm.ParserName, version)
|
err := versionfmt.Valid(rpm.ParserName, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,7 +46,7 @@ func TestRHELParserMultipleCVE(t *testing.T) {
|
|||||||
database.MediumSeverity, database.MediumSeverity}
|
database.MediumSeverity, database.MediumSeverity}
|
||||||
expectedFeatures := []database.AffectedFeature{
|
expectedFeatures := []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "centos:6",
|
Name: "centos:6",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
@ -56,7 +56,7 @@ func TestRHELParserMultipleCVE(t *testing.T) {
|
|||||||
AffectedVersion: "0:38.1.0-1.el6_6",
|
AffectedVersion: "0:38.1.0-1.el6_6",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "centos:7",
|
Name: "centos:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
@ -96,7 +96,7 @@ func TestRHELParserOneCVE(t *testing.T) {
|
|||||||
|
|
||||||
expectedFeatures := []database.AffectedFeature{
|
expectedFeatures := []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "centos:7",
|
Name: "centos:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
@ -106,7 +106,7 @@ func TestRHELParserOneCVE(t *testing.T) {
|
|||||||
FixedInVersion: "0:3.1.1-7.el7_1",
|
FixedInVersion: "0:3.1.1-7.el7_1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "centos:7",
|
Name: "centos:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
@ -116,7 +116,7 @@ func TestRHELParserOneCVE(t *testing.T) {
|
|||||||
FixedInVersion: "0:3.1.1-7.el7_1",
|
FixedInVersion: "0:3.1.1-7.el7_1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "centos:7",
|
Name: "centos:7",
|
||||||
VersionFormat: rpm.ParserName,
|
VersionFormat: rpm.ParserName,
|
||||||
|
@ -39,7 +39,7 @@ const (
|
|||||||
trackerURI = "https://git.launchpad.net/ubuntu-cve-tracker"
|
trackerURI = "https://git.launchpad.net/ubuntu-cve-tracker"
|
||||||
updaterFlag = "ubuntuUpdater"
|
updaterFlag = "ubuntuUpdater"
|
||||||
cveURL = "http://people.ubuntu.com/~ubuntu-security/cve/%s"
|
cveURL = "http://people.ubuntu.com/~ubuntu-security/cve/%s"
|
||||||
affectedType = database.AffectSourcePackage
|
affectedType = database.SourcePackage
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -335,7 +335,7 @@ func parseUbuntuCVE(fileContent io.Reader) (vulnerability database.Vulnerability
|
|||||||
|
|
||||||
// Create and add the new package.
|
// Create and add the new package.
|
||||||
featureVersion := database.AffectedFeature{
|
featureVersion := database.AffectedFeature{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: releaseName,
|
Name: releaseName,
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
|
@ -46,7 +46,7 @@ func TestUbuntuParser(t *testing.T) {
|
|||||||
|
|
||||||
expectedFeatures := []database.AffectedFeature{
|
expectedFeatures := []database.AffectedFeature{
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "ubuntu:14.04",
|
Name: "ubuntu:14.04",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
@ -55,7 +55,7 @@ func TestUbuntuParser(t *testing.T) {
|
|||||||
AffectedVersion: versionfmt.MaxVersion,
|
AffectedVersion: versionfmt.MaxVersion,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "ubuntu:15.04",
|
Name: "ubuntu:15.04",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
@ -65,7 +65,7 @@ func TestUbuntuParser(t *testing.T) {
|
|||||||
AffectedVersion: "0.4-3",
|
AffectedVersion: "0.4-3",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
AffectedType: affectedType,
|
FeatureType: affectedType,
|
||||||
Namespace: database.Namespace{
|
Namespace: database.Namespace{
|
||||||
Name: "ubuntu:15.10",
|
Name: "ubuntu:15.10",
|
||||||
VersionFormat: dpkg.ParserName,
|
VersionFormat: dpkg.ParserName,
|
||||||
|
@ -425,7 +425,7 @@ func doVulnerabilitiesNamespacing(vulnerabilities []database.VulnerabilityWithAf
|
|||||||
|
|
||||||
for _, fv := range namespacedFeatures {
|
for _, fv := range namespacedFeatures {
|
||||||
// validate vulnerabilities, throw out the invalid vulnerabilities
|
// validate vulnerabilities, throw out the invalid vulnerabilities
|
||||||
if fv.AffectedType == "" || fv.AffectedVersion == "" || fv.FeatureName == "" || fv.Namespace.Name == "" || fv.Namespace.VersionFormat == "" {
|
if fv.FeatureType == "" || fv.AffectedVersion == "" || fv.FeatureName == "" || fv.Namespace.Name == "" || fv.Namespace.VersionFormat == "" {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"Name": fv.FeatureName,
|
"Name": fv.FeatureName,
|
||||||
"Affected Version": fv.AffectedVersion,
|
"Affected Version": fv.AffectedVersion,
|
||||||
|
@ -183,7 +183,7 @@ func newmockUpdaterDatastore() *mockUpdaterDatastore {
|
|||||||
|
|
||||||
func TestDoVulnerabilitiesNamespacing(t *testing.T) {
|
func TestDoVulnerabilitiesNamespacing(t *testing.T) {
|
||||||
fv1 := database.AffectedFeature{
|
fv1 := database.AffectedFeature{
|
||||||
AffectedType: database.AffectSourcePackage,
|
FeatureType: database.SourcePackage,
|
||||||
Namespace: database.Namespace{Name: "Namespace1"},
|
Namespace: database.Namespace{Name: "Namespace1"},
|
||||||
FeatureName: "Feature1",
|
FeatureName: "Feature1",
|
||||||
FixedInVersion: "0.1",
|
FixedInVersion: "0.1",
|
||||||
@ -191,7 +191,7 @@ func TestDoVulnerabilitiesNamespacing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fv2 := database.AffectedFeature{
|
fv2 := database.AffectedFeature{
|
||||||
AffectedType: database.AffectSourcePackage,
|
FeatureType: database.SourcePackage,
|
||||||
Namespace: database.Namespace{Name: "Namespace2"},
|
Namespace: database.Namespace{Name: "Namespace2"},
|
||||||
FeatureName: "Feature1",
|
FeatureName: "Feature1",
|
||||||
FixedInVersion: "0.2",
|
FixedInVersion: "0.2",
|
||||||
@ -199,7 +199,7 @@ func TestDoVulnerabilitiesNamespacing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fv3 := database.AffectedFeature{
|
fv3 := database.AffectedFeature{
|
||||||
AffectedType: database.AffectSourcePackage,
|
FeatureType: database.SourcePackage,
|
||||||
Namespace: database.Namespace{Name: "Namespace2"},
|
Namespace: database.Namespace{Name: "Namespace2"},
|
||||||
FeatureName: "Feature2",
|
FeatureName: "Feature2",
|
||||||
FixedInVersion: "0.3",
|
FixedInVersion: "0.3",
|
||||||
@ -237,7 +237,7 @@ func TestCreatVulnerabilityNotification(t *testing.T) {
|
|||||||
VersionFormat: vf1,
|
VersionFormat: vf1,
|
||||||
}
|
}
|
||||||
af1 := database.AffectedFeature{
|
af1 := database.AffectedFeature{
|
||||||
AffectedType: database.AffectSourcePackage,
|
FeatureType: database.SourcePackage,
|
||||||
Namespace: ns1,
|
Namespace: ns1,
|
||||||
FeatureName: "feature 1",
|
FeatureName: "feature 1",
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user