mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 23:16:30 +01:00
respond to authoratative CPEs from catalogers (#3166)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/anchore/syft/syft/cpe"
|
||||
)
|
||||
|
||||
func Test_hasAuthoritativeCPE(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
cpes []cpe.CPE
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "no cpes",
|
||||
cpes: []cpe.CPE{},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "no authoritative cpes",
|
||||
cpes: []cpe.CPE{
|
||||
{
|
||||
Source: cpe.GeneratedSource,
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "has declared (authoritative) cpe",
|
||||
cpes: []cpe.CPE{
|
||||
{
|
||||
Source: cpe.DeclaredSource,
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "has lookup (authoritative) cpe",
|
||||
cpes: []cpe.CPE{
|
||||
{
|
||||
Source: cpe.NVDDictionaryLookupSource,
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assert.Equal(t, tt.want, hasAuthoritativeCPE(tt.cpes))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user