From cda7483d6c53b2919b57741b77efe0ecb850e132 Mon Sep 17 00:00:00 2001 From: Jan Dobes Date: Tue, 1 Oct 2024 16:08:00 +0200 Subject: [PATCH] fix: revert appendUniq due to performance hit --- go.mod | 1 - go.sum | 2 -- vmaas/vulnerabilities.go | 17 +---------------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/go.mod b/go.mod index bba73a3..f44161f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/ezamriy/gorpm v0.0.0-20160905202458-25f7273cbf51 - github.com/google/go-cmp v0.6.0 github.com/hashicorp/go-version v1.7.0 github.com/mattn/go-sqlite3 v1.14.22 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 2265ef3..74e90ea 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= diff --git a/vmaas/vulnerabilities.go b/vmaas/vulnerabilities.go index caa7257..51edb07 100644 --- a/vmaas/vulnerabilities.go +++ b/vmaas/vulnerabilities.go @@ -4,7 +4,6 @@ import ( "sort" "time" - "github.com/google/go-cmp/cmp" "github.com/hashicorp/go-version" "github.com/pkg/errors" "github.com/redhatinsights/vmaas-lib/vmaas/utils" @@ -438,21 +437,7 @@ func updateCves(cves map[string]VulnerabilityDetail, cve string, pkg Package, er affectedPackage.ModuleStreamPtrs.Module = &module.Module affectedPackage.ModuleStreamPtrs.Stream = &module.Stream } - vulnDetail.Affected = appendUniq(vulnDetail.Affected, &affectedPackage) + vulnDetail.Affected = append(vulnDetail.Affected, affectedPackage) } cves[cve] = vulnDetail } - -func appendUniq(affected []AffectedPackage, item *AffectedPackage) []AffectedPackage { - if item == nil { - return affected - } - - for _, a := range affected { - if cmp.Equal(a, *item) { - return affected - } - } - affected = append(affected, *item) - return affected -}