feat: [CMPA-603] Add npm support for SBOM component metadata being FF#6950
Open
calhar-snyk wants to merge 2 commits into
Open
feat: [CMPA-603] Add npm support for SBOM component metadata being FF#6950calhar-snyk wants to merge 2 commits into
calhar-snyk wants to merge 2 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This comment has been minimized.
This comment has been minimized.
59984f8 to
2fe53c6
Compare
This comment has been minimized.
This comment has been minimized.
Contributor
2fe53c6 to
5f7299b
Compare
This comment has been minimized.
This comment has been minimized.
5f7299b to
83d9058
Compare
This comment has been minimized.
This comment has been minimized.
83d9058 to
aff526d
Compare
This comment has been minimized.
This comment has been minimized.
aff526d to
35c9cf1
Compare
This comment has been minimized.
This comment has been minimized.
35c9cf1 to
714ee6c
Compare
This comment has been minimized.
This comment has been minimized.
714ee6c to
98c902f
Compare
PR Reviewer Guide 🔍
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Submission Checklist
What does this PR do?
Extends
--include-component-metadatasupport to npm projects, following on from the Maven support added in #6948.When the flag is set, the npm plugin now forwards it to
snyk-nodejs-lockfile-parser, which reads the install-timeintegrityandresolvedfields already recorded in the lockfile and surfaces them ashash:<algorithm>anddistribution:urllabels on the dep-graph nodes. The SBOM extension then uses these labels to populate component hashes and external distribution URLs in the CycloneDX output.Concretely:
includeComponentMetadatathrough the legacynpm-lock-parserin both code paths — the v2/v3 dep-graph path (parseNpmLockV2Project) and the v1 depTree path (buildDepTreeFromFiles). For v1, the labels survive the downstream depTree→dep-graph conversion.includeComponentMetadatato the pluginOptionstype.snyk-nodejs-lockfile-parserto2.9.0, the version that emits the component-metadata labels.The flag remains internal/undocumented and is gated by the feature-flag gateway — the same surface as the Maven precursor. Unlike Maven, no artifact resolution step is needed: the metadata already lives in the lockfile, so nothing has to be installed/resolved first.
Where should the reviewer start?
src/lib/plugins/nodejs-plugin/npm-lock-parser.ts— the two-line forwarding change (v1 and v2/v3 paths).src/lib/plugins/types.ts— the new optionalOptionsfield.test/jest/acceptance/snyk-test/npm-include-component-metadata.spec.ts— coverage across lockfile v1/v2/v3.N.B. 1: npm intentionally stays on the in-tree legacy plugin here (the change just threads the flag through it).
N.B. 2: The
snyk-nuget-pluginbump inpackage-lock.jsonis a drive-by correction of a previous oversight.package.jsonwants"snyk-nuget-plugin": "4.2.3",How should this be manually tested?
Against an npm project with a
package-lock.json(v1, v2, or v3):Dep-graph nodes should carry
hash:<algorithm>anddistribution:urllabels. Re-running without--include-component-metadatashould produce no such labels.Automated coverage:
test/jest/acceptance/snyk-test/npm-include-component-metadata.spec.tsexercises lockfile v1/v2/v3, each asserting the labels are present with the flag and absent without it.The full
snyk sbomflow can also be tested against the pre-prod API:What's the product update that needs to be communicated to CLI users?
None. The feature is inert by default and gated behind an internal feature flag; there is no user-facing change unless explicitly enabled.
Risk assessment (Low | Medium | High)?
Low. The behaviour is gated behind an internal feature flag from the feature-flag gateway and is inert by default — clients see no change unless it is explicitly enabled for them. The only always-on change is the
snyk-nodejs-lockfile-parser2.9.0 bump, which adds the label-emitting code path without altering default output. npm scans continue to run through the existing legacy plugin.Any background context you want to provide?
Precursor: #6948 (Maven component metadata + registering
include-component-metadataas a recognised CLI argument forwarded to the plugins). This PR is the npm counterpart.What are the relevant tickets?