mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 17:03:17 +01:00
Fix CycloneDX license decoding panic (#898)
This commit is contained in:
parent
f4734d28b3
commit
99c3339810
@ -272,4 +272,14 @@ func Test_missingDataDecode(t *testing.T) {
|
|||||||
|
|
||||||
_, err = toSyftModel(bom)
|
_, err = toSyftModel(bom)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
pkg := decodeComponent(&cyclonedx.Component{
|
||||||
|
Licenses: &cyclonedx.Licenses{
|
||||||
|
{
|
||||||
|
License: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.Len(t, pkg.Licenses, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,9 @@ func encodeLicenses(p pkg.Package) *cyclonedx.Licenses {
|
|||||||
func decodeLicenses(c *cyclonedx.Component) (out []string) {
|
func decodeLicenses(c *cyclonedx.Component) (out []string) {
|
||||||
if c.Licenses != nil {
|
if c.Licenses != nil {
|
||||||
for _, l := range *c.Licenses {
|
for _, l := range *c.Licenses {
|
||||||
out = append(out, l.License.ID)
|
if l.License != nil {
|
||||||
|
out = append(out, l.License.ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user