Repository navigation
tools,build: add CycloneDX SBOM generation - #66761
Draft
BethGriggs wants to merge 1 commit into
Draft
BethGriggs wants to merge 1 commit into
BethGriggs wants to merge 1 commit into
Conversation
Add tools/generate_sbom.py, a stdlib-only Python 3 script that writes a
CycloneDX 1.5 SBOM describing the bundled dependencies of the Node.js
binary.
The script reads config.gypi to determine which dependencies are active
in the current build, then extracts version strings from whichever file
each dependency uses to record its version: C headers, CMakeLists.txt,
package.json, Cargo.toml and others. A dependency whose version cannot
be read is reported as "unknown" with a warning rather than failing the
run. Dependencies satisfied by a system library or disabled via a
configure flag are emitted with scope "excluded", so the document
reflects the build that was configured.
Output defaults to out/Release/node-v{version}-sbom.json.
New Makefile targets:
make sbom - generate the SBOM (requires ./configure first)
make test-sbom - validate the generated SBOM
doc/contributing/maintaining/maintaining-dependencies.md now asks for a
DEP_CATALOG entry when adding a dependency, so new deps do not silently
go missing from the SBOM.
Unit tests in test/tools/test_generate_sbom.py cover catalog structural
correctness, the version extractors, scope resolution and deps/
coverage. They run under the existing `make tooltest` target.
Refs: nodejs/security-wg#1115
Assisted-by: IBM Bob
Signed-off-by: Beth Griggs <bethanyngriggs@gmail.com>
Collaborator
|
Review requested:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a proof-of-concept for build-time SBOM generation in Node.js core (nodejs/security-wg#1115).
The PR adds
tools/generate-sbom.py, a stdlib-only Python 3 script that produces a CycloneDX 1.5 JSON Software Bill of Materials covering all bundled runtime dependencies of the Node.js binary.The script reads
config.gypi(produced by./configure) to determine which dependencies are active in the current build, then extracts version strings from committed C headers,CMakeLists.txtfiles,package.jsonfiles,and other metadata sources across all
deps/subdirectories. Dependencies disabled via configure flags or satisfied by system libraries are listed withscope: excludedso the document accurately reflects the actual build.Pre-emptive questions
package.jsonfiles. New JS files inlib/flow throughconfig.gypiautomatically. The only manual step is oneDEP_CATALOGentry when a new C/C++ dep is added - a CI test enforces this so a missing entry fails rather than producing a silent gap.deps/npm/lib/utils/sbom-cyclonedx.js. SPDX support could be added later behind a--formatflag../configurejust needs to have run. Python is already the language of the entire build toolchain (configure.py,gyp_node.py,install.py).make build/make release?SBOM snippets