[BUG] npm sbom does not create suitable external references for git repository settings in some packages
Nobody has claimed this yet.
- 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
- nvm use 25
- npm sbom
- With some packages like parseargs
- Run 'npm sbom'
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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