mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
Add ability to scan snaps (as a source) (#3929)
This commit is contained in:
@@ -45,6 +45,15 @@ func Test_DocumentName(t *testing.T) {
|
||||
},
|
||||
expected: "some/path/to/place",
|
||||
},
|
||||
{
|
||||
name: "snap",
|
||||
srcMetadata: source.Description{
|
||||
Name: "some/name",
|
||||
// there is nothing in the snap metadata that indicates a name
|
||||
Metadata: source.SnapMetadata{},
|
||||
},
|
||||
expected: "some/name",
|
||||
},
|
||||
{
|
||||
name: "named",
|
||||
srcMetadata: source.Description{
|
||||
|
||||
@@ -16,6 +16,7 @@ const (
|
||||
InputImage = "image"
|
||||
InputDirectory = "dir"
|
||||
InputFile = "file"
|
||||
InputSnap = "snap"
|
||||
)
|
||||
|
||||
func DocumentNameAndNamespace(src source.Description, desc sbom.Descriptor) (string, string) {
|
||||
@@ -33,6 +34,8 @@ func DocumentNamespace(name string, src source.Description, desc sbom.Descriptor
|
||||
input = InputDirectory
|
||||
case source.FileMetadata:
|
||||
input = InputFile
|
||||
case source.SnapMetadata:
|
||||
input = InputSnap
|
||||
}
|
||||
|
||||
uniqueID := uuid.Must(uuid.NewRandom())
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/anchore/syft/syft/source"
|
||||
)
|
||||
|
||||
func Test_documentNamespace(t *testing.T) {
|
||||
func Test_DocumentNamespace(t *testing.T) {
|
||||
tracker := sourcemetadata.NewCompletionTester(t)
|
||||
|
||||
tests := []struct {
|
||||
@@ -53,6 +53,14 @@ func Test_documentNamespace(t *testing.T) {
|
||||
},
|
||||
expected: "https://anchore.com/syft/file/my-name-",
|
||||
},
|
||||
{
|
||||
name: "snap",
|
||||
inputName: "my-name",
|
||||
src: source.Description{
|
||||
Metadata: source.SnapMetadata{},
|
||||
},
|
||||
expected: "https://anchore.com/syft/snap/my-name-",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user