Skip to content

feat(pacquet): port the "ping" command - #12666

Merged
zkochan merged 5 commits into
pnpm:mainfrom
Safort:feat/pacquet-ping
Jun 26, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
Safort:feat/pacquet-ping

Conversation

@Safort

@Safort Safort commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ports pnpm's ping command to pacquet. pacquet ping tests connectivity
to the configured registry: it GETs <registry>-/ping?write=true and
prints

PING <registry>
PONG <elapsed>ms

plus a pretty-printed PONG <details> line when the registry returns a
non-empty JSON body. Faithful to ping.ts:
--registry override with fallback to the configured default, trailing-slash
normalization that preserves a registry path prefix, an optional (not
required) Authorization header, no retries (retry: { retries: 0 }), and
a single ERR_PNPM_PING_ERROR code for both transport failures and
non-success statuses.

Also dedups the registry-client builder: whoami and ping now share
cli_args::registry_client::build_registry_client instead of each keeping
its own copy.

Squash Commit Body

Add `pacquet ping`, ported from pnpm's ping command.

`ping` GETs `<registry>-/ping?write=true` and prints pnpm's PING/PONG
report, plus a pretty-printed `PONG <details>` line when the registry
returns a non-empty JSON body. It resolves the registry from `--registry`
or the configured default, adds a trailing slash before joining so a
registry path prefix is preserved (matching pnpm's
`new URL('./-/ping', ...)`), sends the optional `Authorization` header when
one is configured (unlike whoami it does not require auth), and issues a
single attempt with no retries (pnpm's `retry: { retries: 0 }`). Timing
wraps the request and body read, matching pnpm's `Date.now()` measurement.

Both a transport failure and a non-success status map to the single
`ERR_PNPM_PING_ERROR` code with pnpm's "Failed to reach registry" message;
the transport error message is credential-redacted before it reaches
stderr / CI logs, the same precaution as whoami. Unlike whoami's username
(printed raw, hence sanitized), ping's JSON details are re-serialized
through serde_json, which escapes control characters, so no raw registry
bytes reach the terminal.

Extract the registry-client builder duplicated from whoami into a shared
`cli_args::registry_client::build_registry_client` and switch whoami to it.

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.
  • Updated the documentation if needed.

Summary by CodeRabbit

  • New Features
    • Added a new pacquet ping command to verify registry connectivity and report PING/PONG latency.
    • Supports an optional --registry override with URL normalization and appends pretty-printed JSON details when the registry returns non-empty JSON.
  • Bug Fixes
    • Improved registry request consistency across commands, and enhanced error/reporting by redacting inline credentials while preserving the requested registry path.
  • Tests
    • Added end-to-end coverage for pacquet ping (success, JSON details, HTTP error handling, URL construction, transport failures, and credential redaction).

@Safort
Safort requested a review from zkochan as a code owner June 25, 2026 17:00
@coderabbitai

coderabbitai Bot commented Jun 25, 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

Adds a pacquet ping subcommand, introduces a shared registry client builder, routes whoami through that helper, adds ping integration tests, and disables credential persistence in the triage workflow checkout step.

Changes

Ping command and registry client

Layer / File(s) Summary
Shared registry client helper
pacquet/crates/cli/src/cli_args/registry_client.rs, pacquet/crates/cli/src/cli_args/whoami.rs
Creates build_registry_client from CLI config and updates whoami to use it.
Ping command wiring and execution
pacquet/crates/cli/src/cli_args.rs, pacquet/crates/cli/src/cli_args/ping.rs
Adds pacquet ping to the CLI, dispatches it from CliArgs::run, and implements registry lookup, request execution, and report formatting.
Ping CLI tests
pacquet/crates/cli/tests/ping.rs
Adds integration tests for ping success, JSON details, registry resolution, prefix handling, credentials redaction, and failure cases.

Workflow checkout credentials

Layer / File(s) Summary
Checkout step credential setting
.github/workflows/triage-issues.yml
Adds persist-credentials: false to the checkout step in the triage workflow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • pnpm/pnpm#12589: Also changes pacquet/crates/cli/src/cli_args.rs dispatch logic and install-family footer handling.
  • pnpm/pnpm#12649: Also touches pacquet/crates/cli/src/cli_args/whoami.rs and registry client construction in the CLI.

Suggested labels

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

feat(pacquet): add ping registry connectivity check
✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Description

• Add pacquet ping to verify registry connectivity via GET -/ping?write=true.
• Match pnpm behavior: registry resolution, auth header (optional), no retries, unified error code.
• Deduplicate registry HTTP client construction and add integration tests for ping scenarios.
Diagram

graph TD
  T[["ping tests"]] --> CLI["CLI dispatcher"] --> P["Ping command"] --> B["Registry client builder"] --> N["HTTP client"] --> R{{"Registry"}}
  CLI --> W["Whoami command"] --> B
  subgraph Legend
    direction LR
    _test[["Tests"]] ~~~ _mod["Module"] ~~~ _ext{{"External"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Route ping through existing install/state initialization
  • ➕ Reuses the exact same client lifecycle as installs (shared caches, consistent init paths)
  • ➕ Potentially fewer bespoke code paths to maintain
  • ➖ Adds unnecessary lockfile/workspace/state requirements for a read-only connectivity check
  • ➖ Increases runtime overhead and coupling for a simple one-off request
2. Generalize a reusable 'registry request' helper (endpoint + parsing + error mapping)
  • ➕ Further reduces duplication across whoami/ping and future registry commands
  • ➕ Standardizes error redaction and retry defaults in one place
  • ➖ Premature abstraction with only two call sites today
  • ➖ May obscure command-specific nuances (ping timing, optional auth, details formatting)

Recommendation: The current approach is a good fit: ping remains a lightweight read-only command that directly uses config-derived settings, while the shared build_registry_client eliminates the most obvious duplication without over-abstracting. Consider a broader registry-request helper only if more one-off registry commands are added.

Files changed (5) +375 / -20

Enhancement (2) +151 / -0
cli_args.rsRegister 'ping' subcommand and route it via config-only execution +18/-0

Register 'ping' subcommand and route it via config-only execution

• Adds the 'Ping(PingArgs)' variant to the CLI command enum and wires dispatch so 'ping' runs using 'config()' (no install/state pipeline). Imports and exposes the new 'ping' and 'registry_client' modules.

pacquet/crates/cli/src/cli_args.rs

ping.rsImplement 'pacquet ping' with pnpm-compatible output and error mapping +133/-0

Implement 'pacquet ping' with pnpm-compatible output and error mapping

• Introduces the 'ping' command that resolves the registry (flag override or configured default), normalizes trailing slashes to preserve path prefixes, and GETs '-/ping?write=true' with an optional Authorization header. Measures elapsed time around request+body read, prints pnpm-style PING/PONG output, pretty-prints non-empty JSON bodies, and maps both transport and non-2xx statuses to 'ERR_PNPM_PING_ERROR' with credential redaction.

pacquet/crates/cli/src/cli_args/ping.rs

Refactor (2) +25 / -20
registry_client.rsExtract shared registry HTTP client builder for one-off commands +22/-0

Extract shared registry HTTP client builder for one-off commands

• Adds 'build_registry_client(Config) -> ThrottledClient' to centralize proxy/TLS/timeout/user-agent configuration for registry queries. Aligns one-off commands with the install client's network configuration source of truth.

pacquet/crates/cli/src/cli_args/registry_client.rs

whoami.rsSwitch whoami to use the shared registry client builder +3/-20

Switch whoami to use the shared registry client builder

• Replaces the local HTTP client construction helper with 'cli_args::registry_client::build_registry_client'. Removes duplicated network settings wiring while keeping whoami’s auth-required behavior and retry configuration intact.

pacquet/crates/cli/src/cli_args/whoami.rs

Tests (1) +199 / -0
ping.rsAdd integration tests covering ping success, details, and failure cases +199/-0

Add integration tests covering ping success, details, and failure cases

• Adds end-to-end tests that spawn 'pacquet ping' against a mockito registry, isolating user auth config via an empty '--npmrc-auth-file'. Verifies PING/PONG output, pretty-printed JSON details, default registry resolution from '.npmrc', erroring on non-success HTTP statuses, preservation of registry path prefixes, and failure on network errors.

pacquet/crates/cli/tests/ping.rs

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Ping leaks registry URL 🐞 Bug ⛨ Security
Description
PingArgs::run formats the PING line using the raw registry_url, and the CLI prints it
verbatim, so a registry like https://user:pass@host/ will leak embedded credentials (and other
control characters) to stdout/CI logs. This bypasses the repo’s existing output-sanitization pattern
used by other read-only registry commands.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R39-66]

+        let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
+        // Add a trailing slash before joining so a registry with a path
+        // prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
+        let normalized_registry_url = if registry_url.ends_with('/') {
+            registry_url.to_owned()
+        } else {
+            format!("{registry_url}/")
+        };
+        let ping_url = format!("{normalized_registry_url}-/ping?write=true");
+        let auth_header = config.auth_headers.for_url(&normalized_registry_url);
+        let http_client = build_registry_client(config)?;
+
+        // `ping` issues a single attempt with no retries, matching pnpm's
+        // `retry: { retries: 0 }`.
+        let (time, body) = fetch_ping(
+            &ping_url,
+            &http_client,
+            auth_header.as_deref(),
+            RetryOpts { retries: 0, ..RetryOpts::default() },
+        )
+        .await?;
+
+        let mut report = format!("PING {registry_url}\nPONG {time}ms");
+        if let Some(details) = format_details(&body) {
+            report.push_str("\nPONG ");
+            report.push_str(&details);
+        }
+        Ok(report)
Evidence
The PING line is built from the raw registry URL and printed without sanitization; pacquet’s auth
system explicitly supports deriving Authorization: Basic ... from inline user:pass@ URLs, making
this a real secret-bearing input. The CLI already has a sanitize helper and uses it for whoami,
but ping does not.

pacquet/crates/cli/src/cli_args/ping.rs[38-66]
pacquet/crates/cli/src/cli_args.rs[519-545]
pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
pacquet/crates/network/src/auth.rs[180-218]

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

## Issue description
`pacquet ping` prints the registry URL directly in the `PING ...` line. Because pacquet supports inline basic-auth in registry URLs, this can leak secrets (e.g. `https://user:pass@host/`) to terminals and CI logs. Additionally, untrusted `.npmrc`/`--registry` can carry control characters that should not reach the terminal.
## Issue Context
- `ping` currently renders `PING {registry_url}` with `registry_url` taken directly from `--registry` or config.
- The repo already has output sanitization utilities (used by `whoami`) and credential redaction utilities (used for network errors) that should be applied to this success-path output too.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[38-67]
- pacquet/crates/cli/src/cli_args.rs[525-545]
- pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
- pacquet/crates/network/src/auth.rs[180-218]
## Suggested fix
- Before formatting the report, create a *display* registry string:
- apply `pacquet_network::redact_url_credentials(registry_url)` to remove any `user:pass@` userinfo
- strip terminal control characters from the display string (either reuse `cli_args::sanitize`, or introduce a variant suitable for single-line values; for a URL, also ensure `\r`/`\n` don’t allow output injection)
- Use the display string in `PING ...` (and anywhere else the registry is echoed).
- Optionally (belt-and-braces), sanitize the final printed report in `CliCommand::Ping` similarly to `CliCommand::Whoami`.

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



Remediation recommended

2. Bad ping URL join 🐞 Bug ≡ Correctness
Description
PingArgs::run builds the ping_url via string concatenation, so a registry URL containing ? or
# causes the appended -/ping?write=true to become part of the query/fragment instead of the path
and the request can target the wrong endpoint (or fail to parse). This is possible because config
normalization only appends a trailing slash and does not remove query/fragment components from
registry= values.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R39-47]

+        let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
+        // Add a trailing slash before joining so a registry with a path
+        // prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
+        let normalized_registry_url = if registry_url.ends_with('/') {
+            registry_url.to_owned()
+        } else {
+            format!("{registry_url}/")
+        };
+        let ping_url = format!("{normalized_registry_url}-/ping?write=true");
Evidence
ping_url is constructed via format!("{normalized_registry_url}-/ping?write=true"), which does
not account for existing ?/# in the registry string. The config layer only appends a trailing
/ to registry= values, so such inputs can reach PingArgs::run unchanged; separately, pacquet’s
URL parsing/normalization code explicitly strips query/fragment when keying URLs, indicating these
components are expected to exist and should not participate in path construction.

pacquet/crates/cli/src/cli_args/ping.rs[39-48]
pacquet/crates/config/src/npmrc_auth.rs[573-577]
pacquet/crates/network/src/auth.rs[348-355]

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

## Issue description
`pacquet ping` currently constructs `<registry>-/ping?write=true` by concatenating strings. If the registry value contains a query string or fragment (e.g. `https://reg.example/npm?x=y`), the concatenation yields `https://reg.example/npm?x=y/-/ping?write=true`, where `/-/ping?write=true` is inside the query portion rather than the path.
### Issue Context
Config only normalizes the registry by ensuring a trailing slash; it does not parse/validate or strip `?query` / `#fragment`. The HTTP client will then parse the final URL and may send a request with an unintended path/query split.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[39-48]
### Suggested fix
Parse `normalized_registry_url` as a URL and use proper URL joining (mirroring pnpm’s `new URL('./-/ping?write=true', base)` semantics):
- `let base = reqwest::Url::parse(&normalized_registry_url) ...?;`
- `let ping_url = base.join("-/ping?write=true")?...;`
- Pass `ping_url.as_str()` / `ping_url.to_string()` into `fetch_ping`.
This keeps path-prefix preservation (because the base ends with `/`) while ensuring query/fragment are handled correctly.

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


3. Ping error not sanitized 🐞 Bug ⛨ Security
Description
fetch_ping builds PingError::Unreachable from reqwest/network error strings with only
credential redaction, so any control characters present in the formatted error can still reach
stderr and affect terminal/log rendering. This is inconsistent with the repo’s existing
terminal-safety pattern (strip control characters from untrusted text) and with ping’s own stdout
sanitization.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R104-124]

+    .map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
+
+    if !response.status().is_success() {
+        let status = response.status();
+        return Err(PingError::Unreachable {
+            message: format!(
+                "{} {}",
+                status.as_u16(),
+                status.canonical_reason().unwrap_or_default(),
+            )
+            .trim_end()
+            .to_owned(),
+        }
+        .into());
+    }
+
+    let body = response.text().await.map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
Evidence
The configured registry string is taken from config as-is (other than adding a trailing slash), so
it can be influenced by repo-controlled .npmrc. The retry layer treats formatted reqwest errors as
potentially containing URLs and redacts them in logs, implying error strings can include URL-derived
text. In ping, those error strings are only credential-redacted and then surfaced via PingError,
without the control-character stripping used elsewhere for terminal safety.

pacquet/crates/cli/src/cli_args/ping.rs[91-106]
pacquet/crates/cli/src/cli_args/ping.rs[122-124]
pacquet/crates/config/src/npmrc_auth.rs[573-577]
pacquet/crates/network/src/retry.rs[127-164]
pacquet/crates/cli/src/cli_args/sanitize.rs[3-14]

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

## Issue description
`pacquet ping` maps network/body-read errors into `PingError::Unreachable { message }` using `redact_url_credentials(&error.to_string())` but does not strip control characters from that message before it is rendered to stderr by the CLI diagnostic layer.
Registry URLs are attacker-controlled via repo `.npmrc`/config, and the codebase already treats formatted network errors as potentially URL-bearing (hence credential redaction). To maintain terminal/log safety, the ping error message should apply control-character stripping (similar to other CLI output sanitization) after credential redaction.
## Issue Context
- `ping` already sanitizes the *stdout* `PING <registry>` line, but not the *stderr* error string.
- The network layer explicitly redacts URLs from formatted reqwest errors in retry logs, indicating errors can contain URL text.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[104-106]
- pacquet/crates/cli/src/cli_args/ping.rs[122-124]
## Suggested fix
- Introduce a small helper in `ping.rs` (or reuse an existing sanitize helper) that:
1) runs `redact_url_credentials(...)`
2) strips `char::is_control()` characters (ideally stripping `\r`/`\n` too, not preserving them)
- Apply it to both `map_err` sites (send failure + `response.text()` failure).
## Acceptance criteria
- The `PingError::Unreachable.message` string cannot contain control characters even if the underlying error formatting includes them.
- Existing behavior (credential redaction, error code) is preserved.

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


4. Unsanitized ping error text 🐞 Bug ⛨ Security
Description
fetch_ping embeds error.to_string() (only credential-redacted) into PingError::Unreachable, so
any control characters present in the underlying URL/error text can reach stderr/CI logs even though
the success-path PING line explicitly strips control characters for untrusted registries. This is
inconsistent with the repo’s stated threat model for .npmrc/--registry and can enable
log/terminal output injection in the ping failure path.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R104-106]

+    .map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
Evidence
The success path explicitly strips control characters from the echoed registry URL, but the error
path only applies credential redaction before emitting the message. The existing whoami
implementation comments that request errors can echo the URL and therefore avoids including it in
diagnostics, supporting that URL-derived text can reach stderr if forwarded.

pacquet/crates/cli/src/cli_args/ping.rs[70-79]
pacquet/crates/cli/src/cli_args/ping.rs[104-106]
pacquet/crates/cli/src/cli_args/ping.rs[122-124]
pacquet/crates/cli/src/cli_args/whoami.rs[65-74]

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

## Issue description
`pacquet ping` sanitizes the echoed registry URL for the success output, but the error path formats `PingError::Unreachable` using `redact_url_credentials(&error.to_string())` without stripping control characters. Since request errors commonly include the request URL in their Display text, a registry value sourced from an untrusted `.npmrc`/`--registry` that includes control characters can still affect stderr/CI output.
### Issue Context
There is already an explicit terminal-safety stance in this PR (sanitizing the `PING` line), and existing code (e.g. whoami) documents that underlying network errors can echo the URL.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[96-106]
- pacquet/crates/cli/src/cli_args/ping.rs[122-124]
### Suggested fix
Create a small helper (local to `ping.rs` or shared) like `fn sanitize_error_message(text: &str) -> String` that:
1) runs `redact_url_credentials(text)` and then
2) strips control characters (at least `is_control()`; consider matching the stricter behavior used for the `PING` line).
Use this helper for both transport errors (`send_with_retry` failure) and body-read errors (`response.text()` failure) when constructing `PingError::Unreachable { message }`.

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


View more (2)
5. Flaky ping network-failure test 🐞 Bug ☼ Reliability
Description
fails_on_a_network_failure assumes http://127.0.0.1:1/ fails immediately, but if the SYN is
silently dropped (firewall/OS behavior), the request can block until the client connect timeout
expires, making CI runs intermittently slow/flaky. This risk is amplified because the registry
client uses fetch_timeout (default 60s) as both connect and total request timeout.
Code

pacquet/crates/cli/tests/ping.rs[R180-187]

+#[test]
+fn fails_on_a_network_failure() {
+    let CommandTempCwd { root, workspace, .. } = CommandTempCwd::init();
+    // Port 1 is not listening, so the connection is refused immediately.
+    let auth_file = empty_auth_file(root.path());
+
+    let output = run_ping(&workspace, &auth_file, Some("http://127.0.0.1:1/"));
+
Evidence
The new test targets http://127.0.0.1:1/ and assumes immediate refusal; however the HTTP client is
configured to wait up to fetch_timeout for connects/requests, and fetch_timeout defaults to 60s,
so a dropped connection can stall the test for a long time.

pacquet/crates/cli/tests/ping.rs[180-187]
pacquet/crates/network/src/lib.rs[405-423]
pacquet/crates/config/src/lib.rs[1006-1011]

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

## Issue description
The `fails_on_a_network_failure` integration test relies on `127.0.0.1:1` refusing connections immediately. On some environments this can instead hang until the HTTP client connect timeout, causing flaky or very slow CI.
## Issue Context
The shared registry client uses `settings.fetch_timeout` for both `connect_timeout` and overall `timeout`, and the default `fetch_timeout` is 60s.
## Fix Focus Areas
- pacquet/crates/cli/tests/ping.rs[180-187]
- pacquet/crates/network/src/lib.rs[405-423]
- pacquet/crates/config/src/lib.rs[1006-1011]
## Suggested fix
Make the test deterministically bounded by explicitly setting a small timeout for the spawned `pacquet` process (e.g. `PNPM_CONFIG_FETCH_TIMEOUT=500` or similar) in `run_ping` or in this specific test, so even a dropped connection fails quickly. Alternatively, use a locally-created ephemeral port that is guaranteed to refuse immediately, but still keep a short timeout as a safety net.

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


6. Unbounded ping body read 🐞 Bug ☼ Reliability
Description
fetch_ping reads the entire registry response via response.text().await with no size limit, so a
malicious/compromised registry can force excessive memory usage or OOM when users run `pacquet
ping`. This is a reliability/DoS risk on attacker-controlled network input.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R111-113]

+    let body =
+        response.text().await.into_diagnostic().wrap_err("reading the registry ping response")?;
+    let time = start.elapsed().as_millis();
Evidence
The new ping implementation calls response.text().await directly, which buffers the full body
with no bounds. The repo demonstrates awareness of response-body buffering costs (e.g. draining only
small error bodies in tarball fetching), but ping lacks any analogous limit.

pacquet/crates/cli/src/cli_args/ping.rs[111-115]
pacquet/crates/tarball/src/lib.rs[1591-1604]

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

## Issue description
`pacquet ping` buffers the entire response body into memory (`response.text().await`) with no Content-Length guard or streaming cap. An attacker-controlled registry endpoint can return an arbitrarily large body and cause memory pressure/oom.
## Issue Context
Other network-facing code in the repo takes explicit steps to avoid pathological buffering (e.g. draining only small error bodies in the tarball path).
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[78-116]
- pacquet/crates/tarball/src/lib.rs[1591-1604]
## Suggested fix
- Introduce a small maximum body size for `ping` (e.g. 64KiB or 1MiB) and enforce it before/while reading:
- If `Content-Length` is present and exceeds the cap, either:
- treat as an error, or
- skip reading/printing details and only print the timing line (keeping behavior stable while avoiding OOM)
- If `Content-Length` is absent, stream `bytes_stream()` and stop once the cap is exceeded.
- Keep the timing semantics explicit (whether you time the partial read or only time up to the cap).

ⓘ 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 60ca74d

Results up to commit 60ca74d


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


Action required
1. Ping leaks registry URL 🐞 Bug ⛨ Security
Description
PingArgs::run formats the PING line using the raw registry_url, and the CLI prints it
verbatim, so a registry like https://user:pass@host/ will leak embedded credentials (and other
control characters) to stdout/CI logs. This bypasses the repo’s existing output-sanitization pattern
used by other read-only registry commands.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R39-66]

+        let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
+        // Add a trailing slash before joining so a registry with a path
+        // prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
+        let normalized_registry_url = if registry_url.ends_with('/') {
+            registry_url.to_owned()
+        } else {
+            format!("{registry_url}/")
+        };
+        let ping_url = format!("{normalized_registry_url}-/ping?write=true");
+        let auth_header = config.auth_headers.for_url(&normalized_registry_url);
+        let http_client = build_registry_client(config)?;
+
+        // `ping` issues a single attempt with no retries, matching pnpm's
+        // `retry: { retries: 0 }`.
+        let (time, body) = fetch_ping(
+            &ping_url,
+            &http_client,
+            auth_header.as_deref(),
+            RetryOpts { retries: 0, ..RetryOpts::default() },
+        )
+        .await?;
+
+        let mut report = format!("PING {registry_url}\nPONG {time}ms");
+        if let Some(details) = format_details(&body) {
+            report.push_str("\nPONG ");
+            report.push_str(&details);
+        }
+        Ok(report)
Evidence
The PING line is built from the raw registry URL and printed without sanitization; pacquet’s auth
system explicitly supports deriving Authorization: Basic ... from inline user:pass@ URLs, making
this a real secret-bearing input. The CLI already has a sanitize helper and uses it for whoami,
but ping does not.

pacquet/crates/cli/src/cli_args/ping.rs[38-66]
pacquet/crates/cli/src/cli_args.rs[519-545]
pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
pacquet/crates/network/src/auth.rs[180-218]

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

## Issue description
`pacquet ping` prints the registry URL directly in the `PING ...` line. Because pacquet supports inline basic-auth in registry URLs, this can leak secrets (e.g. `https://user:pass@host/`) to terminals and CI logs. Additionally, untrusted `.npmrc`/`--registry` can carry control characters that should not reach the terminal.
## Issue Context
- `ping` currently renders `PING {registry_url}` with `registry_url` taken directly from `--registry` or config.
- The repo already has output sanitization utilities (used by `whoami`) and credential redaction utilities (used for network errors) that should be applied to this success-path output too.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[38-67]
- pacquet/crates/cli/src/cli_args.rs[525-545]
- pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
- pacquet/crates/network/src/auth.rs[180-218]
## Suggested fix
- Before formatting the report, create a *display* registry string:
- apply `pacquet_network::redact_url_credentials(registry_url)` to remove any `user:pass@` userinfo
- strip terminal control characters from the display string (either reuse `cli_args::sanitize`, or introduce a variant suitable for single-line values; for a URL, also ensure `\r`/`\n` don’t allow output injection)
- Use the display string in `PING ...` (and anywhere else the registry is echoed).
- Optionally (belt-and-braces), sanitize the final printed report in `CliCommand::Ping` similarly to `CliCommand::Whoami`.

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



Remediation recommended
2. Bad ping URL join 🐞 Bug ≡ Correctness
Description
PingArgs::run builds the ping_url via string concatenation, so a registry URL containing ? or
# causes the appended -/ping?write=true to become part of the query/fragment instead of the path
and the request can target the wrong endpoint (or fail to parse). This is possible because config
normalization only appends a trailing slash and does not remove query/fragment components from
registry= values.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R39-47]

+        let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
+        // Add a trailing slash before joining so a registry with a path
+        // prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
+        let normalized_registry_url = if registry_url.ends_with('/') {
+            registry_url.to_owned()
+        } else {
+            format!("{registry_url}/")
+        };
+        let ping_url = format!("{normalized_registry_url}-/ping?write=true");
Evidence
ping_url is constructed via format!("{normalized_registry_url}-/ping?write=true"), which does
not account for existing ?/# in the registry string. The config layer only appends a trailing
/ to registry= values, so such inputs can reach PingArgs::run unchanged; separately, pacquet’s
URL parsing/normalization code explicitly strips query/fragment when keying URLs, indicating these
components are expected to exist and should not participate in path construction.

pacquet/crates/cli/src/cli_args/ping.rs[39-48]
pacquet/crates/config/src/npmrc_auth.rs[573-577]
pacquet/crates/network/src/auth.rs[348-355]

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

## Issue description
`pacquet ping` currently constructs `<registry>-/ping?write=true` by concatenating strings. If the registry value contains a query string or fragment (e.g. `https://reg.example/npm?x=y`), the concatenation yields `https://reg.example/npm?x=y/-/ping?write=true`, where `/-/ping?write=true` is inside the query portion rather than the path.
### Issue Context
Config only normalizes the registry by ensuring a trailing slash; it does not parse/validate or strip `?query` / `#fragment`. The HTTP client will then parse the final URL and may send a request with an unintended path/query split.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[39-48]
### Suggested fix
Parse `normalized_registry_url` as a URL and use proper URL joining (mirroring pnpm’s `new URL('./-/ping?write=true', base)` semantics):
- `let base = reqwest::Url::parse(&normalized_registry_url) ...?;`
- `let ping_url = base.join("-/ping?write=true")?...;`
- Pass `ping_url.as_str()` / `ping_url.to_string()` into `fetch_ping`.
This keeps path-prefix preservation (because the base ends with `/`) while ensuring query/fragment are handled correctly.

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


3. Ping error not sanitized 🐞 Bug ⛨ Security
Description
fetch_ping builds PingError::Unreachable from reqwest/network error strings with only
credential redaction, so any control characters present in the formatted error can still reach
stderr and affect terminal/log rendering. This is inconsistent with the repo’s existing
terminal-safety pattern (strip control characters from untrusted text) and with ping’s own stdout
sanitization.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R104-124]

+    .map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
+
+    if !response.status().is_success() {
+        let status = response.status();
+        return Err(PingError::Unreachable {
+            message: format!(
+                "{} {}",
+                status.as_u16(),
+                status.canonical_reason().unwrap_or_default(),
+            )
+            .trim_end()
+            .to_owned(),
+        }
+        .into());
+    }
+
+    let body = response.text().await.map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
Evidence
The configured registry string is taken from config as-is (other than adding a trailing slash), so
it can be influenced by repo-controlled .npmrc. The retry layer treats formatted reqwest errors as
potentially containing URLs and redacts them in logs, implying error strings can include URL-derived
text. In ping, those error strings are only credential-redacted and then surfaced via PingError,
without the control-character stripping used elsewhere for terminal safety.

pacquet/crates/cli/src/cli_args/ping.rs[91-106]
pacquet/crates/cli/src/cli_args/ping.rs[122-124]
pacquet/crates/config/src/npmrc_auth.rs[573-577]
pacquet/crates/network/src/retry.rs[127-164]
pacquet/crates/cli/src/cli_args/sanitize.rs[3-14]

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

## Issue description
`pacquet ping` maps network/body-read errors into `PingError::Unreachable { message }` using `redact_url_credentials(&error.to_string())` but does not strip control characters from that message before it is rendered to stderr by the CLI diagnostic layer.
Registry URLs are attacker-controlled via repo `.npmrc`/config, and the codebase already treats formatted network errors as potentially URL-bearing (hence credential redaction). To maintain terminal/log safety, the ping error message should apply control-character stripping (similar to other CLI output sanitization) after credential redaction.
## Issue Context
- `ping` already sanitizes the *stdout* `PING <registry>` line, but not the *stderr* error string.
- The network layer explicitly redacts URLs from formatted reqwest errors in retry logs, indicating errors can contain URL text.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[104-106]
- pacquet/crates/cli/src/cli_args/ping.rs[122-124]
## Suggested fix
- Introduce a small helper in `ping.rs` (or reuse an existing sanitize helper) that:
1) runs `redact_url_credentials(...)`
2) strips `char::is_control()` characters (ideally stripping `\r`/`\n` too, not preserving them)
- Apply it to both `map_err` sites (send failure + `response.text()` failure).
## Acceptance criteria
- The `PingError::Unreachable.message` string cannot contain control characters even if the underlying error formatting includes them.
- Existing behavior (credential redaction, error code) is preserved.

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


4. Unsanitized ping error text 🐞 Bug ⛨ Security
Description
fetch_ping embeds error.to_string() (only credential-redacted) into PingError::Unreachable, so
any control characters present in the underlying URL/error text can reach stderr/CI logs even though
the success-path PING line explicitly strips control characters for untrusted registries. This is
inconsistent with the repo’s stated threat model for .npmrc/--registry and can enable
log/terminal output injection in the ping failure path.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R104-106]

+    .map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
Evidence
The success path explicitly strips control characters from the echoed registry URL, but the error
path only applies credential redaction before emitting the message. The existing whoami
implementation comments that request errors can echo the URL and therefore avoids including it in
diagnostics, supporting that URL-derived text can reach stderr if forwarded.

pacquet/crates/cli/src/cli_args/ping.rs[70-79]
pacquet/crates/cli/src/cli_args/ping.rs[104-106]
pacquet/crates/cli/src/cli_args/ping.rs[122-124]
pacquet/crates/cli/src/cli_args/whoami.rs[65-74]

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

## Issue description
`pacquet ping` sanitizes the echoed registry URL for the success output, but the error path formats `PingError::Unreachable` using `redact_url_credentials(&error.to_string())` without stripping control characters. Since request errors commonly include the request URL in their Display text, a registry value sourced from an untrusted `.npmrc`/`--registry` that includes control characters can still affect stderr/CI output.
### Issue Context
There is already an explicit terminal-safety stance in this PR (sanitizing the `PING` line), and existing code (e.g. whoami) documents that underlying network errors can echo the URL.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[96-106]
- pacquet/crates/cli/src/cli_args/ping.rs[122-124]
### Suggested fix
Create a small helper (local to `ping.rs` or shared) like `fn sanitize_error_message(text: &str) -> String` that:
1) runs `redact_url_credentials(text)` and then
2) strips control characters (at least `is_control()`; consider matching the stricter behavior used for the `PING` line).
Use this helper for both transport errors (`send_with_retry` failure) and body-read errors (`response.text()` failure) when constructing `PingError::Unreachable { message }`.

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


View more (2)
5. Flaky ping network-failure test 🐞 Bug ☼ Reliability
Description
fails_on_a_network_failure assumes http://127.0.0.1:1/ fails immediately, but if the SYN is
silently dropped (firewall/OS behavior), the request can block until the client connect timeout
expires, making CI runs intermittently slow/flaky. This risk is amplified because the registry
client uses fetch_timeout (default 60s) as both connect and total request timeout.
Code

pacquet/crates/cli/tests/ping.rs[R180-187]

+#[test]
+fn fails_on_a_network_failure() {
+    let CommandTempCwd { root, workspace, .. } = CommandTempCwd::init();
+    // Port 1 is not listening, so the connection is refused immediately.
+    let auth_file = empty_auth_file(root.path());
+
+    let output = run_ping(&workspace, &auth_file, Some("http://127.0.0.1:1/"));
+
Evidence
The new test targets http://127.0.0.1:1/ and assumes immediate refusal; however the HTTP client is
configured to wait up to fetch_timeout for connects/requests, and fetch_timeout defaults to 60s,
so a dropped connection can stall the test for a long time.

pacquet/crates/cli/tests/ping.rs[180-187]
pacquet/crates/network/src/lib.rs[405-423]
pacquet/crates/config/src/lib.rs[1006-1011]

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

## Issue description
The `fails_on_a_network_failure` integration test relies on `127.0.0.1:1` refusing connections immediately. On some environments this can instead hang until the HTTP client connect timeout, causing flaky or very slow CI.
## Issue Context
The shared registry client uses `settings.fetch_timeout` for both `connect_timeout` and overall `timeout`, and the default `fetch_timeout` is 60s.
## Fix Focus Areas
- pacquet/crates/cli/tests/ping.rs[180-187]
- pacquet/crates/network/src/lib.rs[405-423]
- pacquet/crates/config/src/lib.rs[1006-1011]
## Suggested fix
Make the test deterministically bounded by explicitly setting a small timeout for the spawned `pacquet` process (e.g. `PNPM_CONFIG_FETCH_TIMEOUT=500` or similar) in `run_ping` or in this specific test, so even a dropped connection fails quickly. Alternatively, use a locally-created ephemeral port that is guaranteed to refuse immediately, but still keep a short timeout as a safety net.

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


6. Unbounded ping body read 🐞 Bug ☼ Reliability
Description
fetch_ping reads the entire registry response via response.text().await with no size limit, so a
malicious/compromised registry can force excessive memory usage or OOM when users run `pacquet
ping`. This is a reliability/DoS risk on attacker-controlled network input.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R111-113]

+    let body =
+        response.text().await.into_diagnostic().wrap_err("reading the registry ping response")?;
+    let time = start.elapsed().as_millis();
Evidence
The new ping implementation calls response.text().await directly, which buffers the full body
with no bounds. The repo demonstrates awareness of response-body buffering costs (e.g. draining only
small error bodies in tarball fetching), but ping lacks any analogous limit.

pacquet/crates/cli/src/cli_args/ping.rs[111-115]
pacquet/crates/tarball/src/lib.rs[1591-1604]

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

## Issue description
`pacquet ping` buffers the entire response body into memory (`response.text().await`) with no Content-Length guard or streaming cap. An attacker-controlled registry endpoint can return an arbitrarily large body and cause memory pressure/oom.
## Issue Context
Other network-facing code in the repo takes explicit steps to avoid pathological buffering (e.g. draining only small error bodies in the tarball path).
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[78-116]
- pacquet/crates/tarball/src/lib.rs[1591-1604]
## Suggested fix
- Introduce a small maximum body size for `ping` (e.g. 64KiB or 1MiB) and enforce it before/while reading:
- If `Content-Length` is present and exceeds the cap, either:
- treat as an error, or
- skip reading/printing details and only print the timing line (keeping behavior stable while avoiding OOM)
- If `Content-Length` is absent, stream `bytes_stream()` and stop once the cap is exceeded.
- Keep the timing semantics explicit (whether you time the partial read or only time up to the cap).

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


Results up to commit a6d1944


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


Action required
1. Ping leaks registry URL 🐞 Bug ⛨ Security
Description
PingArgs::run formats the PING line using the raw registry_url, and the CLI prints it
verbatim, so a registry like https://user:pass@host/ will leak embedded credentials (and other
control characters) to stdout/CI logs. This bypasses the repo’s existing output-sanitization pattern
used by other read-only registry commands.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R39-66]

+        let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
+        // Add a trailing slash before joining so a registry with a path
+        // prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
+        let normalized_registry_url = if registry_url.ends_with('/') {
+            registry_url.to_owned()
+        } else {
+            format!("{registry_url}/")
+        };
+        let ping_url = format!("{normalized_registry_url}-/ping?write=true");
+        let auth_header = config.auth_headers.for_url(&normalized_registry_url);
+        let http_client = build_registry_client(config)?;
+
+        // `ping` issues a single attempt with no retries, matching pnpm's
+        // `retry: { retries: 0 }`.
+        let (time, body) = fetch_ping(
+            &ping_url,
+            &http_client,
+            auth_header.as_deref(),
+            RetryOpts { retries: 0, ..RetryOpts::default() },
+        )
+        .await?;
+
+        let mut report = format!("PING {registry_url}\nPONG {time}ms");
+        if let Some(details) = format_details(&body) {
+            report.push_str("\nPONG ");
+            report.push_str(&details);
+        }
+        Ok(report)
Evidence
The PING line is built from the raw registry URL and printed without sanitization; pacquet’s auth
system explicitly supports deriving Authorization: Basic ... from inline user:pass@ URLs, making
this a real secret-bearing input. The CLI already has a sanitize helper and uses it for whoami,
but ping does not.

pacquet/crates/cli/src/cli_args/ping.rs[38-66]
pacquet/crates/cli/src/cli_args.rs[519-545]
pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
pacquet/crates/network/src/auth.rs[180-218]

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

## Issue description
`pacquet ping` prints the registry URL directly in the `PING ...` line. Because pacquet supports inline basic-auth in registry URLs, this can leak secrets (e.g. `https://user:pass@host/`) to terminals and CI logs. Additionally, untrusted `.npmrc`/`--registry` can carry control characters that should not reach the terminal.
## Issue Context
- `ping` currently renders `PING {registry_url}` with `registry_url` taken directly from `--registry` or config.
- The repo already has output sanitization utilities (used by `whoami`) and credential redaction utilities (used for network errors) that should be applied to this success-path output too.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[38-67]
- pacquet/crates/cli/src/cli_args.rs[525-545]
- pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
- pacquet/crates/network/src/auth.rs[180-218]
## Suggested fix
- Before formatting the report, create a *display* registry string:
- apply `pacquet_network::redact_url_credentials(registry_url)` to remove any `user:pass@` userinfo
- strip terminal control characters from the display string (either reuse `cli_args::sanitize`, or introduce a variant suitable for single-line values; for a URL, also ensure `\r`/`\n` don’t allow output injection)
- Use the display string in `PING ...` (and anywhere else the registry is echoed).
- Optionally (belt-and-braces), sanitize the final printed report in `CliCommand::Ping` similarly to `CliCommand::Whoami`.

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



Remediation recommended
2. Bad ping URL join 🐞 Bug ≡ Correctness
Description
PingArgs::run builds the ping_url via string concatenation, so a registry URL containing ? or
# causes the appended -/ping?write=true to become part of the query/fragment instead of the path
and the request can target the wrong endpoint (or fail to parse). This is possible because config
normalization only appends a trailing slash and does not remove query/fragment components from
registry= values.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R39-47]

+        let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
+        // Add a trailing slash before joining so a registry with a path
+        // prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
+        let normalized_registry_url = if registry_url.ends_with('/') {
+            registry_url.to_owned()
+        } else {
+            format!("{registry_url}/")
+        };
+        let ping_url = format!("{normalized_registry_url}-/ping?write=true");
Evidence
ping_url is constructed via format!("{normalized_registry_url}-/ping?write=true"), which does
not account for existing ?/# in the registry string. The config layer only appends a trailing
/ to registry= values, so such inputs can reach PingArgs::run unchanged; separately, pacquet’s
URL parsing/normalization code explicitly strips query/fragment when keying URLs, indicating these
components are expected to exist and should not participate in path construction.

pacquet/crates/cli/src/cli_args/ping.rs[39-48]
pacquet/crates/config/src/npmrc_auth.rs[573-577]
pacquet/crates/network/src/auth.rs[348-355]

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

## Issue description
`pacquet ping` currently constructs `<registry>-/ping?write=true` by concatenating strings. If the registry value contains a query string or fragment (e.g. `https://reg.example/npm?x=y`), the concatenation yields `https://reg.example/npm?x=y/-/ping?write=true`, where `/-/ping?write=true` is inside the query portion rather than the path.
### Issue Context
Config only normalizes the registry by ensuring a trailing slash; it does not parse/validate or strip `?query` / `#fragment`. The HTTP client will then parse the final URL and may send a request with an unintended path/query split.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[39-48]
### Suggested fix
Parse `normalized_registry_url` as a URL and use proper URL joining (mirroring pnpm’s `new URL('./-/ping?write=true', base)` semantics):
- `let base = reqwest::Url::parse(&normalized_registry_url) ...?;`
- `let ping_url = base.join("-/ping?write=true")?...;`
- Pass `ping_url.as_str()` / `ping_url.to_string()` into `fetch_ping`.
This keeps path-prefix preservation (because the base ends with `/`) while ensuring query/fragment are handled correctly.

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


3. Ping error not sanitized 🐞 Bug ⛨ Security
Description
fetch_ping builds PingError::Unreachable from reqwest/network error strings with only
credential redaction, so any control characters present in the formatted error can still reach
stderr and affect terminal/log rendering. This is inconsistent with the repo’s existing
terminal-safety pattern (strip control characters from untrusted text) and with ping’s own stdout
sanitization.
Code

pacquet/crates/cli/src/cli_args/ping.rs[R104-124]

+    .map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
+
+    if !response.status().is_success() {
+        let status = response.status();
+        return Err(PingError::Unreachable {
+            message: format!(
+                "{} {}",
+                status.as_u16(),
+                status.canonical_reason().unwrap_or_default(),
+            )
+            .trim_end()
+            .to_owned(),
+        }
+        .into());
+    }
+
+    let body = response.text().await.map_err(|error| PingError::Unreachable {
+        message: redact_url_credentials(&error.to_string()),
+    })?;
Evidence
The configured registry string is taken from config as-is (other than adding a trailing slash), so
it can be influenced by repo-controlled .npmrc. The retry layer treats formatted reqwest errors as
potentially containing URLs and redacts them in logs, implying error strings can include URL-derived
text. In ping, those error strings are only credential-redacted and then surfaced via PingError,
without the control-character stripping used elsewhere for terminal safety.

pacquet/crates/cli/src/cli_args/ping.rs[91-106]
pacquet/crates/cli/src/cli_args/ping.rs[122-124]
pacquet/crates/config/src/npmrc_auth.rs[573-577]
pacquet/crates/network/src/retry.rs[127-164]
pacquet/crates/cli/src/cli_args/sanitize.rs[3-14]

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

## Issue description
`pacquet ping` maps network/body-read errors into `PingError::Unreachable { message }` using `redact_url_credentials(&error.to_string())` but does not strip control characters from that message before it is rendered to stderr by the CLI diagnostic layer.
Registry URLs are attacker-controlled via repo `.npmrc`/config, and the codebase already treats formatted network errors as potentially URL-bearing (hence credential redaction). To maintain terminal/log safety, the ping error message should apply control-character stripping (similar to other CLI output sanitization) after credential redaction.
## Issue Context
- `ping` already sanitizes the *stdout* `PING <registry>` line, but not the *stderr* error string.
-...

Comment on lines +39 to +66
let registry_url = self.registry.as_deref().unwrap_or(&config.registry);
// Add a trailing slash before joining so a registry with a path
// prefix keeps it, matching `new URL('./-/ping', normalizedRegistryUrl)`.
let normalized_registry_url = if registry_url.ends_with('/') {
registry_url.to_owned()
} else {
format!("{registry_url}/")
};
let ping_url = format!("{normalized_registry_url}-/ping?write=true");
let auth_header = config.auth_headers.for_url(&normalized_registry_url);
let http_client = build_registry_client(config)?;

// `ping` issues a single attempt with no retries, matching pnpm's
// `retry: { retries: 0 }`.
let (time, body) = fetch_ping(
&ping_url,
&http_client,
auth_header.as_deref(),
RetryOpts { retries: 0, ..RetryOpts::default() },
)
.await?;

let mut report = format!("PING {registry_url}\nPONG {time}ms");
if let Some(details) = format_details(&body) {
report.push_str("\nPONG ");
report.push_str(&details);
}
Ok(report)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Ping leaks registry url 🐞 Bug ⛨ Security

PingArgs::run formats the PING line using the raw registry_url, and the CLI prints it
verbatim, so a registry like https://user:pass@host/ will leak embedded credentials (and other
control characters) to stdout/CI logs. This bypasses the repo’s existing output-sanitization pattern
used by other read-only registry commands.
Agent Prompt
## Issue description
`pacquet ping` prints the registry URL directly in the `PING ...` line. Because pacquet supports inline basic-auth in registry URLs, this can leak secrets (e.g. `https://user:pass@host/`) to terminals and CI logs. Additionally, untrusted `.npmrc`/`--registry` can carry control characters that should not reach the terminal.

## Issue Context
- `ping` currently renders `PING {registry_url}` with `registry_url` taken directly from `--registry` or config.
- The repo already has output sanitization utilities (used by `whoami`) and credential redaction utilities (used for network errors) that should be applied to this success-path output too.

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/ping.rs[38-67]
- pacquet/crates/cli/src/cli_args.rs[525-545]
- pacquet/crates/cli/src/cli_args/sanitize.rs[1-18]
- pacquet/crates/network/src/auth.rs[180-218]

## Suggested fix
- Before formatting the report, create a *display* registry string:
  - apply `pacquet_network::redact_url_credentials(registry_url)` to remove any `user:pass@` userinfo
  - strip terminal control characters from the display string (either reuse `cli_args::sanitize`, or introduce a variant suitable for single-line values; for a URL, also ensure `\r`/`\n` don’t allow output injection)
- Use the display string in `PING ...` (and anywhere else the registry is echoed).
- Optionally (belt-and-braces), sanitize the final printed report in `CliCommand::Ping` similarly to `CliCommand::Whoami`.

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

@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 `@pacquet/crates/cli/src/cli_args/ping.rs`:
- Around line 111-112: The body-read path in `ping.rs` currently sends the
`reqwest::Response::text()` error through `into_diagnostic()`, which can leak
credentials from the registry URL in the error display. Update the response body
read in the ping flow to match the transport-error handling used earlier in the
same function by mapping failures to `PingError::Unreachable` and passing the
message through `redact_url_credentials` before returning it. Keep the fix
localized around the `response.text().await` handling in the ping command so the
redaction behavior is consistent across all request failure paths.
🪄 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: b517b15a-955b-43a7-8cb7-56dde8a76146

📥 Commits

Reviewing files that changed from the base of the PR and between c50c6aa and 76f399a.

📒 Files selected for processing (5)
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/ping.rs
  • pacquet/crates/cli/src/cli_args/registry_client.rs
  • pacquet/crates/cli/src/cli_args/whoami.rs
  • pacquet/crates/cli/tests/ping.rs

Comment thread pacquet/crates/cli/src/cli_args/ping.rs Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 76f399a

@codecov-commenter

codecov-commenter commented Jun 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.47826% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.20%. Comparing base (6312916) to head (60ca74d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pacquet/crates/cli/src/cli_args/ping.rs 92.95% 5 Missing ⚠️
pacquet/crates/cli/src/cli_args.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12666      +/-   ##
==========================================
- Coverage   87.48%   87.20%   -0.29%     
==========================================
  Files         370      373       +3     
  Lines       55767    56296     +529     
==========================================
+ Hits        48789    49092     +303     
- Misses       6978     7204     +226     

☔ 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 Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 60ca74d6e63b

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.837 ± 0.121 4.700 5.048 1.68 ± 0.07
pacquet@main 4.862 ± 0.128 4.686 5.091 1.69 ± 0.07
pnpr@HEAD 2.923 ± 0.167 2.742 3.218 1.02 ± 0.07
pnpr@main 2.874 ± 0.098 2.801 3.088 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.8372924593199995,
      "stddev": 0.12071010131360045,
      "median": 4.81104406412,
      "user": 3.9482655600000003,
      "system": 3.4967228999999995,
      "min": 4.699647233119999,
      "max": 5.04781244212,
      "times": [
        4.75270321812,
        4.9085687911199996,
        4.91318876612,
        5.04781244212,
        4.699647233119999,
        4.73107992012,
        4.86539318012,
        4.75669494812,
        4.72433763212,
        4.973498462119999
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.86184671832,
      "stddev": 0.12799138255619838,
      "median": 4.82081188812,
      "user": 3.9866402599999993,
      "system": 3.5444008999999994,
      "min": 4.68585472512,
      "max": 5.091490880119999,
      "times": [
        4.84862129112,
        4.83123751812,
        4.80420957812,
        5.091490880119999,
        5.02860821312,
        4.68585472512,
        4.81038625812,
        4.79786938812,
        4.74888352612,
        4.97130580512
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.9228427467199998,
      "stddev": 0.1674830306654991,
      "median": 2.83610252212,
      "user": 2.7015189599999996,
      "system": 2.9989517999999995,
      "min": 2.74247391412,
      "max": 3.21847240112,
      "times": [
        2.8326279651200004,
        2.76705854912,
        2.8060980411200003,
        2.74247391412,
        2.83957707912,
        2.81229431712,
        3.0509131761200003,
        3.04882154612,
        3.21847240112,
        3.11009047812
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.8742014629200003,
      "stddev": 0.09807681846557302,
      "median": 2.83249715112,
      "user": 2.75707306,
      "system": 2.9945277,
      "min": 2.8011743371200004,
      "max": 3.08780663512,
      "times": [
        3.08780663512,
        2.8011743371200004,
        2.80194294212,
        2.8493314521200004,
        2.8156628501200003,
        2.8131905171200002,
        2.8833760061200002,
        2.87344616912,
        2.80742519512,
        3.0086585251200004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 639.5 ± 16.0 620.9 667.5 1.00
pacquet@main 658.5 ± 12.3 637.6 680.4 1.03 ± 0.03
pnpr@HEAD 703.6 ± 68.2 657.1 885.8 1.10 ± 0.11
pnpr@main 710.4 ± 76.9 674.2 926.6 1.11 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6394936845400002,
      "stddev": 0.01601764658937133,
      "median": 0.6349608089400001,
      "user": 0.37328482,
      "system": 1.33335528,
      "min": 0.62091173794,
      "max": 0.66746583594,
      "times": [
        0.66746583594,
        0.63900611694,
        0.65932024594,
        0.63067174894,
        0.63656041894,
        0.62091173794,
        0.65551157594,
        0.63089617594,
        0.63336119894,
        0.62123178994
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.65847487304,
      "stddev": 0.01230221821809584,
      "median": 0.6589852844399999,
      "user": 0.37493732,
      "system": 1.33725378,
      "min": 0.63763316594,
      "max": 0.68042332494,
      "times": [
        0.68042332494,
        0.67262973994,
        0.66139547094,
        0.65836275894,
        0.63763316594,
        0.65960780994,
        0.64648558694,
        0.6620664429399999,
        0.64984856694,
        0.65629586294
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7036373302400001,
      "stddev": 0.06824034616317312,
      "median": 0.68224723044,
      "user": 0.38904322,
      "system": 1.3524812799999997,
      "min": 0.65713821394,
      "max": 0.88581950694,
      "times": [
        0.71976208494,
        0.66177834394,
        0.69484106694,
        0.66435654394,
        0.66517858094,
        0.72300449994,
        0.69109081594,
        0.67340364494,
        0.65713821394,
        0.88581950694
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7103725248399999,
      "stddev": 0.07691327169728085,
      "median": 0.68354832194,
      "user": 0.38267671999999997,
      "system": 1.35134918,
      "min": 0.67420878494,
      "max": 0.92660050394,
      "times": [
        0.70245742794,
        0.68885576094,
        0.68588696194,
        0.71114271194,
        0.67420878494,
        0.68114115594,
        0.68120968194,
        0.92660050394,
        0.67635669994,
        0.67586555894
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.744 ± 0.052 4.655 4.836 1.50 ± 0.04
pacquet@main 4.747 ± 0.056 4.641 4.836 1.50 ± 0.04
pnpr@HEAD 3.187 ± 0.111 3.051 3.351 1.01 ± 0.04
pnpr@main 3.168 ± 0.075 3.072 3.306 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.744458368679998,
      "stddev": 0.051690460047674774,
      "median": 4.73954161648,
      "user": 3.8046007600000005,
      "system": 3.3990100599999997,
      "min": 4.65460493498,
      "max": 4.8360146869800005,
      "times": [
        4.8360146869800005,
        4.74975689298,
        4.73574043898,
        4.81799931898,
        4.74334279398,
        4.74717368898,
        4.73014493498,
        4.65460493498,
        4.72258590798,
        4.707220087980001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.74717050598,
      "stddev": 0.056289990422602416,
      "median": 4.75123595098,
      "user": 3.8611159599999993,
      "system": 3.3817113599999997,
      "min": 4.6406087749800005,
      "max": 4.83623190698,
      "times": [
        4.73315728198,
        4.77878654098,
        4.739460755980001,
        4.69086448498,
        4.6406087749800005,
        4.76301114598,
        4.77254988198,
        4.80124563598,
        4.71578864998,
        4.83623190698
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.1869403921800004,
      "stddev": 0.11143772304953177,
      "median": 3.16708924798,
      "user": 2.7816105600000003,
      "system": 3.19054316,
      "min": 3.05075109498,
      "max": 3.3506934679800002,
      "times": [
        3.1288155249800003,
        3.3506934679800002,
        3.17768277998,
        3.09450622598,
        3.29121529698,
        3.21361243798,
        3.1564957159800002,
        3.34665386098,
        3.05075109498,
        3.05897751598
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.16807530078,
      "stddev": 0.07521523719882636,
      "median": 3.15604137248,
      "user": 2.84285606,
      "system": 3.1826164599999998,
      "min": 3.07182734598,
      "max": 3.30588422998,
      "times": [
        3.20513161498,
        3.15653003398,
        3.30588422998,
        3.11306487398,
        3.21273879598,
        3.25441390298,
        3.10378446998,
        3.07182734598,
        3.15555271098,
        3.10182502898
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.320 ± 0.010 1.311 1.340 1.00
pacquet@main 1.324 ± 0.035 1.294 1.420 1.00 ± 0.03
pnpr@HEAD 1.394 ± 0.034 1.368 1.482 1.06 ± 0.03
pnpr@main 1.403 ± 0.071 1.361 1.603 1.06 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.32041645154,
      "stddev": 0.009566773205455969,
      "median": 1.3168532601399998,
      "user": 1.27466566,
      "system": 1.6976045800000001,
      "min": 1.31104781164,
      "max": 1.33976376064,
      "times": [
        1.31372545264,
        1.32853142364,
        1.3167697756399999,
        1.31211937664,
        1.31104781164,
        1.33976376064,
        1.32496745764,
        1.31693674464,
        1.31190829664,
        1.3283944156399998
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.32393020824,
      "stddev": 0.0350257911825021,
      "median": 1.31594872864,
      "user": 1.28941486,
      "system": 1.68169238,
      "min": 1.29403526964,
      "max": 1.42015596664,
      "times": [
        1.3174430396399999,
        1.32385420564,
        1.29403526964,
        1.42015596664,
        1.30253199364,
        1.3101819776399999,
        1.31546154464,
        1.32374062764,
        1.31597784364,
        1.31591961364
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.39408322994,
      "stddev": 0.03441596531278615,
      "median": 1.3817801806399999,
      "user": 0.5590528599999999,
      "system": 1.55389048,
      "min": 1.36798334464,
      "max": 1.48227634764,
      "times": [
        1.38641197064,
        1.48227634764,
        1.40130210064,
        1.40323498264,
        1.4078786696399999,
        1.37097382364,
        1.36798334464,
        1.37059460464,
        1.37714839064,
        1.37302806464
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.40324192744,
      "stddev": 0.07094542497621835,
      "median": 1.38298678814,
      "user": 0.5729957600000001,
      "system": 1.5467552799999997,
      "min": 1.36095576864,
      "max": 1.60257326464,
      "times": [
        1.38164583664,
        1.39423467664,
        1.60257326464,
        1.3705196846399998,
        1.37480932564,
        1.38432773964,
        1.3990588636399999,
        1.36095576864,
        1.37557943364,
        1.38871468064
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.972 ± 0.027 2.917 3.018 2.13 ± 0.03
pacquet@main 2.998 ± 0.033 2.957 3.055 2.15 ± 0.04
pnpr@HEAD 1.394 ± 0.018 1.370 1.413 1.00
pnpr@main 1.420 ± 0.100 1.374 1.704 1.02 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.9716161693,
      "stddev": 0.027052902769176053,
      "median": 2.9770790516,
      "user": 1.7471231399999998,
      "system": 1.9466351399999997,
      "min": 2.9168553371,
      "max": 3.0178473231,
      "times": [
        2.9817253841,
        2.9888158981,
        2.9729065211,
        2.9812515821,
        2.9678725311,
        2.9605509510999997,
        2.9453169201,
        3.0178473231,
        2.9830192451,
        2.9168553371
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9978082513000004,
      "stddev": 0.03271246241872484,
      "median": 2.9919177956,
      "user": 1.7405230399999998,
      "system": 1.9643912399999999,
      "min": 2.9574352061,
      "max": 3.0552074921,
      "times": [
        2.9800156291,
        2.9716229331,
        3.0437612901,
        3.0036385991,
        3.0144252530999998,
        2.9574352061,
        2.9801969920999998,
        2.9673426391,
        3.0044364791,
        3.0552074921
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.3938316969,
      "stddev": 0.017659010201707553,
      "median": 1.3985452101000002,
      "user": 0.56159504,
      "system": 1.5509329399999998,
      "min": 1.3696483081000002,
      "max": 1.4129112811000002,
      "times": [
        1.3806865111000002,
        1.3782031591000001,
        1.3697265361000002,
        1.3962145951000002,
        1.4123050301000002,
        1.4129112811000002,
        1.4111704481000003,
        1.4065752751,
        1.4008758251000002,
        1.3696483081000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.4195993697,
      "stddev": 0.10022600409343897,
      "median": 1.3875537771,
      "user": 0.57187784,
      "system": 1.54027074,
      "min": 1.3742354261,
      "max": 1.7037393911000003,
      "times": [
        1.3922679201000001,
        1.7037393911000003,
        1.4045076711000002,
        1.3798136371,
        1.3887365301,
        1.3742354261,
        1.3986716731000002,
        1.3828330181000001,
        1.3863710241,
        1.3848174061
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12666
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,744.46 ms
(-0.23%)Baseline: 4,755.17 ms
5,706.21 ms
(83.15%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,971.62 ms
(-2.18%)Baseline: 3,037.73 ms
3,645.27 ms
(81.52%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,320.42 ms
(-2.33%)Baseline: 1,351.90 ms
1,622.29 ms
(81.39%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,837.29 ms
(+1.78%)Baseline: 4,752.46 ms
5,702.96 ms
(84.82%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
639.49 ms
(-1.75%)Baseline: 650.92 ms
781.10 ms
(81.87%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12666
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
3,186.94 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,393.83 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,394.08 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,922.84 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
703.64 ms
🐰 View full continuous benchmarking report in Bencher

@Safort
Safort force-pushed the feat/pacquet-ping branch from 76f399a to 6993fa6 Compare June 25, 2026 19:56
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6993fa6

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6993fa6

@Safort
Safort force-pushed the feat/pacquet-ping branch from 6993fa6 to 2bcdaf5 Compare June 25, 2026 22:27
@qodo-free-for-open-source-projects

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

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@Safort
Safort force-pushed the feat/pacquet-ping branch from 2bcdaf5 to 2cf28ad Compare June 25, 2026 22:33
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

@Safort

Safort commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up: this PR includes a one-line change to .github/workflows/triage-issues.yml
that's unrelated to ping.

That workflow (added in #12673) checks out the repo without persist-credentials: false,
which zizmor flags as artipacked. The finding hard-fails zizmor on fork PRs — they
run with a read-only token, so the action uses console mode and exits non-zero on any
finding — while internal branches and pushes to main upload SARIF to code scanning and
stay green. So it's invisible on main but blocks every external contributor's PR.

The fix is the standard remediation (persist-credentials: false), matching the
zizmor.yml checkout. The triage workflow only reads the repo and writes issue labels —
it runs no git operations — so disabling credential persistence is safe. Happy to split
it into its own PR if you'd prefer.


Made with the help of Claude Code (Claude Opus 4.8).

@zkochan fyi ^

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

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

The perfectionist::unit_test_file_layout dylint lint rejects inline
`#[cfg(test)] mod tests { ... }` blocks. Move the redact_and_sanitize
test into src/cli_args/ping/tests.rs and declare it with an external
`mod tests;`, matching the convention used by the other cli_args modules.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 60ca74d

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 60ca74d

@zkochan
zkochan merged commit ec76ca3 into pnpm:main Jun 26, 2026
31 checks passed
kairosci pushed a commit to kairosci/pnpm that referenced this pull request Jun 26, 2026
Add `pacquet ping`, ported from pnpm's ping command.

`ping` GETs `<registry>-/ping?write=true` and prints pnpm's PING/PONG
report, plus a pretty-printed `PONG <details>` line when the registry
returns a non-empty JSON body. It resolves the registry from `--registry`
or the configured default, adds a trailing slash before joining so a
registry path prefix is preserved (matching pnpm's
`new URL('./-/ping', ...)`), sends the optional `Authorization` header when
one is configured (unlike whoami it does not require auth), and issues a
single attempt with no retries (pnpm's `retry: { retries: 0 }`). Timing
wraps the request and body read, matching pnpm's `Date.now()` measurement.

Both a transport failure and a non-success status map to the single
`ERR_PNPM_PING_ERROR` code with pnpm's "Failed to reach registry" message;
the transport error message is credential-redacted before it reaches
stderr / CI logs, the same precaution as whoami. Unlike whoami's username
(printed raw, hence sanitized), ping's JSON details are re-serialized
through serde_json, which escapes control characters, so no raw registry
bytes reach the terminal.

Extract the registry-client builder duplicated from whoami into a shared
`cli_args::registry_client::build_registry_client` and switch whoami to it.

---------

Co-authored-by: Zoltan Kochan <[email protected]>
@qodo-code-review qodo-code-review Bot mentioned this pull request Nov 7, 2026
4 tasks done
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.

3 participants