Skip to content

Commit

Permalink
fix(sbom): export bom-ref when converting a package to a component (#…
Browse files Browse the repository at this point in the history
…7340)

Signed-off-by: knqyf263 <[email protected]>
Co-authored-by: amf <[email protected]>
Co-authored-by: knqyf263 <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent dbd2dd6 commit 5dd94eb
Show file tree
Hide file tree
Showing 6 changed files with 571 additions and 15 deletions.
1 change: 0 additions & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func readCycloneDX(t *testing.T, filePath string) *cdx.BOM {
return (*bom.Components)[i].Name < (*bom.Components)[j].Name
})
for i := range *bom.Components {
(*bom.Components)[i].BOMRef = ""
sort.Slice(*(*bom.Components)[i].Properties, func(ii, jj int) bool {
return (*(*bom.Components)[i].Properties)[ii].Name < (*(*bom.Components)[i].Properties)[jj].Name
})
Expand Down
12 changes: 12 additions & 0 deletions integration/sbom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestSBOM(t *testing.T) {
name string
args args
golden string
fakeUUID string
override OverrideFunc
}{
{
Expand Down Expand Up @@ -57,6 +58,16 @@ func TestSBOM(t *testing.T) {
},
golden: "testdata/fluentd-multiple-lockfiles.json.golden",
},
{
name: "scan SBOM into SBOM",
args: args{
input: "testdata/fixtures/sbom/fluentd-multiple-lockfiles-cyclonedx.json",
format: "cyclonedx",
artifactType: "cyclonedx",
},
fakeUUID: "3ff14136-e09f-4df9-80ea-%012d",
golden: "testdata/fluentd-multiple-lockfiles-short.cdx.json.golden",
},
{
name: "minikube KBOM",
args: args{
Expand Down Expand Up @@ -165,6 +176,7 @@ func TestSBOM(t *testing.T) {
// Run "trivy sbom"
runTest(t, osArgs, tt.golden, outputFile, types.Format(tt.args.format), runOptions{
override: overrideFuncs(overrideSBOMReport, overrideUID, tt.override),
fakeUUID: tt.fakeUUID,
})
})
}
Expand Down
Loading

0 comments on commit 5dd94eb

Please sign in to comment.