Repository navigation
Conversation
Filter omitted dev, optional, and peer dependency edges across the full npm-ls graph and prune unreachable or omitted packages from root. This ensures transitive optional/peer dependencies and devOptional packages (when both dev and optional are omitted) are excluded even when npm-ls only filters root-level edges or omits lockfile flags. Fixes CycloneDX#1325 Signed-off-by: Kemal Yilmaz <kemalylmz@gmail.com>
Up to standards ✅🟢 Issues
|
jkowalleck
marked this pull request as draft
November 11, 2026 11:08
This comment was marked as resolved.
This comment was marked as resolved.
1 of 2 tasks
jkowalleck
marked this pull request as ready for review
November 11, 2026 11:15
Member
|
Thank you for tackling this issue. I need to look into the details; this will take a while - please stay patient :-) Any peer review is very welcome. |
Member
|
i think this fix needs some in-depth docs added to https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/docs/how.md COuld you add a separate section for this regard in the document? |
Signed-off-by: Kemal Yilmaz <kemalylmz@gmail.com>
Author
|
Added the |
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.
Description
npm ls --omit=...only filters direct root/workspace dependency edges (currentDepth === 0) and (without--package-lock-only, see npm/cli#8485) omitsdev,optional, anddevOptionalnode flags from JSON output. As a result, transitiveoptionalandpeerdependencies as well asdevOptionaldependencies reachable only through omitteddevandoptionalpaths remained in the generated SBOM.This change updates
BomBuilder.gatherPackagesto:devDependencieson root/workspaces,optionalDependencies,_dependencies,peerDependencies,peerDependenciesMeta) while still indexing dedupednpm lsnodes before reachability pruning,dev,optional,peer, ordevOptional(when bothdevandoptionalare omitted) flags starting fromrootPath,tests/unit/builders.BomBuilder.spec.jsand update theomit-*integration snapshots introduced in tests: omit dev/optional/peer #1329.Resolves or fixes issue: #1325
AI Tool Disclosure
Google AntigravityGemini 4 CarbonAnalyze root cause of #1325 across npm-ls and BomBuilder.gatherPackages, implement edge/reachability filtering for omitted dev/optional/peer/devOptional dependencies, add unit tests, and verify snapshots in isolated container.Affirmation