npm / npm/cli

[BUG] SBOM packages and relationships missing under some circumstances

Open
#7,204 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 10.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

When I try to generate SBOM for the opentelemetry-js repository, the output is missing some packages and relationships.

The repository is a monorepo with many sub-packages. They are defined using npm workspaces and listed under the packages and experimental/packages directories. Ideally, I would like to generate an SBOM file for each sub-package.

When I run the command below to generate SBOM for a single sub-package (packages/opentelemetry-core), it is missing in the relationships section (the dependency is in the packages/opentelemetry-semantic-conventions directory).

npm sbom --sbom-format spdx --omit dev --workspace packages/opentelemetry-core > sbom.json

The relationship is missing even when I generate SBOM for the whole repository by running this in the root directory:

npm sbom --sbom-format spdx --omit dev > sbom.json

In addition, the SBOM output for the whole repository is missing some dependencies completely even in the packages section of the SBOM file. For example, the sub-package in folder packages/opentelemetry-sdk-trace-node has a dependency on semver, but semver is not included in the SBOM file at all.

Expected Behavior

npm sbom should capture all dependencies in a repository with workspaces.

Steps To Reproduce

First issue:

  1. Generate SBOM file using these steps
git clone git@github.com:open-telemetry/opentelemetry-js.git
cd opentelemetry-js
npm ci
npm sbom --sbom-format spdx --omit dev --workspace packages/opentelemetry-core > sbom.json
  1. In the generated SBOM file, note that the package @opentelemetry/semantic-conventions is listed under packages, but NOT under dependencies.

Second issue:

  1. Generate SBOM file using these steps
git clone git@github.com:open-telemetry/opentelemetry-js.git
cd opentelemetry-js
npm ci
npm sbom --sbom-format spdx --omit dev > sbom.json
  1. In the generates SBOM file, note that the semver package is completely missing (in both packages and relationships sections), even though the package in packages/opentelemetry-sdk-trace-node depends on it.
Environment
  • npm: 10.4.0
  • Node.js: v18.18.0
  • OS Name: macOS 14.2.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two SBOM commands in the opentelemetry-js repository after npm ci, using the workspace and root cases described. Compare the generated SPDX packages, dependencies, and relationships, including @opentelemetry/semantic-conventions and semver; done means all workspace dependencies and relationships are captured.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.