From 9e875f748dd218ac0d3bdb4a11bc3830cee5c8be Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 23 Feb 2017 02:05:33 -0500 Subject: [PATCH 1/2] database/pgsql: copy whole namespace --- database/pgsql/vulnerability.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/pgsql/vulnerability.go b/database/pgsql/vulnerability.go index 4f67a380..f7a88199 100644 --- a/database/pgsql/vulnerability.go +++ b/database/pgsql/vulnerability.go @@ -241,7 +241,7 @@ func (pgSQL *pgSQL) insertVulnerability(vulnerability database.Vulnerability, on if fifv.Feature.Namespace.Name == "" { // As there is no Namespace on that FixedIn FeatureVersion, set it to the Vulnerability's // Namespace. - fifv.Feature.Namespace.Name = vulnerability.Namespace.Name + fifv.Feature.Namespace = vulnerability.Namespace } else if fifv.Feature.Namespace.Name != vulnerability.Namespace.Name { msg := "could not insert an invalid vulnerability that contains FixedIn FeatureVersion that are not in the same namespace as the Vulnerability" log.Warning(msg) From b792eb61f69c8e9c100675970ac4d928fd2b5e98 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 23 Feb 2017 02:05:52 -0500 Subject: [PATCH 2/2] updater: copy whole namespace when deduping vulns --- updater.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/updater.go b/updater.go index d3379cdd..a404dceb 100644 --- a/updater.go +++ b/updater.go @@ -333,12 +333,14 @@ func (lv *lockableVulnerability) appendFunc(metadataKey string, metadata interfa } } -// doVulnerabilitiesNamespacing takes Vulnerabilities that don't have a Namespace and split them -// into multiple vulnerabilities that have a Namespace and only contains the FixedIn -// FeatureVersions corresponding to their Namespace. +// doVulnerabilitiesNamespacing takes Vulnerabilities that don't have a +// Namespace and split them into multiple vulnerabilities that have a Namespace +// and only contains the FixedIn FeatureVersions corresponding to their +// Namespace. // -// It helps simplifying the fetchers that share the same metadata about a Vulnerability regardless -// of their actual namespace (ie. same vulnerability information for every version of a distro). +// It helps simplifying the fetchers that share the same metadata about a +// Vulnerability regardless of their actual namespace (ie. same vulnerability +// information for every version of a distro). func doVulnerabilitiesNamespacing(vulnerabilities []database.Vulnerability) []database.Vulnerability { vulnerabilitiesMap := make(map[string]*database.Vulnerability) @@ -351,7 +353,7 @@ func doVulnerabilitiesNamespacing(vulnerabilities []database.Vulnerability) []da if vulnerability, ok := vulnerabilitiesMap[index]; !ok { newVulnerability := v - newVulnerability.Namespace.Name = fv.Feature.Namespace.Name + newVulnerability.Namespace = fv.Feature.Namespace newVulnerability.FixedIn = []database.FeatureVersion{fv} vulnerabilitiesMap[index] = &newVulnerability