Repository navigation
feat(sbom): add issue-tracker external reference from package bugs - #12445
Conversation
Code Review by Qodo
1. Bugs URL creds leaked
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe PR extends ChangesSBOM issue-tracker external reference from bugs field
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
PR Summary by Qodosbom: emit CycloneDX issue-tracker refs from package.json bugs WalkthroughsDescription• Emit CycloneDX issue-tracker external references from package bugs http(s) URLs. • Propagate bugsUrl through SBOM collection for root and dependency components. • Add serializer tests covering presence/absence of issue-tracker references. Diagramgraph TD
A["pnpm sbom"] --> B["Read root manifest"] --> C["collectSbomComponents"] --> D["getPkgMetadata"] --> E["serializeCycloneDx"] --> F["CycloneDX JSON"]
B --> G["bugs URL (http/s)"]
D --> H["dep package.json"]
High-Level AssessmentThe following are alternative approaches to this PR: 1. Derive issue tracker from repository URL
2. Allow non-http(s) schemes (e.g. mailto:)
Recommendation: Current approach (emit only when File ChangesEnhancement (5)
Tests (1)
Documentation (1)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deps/compliance/sbom/src/getPkgMetadata.ts`:
- Around line 104-113: The parseBugsField function validates URLs only by
checking for http(s):// prefix, which allows malformed values with trailing
whitespace or control characters to pass through into SBOM serialization,
potentially breaking strict consumers. Harden the validation by trimming the URL
string and enforcing that it contains no whitespace characters after validation.
Apply the same trimming and stricter no-whitespace validation rule to the URL
parsing logic in deps/compliance/commands/src/sbom/sbom.ts at lines 188-191 to
maintain consistent behavior across both locations for untrusted manifest input.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 78f66ad4-513f-4efa-8d5f-35d9e9393a7b
📒 Files selected for processing (7)
.changeset/sbom-issue-tracker-ref.mddeps/compliance/commands/src/sbom/sbom.tsdeps/compliance/sbom/src/collectComponents.tsdeps/compliance/sbom/src/getPkgMetadata.tsdeps/compliance/sbom/src/serializeCycloneDx.tsdeps/compliance/sbom/src/types.tsdeps/compliance/sbom/test/serializeCycloneDx.test.ts
ec4e5cb to
a33c51c
Compare
|
Code review by qodo was updated up to the latest commit a33c51c |
|
Code review by qodo was updated up to the latest commit f8116e7 |
|
Code review by qodo was updated up to the latest commit bd1fe99 |
Emits a CycloneDX `issue-tracker` external reference for components (and the root) whose package.json declares a `bugs` URL. The value is parsed with `new URL()` and kept only when the protocol is http(s), so malformed values and email-only bug contacts are dropped while uppercase schemes still pass. A single shared helper handles both transitive components and the root package. Like homepage and repository, this is populated from package metadata, so it appears only when the store is read (not in --lockfile-only mode).
bugsUrlFromField used new URL() only as a validity gate but returned the raw input string, so a crafted http(s) `bugs` value containing CR/LF or whitespace would pass verbatim into the CycloneDX externalReferences url (format iri-reference). Return parsed.href instead: new URL strips CR/LF/tab and percent-encodes spaces and control characters, so the emitted url is always a clean, single-line value.
bugsUrlFromField returned new URL().href, which preserves any embedded username:password. An SBOM is a shareable, often-published artifact, so a bugs value like https://user:token@tracker/... would leak the credentials into externalReferences[].url. Clear username and password before emitting; the tracker URL itself stays useful.
bd1fe99 to
ae77d4e
Compare
|
Code review by qodo was updated up to the latest commit ae77d4e |
pnpm sbom's CycloneDX output already emitswebsite(homepage) andvcs(repository) external references, but not the issue tracker, even though
package.jsoncommonly declares one viabugs. This adds a CycloneDXissue-trackerexternal reference for each component (and the root) that has abugsURL.bugscan be a URL string, a bare email, or{ url, email }. Only http(s)URLs are emitted; email-only bug contacts are skipped, since the reference
requires a URL. Like
homepage/repository, the value comes from packagemetadata, so it appears only when the store is read (not under
--lockfile-only).Tests
Serializer unit tests assert the
issue-trackerref is emitted for a componentand the root when
bugsUrlis set, and omitted otherwise.Written by an agent (Claude Code, claude-fable-5).
Summary by CodeRabbit
pnpm sbomnow includes CycloneDXissue-trackerexternal references for both the root and dependency components when their manifests define a valid HTTP(S)bugsURL.bugsentries that can’t be converted into a valid URL (including email-only or non-HTTP(S) values) are skipped to avoid invalid references.issue-trackeremission whenbugsUrlis present and omission when it’s not.