From c73a33700af085a46da829e0c3432b5643eefee6 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Tue, 22 Sep 2020 16:10:23 -0400 Subject: [PATCH] fix replacement of results with matches (#158) Signed-off-by: Alex Goodman --- cmd/root.go | 8 ++++---- cmd/root_test.go | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 330bba39776..70b83b432f4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,8 +12,8 @@ import ( "github.com/anchore/grype/grype" "github.com/anchore/grype/grype/event" "github.com/anchore/grype/grype/grypeerr" + "github.com/anchore/grype/grype/match" "github.com/anchore/grype/grype/presenter" - "github.com/anchore/grype/grype/result" "github.com/anchore/grype/grype/vulnerability" "github.com/anchore/grype/internal" "github.com/anchore/grype/internal/bus" @@ -190,7 +190,7 @@ func startWorker(userInput string, failOnSeverity *vulnerability.Severity) <-cha // determine if there are any severities >= to the max allowable severity (which is optional). // note: until the shared file lock in sqlittle is fixed the sqlite DB cannot be access concurrently, // implying that the fail-on-severity check must be done before sending the presenter object. - if hitSeverityThreshold(failOnSeverity, results, metadataProvider) { + if hitSeverityThreshold(failOnSeverity, matches, metadataProvider) { errs <- grypeerr.ErrAboveSeverityThreshold } @@ -210,10 +210,10 @@ func runDefaultCmd(_ *cobra.Command, args []string) error { } // hitSeverityThreshold indicates if there are any severities >= to the max allowable severity (which is optional) -func hitSeverityThreshold(thresholdSeverity *vulnerability.Severity, results result.Result, metadataProvider vulnerability.MetadataProvider) bool { +func hitSeverityThreshold(thresholdSeverity *vulnerability.Severity, matches match.Matches, metadataProvider vulnerability.MetadataProvider) bool { if thresholdSeverity != nil { var maxDiscoveredSeverity vulnerability.Severity - for m := range results.Enumerate() { + for m := range matches.Enumerate() { metadata, err := metadataProvider.GetMetadata(m.Vulnerability.ID, m.Vulnerability.RecordSource) if err != nil { continue diff --git a/cmd/root_test.go b/cmd/root_test.go index 72b191547c8..4cf9c1b2dfd 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -2,7 +2,6 @@ package cmd import ( "github.com/anchore/grype/grype/match" - "github.com/anchore/grype/grype/result" "github.com/anchore/grype/grype/vulnerability" "github.com/anchore/syft/syft/pkg" "testing" @@ -42,7 +41,7 @@ func TestAboveAllowableSeverity(t *testing.T) { Type: pkg.RpmPkg, } - matches := result.NewResult() + matches := match.NewMatches() matches.Add(thePkg, match.Match{ Type: match.ExactDirectMatch, Vulnerability: vulnerability.Vulnerability{ @@ -55,7 +54,7 @@ func TestAboveAllowableSeverity(t *testing.T) { tests := []struct { name string failOnSeverity string - matches result.Result + matches match.Matches expectedResult bool }{ {