You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(cyclonedx): emit component.scope for dev and prod dependencies - #1488
The lockfile parsers already identify whether a package is a development or production dependency (PackageRef.dev), but the CycloneDX generator was dropping this information entirely when emitting components. Downstream tools ingesting the SBOM (e.g., Dependency-Track, vulnerability scanners) had no way to filter or prioritize dev-only versus production vulnerabilities.
Component scope attribute: Added scope to CycloneDxComponent and updated buildCycloneDxBom to emit:
"optional" for development dependencies (pkg.dev === true), per CycloneDX spec guidance for dev/test dependencies.
"required" for runtime/production dependencies (pkg.dev === false).
Omitted when pkg.dev === undefined (undetermined / no assertion made).
Test validation: Added tests in tests/cyclonedx.test.ts covering scope mapping (optional, required, omitted), schema conformance against allowed 1.6 enum values, and end-to-end report serialization via writeCycloneDxReport
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
New Features
CycloneDX reports now show development packages with an excluded scope and production packages with a required scope when development status is known. Packages without that information continue to appear without a scope. Scope values are included in serialized reports.
Documentation
The CycloneDX documentation now describes the scope values for production and development packages, and notes that scope is omitted when development status is unknown.
CycloneDX SBOM components now include scope when package development status is known. Development packages receive "excluded" scope, production packages receive "required" scope, and packages with unknown status omit the field.
Changes: CycloneDX scope mapping
Layer / File(s)
Summary
Component scope mapping and validation src/output/cyclonedx.ts, tests/cyclonedx.test.ts, website/docs/cyclonedx.md
The BOM builder maps package development status to component scope. Tests cover defined and undefined status and serialized reports. The documentation describes the production and development scope values.
CycloneDX output correctly maps explicit development status, but production Yarn dependencies still omit scope. This bounded metadata gap warrants owner awareness or follow-up; it does not block report generation.
Pre-merge checks: 6 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Linked Issue
The pull request body references Part of #1486, but it does not contain Closes, Fixes, Resolves, or Refs followed by an issue number.
Update the pull request body to include an accepted reference, such as Refs #1486.
Passed checks: 6 passed
Check name
Status
Explanation
Title check
The title follows the required "type: short description" form with the feat prefix, lowercase after the colon, and no trailing period. It names the change accurately: CycloneDX components gain a scope…
Description check
The description covers the required section, "What changed and why", and explains the motivation, which is that dev and prod information was dropped from CycloneDX output. It lists the scope mapping (…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Closes Keyword Matches Scope
The pull request body says “Part of #1486” and does not use “Closes,” “Fixes,” or “Resolves.” The issue will not auto-close from this pull request. The reviewed diff also contains no closing keyword.
No New Runtime Dependency
The pull request changes only CycloneDX source, tests, and documentation. No package.json file changed, so it adds no entry under dependencies or optionalDependencies and moves no package from devDepe…
Full details: Title check
Explanation
The title follows the required "type: short description" form with the feat prefix, lowercase after the colon, and no trailing period. It names the change accurately: CycloneDX components gain a scope value for dev and prod dependencies. One mismatch remains. The title puts the scope name in the code path and omits the "optional" and "required" values, but this is a minor point and does not make the title misleading.
Full details: Description check
Explanation
The description covers the required section, "What changed and why", and explains the motivation, which is that dev and prod information was dropped from CycloneDX output. It lists the scope mapping (optional, required, omitted when undefined) and the tests added. It links the work to the issue with "Part of #1486". The template uses "Closes #", which the author did not fill in. The leftover HTML comment placeholder "Brief description of the change" also remains in the text. Neither gap blocks the check.
Full details: No New Runtime Dependency
Explanation
The pull request changes only CycloneDX source, tests, and documentation. No package.json file changed, so it adds no entry under dependencies or optionalDependencies and moves no package from devDependencies.
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 1780570 and 3af6400.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
src/output/cyclonedx.ts-98-98: 1
98-98: Major · Data Integrity & Integration · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Do not infer runtime scope from dev alone.
A package in devDependencies can still run in production, such as a CLI used to start the server. This emits optional for that package, but CycloneDX defines optional as unavailable to be called at runtime. Consumers may therefore deprioritize a runtime vulnerability. (raw.githubusercontent.com)
I recommend recording development status in a separate property and setting scope only when runtime availability is known.
Reviewing files that changed from the base of the PR and between 280f098 and 500a9fd.
Files selected for processing: 2
src/output/cyclonedx.ts
tests/cyclonedx.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Nachiket-Roy. The classification matches #1487 exactly, mixed dev-and-prod packages come out required, Yarn's unflagged packages are left without a scope rather than guessed, and every BOM I generated validates against the CycloneDX 1.6 schema.
The one thing I'd change is the value. 1.6 defines optional as not installed or not callable at runtime, and CycloneDX's own npm tool uses it for optionalDependencies. Dev-only packages match excluded, which the spec describes as usage for test and other non-runtime purposes, not reachable at runtime. Could we emit excluded for dev-only components instead?
Two smaller ones: could you add a scope row to the field table in website/docs/cyclonedx.md, and change Closes #1486 to Part of #1486? The issue covers both formats, so whichever of this and #1487 lands second can close it.
…output
- Emit 'excluded' instead of 'optional' for dev-only components per CycloneDX 1.6 spec
- Drop vacuous schema enum test in cyclonedx test suite
- Document components[].scope and omit behavior in website field table
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Nachiket-Roy, all three are in: dev-only components are excluded, the docs table has the scope row, and it's Part of #1486. Switching the value back to optional fails the new tests, and the full suite passes on the merge with current main. Approved.
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
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.
What changed and why
Part of #1486