Skip to content

Commit 5dd94eb

Browse files
afdeskamfknqyf263
authored
fix(sbom): export bom-ref when converting a package to a component (#7340)
Signed-off-by: knqyf263 <[email protected]> Co-authored-by: amf <[email protected]> Co-authored-by: knqyf263 <[email protected]>
1 parent dbd2dd6 commit 5dd94eb

File tree

6 files changed

+571
-15
lines changed

6 files changed

+571
-15
lines changed

integration/integration_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ func readCycloneDX(t *testing.T, filePath string) *cdx.BOM {
186186
return (*bom.Components)[i].Name < (*bom.Components)[j].Name
187187
})
188188
for i := range *bom.Components {
189-
(*bom.Components)[i].BOMRef = ""
190189
sort.Slice(*(*bom.Components)[i].Properties, func(ii, jj int) bool {
191190
return (*(*bom.Components)[i].Properties)[ii].Name < (*(*bom.Components)[i].Properties)[jj].Name
192191
})

integration/sbom_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestSBOM(t *testing.T) {
2525
name string
2626
args args
2727
golden string
28+
fakeUUID string
2829
override OverrideFunc
2930
}{
3031
{
@@ -57,6 +58,16 @@ func TestSBOM(t *testing.T) {
5758
},
5859
golden: "testdata/fluentd-multiple-lockfiles.json.golden",
5960
},
61+
{
62+
name: "scan SBOM into SBOM",
63+
args: args{
64+
input: "testdata/fixtures/sbom/fluentd-multiple-lockfiles-cyclonedx.json",
65+
format: "cyclonedx",
66+
artifactType: "cyclonedx",
67+
},
68+
fakeUUID: "3ff14136-e09f-4df9-80ea-%012d",
69+
golden: "testdata/fluentd-multiple-lockfiles-short.cdx.json.golden",
70+
},
6071
{
6172
name: "minikube KBOM",
6273
args: args{
@@ -165,6 +176,7 @@ func TestSBOM(t *testing.T) {
165176
// Run "trivy sbom"
166177
runTest(t, osArgs, tt.golden, outputFile, types.Format(tt.args.format), runOptions{
167178
override: overrideFuncs(overrideSBOMReport, overrideUID, tt.override),
179+
fakeUUID: tt.fakeUUID,
168180
})
169181
})
170182
}

0 commit comments

Comments
 (0)