Skip to content

Commit 0600d65

Browse files
🐛 Fix panic in cyclonedx sbom handling.
1 parent 4a5a0aa commit 0600d65

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

sbom/cyclonedx.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (ccx *CycloneDX) convertCycloneDxToSbom(bom *cyclonedx.BOM) (*Sbom, error)
173173
Packages: make([]*Package, 0),
174174
}
175175

176-
if bom.Metadata.Tools != nil {
176+
if bom.Metadata.Tools != nil && bom.Metadata.Tools.Components != nil {
177177
// last one wins :-) - we only support one tool
178178
for i := range *bom.Metadata.Tools.Components {
179179
component := (*bom.Metadata.Tools.Components)[i]
@@ -237,12 +237,12 @@ func (ccx *CycloneDX) convertCycloneDxToSbom(bom *cyclonedx.BOM) (*Sbom, error)
237237
}
238238

239239
var familyMap = map[string][]string{
240-
"windows": []string{"windows", "os"},
241-
"macos": []string{"darwin", "bsd", "unix", "os"},
242-
"debian": []string{"linux", "unix", "os"},
243-
"ubuntu": []string{"linux", "unix", "os"},
244-
"centos": []string{"linux", "unix", "os"},
245-
"alpine": []string{"linux", "unix", "os"},
246-
"fedora": []string{"linux", "unix", "os"},
247-
"rhel": []string{"linux", "unix", "os"},
240+
"windows": {"windows", "os"},
241+
"macos": {"darwin", "bsd", "unix", "os"},
242+
"debian": {"linux", "unix", "os"},
243+
"ubuntu": {"linux", "unix", "os"},
244+
"centos": {"linux", "unix", "os"},
245+
"alpine": {"linux", "unix", "os"},
246+
"fedora": {"linux", "unix", "os"},
247+
"rhel": {"linux", "unix", "os"},
248248
}

0 commit comments

Comments
 (0)