mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
Add tools/sbom/generate_sbom.py, a stdlib-only Python 3 script that
writes a CycloneDX 1.7 SBOM describing the bundled dependencies of the
Node.js binary.
The script reads config.gypi to determine which dependencies are
active in the build, then extracts each one's version from whichever
file records it: C headers, CMakeLists.txt, package.json, Cargo.toml
and others. A version that 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 omitted, so the
document lists only what ships in the build.
The root component records a pkg:generic/nodejs/node purl, the git
commit SHA as a hash on a VCS external reference, V8's embedder string
and the build machine's hostname. Its version, and the file name,
match process.version, including -pre, -alpha.* and `--tag=` suffixes.
A formulation section records the build environment: the C/C++
compiler, rustc, cargo and nasm versions that ./configure recorded in
config.gypi, their distro package versions on Linux, the host's glibc
version, and the ./configure command from config.status. Each probe is
independent, and anything undetermined is left out rather than failing
generation. The C and C++ compilers are named by product - gcc, clang
or apple-clang - since the version alone is ambiguous: Apple clang
17.0.0 is not upstream clang 17. configure.py now records those
products and versions, plus rustc and cargo, in config.gypi.
Output defaults to out/Release/node-v{version}-sbom.json, overridable
with SBOM_OUTPUT.
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. tools/sbom/README.md covers the output and
how to generate it.
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: https://github.com/nodejs/security-wg/issues/1115
Signed-off-by: Beth Griggs <bethanyngriggs@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66761
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stewart X Addison <sxa@redhat.com>