Skip to content

Use rules_nodejs toolchain for hermetic cdxgen execution - #4

Open
olivembo wants to merge 2 commits into
eclipse-score:mainfrom
etas-contrib:hermetic
Open

Use rules_nodejs toolchain for hermetic cdxgen execution#4
olivembo wants to merge 2 commits into
eclipse-score:mainfrom
etas-contrib:hermetic

Conversation

@olivembo

@olivembo olivembo commented Apr 7, 2026

Copy link
Copy Markdown

Summary

This PR makes SBOM generation more reproducible and closer to hermetic builds.

What changed

Notes

Includes both branch commits (23d543e, d56768c).
auto_cdxgen still requires network and no-sandbox behavior as configured.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make SBOM generation more reproducible by moving cdxgen execution onto a Bazel-managed Node/npm toolchain and by refining how Rust crate metadata is generated (crates.io-first, with optional dash-license-scan).

Changes:

  • Switched auto-cdxgen to run via rules_nodejs toolchain and added a pinned cdxgen_version parameter.
  • Updated Rust crates metadata cache generation to use crates.io metadata by default, with optional dash-license-scan via CLI flag.
  • Removed the legacy host npm_wrapper and tightened Bazel reproducibility with lockfile enforcement.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/rules.bzl Uses Bazel-managed Node toolchain for cdxgen; refactors crates cache generation to a Bazel py_binary; adds cdxgen_version; adds Node toolchain requirement.
defs.bzl Threads cdxgen_version through the public sbom() macro.
scripts/generate_crates_metadata_cache.py Adds crates.io license fallback and optional dash-license-scan execution via --use-dash-license-scan.
scripts/BUILD.bazel Adds py_binary target for generate_crates_metadata_cache to support Bazel execution.
tests/test_generate_crates_metadata_cache.py Adds unit tests for crates.io license normalization and precedence over dash-license-scan.
README.md Updates documentation to reflect Bazel-managed Node/npm usage, crates.io-first Rust metadata, and new cdxgen_version.
MODULE.bazel Adds rules_nodejs and configures Node toolchain; configures uv extension as a dev dependency.
MODULE.bazel.lock Adds the module lockfile to the repo to support --lockfile_mode=error reproducibility.
BUILD.bazel Removes the legacy npm_wrapper sh_binary.
npm_wrapper.sh Deletes the host npm/nvm wrapper script.
.bazelrc Enforces lockfile reproducibility with --lockfile_mode=error.
.gitignore Stops ignoring MODULE.bazel.lock so it can be checked in.
Comments suppressed due to low confidence (1)

internal/rules.bzl:146

  • The cdxgen action passes node_info.npm.path as a script argument, but node_info.npm itself is not explicitly declared as an input/tool. If npm_sources doesn’t include the entrypoint file, the action will fail with a missing file at execution time.
        ctx.actions.run(
            outputs = [cdxgen_sbom],
            tools = [node_info.node],
            inputs = node_info.npm_sources,
            executable = node_info.node,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/rules.bzl
Comment on lines +124 to +128
ctx.actions.run(
inputs = cache_inputs,
outputs = [crates_cache],
command = cache_cmd,
executable = ctx.executable._crates_cache_script,
arguments = [cache_args],
Comment thread internal/rules.bzl
cfg = "exec",
),
},
toolchains = ["@rules_nodejs//nodejs:toolchain_type"],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants