Open WIStudent opened 1 month ago
@WIStudent I can see why this is happening, but I'm not sure what is the best way is to resolve it.
Here is the rough summary:
As a side-note, I think the xml serialization will write out both variants (and thus violate the specs).
It is a tricky problem because an automatic conversion between the legacy format and the new format would require making some assumptions. One solution could be to let the user choose a tools-merging-strategy
:
error
: This throws an error when the input SBOMs contain different tool formats. It is up to the user to ensure that the input SBOMs all use the same tool format. This should be the default in my opinion.drop-new-format
: If multiple formats are present, only export the legacy format tools and print a warning that some tools were dropped. This is the behavior we currently see in the JSON export.drop-legacy-format
: If multiple formats are present, only export the tools using the new format and print a warning that some legacy tools were droppedautomatic-conversion
: Use some assumptions to convert all tools to the new or legacy format (depending on the output spec version).Another solution would be to only implement the error
strategy without giving the user a choice. This would at least ensure that the merged SBOM is not incomplete or invalid.
In my case I have a Java Spring application that uses npm dependencies for parts of its frontend. I am using cyclonedx-maven-plugin
and @cyclonedx/cyclonedx-npm
to collect the maven and npm dependencies. @cyclonedx/cyclonedx-npm
can handle v1.6 but currently only produces SBOMs using the legacy tool format. cyclonedx-maven-plugin
on the other hand uses the new format if the output spec version supports it. Instead of using cyclonedx-cli merge
I ended up writing my own custom maven plugin for my specific merging needs using cyclonedx-core-java
. For now It merges the tools by requiring that all input SBOMs use the legacy tool format.
I have 2 SBOM files. One created with
cyclonedx-maven-plugin
and one created with
@cyclonedx/cyclonedx-npm
(I removed irrelevant parts for readability).
cyclonedx-maven-plugin
creates an SBOM that uses the newer format for themetadata.tools
field,@cyclonedx/cyclonedx-npm
creates one that uses the legacy format.If I try to merge these two SBOMs, only the tools in the legacy format are included in the result:
The order of the input files did not matter