You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using syft to output cyclonedx format, component properties for syft:metadata are excluded if those properties are default values (like empty string for a string), however syft:metadatatype is populated.
Using syft to convert this to syft-json results in a syft-json SBOM with the metadatatype field populated but missing the metadata field. Using this syft-json in grype results in an error:
unable to decode syft-json: unexpected end of JSON input
You can recreate this error by removing the "metadata" field from an artifact with metadata in an otherwise valid syft-json SBOM.
I think there are a couple issues here:
syft-json decoder should handle a missing metadata field either with a better error message or simply skipping the Unmarshal leaving the Metadata as an empty struct of the correct type.
Fixing this would ensure that grype doesn't crash when given an input with missing info.
cyclonedx decoder should ensure that when the cyclonedx is decoded into the SBOM and there is no metadata properties, but there is a MetadataType propertie, the Package's Metadata is still set to an empty struct of the correct type.
Fixing this would ensure that converting a cyclonedx SBOM to syft-json when there is data missing or not included, results in all the expected data in the syft-json SBOM.
When using syft to output cyclonedx format, component properties for
syft:metadata
are excluded if those properties are default values (like empty string for a string), howeversyft:metadatatype
is populated.Using syft to convert this to syft-json results in a syft-json SBOM with the
metadatatype
field populated but missing themetadata
field. Using this syft-json in grype results in an error:unable to decode syft-json: unexpected end of JSON input
Root cause is the code here: https://github.com/anchore/syft/blob/v0.60.2/syft/formats/syftjson/model/package.go#L81 that expects Metadata to always be at least "{}".
You can recreate this error by removing the "metadata" field from an artifact with metadata in an otherwise valid syft-json SBOM.
I think there are a couple issues here:
syft-json decoder should handle a missing metadata field either with a better error message or simply skipping the Unmarshal leaving the Metadata as an empty struct of the correct type.
Fixing this would ensure that grype doesn't crash when given an input with missing info.
cyclonedx decoder should ensure that when the cyclonedx is decoded into the SBOM and there is no metadata properties, but there is a MetadataType propertie, the Package's Metadata is still set to an empty struct of the correct type.
Fixing this would ensure that converting a cyclonedx SBOM to syft-json when there is data missing or not included, results in all the expected data in the syft-json SBOM.
Environment:
The text was updated successfully, but these errors were encountered: