mirror of
https://github.com/anchore/grype
synced 2024-11-10 14:44:12 +00:00
add presenter tests for ignore functionality (#459)
Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com>
This commit is contained in:
parent
30340dbdf6
commit
4682dcc2f4
2 changed files with 16 additions and 0 deletions
|
@ -9,6 +9,7 @@ type IgnoredMatch struct {
|
|||
|
||||
type IgnoreRule struct {
|
||||
Vulnerability string `json:"vulnerability,omitempty"`
|
||||
FixState string `json:"fix-state,omitempty"`
|
||||
Package *IgnoreRulePackage `json:"package,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -34,6 +35,7 @@ func newIgnoreRule(r match.IgnoreRule) IgnoreRule {
|
|||
|
||||
return IgnoreRule{
|
||||
Vulnerability: r.Vulnerability,
|
||||
FixState: r.FixState,
|
||||
Package: ignoreRulePackage,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
grypeDb "github.com/anchore/grype-db/pkg/db/v3"
|
||||
"github.com/anchore/grype/grype/match"
|
||||
)
|
||||
|
||||
|
@ -19,6 +20,7 @@ func TestNewIgnoreRule(t *testing.T) {
|
|||
input: match.IgnoreRule{},
|
||||
expected: IgnoreRule{
|
||||
Vulnerability: "",
|
||||
FixState: "",
|
||||
Package: nil,
|
||||
},
|
||||
},
|
||||
|
@ -31,6 +33,16 @@ func TestNewIgnoreRule(t *testing.T) {
|
|||
Vulnerability: "CVE-2020-1234",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "only fix state field",
|
||||
input: match.IgnoreRule{
|
||||
FixState: string(grypeDb.NotFixedState),
|
||||
},
|
||||
expected: IgnoreRule{
|
||||
FixState: string(grypeDb.NotFixedState),
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "all package fields",
|
||||
input: match.IgnoreRule{
|
||||
|
@ -67,6 +79,7 @@ func TestNewIgnoreRule(t *testing.T) {
|
|||
name: "all fields",
|
||||
input: match.IgnoreRule{
|
||||
Vulnerability: "CVE-2020-1234",
|
||||
FixState: string(grypeDb.NotFixedState),
|
||||
Package: match.IgnoreRulePackage{
|
||||
Name: "libc",
|
||||
Version: "3.0.0",
|
||||
|
@ -76,6 +89,7 @@ func TestNewIgnoreRule(t *testing.T) {
|
|||
},
|
||||
expected: IgnoreRule{
|
||||
Vulnerability: "CVE-2020-1234",
|
||||
FixState: "not-fixed",
|
||||
Package: &IgnoreRulePackage{
|
||||
Name: "libc",
|
||||
Version: "3.0.0",
|
||||
|
|
Loading…
Reference in a new issue