mirror of
https://github.com/anchore/grype
synced 2024-11-10 14:44:12 +00:00
fix replacement of results with matches (#158)
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
f0f8f4bf02
commit
c73a33700a
2 changed files with 6 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}{
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue