Skip to content

fix(resolving): reject malformed jsr: and named-registry package names (empty scope/name, path separators) - #12677

Merged
zkochan merged 7 commits into
pnpm:mainfrom
JSap0914:fix/jsr-specifier-empty-package-name
Jul 3, 2026
Merged

zkochan merged 7 commits into
pnpm:mainfrom
JSap0914:fix/jsr-specifier-empty-package-name

Conversation

@JSap0914

@JSap0914 JSap0914 commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

jsrToNpmPackageName checked for a missing / separator but not for other malformed shapes. Passing jsr:@foo/ (a scope with a trailing slash but no name) silently returned the malformed npm package name @jsr/foo__ instead of raising INVALID_JSR_PACKAGE_NAME. Review also surfaced that the name segment could carry extra path separators (e.g. jsr:@foo/../bar), which flowed into the generated @jsr/... npm name and from there into registry URLs and metadata cache file paths — a path-injection risk.

The named-registry specifier parser (e.g. gh:) had the same class of gap: its scoped branch only checked for a missing / and a trailing slash, and its unscoped branch checked nothing, so names like gh:@foo/../bar, gh:@/bar, gh:foo/../bar, dot segments (gh:..), and backslash variants parsed successfully. The downstream validatePackageName in pick-package only rejects a / in unscoped names, so scoped traversal reached getPkgMirrorPath, which joins the raw name into the metadata cache file path.

Fix

Both parsers now validate the package name with the validator the repo already ships — validate-npm-package-name (validForOldPackages) in TypeScript and its existing pacquet port is_valid_old_npm_package_name — instead of hand-rolled shape checks. That rejects every shape above (empty scope/name, extra /, \, ./..) plus everything else npm forbids (leading dots/underscores/hyphens, non-URL-safe characters, node_modules, whitespace).

  • jsrToNpmPackageName throws INVALID_JSR_PACKAGE_NAME for any invalid scoped name (missing-scope input still throws MISSING_JSR_PACKAGE_SCOPE).
  • parseNamedRegistrySpecifierToRegistryPackageSpec validates all branches (scoped, unscoped, and alias-derived names) and throws INVALID_NAMED_REGISTRY_PACKAGE_NAME — the error code its scoped branch already used.

Both fixes land in the TypeScript CLI and pacquet, keeping the two stacks behaviorally identical.

Testing

  • pnpm --filter @pnpm/resolving.jsr-specifier-parser test — 8/8 pass (new cases for the rejected shapes).
  • pnpm --filter @pnpm/resolving.npm-resolver test — 236/236 pass (new negative cases for named-registry names, incl. dot segments).
  • cargo nextest run -p pacquet-resolving-jsr-specifier-parser -p pacquet-resolving-npm-resolver — 283/283 pass.
  • cargo clippy --all-targets -- --deny warnings, cargo fmt --check, and typos pacquet pnpr clean.

Squash Commit Body

The jsr: specifier parser accepted scoped names with an empty scope or
name and with path separators inside the name; the malformed name was
folded into the @jsr/... npm name and flowed into registry URLs and
metadata cache file paths. It now throws INVALID_JSR_PACKAGE_NAME for
any name rejected by npm's package-name rules.

The named-registry specifier parser (e.g. gh:) had the same gap: the
scoped branch only rejected a missing '/' or trailing slash, and the
unscoped branch validated nothing, while the downstream pick-package
validator only rejects '/' in unscoped names. The parser now validates
the final package name in every branch (including alias-derived names)
and throws INVALID_NAMED_REGISTRY_PACKAGE_NAME for the same shapes.

Rather than hand-rolling the shape checks, both parsers delegate to the
validator the repo already ships: validate-npm-package-name
(validForOldPackages) in TypeScript and its existing pacquet port
is_valid_old_npm_package_name. Both fixes land in the TypeScript CLI
and pacquet, with matching tests.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

AI-assisted fix (Anthropic Claude). Review-hardening commit 2d368ac and the named-registry/validator commits written by an agent (Claude Code, claude-fable-5).

@JSap0914
JSap0914 requested a review from zkochan as a code owner June 26, 2026 06:04
Copilot AI review requested due to automatic review settings June 26, 2026 06:04

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 26, 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
📝 Walkthrough

Walkthrough

This PR tightens package-name validation in the JSR and named-registry specifier parsers, rejecting malformed scopes, empty names, and path-separator variants with invalid-package-name errors. It also expands test coverage and adds changeset entries.

Changes

Specifier package-name validation

Layer / File(s) Summary
JSR parser validation
pacquet/crates/resolving-jsr-specifier-parser/src/lib.rs, pacquet/crates/resolving-jsr-specifier-parser/src/tests.rs, pnpm11/resolving/jsr-specifier-parser/src/index.ts, pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts, .changeset/jsr-specifier-empty-name.md
jsr_to_npm_package_name and jsrToNpmPackageName now reject empty scope or name values, embedded path separators, and backslashes, and both test suites cover the new invalid inputs.
Named-registry parser validation
pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier.rs, pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier/tests.rs, pnpm11/resolving/npm-resolver/src/parseBareSpecifier.ts, pnpm11/resolving/npm-resolver/test/parseBareSpecifier.test.ts, .changeset/named-registry-invalid-name.md
parse_named_registry_specifier_to_registry_package_spec and parseNamedRegistrySpecifierToRegistryPackageSpec now use centralized package-name checks, and the Rust and pnpm tests cover empty-scope and path-separator cases.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • pnpm/pnpm#11772: Introduces the JSR specifier parsing code that this PR tightens with additional invalid-name validation.
  • pnpm/pnpm#11785: Touches the named-registry parsing path that this PR updates with broader invalid-package-name rejection.

Suggested labels: product: pnpm@11, product: pacquet

Suggested reviewers: zkochan

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

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.

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

Copy link
Copy Markdown

PR Summary by Qodo

Fix JSR specifier parsing: reject scoped specifiers with empty package name
🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 10-20 Minutes

Grey Divider

Description

• Throw INVALID_JSR_PACKAGE_NAME for jsr:@scope/ specifiers with missing name segment.
• Prevent generation of malformed npm names like @jsr/scope__ from invalid JSR inputs.
• Add regression test and changeset entry for the fix.
Diagram

graph TD
  A["parseJsrSpecifier()"] --> B["jsrToNpmPackageName()"] --> C{"Name segment empty?"}
  C -->|"Yes"| D["Throw PnpmError: INVALID_JSR_PACKAGE_NAME"]
  C -->|"No"| E["Return npm name: @jsr/<scope>__<name>"]
Loading
High-Level Assessment

The chosen approach (adding an explicit empty-name guard in jsrToNpmPackageName) is the most direct and consistent with the existing invalid-name handling, and it avoids duplicating validation logic elsewhere. Alternatives like pre-validating in parseJsrSpecifier or switching to a single regex-based parser would add complexity without improving correctness for this specific bug.

Files changed (3) +12 / -0

Bug fix (1) +3 / -0
index.tsReject scoped JSR names with empty package segment +3/-0

Reject scoped JSR names with empty package segment

• Adds an explicit guard after splitting the scope/name segments to detect an empty name (e.g., '@foo/'). Throws 'PnpmError('INVALID_JSR_PACKAGE_NAME', ...)' to match the existing invalid-name error behavior.

pnpm11/resolving/jsr-specifier-parser/src/index.ts

Tests (1) +4 / -0
parse.test.tsAdd regression test for 'jsr:@scope/' empty-name error +4/-0

Add regression test for 'jsr:@scope/' empty-name error

• Extends the existing invalid scoped-specifier test coverage to include 'jsr:@foo/'. Asserts that parsing throws an error with code 'ERR_PNPM_INVALID_JSR_PACKAGE_NAME'.

pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts

Documentation (1) +5 / -0
jsr-specifier-empty-name.mdAdd changeset for INVALID_JSR_PACKAGE_NAME fix +5/-0

Add changeset for INVALID_JSR_PACKAGE_NAME fix

• Introduces a patch-level changeset for '@pnpm/resolving.jsr-specifier-parser'. Documents that 'jsr:@scope/' now throws INVALID_JSR_PACKAGE_NAME instead of producing a malformed npm name.

.changeset/jsr-specifier-empty-name.md

@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

🧹 Nitpick comments (1)
pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts (1)

45-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Drop the redundant comment.

Line 45 just restates the assertion below, so it adds noise without clarifying intent. As per coding guidelines, "Do not write comments that restate what the code already says."

🤖 Prompt for 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.

In `@pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts` at line 45, Remove
the redundant inline comment in the jsr-specifier-parser test that simply
restates the empty scoped package case; update the `parse.test.ts` test near the
`jsr:`@scope/`` assertion to rely on the assertion name/value itself instead of
the extra comment.

Source: Coding guidelines

🤖 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 @.changeset/jsr-specifier-empty-name.md:
- Line 5: Update the changeset summary to mention pnpm explicitly and describe
the user-visible behavior change concisely: the release note should state that
pnpm rejects `jsr:`@scope/`` specifiers with an empty package name instead of
silently producing a malformed npm package name. Keep the wording accurate for
the parser change and ensure the `.changeset` entry reflects the correct bump
type.

---

Nitpick comments:
In `@pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts`:
- Line 45: Remove the redundant inline comment in the jsr-specifier-parser test
that simply restates the empty scoped package case; update the `parse.test.ts`
test near the `jsr:`@scope/`` assertion to rely on the assertion name/value itself
instead of the extra comment.
🪄 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: f006de3a-6975-4234-a5d0-1051537cb3de

📥 Commits

Reviewing files that changed from the base of the PR and between aea6ace and 5ae3b61.

📒 Files selected for processing (3)
  • .changeset/jsr-specifier-empty-name.md
  • pnpm11/resolving/jsr-specifier-parser/src/index.ts
  • pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts

Comment thread .changeset/jsr-specifier-empty-name.md Resolved
@qodo-free-for-open-source-projects

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. JSR name path injection 🐞 Bug ⛨ Security
Description
jsrToNpmPackageName() still allows the JSR name segment to contain additional / (e.g.
jsr:@foo/../../x), and it embeds that substring into the generated npm package name unchanged.
That npm package name is later used to construct metadata cache file paths via path.join(...),
enabling crafted names with .. segments to steer cache writes outside the intended metadata
directory.
Code

pnpm11/resolving/jsr-specifier-parser/src/index.ts[R61-66]

const scope = jsrPkgName.substring(0, sepIndex)
const name = jsrPkgName.substring(sepIndex + '/'.length)
+  if (!name) {
+    throw new PnpmError('INVALID_JSR_PACKAGE_NAME', `The package name '${jsrPkgName}' is invalid`)
+  }
return `@jsr/${scope.substring(1)}__${name}`
Evidence
The JSR parser constructs npmPkgName by concatenating an unvalidated name substring; the npm
resolver then uses the package name directly in a path.join(...)-built cache filename, and
encodePkgName() preserves the raw string when already lowercase. Finally, saveMeta() creates
directories and writes to that computed path, so a crafted name with extra /.. segments can
influence the write target.

pnpm11/resolving/jsr-specifier-parser/src/index.ts[53-67]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[592-597]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[640-642]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[741-749]
pnpm11/resolving/npm-resolver/src/fetchFullMetadataCached.ts[55-97]

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

## Issue description
`jsrToNpmPackageName()` only checks that a `/` exists and that `name` is non-empty, but it does not ensure `name` contains no additional path separators. Because the generated `npmPkgName` is later used in metadata cache file paths, allowing extra `/` (and especially `..` segments) creates a path-injection risk.
### Issue Context
- `jsrToNpmPackageName()` currently embeds the raw `name` substring into `@jsr/<scope>__<name>`.
- The npm resolver builds on-disk metadata mirror paths using `path.join(cacheDir, ..., `${encodePkgName(pkgName)}.jsonl`)`, and `encodePkgName()` does not escape `/`.
### Fix Focus Areas
- pnpm11/resolving/jsr-specifier-parser/src/index.ts[53-67]
### What to change
- Add validation after extracting `name` (and optionally `scope`) to reject any additional path separators (both `/` and `\\`) in `name`.
- Consider validating the final generated npm name using `validate-npm-package-name` (as used elsewhere in the repo) and throwing `INVALID_JSR_PACKAGE_NAME` when invalid, ensuring the mapped name is safe for both registry requests and filesystem cache paths.

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



Remediation recommended

2. quick-xml ignore trust gap 🐞 Bug ⛨ Security ⭐ New
Description
deny.toml globally ignores quick-xml DoS advisories with the rationale that XML is only parsed
from an operator-configured S3 backend, but pnpr explicitly supports arbitrary S3 endpoints and even
plain HTTP via allow_http. In deployments where that endpoint (or network path) is not fully
trusted, a malicious/compromised S3-compatible service (or MITM when HTTP is enabled) can return
pathological XML that triggers the ignored DoS conditions on request paths that call object_store
listing.
Code

deny.toml[R55-63]

+  # quick-xml DoS advisories (quadratic duplicate-attribute check, unbounded
+  # namespace-declaration allocation). quick-xml is reached only through
+  # object_store's S3 XML response parsing in pnpr, so the XML comes from the
+  # operator-configured S3-compatible storage backend, not from untrusted
+  # clients. Both fixes ship only in quick-xml 0.41.0, which no object_store
+  # release can resolve yet: object_store 0.13 requires ^0.39 and 0.14
+  # requires ^0.40.1. Revisit when object_store consumes quick-xml 0.41+.
+  { id = "RUSTSEC-2026-0194", reason = "Temporary risk acceptance: XML parsed by quick-xml comes only from the operator-configured S3 backend via object_store; no object_store release consumes the patched quick-xml 0.41 yet." },
+  { id = "RUSTSEC-2026-0195", reason = "Temporary risk acceptance: XML parsed by quick-xml comes only from the operator-configured S3 backend via object_store; no object_store release consumes the patched quick-xml 0.41 yet." },
Evidence
The ignore reasons claim quick-xml is only reached through operator-configured S3 XML parsing, while
pnpr’s S3 backend allows a custom endpoint and enables plain HTTP when allow_http is set. pnpr
also uses object_store.list(...) for S3-backed package listing, which is one of the paths that
will parse S3 XML responses.

deny.toml[55-63]
pnpr/crates/pnpr/src/s3.rs[40-111]
pnpr/crates/pnpr/src/s3.rs[242-261]
pnpr/crates/pnpr/Cargo.toml[27-60]

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

## Issue description
`deny.toml` ignores `RUSTSEC-2026-0194` and `RUSTSEC-2026-0195` with a rationale that assumes S3 XML inputs are effectively trusted. However, pnpr supports configuring arbitrary S3 endpoints and optionally allowing plain HTTP, which broadens the threat model beyond what the ignore text states.

## Issue Context
Even if end users can’t directly craft the XML attributes involved in these advisories, pnpr can be pointed at a non-AWS S3-compatible endpoint (or HTTP endpoint) where a compromised backend or network attacker could return pathological XML, leading to CPU/memory DoS in pnpr paths that list objects.

## Fix Focus Areas
- deny.toml[52-64]
- pnpr/crates/pnpr/src/s3.rs[40-110]
- pnpr/crates/pnpr/src/s3.rs[227-261]

## Suggested fix
- Update the ignore `reason` to explicitly state the security assumption (endpoint must be trusted; `allow_http` increases exposure to on-path attackers).
- Optionally harden pnpr by restricting `allow_http` to explicitly-local endpoints (e.g., localhost) or by adding a prominent warning/log when enabled, so the operational risk matches the accepted advisory risk.

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


3. Missing name length cap 🐞 Bug ⛨ Security
Description
Pacquet’s is_valid_old_npm_package_name() does not enforce a maximum name length, so the new
JSR/named-registry validation can still accept extremely long attacker-controlled names and
propagate them into URL/path construction, risking path-length filesystem errors and large
allocations. This is inconsistent with other repo validation (pnpr rejects raw.len() > 214), so
pacquet behavior can diverge across stacks.
Code

pacquet/crates/resolving-jsr-specifier-parser/src/lib.rs[R136-143]

+    let invalid =
+        || ParseJsrSpecifierError::InvalidPackageName { pkg_name: jsr_pkg_name.to_string() };
+    // The returned name is used in registry URLs and metadata cache file
+    // paths, so anything that is not a valid npm package name must never
+    // make it through.
+    if !is_valid_old_npm_package_name(jsr_pkg_name) {
+        return Err(invalid());
+    }
Evidence
The new JSR parser relies on is_valid_old_npm_package_name to prevent unsafe names from reaching
“registry URLs and metadata cache file paths,” but the validator implementation does not check
length at all. Elsewhere in this repo, pnpr’s package-name parsing explicitly rejects names longer
than 214 characters, indicating a repository expectation that should be enforced here too.

pacquet/crates/resolving-jsr-specifier-parser/src/lib.rs[130-147]
pacquet/crates/resolving-parse-wanted-dependency/src/validate_npm_package_name.rs[32-59]
pnpr/crates/pnpr/src/package_name.rs[15-25]

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

## Issue description
`is_valid_old_npm_package_name` is now used as a security boundary for JSR and named-registry specifiers (“must never make it through” to URL/file-path construction), but it currently has no maximum-length check. This allows extremely long names comprised of URL-friendly characters to pass validation and then be embedded into cache paths / URL paths, causing path-length failures and avoidable large allocations.
### Issue Context
The repo already treats >214-byte package names as invalid in pnpr.
### Fix Focus Areas
- pacquet/crates/resolving-parse-wanted-dependency/src/validate_npm_package_name.rs[32-59]
- pacquet/crates/resolving-parse-wanted-dependency/src/tests.rs[107-140]
- pnpr/crates/pnpr/src/package_name.rs[15-24]
### What to change
1. In `is_valid_old_npm_package_name(name: &str)`, add an early guard:
 - `if name.len() > 214 { return false; }`
 (ideally right after the empty-string check).
2. Add a regression test that constructs a URL-friendly string longer than 214 (both unscoped and scoped variants) and asserts it is rejected.
3. (Optional but helpful) Update the Rust docstring’s rule list to include the max-length rule so it matches actual behavior and the repo’s other validators.

ⓘ 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 64a550a

Results up to commit 64a550a


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


Action required
1. JSR name path injection 🐞 Bug ⛨ Security
Description
jsrToNpmPackageName() still allows the JSR name segment to contain additional / (e.g.
jsr:@foo/../../x), and it embeds that substring into the generated npm package name unchanged.
That npm package name is later used to construct metadata cache file paths via path.join(...),
enabling crafted names with .. segments to steer cache writes outside the intended metadata
directory.
Code

pnpm11/resolving/jsr-specifier-parser/src/index.ts[R61-66]

const scope = jsrPkgName.substring(0, sepIndex)
const name = jsrPkgName.substring(sepIndex + '/'.length)
+  if (!name) {
+    throw new PnpmError('INVALID_JSR_PACKAGE_NAME', `The package name '${jsrPkgName}' is invalid`)
+  }
return `@jsr/${scope.substring(1)}__${name}`
Evidence
The JSR parser constructs npmPkgName by concatenating an unvalidated name substring; the npm
resolver then uses the package name directly in a path.join(...)-built cache filename, and
encodePkgName() preserves the raw string when already lowercase. Finally, saveMeta() creates
directories and writes to that computed path, so a crafted name with extra /.. segments can
influence the write target.

pnpm11/resolving/jsr-specifier-parser/src/index.ts[53-67]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[592-597]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[640-642]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[741-749]
pnpm11/resolving/npm-resolver/src/fetchFullMetadataCached.ts[55-97]

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

## Issue description
`jsrToNpmPackageName()` only checks that a `/` exists and that `name` is non-empty, but it does not ensure `name` contains no additional path separators. Because the generated `npmPkgName` is later used in metadata cache file paths, allowing extra `/` (and especially `..` segments) creates a path-injection risk.
### Issue Context
- `jsrToNpmPackageName()` currently embeds the raw `name` substring into `@jsr/<scope>__<name>`.
- The npm resolver builds on-disk metadata mirror paths using `path.join(cacheDir, ..., `${encodePkgName(pkgName)}.jsonl`)`, and `encodePkgName()` does not escape `/`.
### Fix Focus Areas
- pnpm11/resolving/jsr-specifier-parser/src/index.ts[53-67]
### What to change
- Add validation after extracting `name` (and optionally `scope`) to reject any additional path separators (both `/` and `\\`) in `name`.
- Consider validating the final generated npm name using `validate-npm-package-name` (as used elsewhere in the repo) and throwing `INVALID_JSR_PACKAGE_NAME` when invalid, ensuring the mapped name is safe for both registry requests and filesystem cache paths.

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



Remediation recommended
2. Missing name length cap 🐞 Bug ⛨ Security ⭐ New
Description
Pacquet’s is_valid_old_npm_package_name() does not enforce a maximum name length, so the new
JSR/named-registry validation can still accept extremely long attacker-controlled names and
propagate them into URL/path construction, risking path-length filesystem errors and large
allocations. This is inconsistent with other repo validation (pnpr rejects raw.len() > 214), so
pacquet behavior can diverge across stacks.
Code

pacquet/crates/resolving-jsr-specifier-parser/src/lib.rs[R136-143]

+    let invalid =
+        || ParseJsrSpecifierError::InvalidPackageName { pkg_name: jsr_pkg_name.to_string() };
+    // The returned name is used in registry URLs and metadata cache file
+    // paths, so anything that is not a valid npm package name must never
+    // make it through.
+    if !is_valid_old_npm_package_name(jsr_pkg_name) {
+        return Err(invalid());
+    }
Evidence
The new JSR parser relies on is_valid_old_npm_package_name to prevent unsafe names from reaching
“registry URLs and metadata cache file paths,” but the validator implementation does not check
length at all. Elsewhere in this repo, pnpr’s package-name parsing explicitly rejects names longer
than 214 characters, indicating a repository expectation that should be enforced here too.

pacquet/crates/resolving-jsr-specifier-parser/src/lib.rs[130-147]
pacquet/crates/resolving-parse-wanted-dependency/src/validate_npm_package_name.rs[32-59]
pnpr/crates/pnpr/src/package_name.rs[15-25]

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

### Issue description
`is_valid_old_npm_package_name` is now used as a security boundary for JSR and named-registry specifiers (“must never make it through” to URL/file-path construction), but it currently has no maximum-length check. This allows extremely long names comprised of URL-friendly characters to pass validation and then be embedded into cache paths / URL paths, causing path-length failures and avoidable large allocations.

### Issue Context
The repo already treats >214-byte package names as invalid in pnpr.

### Fix Focus Areas
- pacquet/crates/resolving-parse-wanted-dependency/src/validate_npm_package_name.rs[32-59]
- pacquet/crates/resolving-parse-wanted-dependency/src/tests.rs[107-140]
- pnpr/crates/pnpr/src/package_name.rs[15-24]

### What to change
1. In `is_valid_old_npm_package_name(name: &str)`, add an early guard:
  - `if name.len() > 214 { return false; }`
  (ideally right after the empty-string check).
2. Add a regression test that constructs a URL-friendly string longer than 214 (both unscoped and scoped variants) and asserts it is rejected.
3. (Optional but helpful) Update the Rust docstring’s rule list to include the max-length rule so it matches actual behavior and the repo’s other validators.

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


Results up to commit 9a14025


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


Action required
1. JSR name path injection 🐞 Bug ⛨ Security
Description
jsrToNpmPackageName() still allows the JSR name segment to contain additional / (e.g.
jsr:@foo/../../x), and it embeds that substring into the generated npm package name unchanged.
That npm package name is later used to construct metadata cache file paths via path.join(...),
enabling crafted names with .. segments to steer cache writes outside the intended metadata
directory.
Code

pnpm11/resolving/jsr-specifier-parser/src/index.ts[R61-66]

const scope = jsrPkgName.substring(0, sepIndex)
const name = jsrPkgName.substring(sepIndex + '/'.length)
+  if (!name) {
+    throw new PnpmError('INVALID_JSR_PACKAGE_NAME', `The package name '${jsrPkgName}' is invalid`)
+  }
return `@jsr/${scope.substring(1)}__${name}`
Evidence
The JSR parser constructs npmPkgName by concatenating an unvalidated name substring; the npm
resolver then uses the package name directly in a path.join(...)-built cache filename, and
encodePkgName() preserves the raw string when already lowercase. Finally, saveMeta() creates
directories and writes to that computed path, so a crafted name with extra /.. segments can
influence the write target.

pnpm11/resolving/jsr-specifier-parser/src/index.ts[53-67]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[592-597]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[640-642]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[741-749]
pnpm11/resolving/npm-resolver/src/fetchFullMetadataCached.ts[55-97]

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

## Issue description
`jsrToNpmPackageName()` only checks that a `/` exists and that `name` is non-empty, but it does not ensure `name` contains no additional path separators. Because the generated `npmPkgName` is later used in metadata cache file paths, allowing extra `/` (and especially `..` segments) creates a path-injection risk.
### Issue Context
- `jsrToNpmPackageName()` currently embeds the raw `name` substring into `@jsr/<scope>__<name>`.
- The npm resolver builds on-disk metadata mirror paths using `path.join(cacheDir, ..., `${encodePkgName(pkgName)}.jsonl`)`, and `encodePkgName()` does not escape `/`.
### Fix Focus Areas
- pnpm11/resolving/jsr-specifier-parser/src/index.ts[53-67]
### What to change
- Add validation after extracting `name` (and optionally `scope`) to reject any additional path separators (both `/` and `\\`) in `name`.
- Consider validating the final generated npm name using `validate-npm-package-name` (as used elsewhere in the repo) and throwing `INVALID_JSR_PACKAGE_NAME` when invalid, ensuring the mapped name is safe for both registry requests and filesystem cache paths.

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


Qodo Logo

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5ae3b61

…cope/` with empty package name

`jsr:@scope/` (scope with trailing slash, no package name) was parsed by
jsrToNpmPackageName as if it were a valid specifier, producing the
malformed npm package name `@jsr/scope__` (empty name after `__`) and
returning without error.

The fix adds a guard after the slash-split to throw INVALID_JSR_PACKAGE_NAME
when the name segment is empty, matching the existing error path for
`jsr:@scope` (no slash at all).
@zkochan
zkochan force-pushed the fix/jsr-specifier-empty-package-name branch from 5ae3b61 to aa1be79 Compare July 2, 2026 21:10
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

… stacks

Broaden the empty-name guard per review: also reject an empty scope
(`jsr:@/bar`) and path separators in the name segment
(`jsr:@foo/../bar`, backslashes). The generated `@jsr/...` npm
package name flows into registry URLs and metadata cache file paths,
so extra separators were a path-injection risk.

Mirror the same validation in pacquet's
resolving-jsr-specifier-parser crate, with matching tests, and note
the "pnpm" package in the changeset.
Copilot AI review requested due to automatic review settings July 2, 2026 21:35
@zkochan zkochan changed the title fix(jsr-specifier-parser): throw INVALID_JSR_PACKAGE_NAME for jsr:@scope/ with empty package name fix(jsr-specifier-parser): reject malformed jsr: package names (empty scope/name, path separators) Jul 2, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2d368ac

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 2, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2d368ac

@codecov-commenter

codecov-commenter commented Jul 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.62%. Comparing base (991405e) to head (64a550a).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...t/crates/resolving-jsr-specifier-parser/src/lib.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12677      +/-   ##
==========================================
+ Coverage   85.55%   85.62%   +0.06%     
==========================================
  Files         413      413              
  Lines       63908    64335     +427     
==========================================
+ Hits        54679    55088     +409     
- Misses       9229     9247      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 8dd1cfb1b6a8

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.006 ± 0.126 3.866 4.266 1.89 ± 0.13
pacquet@main 4.022 ± 0.161 3.843 4.299 1.90 ± 0.14
pnpr@HEAD 2.122 ± 0.125 1.963 2.271 1.00
pnpr@main 2.217 ± 0.103 2.045 2.351 1.04 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.0056362105,
      "stddev": 0.12616967496069192,
      "median": 3.9495244986,
      "user": 3.8248342200000005,
      "system": 3.45871364,
      "min": 3.8660412096,
      "max": 4.2656306216,
      "times": [
        4.0238537176,
        4.2656306216,
        3.9198250536000003,
        4.086659335599999,
        4.1508548056,
        3.9618704896000003,
        3.9348649116,
        3.9371785076,
        3.9095834526,
        3.8660412096
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.022186454200001,
      "stddev": 0.16129750737736406,
      "median": 3.9966046056,
      "user": 3.81939242,
      "system": 3.4360019399999997,
      "min": 3.8432087206000003,
      "max": 4.2987860026,
      "times": [
        4.2987860026,
        4.2456786825999995,
        4.0469596646,
        3.8896124696000003,
        3.9462495466000003,
        4.0546811736,
        3.8432087206000003,
        4.130906555599999,
        3.8863822526000003,
        3.8793994736000004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1219819351,
      "stddev": 0.12536657110902802,
      "median": 2.1059245256000003,
      "user": 2.6014214199999994,
      "system": 2.9905332400000004,
      "min": 1.9630437576,
      "max": 2.2712698746,
      "times": [
        2.0961164456000003,
        1.9630437576,
        2.2696241086,
        2.2236297466000003,
        2.0123659146,
        2.2712698746,
        2.0101002846,
        2.2639375626000002,
        2.1157326056000003,
        1.9939990506
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.2166520278000004,
      "stddev": 0.10348008640754719,
      "median": 2.1961377971000005,
      "user": 2.621982719999999,
      "system": 2.9471531399999997,
      "min": 2.0453367746,
      "max": 2.3513962996,
      "times": [
        2.3053407056000004,
        2.1592988756000002,
        2.0453367746,
        2.3513962996,
        2.1781893006,
        2.2140862936000003,
        2.3279423426,
        2.1587489146000003,
        2.1119382366000004,
        2.3142425346000004
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 636.4 ± 12.2 617.4 649.4 1.01 ± 0.03
pacquet@main 629.6 ± 14.4 607.9 648.1 1.00
pnpr@HEAD 687.0 ± 50.7 647.8 823.0 1.09 ± 0.08
pnpr@main 708.8 ± 21.7 678.8 741.7 1.13 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6364346540200001,
      "stddev": 0.012192720464231914,
      "median": 0.6409637825200001,
      "user": 0.36784668,
      "system": 1.3181179,
      "min": 0.61736196152,
      "max": 0.64938602652,
      "times": [
        0.61736196152,
        0.6439398955200001,
        0.64774873552,
        0.64938602652,
        0.62303320252,
        0.6212247725200001,
        0.64702044552,
        0.63162918052,
        0.6450146505200001,
        0.6379876695200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.62957485182,
      "stddev": 0.014385923383705843,
      "median": 0.62942718202,
      "user": 0.35852548,
      "system": 1.3172837999999998,
      "min": 0.60792741252,
      "max": 0.64810015352,
      "times": [
        0.62215303052,
        0.62755075752,
        0.6313036065200001,
        0.62114050052,
        0.6452513295200001,
        0.64065660552,
        0.64197134552,
        0.64810015352,
        0.60969377652,
        0.60792741252
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6869789344200001,
      "stddev": 0.05072568356888418,
      "median": 0.67336599852,
      "user": 0.37668818000000004,
      "system": 1.3396289999999997,
      "min": 0.6478100815200001,
      "max": 0.82298254352,
      "times": [
        0.71020773752,
        0.66369966352,
        0.6478100815200001,
        0.67560373052,
        0.67112826652,
        0.6808128155200001,
        0.6794248205200001,
        0.66135072752,
        0.6567689575200001,
        0.82298254352
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.70875078642,
      "stddev": 0.02170818446443872,
      "median": 0.71138790702,
      "user": 0.37924448,
      "system": 1.3705843999999998,
      "min": 0.67878378852,
      "max": 0.74165985152,
      "times": [
        0.74165985152,
        0.73175203952,
        0.67878378852,
        0.71335017152,
        0.68039783452,
        0.73034641252,
        0.71039142252,
        0.6951101995200001,
        0.71238439152,
        0.69333175252
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.155 ± 0.037 4.083 4.207 1.94 ± 0.11
pacquet@main 4.181 ± 0.055 4.110 4.277 1.96 ± 0.12
pnpr@HEAD 2.173 ± 0.136 2.019 2.410 1.02 ± 0.09
pnpr@main 2.139 ± 0.125 2.009 2.390 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.15546584738,
      "stddev": 0.0367228454747338,
      "median": 4.1642490294800005,
      "user": 3.7019722799999997,
      "system": 3.31943738,
      "min": 4.08316323748,
      "max": 4.20705918648,
      "times": [
        4.18336539448,
        4.1328178734800005,
        4.08316323748,
        4.165912505480001,
        4.117445876480001,
        4.1625855534800005,
        4.14524152548,
        4.18807633048,
        4.20705918648,
        4.16899099048
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.18143007688,
      "stddev": 0.05493465466077461,
      "median": 4.18207019098,
      "user": 3.7227821800000003,
      "system": 3.3248651799999998,
      "min": 4.11045335748,
      "max": 4.27733095548,
      "times": [
        4.27733095548,
        4.12618715648,
        4.23795786348,
        4.1415088974800005,
        4.131185110480001,
        4.11045335748,
        4.17419698848,
        4.18994339348,
        4.228118680480001,
        4.19741836548
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1725372868800004,
      "stddev": 0.13595484616342873,
      "median": 2.14488310798,
      "user": 2.4502945800000004,
      "system": 2.88412328,
      "min": 2.0188621504800004,
      "max": 2.41037242148,
      "times": [
        2.2976115054800004,
        2.14076282048,
        2.0488901894800002,
        2.1490033954800003,
        2.06296163948,
        2.41037242148,
        2.35630224248,
        2.0188621504800004,
        2.0853526644800002,
        2.1552538394800003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1387291081800006,
      "stddev": 0.12450720824432178,
      "median": 2.07984415798,
      "user": 2.4679212799999997,
      "system": 2.86958058,
      "min": 2.0087135334800004,
      "max": 2.3899014854800003,
      "times": [
        2.06266805148,
        2.1926449704800004,
        2.2459522734800004,
        2.03914546848,
        2.3899014854800003,
        2.0970202644800002,
        2.2493980284800004,
        2.05356851348,
        2.04827849248,
        2.0087135334800004
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.312 ± 0.014 1.295 1.341 2.04 ± 0.03
pacquet@main 1.349 ± 0.100 1.306 1.631 2.09 ± 0.16
pnpr@HEAD 0.663 ± 0.061 0.628 0.835 1.03 ± 0.09
pnpr@main 0.645 ± 0.006 0.636 0.653 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.3118978072999998,
      "stddev": 0.014454154306708497,
      "median": 1.3074907550000001,
      "user": 1.2823868000000003,
      "system": 1.6643307999999997,
      "min": 1.2949836435000002,
      "max": 1.3407934045,
      "times": [
        1.3038913285,
        1.2992780915000002,
        1.3124781635,
        1.3101388135,
        1.3018877295000002,
        1.3048426965000002,
        1.2949836435000002,
        1.3285819005000001,
        1.3221023015000002,
        1.3407934045
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3489121831000002,
      "stddev": 0.09968237585881036,
      "median": 1.315974765,
      "user": 1.2984743,
      "system": 1.6755729,
      "min": 1.3057929725000001,
      "max": 1.6309404255,
      "times": [
        1.3137717335,
        1.3164226025,
        1.6309404255,
        1.3057929725000001,
        1.3416736495000001,
        1.3155269275,
        1.3097776695,
        1.3197424815,
        1.3066374075,
        1.3288359615
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6633434572999999,
      "stddev": 0.06095452423281082,
      "median": 0.645141008,
      "user": 0.32123669999999993,
      "system": 1.2788513000000001,
      "min": 0.6276907765,
      "max": 0.8352247705,
      "times": [
        0.6416219055,
        0.6402606925,
        0.6511648595,
        0.6402671955,
        0.6395437915,
        0.6276907765,
        0.8352247705,
        0.6551654004999999,
        0.6486601104999999,
        0.6538350705
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6446307398,
      "stddev": 0.005643391748412421,
      "median": 0.6459352295,
      "user": 0.3244979,
      "system": 1.2686042000000002,
      "min": 0.6362327005,
      "max": 0.6529167835,
      "times": [
        0.6529167835,
        0.6364616095,
        0.6485022095,
        0.6412848185,
        0.6490882575,
        0.6362327005,
        0.6411415655,
        0.6488089945,
        0.6468358104999999,
        0.6450346485
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.005 ± 0.034 2.968 3.081 4.61 ± 0.07
pacquet@main 2.976 ± 0.055 2.928 3.126 4.57 ± 0.09
pnpr@HEAD 0.663 ± 0.011 0.650 0.686 1.02 ± 0.02
pnpr@main 0.651 ± 0.006 0.641 0.658 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.0045481645000005,
      "stddev": 0.03390807553862202,
      "median": 3.0036928432000005,
      "user": 1.7455229200000002,
      "system": 1.95695092,
      "min": 2.9679821252000003,
      "max": 3.0806193112,
      "times": [
        3.0342289782000003,
        3.0007758682000003,
        2.9855029632,
        3.0088485582,
        2.9679821252000003,
        3.0119366062,
        2.9808741752000003,
        3.0806193112,
        2.9681032412,
        3.0066098182000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9757771449000003,
      "stddev": 0.055302278785092314,
      "median": 2.9644057742000003,
      "user": 1.7459214199999997,
      "system": 1.95011872,
      "min": 2.9276162132000003,
      "max": 3.1259827912,
      "times": [
        2.9803401882,
        2.9795340702,
        2.9700004242,
        2.9515287002000004,
        2.9448034352000003,
        2.9588922052,
        2.9699193432000004,
        3.1259827912,
        2.9491540782000003,
        2.9276162132000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6633370109,
      "stddev": 0.011014542430201547,
      "median": 0.6626708547,
      "user": 0.32270941999999997,
      "system": 1.2974386199999999,
      "min": 0.6497596312,
      "max": 0.6858364912,
      "times": [
        0.6858364912,
        0.6587548412,
        0.6637002182,
        0.6572898302000001,
        0.6625240952,
        0.6766487672,
        0.6653991312,
        0.6506394892,
        0.6497596312,
        0.6628176142000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6511300593,
      "stddev": 0.006009927558261722,
      "median": 0.6540373302000001,
      "user": 0.33061942,
      "system": 1.2695903199999998,
      "min": 0.6412426052000001,
      "max": 0.6581678572,
      "times": [
        0.6445458982000001,
        0.6581678572,
        0.6482063582,
        0.6562506322,
        0.6556555442,
        0.6549366302,
        0.6541848212000001,
        0.6442204072000001,
        0.6412426052000001,
        0.6538898392000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.817 ± 0.153 6.612 7.166 1.38 ± 0.05
pacquet@main 6.818 ± 0.147 6.601 7.010 1.38 ± 0.05
pnpr@HEAD 4.951 ± 0.142 4.752 5.181 1.00
pnpr@main 4.954 ± 0.092 4.809 5.121 1.00 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.81654523842,
      "stddev": 0.1525172075511404,
      "median": 6.812667021219999,
      "user": 3.9761263,
      "system": 3.7369768599999986,
      "min": 6.61181375122,
      "max": 7.16563659722,
      "times": [
        6.7143106572199995,
        6.81940631222,
        6.61181375122,
        6.85167018922,
        6.86792255522,
        6.90855924622,
        6.70943414122,
        7.16563659722,
        6.80592773022,
        6.71077120422
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.817951988520001,
      "stddev": 0.14670840750385714,
      "median": 6.79155502022,
      "user": 3.9799764999999994,
      "system": 3.7264006599999995,
      "min": 6.60053783922,
      "max": 7.01010277122,
      "times": [
        7.01010277122,
        6.84106245522,
        6.70852796022,
        6.80797804622,
        6.75286247822,
        7.00025348522,
        6.67345975722,
        6.60053783922,
        6.77513199422,
        7.00960309822
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.951087080620001,
      "stddev": 0.14163680482267002,
      "median": 4.91614297022,
      "user": 2.7127733999999997,
      "system": 3.20011066,
      "min": 4.75192723422,
      "max": 5.18149578222,
      "times": [
        4.82656696122,
        5.05882948222,
        4.97920256922,
        4.75192723422,
        5.18149578222,
        5.15082426322,
        4.89917046422,
        4.8323761452200005,
        4.89736242822,
        4.93311547622
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.95407932732,
      "stddev": 0.09180907022379446,
      "median": 4.93573687922,
      "user": 2.7175761999999994,
      "system": 3.2030685599999997,
      "min": 4.80908792822,
      "max": 5.1212584442199995,
      "times": [
        4.96304502722,
        4.95933228722,
        4.94228185922,
        4.92919189922,
        5.1212584442199995,
        4.90880422222,
        4.80908792822,
        4.89910885622,
        5.09349884522,
        4.91518390422
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12677
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,155.47 ms
(-6.23%)Baseline: 4,431.59 ms
5,317.91 ms
(78.14%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,004.55 ms
(-1.61%)Baseline: 3,053.78 ms
3,664.54 ms
(81.99%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,311.90 ms
(-3.62%)Baseline: 1,361.13 ms
1,633.35 ms
(80.32%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,005.64 ms
(-7.28%)Baseline: 4,320.24 ms
5,184.28 ms
(77.27%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,816.55 ms
(-2.90%)Baseline: 7,019.92 ms
8,423.91 ms
(80.92%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
636.43 ms
(+1.35%)Baseline: 627.93 ms
753.51 ms
(84.46%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12677
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,172.54 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
663.34 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
663.34 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,121.98 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,951.09 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
686.98 ms
🐰 View full continuous benchmarking report in Bencher

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8dd1cfb

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan zkochan changed the title fix(jsr-specifier-parser): reject malformed jsr: package names (empty scope/name, path separators) fix(resolving): reject malformed jsr: and named-registry package names (empty scope/name, path separators) Jul 3, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 85f2074

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 85f2074

@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: 4

🤖 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 `@pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier.rs`:
- Around line 268-280: The package-name validation in
is_well_formed_package_name still allows dot-segment names, which then reach
to_registry_url and can be normalized incorrectly in request URLs. Update this
validator to reject "." and ".." for both unscoped and scoped names, and add
regression coverage for gh:.. and gh:`@acme/`..; also apply the same dot-segment
guard in the TypeScript parser to keep both parsers consistent.

In `@pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier/tests.rs`:
- Around line 381-413: The new regression tests in
named_registry_path_separators_in_name_error cover embedded traversal, but they
still miss bare "." and ".." package-name segments that should also be rejected.
Extend parse_bare_specifier tests by adding cases for inputs like gh:.., gh:.,
and gh:`@acme/`.. so parse_named_registry_specifier_to_registry_package_spec
returns InvalidPackageName for each. Keep the coverage alongside the existing
named_registry_empty_scope_errors and
named_registry_path_separators_in_name_error tests to ensure every rejected
shape is exercised.

In `@pnpm11/resolving/npm-resolver/src/parseBareSpecifier.ts`:
- Around line 172-182: Update the package-name validation so bare `.` and `..`
are rejected before they can flow into mirror path resolution. In
`isWellFormedPackageName` inside `parseBareSpecifier`, add explicit checks for
these dot-segment names and ensure scoped forms like `@scope/..` are also
rejected, then mirror the same guard in the pacquet resolver path that feeds
`getPkgMirrorPath`. Keep the fix localized to the package-name validation
helpers so all resolver entry points consistently block these names.

In `@pnpm11/resolving/npm-resolver/test/parseBareSpecifier.test.ts`:
- Around line 118-131: Add test coverage in parseBareSpecifier.test.ts for bare
"." and ".." segments such as gh:.. and gh:`@acme/`.., since
parseNamedRegistrySpecifierToRegistryPackageSpec currently has a validation gap
for these inputs. Extend the existing invalid-specifier tests alongside the
current path-separator cases so the same
ERR_PNPM_INVALID_NAMED_REGISTRY_PACKAGE_NAME expectation is asserted for these
new bare segment variants.
🪄 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: e7f6889f-b105-44bc-8ca0-958afd79328d

📥 Commits

Reviewing files that changed from the base of the PR and between 8dd1cfb and 85f2074.

📒 Files selected for processing (5)
  • .changeset/named-registry-invalid-name.md
  • pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier.rs
  • pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier/tests.rs
  • pnpm11/resolving/npm-resolver/src/parseBareSpecifier.ts
  • pnpm11/resolving/npm-resolver/test/parseBareSpecifier.test.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/named-registry-invalid-name.md

'.' and '..' passed the separator checks but are never valid npm names,
and as URL path segments they normalize away from the intended registry
path. Reject them in both stacks.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 0d12999

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 0d12999

…pm-package-name

Replace the hand-rolled shape checks in the jsr: and named-registry
specifier parsers with the validator both stacks already ship:
validate-npm-package-name (validForOldPackages) in TypeScript and its
existing port is_valid_old_npm_package_name in pacquet. It covers the
previously rejected shapes and everything else npm forbids (leading
dots, non-URL-safe characters, node_modules, whitespace).
Copilot AI review requested due to automatic review settings July 3, 2026 22:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9a14025

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9a14025

…tore upgrade

Both DoS advisories are fixed only in quick-xml 0.41.0, which no
object_store release can resolve yet (0.13 requires ^0.39, 0.14
requires ^0.40.1). The parsed XML comes only from the
operator-configured S3 backend in pnpr, not from untrusted clients.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 64a550a

@zkochan
zkochan merged commit 25c7388 into pnpm:main Jul 3, 2026
26 checks passed
@welcome

welcome Bot commented Jul 3, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 64a550a

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.

4 participants