npm / npm/cli

[BUG] npm sbom does not create suitable external references for git repository settings in some packages

Open
#9,144 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
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

npm sbom does not create suitable external references for git repository settings in some packages.
For example, package @pkgjs/parseargs@0.11.0 has in its package.json file:

  "repository": {
    "type": "git",
    "url": "git@github.com:pkgjs/parseargs.git"
  },

However, npm sbom will create a component for this package with the following external reference:

      "externalReferences": [
        ...
        {
          "type": "vcs",
          "url": "git@github.com:pkgjs/parseargs.git"  
        },
        ...

The url is not in a valid format to meet RFC 3987.
This can be also be seen failing the CycloneDX SBOM validation in Dependency-Track v4.13.5 i.e.

Error: $.components[264].externalReferences[1].url: does not match the iri-reference pattern must be a valid RFC 3987 IRI-reference
Error: $.components[264].externalReferences[1].url: does not match the iri-reference pattern must be a valid RFC 3987 IRI-reference
Error: $.components[264].externalReferences[1].url: does not match the regex pattern ^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[1-9][0-9]*$
Error: $.components[264].externalReferences[1].url: does not match the iri-reference pattern must be a valid RFC 3987 IRI-reference
Error: $.components[264].externalReferences[1].url: does not match the regex pattern ^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[1-9][0-9]*#.+$
Expected Behavior

Generated sbom file should be loadable into Dependency Track for example and pass its validation.

Steps To Reproduce
  1. nvm use 25
  2. npm sbom
  3. With some packages like parseargs
  4. Run 'npm sbom'
  5. Inspect output and look in components->externalReferences->url values that start with git@...
Environment
  • npm: 25
  • Node.js:
  • OS Name: ubuntu
  • System Model Name:
  • npm config:
; "project" config from /home/NAME/git/eroll/.npmrc

engine-strict = true

; node bin location = /home/NAME/.nvm/versions/node/v25.8.1/bin/node
; node version = v25.8.1
; npm local prefix = /home/NAME/git/eroll
; npm version = 11.11.0
; cwd = /home/NAME/git/eroll
; HOME = /home/NAME
; Run `npm config ls -l` to show all defaults.

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

Start by reproducing npm sbom with a package whose package.json uses a git@github.com repository URL, such as @pkgjs/parseargs@0.11.0, and inspect the generated externalReferences values. Trace the npm sbom entry point to the SBOM generation code and add coverage for the repository URL conversion; done means the generated URL is a valid RFC 3987 IRI-reference and passes Dependency-Track validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.