-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for generating JSON output #20
base: master
Are you sure you want to change the base?
Conversation
@voltone is this an interesting addition? We (Stritzinger) want to add more enhancements to this repo, and getting some feedback for this one is highly appreciated :). |
Yes, I'm definitely interested in adding JSON support, and in general moving this project forward. But I'm pretty sure the best way to do that is to extract the CycloneDX support into a package that can be used by any tool that wants to support it (including the Elixir/Mix sibling of this project). If someone were to create a SPDX package we could add support for that too. I've made a few false starts creating such a package and reworking the Rebar3 plugin and Mix task, but unfortunately I've never had a chance to wrap up that work due to other priorities. Do you think a first shot at a CycloneDX Erlang Hex package could be extracted from this PR? |
Hi @voltone! I think this is definitely a cool idea which we could follow along with. I will get back to you about this when we have more brain capacity to think about this :) |
I started taking another shot at a generic Erlang/Elixir CycloneDX library the other day. I have a pretty good idea how I can create a package with support for both languages: the core would be implemented in Erlang, built using Rebar3, but the package would also include a Mix file and a bunch of Elixir module that wrap the Erlang modules in idiomatic Elixir APIs. But, I found myself wondering whether the Erlang core should use records or maps to represent the SBOM before serialization to JSON/XML, and whether "strings" should be represented using Erlang strings or binaries. I think Elixir users would prefer maps and binaries, but I really want the core data structures to be the same for both. So I'm wondering whether Erlang users would insist on records and strings instead. Any thoughts...? |
I, for one, don't have the impression that Erlang developers have a strong preference towards any of these (maps vs records or binaries vs strings). |
This (admittedly pretty hefty) PR adds support for generating an SBoM in JSON format.
This is achieved by introducing an internal SBoM format based on Erlang records, and then converting that to either XML or JSON.
Old SBoM files are also parsed into the record-based format to check their version and contents.
Existing user-facing behavior is not changed; JSON can be generated by passing the
-F json
argument.Additionally, two fixes have been made to ensure the generated SBoM files are valid (against both the schema and the CycloneDX CLI):
serialNumber
field now contains the requiredurn:uuid:
prefix.<component>
XML elements are now ordered as the CycloneDX XML spec expects.