Skip to content

feat(sbom): add issue-tracker external reference from package bugs - #12445

Merged
zkochan merged 3 commits into
pnpm:mainfrom
Saturate:feat/sbom-issue-tracker-ref
Jun 19, 2026
Merged

zkochan merged 3 commits into
pnpm:mainfrom
Saturate:feat/sbom-issue-tracker-ref

Conversation

@Saturate

@Saturate Saturate commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

pnpm sbom's CycloneDX output already emits website (homepage) and vcs
(repository) external references, but not the issue tracker, even though
package.json commonly declares one via bugs. This adds a CycloneDX
issue-tracker external reference for each component (and the root) that has a
bugs URL.

bugs can 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 package
metadata, so it appears only when the store is read (not under
--lockfile-only).

Tests

Serializer unit tests assert the issue-tracker ref is emitted for a component
and the root when bugsUrl is set, and omitted otherwise.


Written by an agent (Claude Code, claude-fable-5).

Summary by CodeRabbit

  • New Features
    • pnpm sbom now includes CycloneDX issue-tracker external references for both the root and dependency components when their manifests define a valid HTTP(S) bugs URL.
  • Bug Fixes
    • bugs entries that can’t be converted into a valid URL (including email-only or non-HTTP(S) values) are skipped to avoid invalid references.
  • Tests
    • Added Jest coverage to verify issue-tracker emission when bugsUrl is present and omission when it’s not.

@Saturate
Saturate requested a review from zkochan as a code owner June 16, 2026 09:04
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Bugs URL creds leaked 🐞 Bug ⛨ Security
Description
bugsUrlFromField() returns new URL(...).href without stripping username/password, so a
bugs value like https://user:[email protected]/... will be serialized into CycloneDX
externalReferences[].url and can leak credentials via generated SBOM artifacts.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R115-127]

+  let parsed: URL
+  try {
+    parsed = new URL(candidate)
+  } catch {
+    return undefined
+  }
+  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return undefined
+  // Emit the normalized URL, not the raw input: `new URL` strips CR/LF/tab and
+  // percent-encodes spaces and control characters, so a crafted `bugs` value
+  // can't push raw whitespace or control chars into the CycloneDX
+  // `externalReferences[].url` (whose format is an `iri-reference`).
+  return parsed.href
+}
Evidence
The helper returns a normalized URL via parsed.href (which retains any URL credentials) and the
CycloneDX serializer directly emits bugsUrl into externalReferences[].url, creating a concrete
secret-leak path when bugs contains credentials.

deps/compliance/sbom/src/getPkgMetadata.ts[101-127]
deps/compliance/sbom/src/serializeCycloneDx.ts[79-91]
deps/compliance/sbom/src/serializeCycloneDx.ts[135-144]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrlFromField()` normalizes and returns `parsed.href`, which preserves embedded URL credentials (`username:password@`). Because `serializeCycloneDx()` writes `comp.bugsUrl` / `rootComponent.bugsUrl` into CycloneDX `externalReferences[].url`, credentials in `package.json#bugs` will be emitted into the SBOM output.
### Issue Context
SBOMs are frequently published/shared; emitting embedded credentials can cause secret disclosure.
### Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[106-127]
- deps/compliance/sbom/src/serializeCycloneDx.ts[82-87]
- deps/compliance/sbom/src/serializeCycloneDx.ts[135-144]
### Suggested fix
In `bugsUrlFromField`, after parsing and verifying protocol, either:
1) **Redact credentials**:
- `parsed.username = ''`
- `parsed.password = ''`
- return `parsed.href`
or
2) **Reject credentialed URLs**:
- if `parsed.username || parsed.password` return `undefined`
Add/adjust unit tests in `deps/compliance/sbom/test/getPkgMetadata.test.ts` to assert credential handling (redaction or rejection) and ensure serialization tests still pass.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Weak bugs URL parsing 🐞 Bug ≡ Correctness
Description
parseBugsField() (and the root rootBugsUrl logic) treats any string starting with http:// or
https:// as valid without URL parsing and is case-sensitive, so malformed values like https://
can be serialized into CycloneDX externalReferences and uppercase schemes like HTTPS://... will
be omitted. This can regress SBOM consumers/validators for packages with non-canonical bugs
metadata.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R101-113]

+// `bugs` may be a URL string, a bare email, or `{ url, email }`. The CycloneDX
+// issue-tracker reference expects a URL, so only accept http(s) values and drop
+// email-only bug contacts.
+function parseBugsField (field: unknown): string | undefined {
+  let url: string | undefined
+  if (typeof field === 'string') {
+    url = field
+  } else if (field && typeof field === 'object' && 'url' in field) {
+    const value = (field as { url?: unknown }).url
+    if (typeof value === 'string') url = value
+  }
+  return url && /^https?:\/\//.test(url) ? url : undefined
+}
Evidence
The new code accepts bugs values by matching a simple, case-sensitive http(s) prefix regex,
which is weaker than the URL parsing approach used elsewhere in the repo and can pass malformed URLs
into serialized SBOM output. Other pnpm code validates http(s) URLs via new URL() and/or uses a
case-insensitive scheme check, indicating the regex approach is inconsistent and error-prone.

deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
deps/compliance/commands/src/sbom/sbom.ts[188-191]
deps/inspection/commands/src/bugs/index.ts[109-116]
installing/deps-installer/src/install/verifyLockfileResolutions.ts[338-341]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrl` is derived using a case-sensitive prefix regex (`/^https?:\/\//`) rather than actual URL parsing. This can (a) allow malformed URLs like `https://` through, and (b) drop URLs with uppercase schemes (e.g. `HTTPS://...`).
## Issue Context
This affects dependency metadata extraction in `getPkgMetadata.ts` and the root component logic in `sbom.ts`. The repo already uses `new URL()` + `protocol` checks for HTTP(S) validation in other commands.
## Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
- deps/compliance/commands/src/sbom/sbom.ts[188-191]
## Suggested fix
- Replace the regex check with a small helper that:
- extracts the candidate string,
- attempts `new URL(candidate)` (or `new URL(candidate.trim())` if you want to be permissive),
- returns the original/normalized string only when `protocol` is `http:` or `https:`.
- Reuse the same helper for both root and dependency parsing to avoid drift.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit ae77d4e

Results up to commit bd1fe99


🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Bugs URL creds leaked 🐞 Bug ⛨ Security
Description
bugsUrlFromField() returns new URL(...).href without stripping username/password, so a
bugs value like https://user:[email protected]/... will be serialized into CycloneDX
externalReferences[].url and can leak credentials via generated SBOM artifacts.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R115-127]

+  let parsed: URL
+  try {
+    parsed = new URL(candidate)
+  } catch {
+    return undefined
+  }
+  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return undefined
+  // Emit the normalized URL, not the raw input: `new URL` strips CR/LF/tab and
+  // percent-encodes spaces and control characters, so a crafted `bugs` value
+  // can't push raw whitespace or control chars into the CycloneDX
+  // `externalReferences[].url` (whose format is an `iri-reference`).
+  return parsed.href
+}
Evidence
The helper returns a normalized URL via parsed.href (which retains any URL credentials) and the
CycloneDX serializer directly emits bugsUrl into externalReferences[].url, creating a concrete
secret-leak path when bugs contains credentials.

deps/compliance/sbom/src/getPkgMetadata.ts[101-127]
deps/compliance/sbom/src/serializeCycloneDx.ts[79-91]
deps/compliance/sbom/src/serializeCycloneDx.ts[135-144]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrlFromField()` normalizes and returns `parsed.href`, which preserves embedded URL credentials (`username:password@`). Because `serializeCycloneDx()` writes `comp.bugsUrl` / `rootComponent.bugsUrl` into CycloneDX `externalReferences[].url`, credentials in `package.json#bugs` will be emitted into the SBOM output.
### Issue Context
SBOMs are frequently published/shared; emitting embedded credentials can cause secret disclosure.
### Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[106-127]
- deps/compliance/sbom/src/serializeCycloneDx.ts[82-87]
- deps/compliance/sbom/src/serializeCycloneDx.ts[135-144]
### Suggested fix
In `bugsUrlFromField`, after parsing and verifying protocol, either:
1) **Redact credentials**:
 - `parsed.username = ''`
 - `parsed.password = ''`
 - return `parsed.href`
 or
2) **Reject credentialed URLs**:
 - if `parsed.username || parsed.password` return `undefined`
Add/adjust unit tests in `deps/compliance/sbom/test/getPkgMetadata.test.ts` to assert credential handling (redaction or rejection) and ensure serialization tests still pass.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
2. Weak bugs URL parsing 🐞 Bug ≡ Correctness
Description
parseBugsField() (and the root rootBugsUrl logic) treats any string starting with http:// or
https:// as valid without URL parsing and is case-sensitive, so malformed values like https://
can be serialized into CycloneDX externalReferences and uppercase schemes like HTTPS://... will
be omitted. This can regress SBOM consumers/validators for packages with non-canonical bugs
metadata.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R101-113]

+// `bugs` may be a URL string, a bare email, or `{ url, email }`. The CycloneDX
+// issue-tracker reference expects a URL, so only accept http(s) values and drop
+// email-only bug contacts.
+function parseBugsField (field: unknown): string | undefined {
+  let url: string | undefined
+  if (typeof field === 'string') {
+    url = field
+  } else if (field && typeof field === 'object' && 'url' in field) {
+    const value = (field as { url?: unknown }).url
+    if (typeof value === 'string') url = value
+  }
+  return url && /^https?:\/\//.test(url) ? url : undefined
+}
Evidence
The new code accepts bugs values by matching a simple, case-sensitive http(s) prefix regex,
which is weaker than the URL parsing approach used elsewhere in the repo and can pass malformed URLs
into serialized SBOM output. Other pnpm code validates http(s) URLs via new URL() and/or uses a
case-insensitive scheme check, indicating the regex approach is inconsistent and error-prone.

deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
deps/compliance/commands/src/sbom/sbom.ts[188-191]
deps/inspection/commands/src/bugs/index.ts[109-116]
installing/deps-installer/src/install/verifyLockfileResolutions.ts[338-341]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrl` is derived using a case-sensitive prefix regex (`/^https?:\/\//`) rather than actual URL parsing. This can (a) allow malformed URLs like `https://` through, and (b) drop URLs with uppercase schemes (e.g. `HTTPS://...`).
## Issue Context
This affects dependency metadata extraction in `getPkgMetadata.ts` and the root component logic in `sbom.ts`. The repo already uses `new URL()` + `protocol` checks for HTTP(S) validation in other commands.
## Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
- deps/compliance/commands/src/sbom/sbom.ts[188-191]
## Suggested fix
- Replace the regex check with a small helper that:
- extracts the candidate string,
- attempts `new URL(candidate)` (or `new URL(candidate.trim())` if you want to be permissive),
- returns the original/normalized string only when `protocol` is `http:` or `https:`.
- Reuse the same helper for both root and dependency parsing to avoid drift.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit f8116e7


🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Bugs URL creds leaked 🐞 Bug ⛨ Security ⭐ New
Description
bugsUrlFromField() returns new URL(...).href without stripping username/password, so a
bugs value like https://user:[email protected]/... will be serialized into CycloneDX
externalReferences[].url and can leak credentials via generated SBOM artifacts.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R115-127]

+  let parsed: URL
+  try {
+    parsed = new URL(candidate)
+  } catch {
+    return undefined
+  }
+  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return undefined
+  // Emit the normalized URL, not the raw input: `new URL` strips CR/LF/tab and
+  // percent-encodes spaces and control characters, so a crafted `bugs` value
+  // can't push raw whitespace or control chars into the CycloneDX
+  // `externalReferences[].url` (whose format is an `iri-reference`).
+  return parsed.href
+}
Evidence
The helper returns a normalized URL via parsed.href (which retains any URL credentials) and the
CycloneDX serializer directly emits bugsUrl into externalReferences[].url, creating a concrete
secret-leak path when bugs contains credentials.

deps/compliance/sbom/src/getPkgMetadata.ts[101-127]
deps/compliance/sbom/src/serializeCycloneDx.ts[79-91]
deps/compliance/sbom/src/serializeCycloneDx.ts[135-144]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`bugsUrlFromField()` normalizes and returns `parsed.href`, which preserves embedded URL credentials (`username:password@`). Because `serializeCycloneDx()` writes `comp.bugsUrl` / `rootComponent.bugsUrl` into CycloneDX `externalReferences[].url`, credentials in `package.json#bugs` will be emitted into the SBOM output.

### Issue Context
SBOMs are frequently published/shared; emitting embedded credentials can cause secret disclosure.

### Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[106-127]
- deps/compliance/sbom/src/serializeCycloneDx.ts[82-87]
- deps/compliance/sbom/src/serializeCycloneDx.ts[135-144]

### Suggested fix
In `bugsUrlFromField`, after parsing and verifying protocol, either:
1) **Redact credentials**:
  - `parsed.username = ''`
  - `parsed.password = ''`
  - return `parsed.href`

  or

2) **Reject credentialed URLs**:
  - if `parsed.username || parsed.password` return `undefined`

Add/adjust unit tests in `deps/compliance/sbom/test/getPkgMetadata.test.ts` to assert credential handling (redaction or rejection) and ensure serialization tests still pass.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
2. Weak bugs URL parsing 🐞 Bug ≡ Correctness
Description
parseBugsField() (and the root rootBugsUrl logic) treats any string starting with http:// or
https:// as valid without URL parsing and is case-sensitive, so malformed values like https://
can be serialized into CycloneDX externalReferences and uppercase schemes like HTTPS://... will
be omitted. This can regress SBOM consumers/validators for packages with non-canonical bugs
metadata.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R101-113]

+// `bugs` may be a URL string, a bare email, or `{ url, email }`. The CycloneDX
+// issue-tracker reference expects a URL, so only accept http(s) values and drop
+// email-only bug contacts.
+function parseBugsField (field: unknown): string | undefined {
+  let url: string | undefined
+  if (typeof field === 'string') {
+    url = field
+  } else if (field && typeof field === 'object' && 'url' in field) {
+    const value = (field as { url?: unknown }).url
+    if (typeof value === 'string') url = value
+  }
+  return url && /^https?:\/\//.test(url) ? url : undefined
+}
Evidence
The new code accepts bugs values by matching a simple, case-sensitive http(s) prefix regex,
which is weaker than the URL parsing approach used elsewhere in the repo and can pass malformed URLs
into serialized SBOM output. Other pnpm code validates http(s) URLs via new URL() and/or uses a
case-insensitive scheme check, indicating the regex approach is inconsistent and error-prone.

deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
deps/compliance/commands/src/sbom/sbom.ts[188-191]
deps/inspection/commands/src/bugs/index.ts[109-116]
installing/deps-installer/src/install/verifyLockfileResolutions.ts[338-341]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrl` is derived using a case-sensitive prefix regex (`/^https?:\/\//`) rather than actual URL parsing. This can (a) allow malformed URLs like `https://` through, and (b) drop URLs with uppercase schemes (e.g. `HTTPS://...`).
## Issue Context
This affects dependency metadata extraction in `getPkgMetadata.ts` and the root component logic in `sbom.ts`. The repo already uses `new URL()` + `protocol` checks for HTTP(S) validation in other commands.
## Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
- deps/compliance/commands/src/sbom/sbom.ts[188-191]
## Suggested fix
- Replace the regex check with a small helper that:
- extracts the candidate string,
- attempts `new URL(candidate)` (or `new URL(candidate.trim())` if you want to be permissive),
- returns the original/normalized string only when `protocol` is `http:` or `https:`.
- Reuse the same helper for both root and dependency parsing to avoid drift.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit a33c51c


🐞 Bugs (1) 📘 Rule violations (0)


Remediation recommended
1. Weak bugs URL parsing 🐞 Bug ≡ Correctness
Description
parseBugsField() (and the root rootBugsUrl logic) treats any string starting with http:// or
https:// as valid without URL parsing and is case-sensitive, so malformed values like https://
can be serialized into CycloneDX externalReferences and uppercase schemes like HTTPS://... will
be omitted. This can regress SBOM consumers/validators for packages with non-canonical bugs
metadata.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R101-113]

+// `bugs` may be a URL string, a bare email, or `{ url, email }`. The CycloneDX
+// issue-tracker reference expects a URL, so only accept http(s) values and drop
+// email-only bug contacts.
+function parseBugsField (field: unknown): string | undefined {
+  let url: string | undefined
+  if (typeof field === 'string') {
+    url = field
+  } else if (field && typeof field === 'object' && 'url' in field) {
+    const value = (field as { url?: unknown }).url
+    if (typeof value === 'string') url = value
+  }
+  return url && /^https?:\/\//.test(url) ? url : undefined
+}
Evidence
The new code accepts bugs values by matching a simple, case-sensitive http(s) prefix regex,
which is weaker than the URL parsing approach used elsewhere in the repo and can pass malformed URLs
into serialized SBOM output. Other pnpm code validates http(s) URLs via new URL() and/or uses a
case-insensitive scheme check, indicating the regex approach is inconsistent and error-prone.

deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
deps/compliance/commands/src/sbom/sbom.ts[188-191]
deps/inspection/commands/src/bugs/index.ts[109-116]
installing/deps-installer/src/install/verifyLockfileResolutions.ts[338-341]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrl` is derived using a case-sensitive prefix regex (`/^https?:\/\//`) rather than actual URL parsing. This can (a) allow malformed URLs like `https://` through, and (b) drop URLs with uppercase schemes (e.g. `HTTPS://...`).
## Issue Context
This affects dependency metadata extraction in `getPkgMetadata.ts` and the root component logic in `sbom.ts`. The repo already uses `new URL()` + `protocol` checks for HTTP(S) validation in other commands.
## Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
- deps/compliance/commands/src/sbom/sbom.ts[188-191]
## Suggested fix
- Replace the regex check with a small helper that:
- extracts the candidate string,
- attempts `new URL(candidate)` (or `new URL(candidate.trim())` if you want to be permissive),
- returns the original/normalized string only when `protocol` is `http:` or `https:`.
- Reuse the same helper for both root and dependency parsing to avoid drift.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit ec4e5cb


🐞 Bugs (1) 📘 Rule violations (0)


Remediation recommended
1. Weak bugs URL parsing 🐞 Bug ≡ Correctness
Description
parseBugsField() (and the root rootBugsUrl logic) treats any string starting with http:// or
https:// as valid without URL parsing and is case-sensitive, so malformed values like https://
can be serialized into CycloneDX externalReferences and uppercase schemes like HTTPS://... will
be omitted. This can regress SBOM consumers/validators for packages with non-canonical bugs
metadata.
Code

deps/compliance/sbom/src/getPkgMetadata.ts[R101-113]

+// `bugs` may be a URL string, a bare email, or `{ url, email }`. The CycloneDX
+// issue-tracker reference expects a URL, so only accept http(s) values and drop
+// email-only bug contacts.
+function parseBugsField (field: unknown): string | undefined {
+  let url: string | undefined
+  if (typeof field === 'string') {
+    url = field
+  } else if (field && typeof field === 'object' && 'url' in field) {
+    const value = (field as { url?: unknown }).url
+    if (typeof value === 'string') url = value
+  }
+  return url && /^https?:\/\//.test(url) ? url : undefined
+}
Evidence
The new code accepts bugs values by matching a simple, case-sensitive http(s) prefix regex,
which is weaker than the URL parsing approach used elsewhere in the repo and can pass malformed URLs
into serialized SBOM output. Other pnpm code validates http(s) URLs via new URL() and/or uses a
case-insensitive scheme check, indicating the regex approach is inconsistent and error-prone.

deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
deps/compliance/commands/src/sbom/sbom.ts[188-191]
deps/inspection/commands/src/bugs/index.ts[109-116]
installing/deps-installer/src/install/verifyLockfileResolutions.ts[338-341]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`bugsUrl` is derived using a case-sensitive prefix regex (`/^https?:\/\//`) rather than actual URL parsing. This can (a) allow malformed URLs like `https://` through, and (b) drop URLs with uppercase schemes (e.g. `HTTPS://...`).

## Issue Context
This affects dependency metadata extraction in `getPkgMetadata.ts` and the root component logic in `sbom.ts`. The repo already uses `new URL()` + `protocol` checks for HTTP(S) validation in other commands.

## Fix Focus Areas
- deps/compliance/sbom/src/getPkgMetadata.ts[101-113]
- deps/compliance/commands/src/sbom/sbom.ts[188-191]

## Suggested fix
- Replace the regex check with a small helper that:
 - extracts the candidate string,
 - attempts `new URL(candidate)` (or `new URL(candidate.trim())` if you want to be permissive),
 - returns the original/normalized string only when `protocol` is `http:` or `https:`.
- Reuse the same helper for both root and dependency parsing to avoid drift.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d005bfa-df97-4a98-8450-82d0e3af8878

📥 Commits

Reviewing files that changed from the base of the PR and between bd1fe99 and ae77d4e.

📒 Files selected for processing (9)
  • .changeset/sbom-issue-tracker-ref.md
  • deps/compliance/commands/src/sbom/sbom.ts
  • deps/compliance/sbom/src/collectComponents.ts
  • deps/compliance/sbom/src/getPkgMetadata.ts
  • deps/compliance/sbom/src/index.ts
  • deps/compliance/sbom/src/serializeCycloneDx.ts
  • deps/compliance/sbom/src/types.ts
  • deps/compliance/sbom/test/getPkgMetadata.test.ts
  • deps/compliance/sbom/test/serializeCycloneDx.test.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/sbom-issue-tracker-ref.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • deps/compliance/sbom/src/index.ts
  • deps/compliance/sbom/test/serializeCycloneDx.test.ts
  • deps/compliance/sbom/test/getPkgMetadata.test.ts
  • deps/compliance/sbom/src/collectComponents.ts
  • deps/compliance/commands/src/sbom/sbom.ts
  • deps/compliance/sbom/src/getPkgMetadata.ts

📝 Walkthrough

Walkthrough

The PR extends pnpm sbom to emit CycloneDX issue-tracker external references when a package's package.json bugs field contains an HTTP(S) URL. A new bugsUrlFromField() helper normalizes and validates bugs entries, bugsUrl is added to SbomComponent, PkgMetadata, and CollectSbomComponentsOptions, the handler extracts root bugs URL, and the serializer conditionally appends issue-tracker external references to both regular and root components.

Changes

SBOM issue-tracker external reference from bugs field

Layer / File(s) Summary
Type contracts for bugsUrl
deps/compliance/sbom/src/types.ts, deps/compliance/sbom/src/getPkgMetadata.ts
SbomComponent, SbomResult.rootComponent, and PkgMetadata interfaces gain optional bugsUrl field to carry bugs URLs through the SBOM pipeline.
Bugs URL extraction and validation
deps/compliance/sbom/src/getPkgMetadata.ts, deps/compliance/sbom/src/index.ts, deps/compliance/sbom/test/getPkgMetadata.test.ts
bugsUrlFromField() helper normalizes string and object-form bugs entries, trims whitespace, parses as URL, and returns candidate only for http/https protocols; extractMetadata() uses it to populate PkgMetadata.bugsUrl; helper is re-exported and covered by dedicated test suite validating acceptance of valid HTTP(S) URLs and rejection of malformed/non-HTTP entries.
Component collection and root bugsUrl wiring
deps/compliance/commands/src/sbom/sbom.ts, deps/compliance/sbom/src/collectComponents.ts
Handler imports bugsUrlFromField, computes rootBugsUrl from manifest.bugs, and passes it into collectSbomComponents; CollectSbomComponentsOptions gains rootBugsUrl field; rootComponent is assigned bugsUrl from opts.rootBugsUrl; walkStep metadata type extended to carry bugsUrl through dependency traversal.
CycloneDX serialization with issue-tracker refs
deps/compliance/sbom/src/serializeCycloneDx.ts, deps/compliance/sbom/test/serializeCycloneDx.test.ts
serializeCycloneDx conditionally appends issue-tracker external reference to each component when bugsUrl is present; root component external references now assembled in rootExternalRefs array covering both repository (vcs) and bugsUrl (issue-tracker); test coverage validates presence and absence of issue-tracker entries.
Changeset and version bump
.changeset/sbom-issue-tracker-ref.md
Patch version bump changeset for @pnpm/deps.compliance.sbom, @pnpm/deps.compliance.commands, and pnpm recording the new issue-tracker external reference feature.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • zkochan
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title follows Conventional Commits specification with 'feat:' prefix and clearly describes the main change: adding issue-tracker external reference support from package bugs field to SBOM output.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

sbom: emit CycloneDX issue-tracker refs from package.json bugs
✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Walkthroughs

Description
• 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.
Diagram
graph 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"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Derive issue tracker from repository URL
  • ➕ Could emit an issue tracker even when bugs is missing.
  • ➖ Heuristic and often wrong (non-GitHub hosts, custom trackers, monorepos).
  • ➖ May produce misleading SBOM references.
2. Allow non-http(s) schemes (e.g. mailto:)
  • ➕ Would preserve email-only bugs contacts instead of dropping them.
  • ➖ CycloneDX issue-tracker externalReference is intended to be a URL to a tracker; mailto is not consistently accepted by consumers.
  • ➖ Could reduce interoperability if downstream tools expect http(s).

Recommendation: Current approach (emit only when bugs provides an http(s) URL) is best for correctness and CycloneDX consumer compatibility. Consider a follow-up to expose email bug contacts via a different CycloneDX field if needed, rather than overloading issue-tracker.

Grey Divider

File Changes

Enhancement (5)
sbom.ts Extract root 'bugs' URL and pass into SBOM collection +5/-0

Extract root 'bugs' URL and pass into SBOM collection

• Parses 'manifest.bugs' (string or '{ url }') and validates it as an http(s) URL. Passes 'rootBugsUrl' into 'collectSbomComponents' so the root component can emit an 'issue-tracker' reference.

deps/compliance/commands/src/sbom/sbom.ts


collectComponents.ts Thread 'rootBugsUrl' and component 'bugsUrl' through collection +3/-1

Thread 'rootBugsUrl' and component 'bugsUrl' through collection

• Extends collection options and root component construction to include 'bugsUrl'. Expands the local metadata shape so dependency metadata can carry 'bugsUrl' into each 'SbomComponent'.

deps/compliance/sbom/src/collectComponents.ts


getPkgMetadata.ts Parse 'bugs' from dependency manifests into 'bugsUrl' +16/-0

Parse 'bugs' from dependency manifests into 'bugsUrl'

• Adds 'bugsUrl' to 'PkgMetadata' and extracts it from dependency 'package.json' via 'parseBugsField'. Only http(s) URLs are accepted; email-only values are ignored.

deps/compliance/sbom/src/getPkgMetadata.ts


serializeCycloneDx.ts Emit CycloneDX 'issue-tracker' externalReferences for bugs URLs +15/-4

Emit CycloneDX 'issue-tracker' externalReferences for bugs URLs

• Adds 'issue-tracker' external references for components when 'bugsUrl' is present. Refactors root component external references to support multiple entries (vcs + issue-tracker).

deps/compliance/sbom/src/serializeCycloneDx.ts


types.ts Extend SBOM types with 'bugsUrl' +2/-0

Extend SBOM types with 'bugsUrl'

• Adds optional 'bugsUrl' to 'SbomComponent' and 'SbomResult.rootComponent' so the field is available to serializers.

deps/compliance/sbom/src/types.ts


Tests (1)
serializeCycloneDx.test.ts Add tests for 'issue-tracker' external references +27/-0

Add tests for 'issue-tracker' external references

• Verifies 'serializeCycloneDx' emits an 'issue-tracker' reference for both a dependency component and the root when 'bugsUrl' is set. Also asserts the reference is omitted when 'bugsUrl' is absent.

deps/compliance/sbom/test/serializeCycloneDx.test.ts


Documentation (1)
sbom-issue-tracker-ref.md Add changeset for SBOM issue-tracker references +7/-0

Add changeset for SBOM issue-tracker references

• Documents the new CycloneDX 'issue-tracker' external reference behavior for 'pnpm sbom'. Notes that email-only 'bugs' entries are skipped.

.changeset/sbom-issue-tracker-ref.md


Grey Divider

Qodo Logo

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 564619f and ec4e5cb.

📒 Files selected for processing (7)
  • .changeset/sbom-issue-tracker-ref.md
  • deps/compliance/commands/src/sbom/sbom.ts
  • deps/compliance/sbom/src/collectComponents.ts
  • deps/compliance/sbom/src/getPkgMetadata.ts
  • deps/compliance/sbom/src/serializeCycloneDx.ts
  • deps/compliance/sbom/src/types.ts
  • deps/compliance/sbom/test/serializeCycloneDx.test.ts

@Saturate
Saturate force-pushed the feat/sbom-issue-tracker-ref branch from ec4e5cb to a33c51c Compare June 16, 2026 09:18
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit a33c51c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f8116e7

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit bd1fe99

Saturate added 3 commits June 18, 2026 12:15
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.
@Saturate
Saturate force-pushed the feat/sbom-issue-tracker-ref branch from bd1fe99 to ae77d4e Compare June 18, 2026 10:32
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ae77d4e

@zkochan
zkochan merged commit 17e7f2c into pnpm:main Jun 19, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants