-
Notifications
You must be signed in to change notification settings - Fork 582
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
feat: add "sbom" command that produces a CycloneDX 1.4 JSON SBOM #3983
Conversation
f2a12f5
to
25a6052
Compare
During our call on Monday, October 1, Snyk expressed interest in having the SBOM generation command be "snyk sbom" instead of "snyk deps" . I personally like "snyk deps" more, but I'd also be happy with any name :) Therefore, I've updated ths pull request with a commit that just changes the command name from "deps" to "sbom" with no other changes. |
7b102b1
to
54690c9
Compare
hello everyone, if the upgrade to TypeScript 4.8 (via #3875) was an issue, |
Regardless of what Snyk does with this request, I think it would be greatly beneficial to users of the CycloneDX library to publish these compatible type definitions to enhance its utility for other projects so I opened the issue at CycloneDX/cyclonedx-javascript-library#291 |
Snyk itself advises keeping dependencies up to date. So regardless of what Snyk wants to do with this request, I hope they will upgrade their Typescript dependency. I'm more than happy to work with Snyk to do with upgrade at #3875 if they would work with me. |
"node": ">=14.0.0" | ||
}, | ||
"optionalDependencies": { | ||
"xmlbuilder2": "^3.0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an optional depedency, that causes transitive dependnecies to install.
if you do not serialize to XML, then you could omit this optional dependency when adding @cyclonedx/cyclonedx-library
as a dependency. see https://docs.npmjs.com/cli/v8/commands/npm-install#omit
from this PR it appears that the XML functionality is not used.
src/cli/commands/sbom/index.ts
Outdated
bomRef: `${targetFile}:${packageURL}`, | ||
}, | ||
); | ||
// The "snyk" property namespace has been reserved: https://github.com/CycloneDX/cyclonedx-property-taxonomy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
package-lock.json
Outdated
@@ -19741,6 +19804,35 @@ | |||
"node": ">=4.0" | |||
} | |||
}, | |||
"node_modules/xmlbuilder2": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the optional dep from https://github.com/snyk/cli/pull/3983/files#r1004854642
93e8a91
to
56ba629
Compare
The SBOM includes the dependencies and the dependency graph. The SBOM is generated entirely client side; it does not communicate with the Snyk server/API. See: https://cyclonedx.org/ Closes: https://github.com/snyk/cli/issues/3862 Signed-off-by: Craig Andrews <[email protected]>
Hi Craig, we really appreciate the contribution. Unfortunately, it diverges a bit from our product vision and therefore we decided to close this PR. Thanks again, |
What does this PR do?
Adds a new command,
sbom
, that produces an SBOM in the CycloneDX JSON 1.4 format.By default,
sbom
will just list the dependency files and the count of the dependencies each contains, for example:Passing the
--cyclonedx-json
option will output CycloneDX 1.4 JSON to stdout:Passing the
--cyclonedx-json-file-output=<file>
option will output CycloneDX 1.4 JSON to the given file:The SBOM includes the dependencies (in the "components" section) and the dependency graph (in the "dependencies" section).
See: https://cyclonedx.org/
This feature facilitates compliance with the May 21, 2021 Executive Order on Improving the Nation’s Cybersecurity . It also bring Snyk CLI into alignment with the industry move towards SBOMs, of which Snyk itself has stressed the importance.
Where should the reviewer start?
I suggest looking at the new
sbom
command's implementation.How should this be manually tested?
snyk sbom --target-dir <project>
snyk sbom --target-dir <project> --cyclonedx-json
snyk sbom --target-dir <project> --cyclonedx-json-file-output=bom.json
As well as the other options as documented.
Any background context you want to provide?
The CycloneDX JSON file is constructed using https://www.npmjs.com/package/%40cyclonedx/cyclonedx-library
What are the relevant tickets?
Closes: https://github.com/snyk/cli/issues/3862
Screenshots
Additional questions