From 686887a23a80453d3b2facd10af8dd4629362bcc Mon Sep 17 00:00:00 2001 From: Vadimas Vasiljevas Date: Tue, 10 Sep 2024 16:53:04 +0300 Subject: [PATCH 1/2] Fix empty name on package --- pkg/bomtools/merge.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/bomtools/merge.go b/pkg/bomtools/merge.go index 9ce90d2..6ef6cdd 100644 --- a/pkg/bomtools/merge.go +++ b/pkg/bomtools/merge.go @@ -248,7 +248,10 @@ func MergeSBOMs(mergedSbomParam MergeSBOMParam) (*cdx.BOM, error) { if b.Components != nil { components := *b.Components for i := range components { - allComponents = append(allComponents, &components[i]) + // Seems that sometimes the name can return empty + if components[i].Name != "" { + allComponents = append(allComponents, &components[i]) + } } } } From 1ae10e7a4e9fc44e33fa7776c2fe37e7c6d4e9cb Mon Sep 17 00:00:00 2001 From: Vadimas Vasiljevas Date: Tue, 10 Sep 2024 17:02:18 +0300 Subject: [PATCH 2/2] update tests that require name --- pkg/collectors/jvm_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/collectors/jvm_test.go b/pkg/collectors/jvm_test.go index a49ff55..b84dcde 100644 --- a/pkg/collectors/jvm_test.go +++ b/pkg/collectors/jvm_test.go @@ -59,11 +59,11 @@ func TestJVMCollector(t *testing.T) { const bomRoot = "/tmp/some-random-dir" executor := new(mockShellExecutor) - firstBOMComponents := []cdx.Component{{PackageURL: "pkg:gem/addressable@2.4.0"}} + firstBOMComponents := []cdx.Component{{PackageURL: "pkg:gem/addressable@2.4.0", Name: "addressable"}} firstBOM := new(cdx.BOM) firstBOM.Components = &firstBOMComponents - secondBOMComponents := []cdx.Component{{PackageURL: "pkg:gem/addressable@2.4.1"}} + secondBOMComponents := []cdx.Component{{PackageURL: "pkg:gem/addressable@2.4.1", Name: "addressable"}} secondBOM := new(cdx.BOM) secondBOM.Components = &secondBOMComponents