Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sbom): use package UIDs for uniqueness #7042

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions integration/convert_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//go:build integration

package integration

import (
"path/filepath"
"testing"

"github.com/aquasecurity/trivy/pkg/types"
)

func TestConvert(t *testing.T) {
type args struct {
input string
format string
scanners string
}
tests := []struct {
name string
args args
golden string
override OverrideFunc
}{
{
name: "npm",
args: args{
input: "testdata/npm.json.golden",
format: "cyclonedx",
},
golden: "testdata/npm-cyclonedx.json.golden",
},
{
name: "npm without package UID",
args: args{
input: "testdata/fixtures/convert/npm.json.golden",
format: "cyclonedx",
},
golden: "testdata/npm-cyclonedx.json.golden",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
osArgs := []string{
"convert",
"--cache-dir",
t.TempDir(),
"-q",
"--format",
tt.args.format,
}

// Set up the output file
outputFile := filepath.Join(t.TempDir(), "output.json")
if *update {
outputFile = tt.golden
}

osArgs = append(osArgs, "--output", outputFile)
osArgs = append(osArgs, tt.args.input)

// Run "trivy convert"
runTest(t, osArgs, tt.golden, outputFile, types.Format(tt.args.format), runOptions{
fakeUUID: "3ff14136-e09f-4df9-80ea-%012d",
})
})
}

}
Loading