Skip to content

feat(pacquet): port audit --fix, --ignore, and --interactive - #12653

Merged
zkochan merged 1 commit into
mainfrom
feat/pacquet-audit-fix-ignore
Jun 25, 2026
Merged

zkochan merged 1 commit into
mainfrom
feat/pacquet-audit-fix-ignore

Conversation

@zkochan

@zkochan zkochan commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Ports the remaining pnpm audit fix/ignore features to the pacquet (Rust) port, which previously implemented only the read/report path of audit. Behavior, flags, output strings, and config writes mirror the TypeScript CLI.

New flags on pacquet audit:

  • --ignore <GHSA> / --ignore-unfixable — suppress advisories and persist GHSAs to auditConfig.ignoreGhsas in pnpm-workspace.yaml. Ports ignore.ts (GHSA normalization, merge-with-existing, unfixable detection via missing patched range, ERR_PNPM_AUDIT_MISSING_GHSA).
  • --fix (override) — writes ^patched overrides to the overrides: block. Ports fix.ts.
  • --fix update — re-resolves the lockfile to non-vulnerable versions using a resolver-time PackageVersionGuard that rejects vulnerable versions (so the picker falls back to a safe one), then reports fixed vs. remaining from the post-update lockfile. Ports fixWithUpdate.ts.
  • -i / --interactive — pick which advisories to fix via a dialoguer multi-select (flat list, matching the convention update --interactive already uses).
  • minimumReleaseAge handling for both fix paths — patched versions are merged into minimumReleaseAgeExclude (new merge_package_version_specs in the config crate) and, for --fix update, injected into the in-process resolve so the maturity cutoff can't block the fix.

Supporting changes:

  • New format-preserving writers in workspace-manifest-writer: set_overrides, set_audit_ignore_ghsas (nested block sequence), set_minimum_release_age_excludes (top-level block sequence).
  • The version guard and exclude specs are carried through the existing ResolutionObserver seam (a new defaulted trait method), so no Install call sites change. Normal installs are unaffected: the resolve override is None unless an audit-fix observer is present (verified by the full install/update suites).

audit signatures remains unported (unchanged from before).

This is a pacquet-side catch-up port; the equivalent features already exist in the TypeScript CLI, so there is no TS-side change and no changeset is needed.

Squash Commit Body

Port the remaining `pnpm audit` fix/ignore features to pacquet, which
previously implemented only the read/report path.

- `--ignore <GHSA>` / `--ignore-unfixable`: suppress advisories and persist
  GHSAs to `auditConfig.ignoreGhsas`.
- `--fix` (override): write `^patched` overrides to the `overrides:` block.
- `--fix update`: re-resolve to non-vulnerable versions via a resolver-time
  PackageVersionGuard carried through the existing ResolutionObserver seam;
  report fixed vs. remaining from the post-update lockfile.
- `-i` / `--interactive`: pick advisories to fix via a dialoguer multi-select.
- minimumReleaseAge handling for both fix paths: patched versions are merged
  into minimumReleaseAgeExclude (new merge_package_version_specs in the config
  crate) and injected into the in-process update's resolve so the maturity
  cutoff doesn't block the fix.

New format-preserving writers (set_overrides, set_audit_ignore_ghsas,
set_minimum_release_age_excludes) land in the workspace-manifest writer.
Normal installs are unchanged: the resolve override is None unless an
audit-fix observer is installed.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
    (pacquet-side catch-up port; the features already exist in the TS CLI.)
  • Added or updated tests.

Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • New Features
    • audit adds --fix (including --interactive), --ignore (repeatable), and --ignore-unfixable; it can persist fixes and ignored advisories to pnpm-workspace.yaml, including updates to minimumReleaseAgeExclude.
    • update now honors additional minimum release-age exclude overrides during version selection.
    • Workspace manifest editing now performs idempotent updates/removals for auditConfig.ignoreGhsas and minimumReleaseAgeExclude.
  • Bug Fixes
    • Improved audit --fix reporting and behavior, including validation errors for invalid fix methods and safer “update-fix” handling to avoid vulnerable resolutions.
    • Detects conflicting non-string overrides and refuses to overwrite them.

@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 audit fix and ignore CLI options, writes related workspace-manifest keys, and threads resolution-observer data through update/install so minimum-release-age exclude specs can be merged during re-resolution.

Changes

Audit fix and ignore flow

Layer / File(s) Summary
Workspace manifest edits
pacquet/crates/workspace-manifest-writer/src/model.rs, pacquet/crates/workspace-manifest-writer/src/edit.rs, pacquet/crates/workspace-manifest-writer/src/lib.rs, pacquet/crates/workspace-manifest-writer/src/tests.rs
pnpm-workspace.yaml parsing and editing now round-trip overrides, auditConfig.ignoreGhsas, and minimumReleaseAgeExclude, with tests for the new YAML shapes.
Minimum-release-age resolution plumbing
pacquet/crates/config/src/version_policy.rs, pacquet/crates/config/src/version_policy/tests.rs, pacquet/crates/package-manager/src/resolution_observer.rs, pacquet/crates/package-manager/src/resolution_policy.rs, pacquet/crates/package-manager/src/update.rs, pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs, pacquet/crates/cli/src/cli_args/update.rs
ResolutionObserver can supply extra minimumReleaseAgeExclude specs, PickPolicy merges them, and update/install wiring passes the observer through.
Audit CLI flow
pacquet/crates/cli/Cargo.toml, pacquet/crates/cli/src/cli_args.rs, pacquet/crates/cli/src/cli_args/audit.rs, pacquet/crates/cli/src/cli_args/audit/tests.rs, pacquet/crates/cli/tests/audit.rs
audit now parses fix and ignore options, dispatches by reporter type, applies override or update fixes, persists ignore settings, and adds unit and integration coverage.

Sequence Diagram(s)

sequenceDiagram
  participant CliArgs as CliArgs::run
  participant AuditArgs as AuditArgs::run
  participant WorkspaceWriter as workspace-manifest-writer
  participant UpdateRun as Update::run
  participant InstallRun as InstallWithFreshLockfile::run
  participant ResolutionObserver as ResolutionObserver
  participant PickPolicy as PickPolicy::from_config_with_extra_excludes

  CliArgs->>AuditArgs: args.run::<ReporterType>(command_state)
  AuditArgs->>WorkspaceWriter: set_overrides / set_audit_ignore_ghsas / set_minimum_release_age_excludes
  AuditArgs->>UpdateRun: build Update with resolution_observer
  UpdateRun->>InstallRun: pass resolution_observer to Install
  InstallRun->>ResolutionObserver: minimum_release_age_exclude_override()
  ResolutionObserver-->>InstallRun: extra excludes
  InstallRun->>PickPolicy: merge extra excludes into policy
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • pnpm/pnpm#12637: Extends the audit-command work by adding fix/ignore handling and reporter-typed dispatch on top of earlier audit reporting changes.
  • pnpm/pnpm#12046: Shares the Update/install resolution path and observer plumbing used to pass extra minimumReleaseAgeExclude data through dependency resolution.

Suggested labels

product: pacquet

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pacquet-audit-fix-ignore

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

Port pnpm audit fix/ignore/interactive flows to pacquet (Rust)
✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

Description

• Add pacquet audit support for --fix, --ignore, --ignore-unfixable, and --interactive.
• Implement --fix update via resolver-time vulnerability guards and minimumReleaseAge exclusions.
• Add format-preserving pnpm-workspace.yaml writers plus unit and end-to-end test coverage.
Diagram

graph TD
  A["CLI: pacquet audit"] --> B["Audit handler"] --> C{"Fix mode?"}
  B --> H{{"Registry audit API"}}
  C -->|"override"| D[/"pnpm-workspace.yaml writer"/]
  C -->|"update"| E["Update resolver"] --> F["ResolutionObserver"] --> G["PickPolicy (age excludes)"]
  subgraph Legend
    direction LR
    _cli["CLI command"] ~~~ _dec{"Decision"} ~~~ _file[/"Workspace file"/] ~~~ _ext{{"External"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Lockfile-only remediation (no guarded resolve)
  • ➕ Potentially faster than running a full update/install pipeline
  • ➕ Avoids adding new observer surface area into resolver plumbing
  • ➖ Hard to do correctly across dependency graphs; risks inconsistent snapshots
  • ➖ Would diverge from pnpm behavior and miss “picker fallback” semantics
2. Always use overrides (skip `--fix update`)
  • ➕ Simpler implementation surface (workspace manifest writes only)
  • ➕ No changes required in resolver/update machinery
  • ➖ Doesn’t replicate pnpm’s update-based remediation workflow
  • ➖ Overrides can be broader than necessary and may not converge dependency tree

Recommendation: Keep the current two-strategy port. The override path is the minimal, deterministic fix mechanism, while --fix update matches pnpm’s behavior by letting the resolver naturally fall back to safe versions via a guard. Using the existing ResolutionObserver seam (with defaulted trait methods) is the right containment strategy: it avoids impacting normal installs/updates unless an audit-fix observer is supplied.

Files changed (16) +1697 / -61

Enhancement (10) +1104 / -35
Cargo.tomlAdd resolver-base dependency for audit fix update guard +1/-0

Add resolver-base dependency for audit fix update guard

• Adds 'pacquet-resolving-resolver-base' as a CLI dependency to use the shared 'PackageVersionGuard' APIs for 'audit --fix update'.

pacquet/crates/cli/Cargo.toml

audit.rsImplement audit --fix/--ignore/--interactive and update-based fixing +674/-32

Implement audit --fix/--ignore/--interactive and update-based fixing

• Adds new audit CLI flags ('--fix [override|update]', '--ignore', '--ignore-unfixable', '--interactive') and ports pnpm’s fix/ignore behaviors. Implements override-based fixes by writing 'overrides:' and (when configured) 'minimumReleaseAgeExclude', and implements update-based fixes via an 'Update' run with a resolver-time 'PackageVersionGuard' plus an observer-provided minimumReleaseAge exclude override.

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

version_policy.rsAdd canonical merge for package version policy specs +61/-0

Add canonical merge for package version policy specs

• Introduces 'merge_package_version_specs', mirroring pnpm’s merge logic to dedupe/sort exact versions per package while preserving first-seen package order. Used to keep 'minimumReleaseAgeExclude' canonical when appending patched versions.

pacquet/crates/config/src/version_policy.rs

install_with_fresh_lockfile.rsPlumb minimumReleaseAgeExclude overrides from resolution observer into pick policy +8/-2

Plumb minimumReleaseAgeExclude overrides from resolution observer into pick policy

• Reads a new observer-provided minimumReleaseAgeExclude override and uses it when building the resolver pick policy, allowing patched versions through maturity cutoffs during audit fix update runs.

pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs

resolution_observer.rsExtend ResolutionObserver with minimumReleaseAgeExclude override hook +9/-0

Extend ResolutionObserver with minimumReleaseAgeExclude override hook

• Adds a defaulted 'minimum_release_age_exclude_override' method to 'ResolutionObserver' so specialized runs can inject additional maturity exclusions without changing existing call sites.

pacquet/crates/package-manager/src/resolution_observer.rs

resolution_policy.rsAdd PickPolicy constructor that merges extra minimumReleaseAgeExclude specs +19/-0

Add PickPolicy constructor that merges extra minimumReleaseAgeExclude specs

• Implements 'PickPolicy::from_config_with_extra_excludes' to merge additional exclude specs on top of config before compiling the version policy, supporting audit-fix update’s in-process override behavior.

pacquet/crates/package-manager/src/resolution_policy.rs

update.rsAllow Update to carry a ResolutionObserver into install/resolution +10/-1

Allow Update to carry a ResolutionObserver into install/resolution

• Adds an optional 'resolution_observer' field to 'Update' and threads it through to the underlying install so 'audit --fix update' can supply a guard that rejects vulnerable versions.

pacquet/crates/package-manager/src/update.rs

edit.rsAdd format-preserving edit ops for overrides, audit ignore list, and age excludes +181/-0

Add format-preserving edit ops for overrides, audit ignore list, and age excludes

• Implements manifest edit helpers to upsert 'overrides:' entries, set/remove 'auditConfig.ignoreGhsas' as a nested sequence, and set/remove top-level 'minimumReleaseAgeExclude' as a block sequence while preserving formatting and key ordering.

pacquet/crates/workspace-manifest-writer/src/edit.rs

lib.rsExpose public APIs to write audit-related workspace settings +91/-0

Expose public APIs to write audit-related workspace settings

• Adds 'set_overrides', 'set_audit_ignore_ghsas', and 'set_minimum_release_age_excludes' to update 'pnpm-workspace.yaml' only when content changes, preserving existing formatting and removing blocks when lists become empty.

pacquet/crates/workspace-manifest-writer/src/lib.rs

model.rsParse overrides/auditConfig/minimumReleaseAgeExclude for no-op detection +50/-0

Parse overrides/auditConfig/minimumReleaseAgeExclude for no-op detection

• Extends the manifest model to retain clean-string overrides, audit ignore GHSA lists, and minimumReleaseAgeExclude lists. Adds tolerant decoding for pnpm’s alternate overrides shapes so parsing doesn’t fail on existing files.

pacquet/crates/workspace-manifest-writer/src/model.rs

Refactor (2) +18 / -6
cli_args.rsRun audit under selected reporter type +17/-6

Run audit under selected reporter type

• Refactors the audit command execution to dispatch 'AuditArgs::run' with the chosen reporter implementation (default/append-only, ndjson, silent).

pacquet/crates/cli/src/cli_args.rs

update.rsInitialize Update with no resolution observer for normal update +1/-0

Initialize Update with no resolution observer for normal update

• Updates the 'pacquet update' CLI path to explicitly pass 'resolution_observer: None', keeping default update behavior unchanged.

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

Tests (4) +575 / -20
tests.rsUnit tests for audit fix helpers and resolver guard +161/-0

Unit tests for audit fix helpers and resolver guard

• Adds tests for caret conversion of patched ranges, override generation, advisory filtering, vulnerability guard decisions, fix-update output formatting, and minimumReleaseAgeExclude computation.

pacquet/crates/cli/src/cli_args/audit/tests.rs

audit.rsEnd-to-end coverage for audit fix/ignore flows +221/-20

End-to-end coverage for audit fix/ignore flows

• Replaces prior “unsupported flag” assertions with e2e tests verifying '--fix' (override) writes workspace overrides and minimumReleaseAgeExclude, '--ignore'/'--ignore-unfixable' persist 'auditConfig.ignoreGhsas', invalid '--fix' values error, and '--fix update' can move resolution to a non-vulnerable version via guarded re-resolve.

pacquet/crates/cli/tests/audit.rs

tests.rsTests for merge_package_version_specs behavior +31/-0

Tests for merge_package_version_specs behavior

• Adds unit tests covering sorting, deduplication, first-seen package order preservation, bare-name absorption semantics, and union merging.

pacquet/crates/config/src/version_policy/tests.rs

tests.rsWriter tests for overrides, audit ignore config, and minimumReleaseAgeExclude +162/-0

Writer tests for overrides, audit ignore config, and minimumReleaseAgeExclude

• Adds unit tests validating block creation, quoting behavior, merge ordering, no-op writes, list replacement, key insertion into existing 'auditConfig', and block removal when lists are emptied.

pacquet/crates/workspace-manifest-writer/src/tests.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 (16) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Update fix ignores scope 🐞 Bug ⛨ Security
Description
fix_with_update() hard-codes include_direct to Prod+Dev+Optional, so `pacquet audit --fix
update` can update additional dependency groups (and run their scripts) even when the audit itself
was scoped with --prod/--dev/--no-optional, causing unexpected lockfile churn and a wider
execution surface.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1834-1838]

+            include_direct: vec![
+                DependencyGroup::Prod,
+                DependencyGroup::Dev,
+                DependencyGroup::Optional,
+            ],
Evidence
The audit command computes an include based on dependency options, but the fix-update path
constructs Update with include_direct hard-coded to all groups. The update implementation
explicitly uses include_direct when snapshotting included direct dependencies and notes group
narrowing scopes the update, so hard-coding all groups breaks expected scoping and increases side
effects.

pacquet/crates/cli/src/cli_args/audit.rs[156-158]
pacquet/crates/cli/src/cli_args/audit.rs[233-240]
pacquet/crates/cli/src/cli_args/audit.rs[1834-1843]
pacquet/crates/package-manager/src/update.rs[239-283]

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 audit --fix update` currently invokes `Update` with `include_direct` set to all dependency groups (Prod/Dev/Optional) regardless of how the audit was scoped. This means a user running a production-only audit fix can still trigger updates (and script execution) in dev/optional dependencies and produce broader lockfile changes than requested.
## Issue Context
- `AuditArgs::run()` already computes the audit scope via `self.dependency_options`.
- The update engine uses `include_direct` to decide which direct dependencies participate in update planning.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[156-240]
- pacquet/crates/cli/src/cli_args/audit.rs[1782-1846]
## Implementation notes
- Compute `include_direct = self.dependency_options.include_direct()` alongside `include`.
- Thread `include_direct` into `fix_with_update(...)` (add a parameter) and pass it through to the `Update { include_direct: ... }` struct literal instead of the current hard-coded `vec![Prod, Dev, Optional]`.
- Add/adjust a test to cover `pacquet audit --prod --fix update` (or equivalent) ensuring only prod direct deps are eligible for update planning.

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


2. Module name not validated 🐞 Bug ⛨ Security
Description
classify_for_update uses AuditAdvisory.module_name verbatim as the key for vulnerability
tracking/guarding; if the registry returns a malformed name (e.g., trailing whitespace), the
resolver guard won't apply to the real package and report_fixed_remaining can incorrectly mark the
advisory fixed because the lockfile’s installed-name set won’t contain the mismatched string. This
can yield a false clean exit (status 0) while vulnerable packages remain installed.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1759-1768]

+        let range = advisory.vulnerable_versions.trim();
+        if range == ">=0.0.0" || range == "*" {
+            unfixable.entry(advisory.module_name.clone()).or_default().push(advisory.id);
+            continue;
+        }
+        let Ok(range) = range.parse::<Range>() else {
+            unparsable.push(advisory.id);
+            continue;
+        };
+        vulnerabilities.entry(advisory.module_name.clone()).or_default().push((advisory.id, range));
Evidence
The code explicitly treats the registry as untrusted but only trims/parses vulnerable_versions; it
still uses advisory.module_name.clone() as the HashMap key. Later, installed package names come
from lockfile snapshot keys (key.name.to_string()), and report_fixed_remaining marks an advisory
fixed when installed.names does not contain the (string-keyed) advisory name, so a name mismatch
can incorrectly classify advisories as fixed/clean.

pacquet/crates/cli/src/cli_args/audit.rs[1751-1769]
pacquet/crates/cli/src/cli_args/audit.rs[1859-1867]
pacquet/crates/cli/src/cli_args/audit.rs[1901-1904]

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

## Issue description
`audit --fix update` uses `AuditAdvisory.module_name` as a trusted lookup key for both (1) the resolver-time `VulnerabilityGuard` ranges map and (2) the post-update `installed.names.contains(name)` fixed/remaining classification. Because the audit response is untrusted, a malformed `module_name` (e.g., whitespace-padded) can bypass guarding and be treated as “not installed”, causing incorrect “fixed/clean” reporting.
## Issue Context
- `classify_for_update` already treats the registry as untrusted for `vulnerable_versions` (it trims before parsing) but does not apply similar normalization/validation to `module_name`.
- Installed package names are read from the lockfile snapshot keys and compared via exact string equality.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1751-1769]
- pacquet/crates/cli/src/cli_args/audit.rs[1859-1874]
- pacquet/crates/cli/src/cli_args/audit.rs[1893-1905]
## What to change
- Introduce a small “canonical advisory package name” step for audit advisories used in `--fix update`:
- `let name = advisory.module_name.trim();` (at minimum), and ideally also validate it matches the expected npm package name grammar and error/mark-remaining if not.
- Use the canonicalized name consistently for:
- keys in `vulnerabilities` / `unfixable`
- the `guard_ranges` map
- comparisons against `installed.names` / `installed.versions`
- Add a targeted unit test that feeds an advisory with `module_name` containing leading/trailing whitespace and asserts it is not misclassified as fixed when the real package remains installed.

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


3. Multiline YAML corruption 🐞 Bug ⛨ Security
Description
The new manifest writers build YAML by concatenating render_value() into single-line key: value
/ - item strings; if an input string contains newlines/control characters that cause YAML to
render as a multi-line scalar, the splice produces invalid YAML and can persistently corrupt
pnpm-workspace.yaml. This is reachable via user-controlled --ignore values and
registry-controlled strings that can flow into minimumReleaseAgeExclude entries.
Code

pacquet/crates/workspace-manifest-writer/src/edit.rs[R240-283]

+/// Render a top-level block whose value is a block sequence (`key:` then
+/// `  - item` lines).
+fn render_top_level_sequence(key: &str, items: &[String]) -> String {
+    let mut block = String::new();
+    block.push_str(key);
+    block.push_str(":\n");
+    for item in items {
+        block.push_str("  - ");
+        block.push_str(&render::render_value(item));
+        block.push('\n');
+    }
+    block
+}
+
+/// Render a brand-new `auditConfig:` block holding `ignoreGhsas`. GHSA IDs are
+/// plain scalars, but route through [`render::render_value`] for safety.
+fn render_audit_config_block(ghsas: &[String]) -> String {
+    let mut block = String::from("auditConfig:\n  ignoreGhsas:\n");
+    for ghsa in ghsas {
+        block.push_str("    - ");
+        block.push_str(&render::render_value(ghsa));
+        block.push('\n');
+    }
+    block
+}
+
+/// Upsert a `key:` entry whose value is a block sequence (`items`) into the
+/// existing top-level mapping `block_name`, creating or replacing the entry
+/// in the position pnpm's reorder pass would choose. The mapping at
+/// `block_name` must already exist. Used to write `auditConfig.ignoreGhsas`.
+fn upsert_sequence_entry(text: &str, block_name: &str, key: &str, items: &[String]) -> String {
+    let mapping = locate(text, &[block_name]).expect("block exists");
+    let item_indent = mapping.entry_indent + 2;
+    let mut rendered = String::new();
+    rendered.push_str(&" ".repeat(mapping.entry_indent));
+    rendered.push_str(&render::render_value(key));
+    rendered.push_str(":\n");
+    for item in items {
+        rendered.push_str(&" ".repeat(item_indent));
+        rendered.push_str("- ");
+        rendered.push_str(&render::render_value(item));
+        rendered.push('\n');
+    }
+
Evidence
render_top_level_sequence, render_audit_config_block, and upsert_sequence_entry build YAML
lines by prefixing "  - " / indentation and then appending render::render_value(...) directly,
which only works if the rendered scalar is single-line. render_value delegates to
yaml_serde::to_string and does not guarantee a single-line output for arbitrary strings.

pacquet/crates/workspace-manifest-writer/src/edit.rs[240-306]
pacquet/crates/workspace-manifest-writer/src/render.rs[80-87]

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

## Issue description
New YAML block writers assume `render::render_value()` always returns a single-line scalar. If the rendered scalar contains newlines (or other formatting that expands to multi-line YAML), the string-concatenation logic will write malformed YAML, corrupting `pnpm-workspace.yaml`.
### Issue Context
These writers are now used for `auditConfig.ignoreGhsas` and `minimumReleaseAgeExclude`, and can be fed by user input (`--ignore`) and by registry-derived strings used to build exclude specs.
### Fix Focus Areas
- pacquet/crates/workspace-manifest-writer/src/edit.rs[240-306]
- pacquet/crates/workspace-manifest-writer/src/render.rs[80-87]
### Implementation notes
- Add a validation step before writing any value into these block-style renderers to reject strings containing `\n`, `\r`, or other control characters that could force multi-line YAML output.
- Alternatively, change the renderers to properly indent multi-line YAML scalars (more complex). For these fields (GHSA IDs and version-policy specs), rejecting multi-line/control inputs is likely the simplest and safest.

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


View more (9)
4. Non-semver marked fixed 🐞 Bug ⛨ Security
Description
fix_with_update() only records installed packages when the snapshot key suffix parses as semver
(version_semver()), so packages installed via non-semver lockfile identifiers (e.g. file: /
tarball / git) are treated as absent and their advisories are reported as fixed. This can cause
pacquet audit --fix update to incorrectly report a clean/fixed state, undermining
security/compliance automation.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1856-1861]

+    let mut installed: HashMap<String, Vec<Version>> = HashMap::new();
+    if let Some(snapshots) = updated.snapshots.as_ref() {
+        for key in snapshots.keys() {
+            if let Some(version) = key.suffix.version_semver() {
+                installed.entry(key.name.to_string()).or_default().push(version.clone());
+            }
Evidence
The post-update installed-package scan only inserts a package into installed when
version_semver() returns Some, but version_semver() explicitly returns None for File and
NonSemver snapshot versions. Therefore, packages present only via non-semver snapshot keys are
treated as uninstalled and advisories for them will take the installed.get(name) == None “fixed”
path.

pacquet/crates/cli/src/cli_args/audit.rs[1856-1889]
pacquet/crates/lockfile/src/pkg_ver_peer.rs[109-117]

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

## Issue description
`fix_with_update()` determines whether an advisory is fixed by scanning the updated lockfile and building an `installed` map keyed by package name. Today it only inserts entries when `key.suffix.version_semver()` returns `Some(_)`, which excludes `VersionPart::File` and `VersionPart::NonSemver` snapshot keys. For packages that remain installed but have only non-semver snapshot keys, `installed.get(name)` returns `None` and the advisory is incorrectly counted as fixed.
### Issue Context
This impacts the correctness of the security fix reporting for `pacquet audit --fix update`. The resolver-time guard may also not be able to reason about non-semver versions, but the post-update reporting must be conservative and must not mark such advisories fixed just because the version wasn’t semver-parsable.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1856-1890]
- Build a separate `installed_names: HashSet<String>` from *all* snapshot keys (regardless of semver parsing).
- Keep `installed_semver_versions: HashMap<String, Vec<Version>>` for the range checks.
- Classification logic:
- If `installed_names` does not contain `name` → fixed.
- If `installed_names` contains `name` but there are no semver versions available to evaluate → treat as **remaining** (cannot prove fixed).
- For `unfixable`, use `installed_names.contains(name)` instead of `installed.contains_key(name)`.
- Add a test that creates a lockfile snapshot for an advisory’s package with a `NonSemver` or `file:` version and asserts it is counted as remaining, not fixed.

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


5. Flow overrides YAML corruption 🐞 Bug ⛨ Security
Description
set_overrides() performs block-style splices into an existing overrides: mapping but does not
refuse flow/inline YAML (e.g. overrides: { foo: bar }), so it can splice indented block entries
after an inline value and corrupt pnpm-workspace.yaml. This can break subsequent installs/updates
by leaving invalid workspace config on disk.
Code

pacquet/crates/workspace-manifest-writer/src/lib.rs[R249-262]

let mut changed = false;
for (selector, specifier) in entries {
+        // Refuse to overwrite a hand-written non-string (parent-scoped
+        // object) override value with a scalar — that would corrupt config.
+        if manifest.non_scalar_overrides.contains(selector) {
+            return Err(UpdateWorkspaceManifestError::OverrideConflict {
+                key: selector.to_string(),
+                path,
+            });
+        }
  changed |= edit::add_overrides(&mut manifest, selector, specifier)
      .map_err(|source| UpdateWorkspaceManifestError::Edit { path: path.clone(), source })?;
}
Evidence
set_overrides lacks an inline-value guard (unlike set_audit_ignore_ghsas). The splice insertion
path uses locate()/insert_rendered_entry_at() which compute insertion offsets based on a block
body; with a flow mapping there are no child lines, so insertion happens at the end of the key line
(after the inline value), yielding invalid YAML.

pacquet/crates/workspace-manifest-writer/src/lib.rs[232-268]
pacquet/crates/workspace-manifest-writer/src/lib.rs[291-298]
pacquet/crates/workspace-manifest-writer/src/edit.rs[832-863]
pacquet/crates/workspace-manifest-writer/src/edit.rs[586-610]

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

## Issue description
`workspace-manifest-writer::set_overrides()` edits the `overrides:` block using indentation-based splices that assume block-style YAML. If `pnpm-workspace.yaml` uses a valid flow-style inline mapping (`overrides: { ... }`), the splice logic can inject block entries after the inline value, producing invalid YAML.
### Issue Context
The PR already added an inline-value guard for `auditConfig` (`UnsupportedInlineBlock` via `top_level_has_inline_value`), but `set_overrides` did not get the same protection.
### Fix Focus Areas
- pacquet/crates/workspace-manifest-writer/src/lib.rs[232-268]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[832-863]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[586-610]
### Suggested fix
1. In `set_overrides()`, add the same guard used by `set_audit_ignore_ghsas()`:
- `if edit::top_level_has_inline_value(manifest.text(), "overrides") { return Err(UpdateWorkspaceManifestError::UnsupportedInlineBlock { path, key: "overrides".to_string() }); }`
2. Add a unit test similar to `ignore_ghsas_refuses_inline_flow_audit_config` that seeds `pnpm-workspace.yaml` with `overrides: { foo: 1.0.0 }` and asserts `set_overrides()` returns `UnsupportedInlineBlock` and leaves the file unchanged.

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


6. Interactive update omits advisories 🐞 Bug ≡ Correctness
Description
interactive_select only allows selecting advisories with patched_versions.is_some(), but `--fix
update operates on vulnerable_versions` ranges and can remediate advisories even when
patched_versions cannot be inferred. As a result, pacquet audit --fix update --interactive can
prevent users from selecting/fixing vulnerabilities that the non-interactive update fix would
handle.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1678-1681]

+    let mut fixable: Vec<&AuditAdvisory> =
+        advisories.values().filter(|advisory| advisory.patched_versions.is_some()).collect();
+    fixable.sort_by_key(|advisory| std::cmp::Reverse(severity_number(advisory.severity)));
+
Evidence
The interactive UI filters on patched_versions, but patched_versions is only inferred for
certain vulnerable-range shapes, while the update fix path uses vulnerable_versions parsing and
does not require patched_versions. This mismatch makes --fix update --interactive incomplete.

pacquet/crates/cli/src/cli_args/audit.rs[212-240]
pacquet/crates/cli/src/cli_args/audit.rs[1675-1681]
pacquet/crates/cli/src/cli_args/audit.rs[1361-1378]
pacquet/crates/cli/src/cli_args/audit.rs[1751-1766]

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

## Issue description
`interactive_select()` filters the advisory list to those with `patched_versions.is_some()`, which is appropriate for the override-based fix strategy but not for the update-based strategy. The update strategy (`fix_with_update`) uses `vulnerable_versions` range parsing and a resolver-time `PackageVersionGuard`, so advisories lacking an inferred `patched_versions` can still be update-fixable.
### Issue Context
- `patched_versions` is derived by `infer_patched_versions()`, which only returns `Some(...)` when the vulnerable range has an upper bound (`<`/`<=`).
- `fix_with_update()` does not rely on `patched_versions`.
- The current code applies `interactive_select()` before dispatching between `FixMethod::Override` and `FixMethod::Update`, so this impacts `--fix update`.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[212-258]
- pacquet/crates/cli/src/cli_args/audit.rs[1675-1735]
- pacquet/crates/cli/src/cli_args/audit.rs[1361-1378]
- pacquet/crates/cli/src/cli_args/audit.rs[1751-1766]
### What to change
- Make the interactive selection criteria depend on `fix_method`:
- For `FixMethod::Override`: keep the existing `patched_versions.is_some()` filter.
- For `FixMethod::Update`: include advisories that are *potentially update-fixable* (e.g., those whose `vulnerable_versions` parses as a `Range` and is not the explicit-unfixable `>=0.0.0`/`*` case).
- Alternatively (if pnpm semantics require it), reject `--interactive` when `--fix update` is selected with a clear error.
- Add/adjust tests to cover `audit --fix update --interactive` selecting an advisory where `patched_versions` is `None` but `vulnerable_versions` is parseable.

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


7. Flow auditConfig corrupts YAML 🐞 Bug ☼ Reliability
Description
set_audit_ignore_ghsas assumes auditConfig: is a block-style mapping; if pnpm-workspace.yaml
uses valid flow-style YAML (e.g. auditConfig: {ignoreGhsas: [...]}), the line-based
locate/upsert_sequence_entry logic splices an indented ignoreGhsas: block after the key line
instead of rewriting the flow mapping. This can produce an invalid pnpm-workspace.yaml (config
corruption / command breakage).
Code

pacquet/crates/workspace-manifest-writer/src/edit.rs[R180-187]

+    let text = manifest.text();
+    if locate(text, &[BLOCK]).is_some() {
+        let new_text = upsert_sequence_entry(text, BLOCK, "ignoreGhsas", ghsas);
+        manifest.set_text(new_text);
+    } else {
+        let block = render_audit_config_block(ghsas);
+        let new_text = insert_top_level_block(manifest, BLOCK, &block);
+        manifest.set_text(new_text);
Evidence
set_audit_ignore_ghsas chooses the in-place upsert path whenever locate(text,["auditConfig"])
finds a key; locate() returns a Mapping even when there is no indented body (flow-style),
setting body_start to the end of the key line. When no existing entry is found,
upsert_sequence_entry splices the rendered block sequence at that offset, which is invalid under a
flow-style value.

pacquet/crates/workspace-manifest-writer/src/edit.rs[141-193]
pacquet/crates/workspace-manifest-writer/src/edit.rs[270-306]
pacquet/crates/workspace-manifest-writer/src/edit.rs[832-863]

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 new `set_audit_ignore_ghsas()` writer uses `locate()` + `upsert_sequence_entry()` which assumes the target node (`auditConfig`) is a block mapping with an indented body. For flow-style YAML like `auditConfig: {ignoreGhsas: [..]}`, `locate()` still returns a `Mapping`, but with no child entries and `body_start` at the end of the `auditConfig:` line; `upsert_sequence_entry()` then splices a block sequence under a flow value, corrupting the YAML.
### Issue Context
This is a format-preserving writer; users may have hand-written flow-style YAML even if pnpm typically emits block style.
### Fix Focus Areas
- pacquet/crates/workspace-manifest-writer/src/edit.rs[141-193]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[270-306]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[832-863]
### What to change
- Detect when `auditConfig:` is not a block mapping (e.g., the `auditConfig:` line has a non-empty value after the structural colon, indicating flow/scalar form).
- In that case, rewrite/replace the entire `auditConfig` block to a canonical block-style mapping containing `ignoreGhsas` (and preserve/merge any other `auditConfig` keys if present).
- If preserving other keys is hard in flow form, prefer a safe behavior: parse with a YAML AST library for that node, or refuse with a targeted error explaining the unsupported YAML shape.
- Add a test case with `auditConfig: {ignoreGhsas: [GHSA-aaaa-bbbb-cccc]}` and ensure `set_audit_ignore_ghsas()` rewrites it to valid YAML without producing mixed flow+block structure.

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


8. Untrimmed unfixable ranges 🐞 Bug ☼ Reliability
Description
classify_for_update checks for unfixable ">=0.0.0" / "*" using the raw vulnerable_versions
string; if the registry includes surrounding whitespace, the advisory may be misclassified and
(depending on parsing) can lead to overly-aggressive guarding or incorrect remaining/fixed
accounting in audit --fix update. This is inconsistent with other audit parsing code that already
trims before interpreting ranges.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1757-1764]

+    for advisory in advisories.values() {
+        let range = advisory.vulnerable_versions.as_str();
+        if range == ">=0.0.0" || range == "*" {
+            unfixable.entry(advisory.module_name.clone()).or_default().push(advisory.id);
+            continue;
+        }
+        let Ok(range) = range.parse::<Range>() else {
+            unparseable.push(advisory.id);
Evidence
The update classification uses the raw vulnerable_versions string for unfixable detection, while
other range interpretation paths already call .trim() first, showing the inconsistency and the
likely misclassification on whitespace-tainted registry input.

pacquet/crates/cli/src/cli_args/audit.rs[1753-1767]
pacquet/crates/cli/src/cli_args/audit.rs[1362-1364]

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

## Issue description
`classify_for_update()` compares `advisory.vulnerable_versions` to sentinel strings without trimming. Because registry responses are untrusted, harmless whitespace around values like `">=0.0.0"` / `"*"` can bypass the unfixable classification and change behavior of `audit --fix update`.
### Issue Context
Other audit range logic already trims before interpreting the range (e.g., `infer_patched_versions(vulnerable_range.trim())`), so this inconsistency is easy to miss.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1757-1767]
### Suggested fix
- Change `let range = advisory.vulnerable_versions.as_str();` to something like:
- `let range_str = advisory.vulnerable_versions.trim();`
- Use `range_str` for both the `">=0.0.0"` / `"*"` checks and for `Range::parse(range_str)`.
- Consider normalizing common sentinel whitespace forms explicitly (e.g., trim then compare).

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


9. Missing lockfile marked fixed 🐞 Bug ≡ Correctness
Description
fix_with_update() accepts Ok(None) when re-reading pnpm-lock.yaml after running Update,
leaving the installed-packages map empty and then classifying advisories as fixed. This can make
pacquet audit --fix update report a clean/fixed result even though it could not verify the
post-update dependency graph.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1843-1861]

+    let updated = Lockfile::load_wanted_from_dir(lockfile_dir)
+        .map_err(|err| miette::Report::new(err).wrap_err("re-read the lockfile after update"))?;
+    let mut installed: HashMap<String, Vec<Version>> = HashMap::new();
+    if let Some(updated) = updated.as_ref()
+        && let Some(snapshots) = updated.snapshots.as_ref()
+    {
+        for key in snapshots.keys() {
+            if let Some(version) = key.suffix.version_semver() {
+                installed.entry(key.name.to_string()).or_default().push(version.clone());
+            }
+        }
+    }
+
+    let mut fixed: Vec<u64> = Vec::new();
+    let mut remaining: Vec<u64> = Vec::new();
+    for (name, entries) in &vulnerabilities {
+        match installed.get(name) {
+            None => fixed.extend(entries.iter().map(|(id, _)| *id)),
+            Some(versions) => {
Evidence
The code re-reads the lockfile into an Option, but if it is None it simply skips populating
installed, and later treats any package missing from installed as fixed. The lockfile loader
explicitly returns Ok(None) when the file is absent/empty, and pnpm’s reference implementation
throws an error when no lockfile is found after update.

pacquet/crates/cli/src/cli_args/audit.rs[1843-1870]
pacquet/crates/lockfile/src/load_lockfile.rs[56-63]
pacquet/crates/lockfile/src/load_lockfile.rs[86-95]
pnpm11/deps/compliance/commands/src/audit/fixWithUpdate.ts[113-117]

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

## Issue description
`fix_with_update()` re-reads the wanted lockfile after running `Update`, but if the lockfile is missing/empty (`Ok(None)`), it proceeds with an empty `installed` map and marks advisories as fixed. This should be treated as an error (cannot report fixed vs remaining reliably).
## Issue Context
- `Lockfile::load_wanted_from_dir()` returns `Ok(None)` on NotFound/empty main document.
- pnpm’s `fixWithUpdate` throws when the lockfile is missing after update.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1843-1861]
- pacquet/crates/lockfile/src/load_lockfile.rs[56-63]
## Suggested change
- After `load_wanted_from_dir(lockfile_dir)?`, require `Some(lockfile)`.
- If `None`, return a dedicated audit error (or a miette error) similar to pnpm’s `AUDIT_NO_LOCKFILE`, e.g. "No pnpm-lock.yaml found after update: Cannot report fixed vulnerabilities".
- Ensure the command exits non-zero in this case (so CI can’t get a false-clean result).

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


10. Overrides overwrite nested objects 🐞 Bug ≡ Correctness
Description
set_overrides can overwrite an existing overrides: entry whose value is a nested (parent-scoped)
object with a scalar string override, because non-scalar override values are dropped during manifest
parse and the writer then blindly Replaces the key’s value. This can silently destroy user
configuration and change resolution behavior when a selector key (e.g. foo@<2.0.0) is already used
in nested form.
Code

pacquet/crates/workspace-manifest-writer/src/model.rs[R146-153]

+        let overrides = data.overrides.map(|entries| {
+            entries
+                .into_iter()
+                .filter_map(|(name, value)| match value {
+                    OverrideValue::Clean(specifier) => Some((name, specifier)),
+                    OverrideValue::Other(_) => None,
+                })
+                .collect()
Evidence
The manifest parser explicitly drops non-string override values, so later no-op detection can’t see
existing object-valued overrides; the override writer then uses replace_value_at (yamlpatch
Op::Replace) when a key exists, which will overwrite an object node with a scalar string.

pacquet/crates/workspace-manifest-writer/src/model.rs[70-78]
pacquet/crates/workspace-manifest-writer/src/model.rs[146-154]
pacquet/crates/workspace-manifest-writer/src/edit.rs[119-140]
pacquet/crates/workspace-manifest-writer/src/edit.rs[310-339]
pacquet/crates/workspace-manifest-writer/src/edit.rs[541-569]

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

## Issue description
`pnpm-workspace.yaml` supports both scalar override values and nested (parent-scoped) override objects. The new writer logic parses overrides but drops non-scalar values, then later rewrites/"replaces" existing YAML entries purely by key. If the key already exists with an object value, `yamlpatch` replaces that entire mapping with a scalar, destroying configuration.
## Issue Context
This is user-config corruption: a repo that already uses parent-scoped overrides can have them silently rewritten by `pacquet audit --fix` if the selector key collides (`name@range` selectors are valid for parent-scoped overrides too).
## Fix Focus Areas
- pacquet/crates/workspace-manifest-writer/src/model.rs[70-78]
- pacquet/crates/workspace-manifest-writer/src/model.rs[146-154]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[119-140]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[310-339]
- pacquet/crates/workspace-manifest-writer/src/edit.rs[541-569]
### Suggested approach
- Preserve the override value shape in the parsed model (e.g., store `OverrideValue` instead of filtering to only `String`), or at minimum track which keys exist with a non-scalar value.
- In `add_overrides`/`upsert_top_level_entry`, if the existing key’s value is non-scalar, **do not replace it**. Prefer:
- returning a clear error explaining the conflict and asking the user to resolve manually, or
- skipping that key while warning (less ideal for audit-fix correctness).
- Add a regression test: seed `pnpm-workspace.yaml` with an `overrides:` key whose value is an object at the same selector, then run `set_overrides` and assert it errors (or preserves the object).

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


11. Invalid ranges skipped 🐞 Bug ⛨ Security
Description
fix_with_update silently skips advisories whose vulnerable_versions fail to parse as a semver
Range, so they are excluded from both the resolver-time vulnerability guard and the
fixed/remaining accounting. This can make pacquet audit --fix update exit 0 and report no
remaining vulnerabilities even when the audit report contained advisories with malformed ranges.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1740-1746]

+        let range = advisory.vulnerable_versions.as_str();
+        if range == ">=0.0.0" || range == "*" {
+            unfixable.entry(advisory.module_name.clone()).or_default().push(advisory.id);
+            continue;
+        }
+        let Ok(range) = range.parse::<Range>() else { continue };
+        vulnerabilities.entry(advisory.module_name.clone()).or_default().push((advisory.id, range));
Evidence
The Rust implementation currently drops unparsable vulnerable_versions via continue, which means
those advisories never enter the guard map and never contribute to fixed/remaining. The
command’s exit status in the --fix update path is determined solely by whether remaining is
empty, so skipped advisories can yield a false-clean outcome. pnpm’s TS reference implementation
constructs a semver range during vulnerability checks (no silent skip), so malformed ranges would
not be ignored.

pacquet/crates/cli/src/cli_args/audit.rs[1739-1747]
pacquet/crates/cli/src/cli_args/audit.rs[235-257]
pnpm11/deps/compliance/commands/src/audit/fixWithUpdate.ts[68-80]

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 audit --fix update` builds its vulnerability guard + reporting sets by parsing `advisory.vulnerable_versions` into a `node_semver::Range`. If parsing fails, the current code `continue`s, which drops the advisory entirely from both (1) the resolver-time rejection guard and (2) the fixed/remaining computation. This can produce a false-clean exit code/output when the registry returns malformed `vulnerable_versions`.
### Issue Context
Registry/audit responses are untrusted per REVIEW_GUIDE.md. pnpm’s TS implementation does not silently ignore invalid ranges; it attempts to construct a semver range and will error if the range is invalid.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1739-1747]
- Replace the `continue` on parse failure with either:
- a hard error (closest to pnpm behavior), OR
- conservative behavior: treat the advisory as `remaining` (so exit code stays vulnerable) and include it in output with an explicit “unparseable vulnerable_versions” note.
- pacquet/crates/cli/src/cli_args/audit.rs[235-257]
- Ensure the `AuditOutcome` cannot become `Clean` when advisories were skipped due to parse failures (e.g., if you choose the conservative “remaining” approach, the existing logic will naturally produce `Vulnerable`).
### Acceptance criteria
- Malformed/unparseable `vulnerable_versions` does not silently disappear from fix/update behavior.
- `audit --fix update` cannot return success/clean solely because it skipped advisories it couldn’t parse.
- Add/adjust tests to cover an advisory with an invalid `vulnerable_versions` string and assert the chosen behavior (error or remaining).

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


12. Interactive audit swallows errors 🐞 Bug ⛨ Security
Description
interactive_select converts dialoguer::MultiSelect::interact() errors into None via .ok()?,
and AuditArgs::run treats None as “cancelled/nothing selected” and returns
AuditOutcome::Clean. This can make pacquet audit --interactive succeed (exit 0) without fixing
or even surfacing vulnerabilities when the prompt fails (e.g., non-TTY/CI stdin or other terminal
I/O errors).
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1705-1709]

+    let selected = MultiSelect::new()
+        .with_prompt("Choose which vulnerabilities to fix (space to select, enter to confirm)")
+        .items(&labels)
+        .interact()
+        .ok()?;
Evidence
The prompt failure is explicitly discarded by .ok()?, converting any dialoguer error into
None. The run method then maps None to AuditOutcome::Clean, so prompt errors result in a
clean/success outcome rather than an error or vulnerable exit code.

pacquet/crates/cli/src/cli_args/audit.rs[1705-1709]
pacquet/crates/cli/src/cli_args/audit.rs[213-223]

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 audit --interactive` currently treats *prompt errors* the same as *user cancellation* because `interactive_select()` uses `.interact().ok()?`.
That means if the prompt fails (common in CI/non-TTY environments), the function returns `None`, and the caller returns `AuditOutcome::Clean`, producing a false-success exit code while vulnerabilities may still exist.
## Issue Context
- The prompt error is introduced at the `dialoguer::MultiSelect::interact()` call.
- `AuditArgs::run` interprets `None` as cancellation/no selection and returns `Ok(AuditOutcome::Clean)`.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1705-1712]
- pacquet/crates/cli/src/cli_args/audit.rs[213-223]
## Suggested fix
1. Change `interactive_select` to return `miette::Result<Option<BTreeMap<...>>>` (or similar) so errors can be propagated.
2. Use `dialoguer`’s `interact_opt()` (preferred) to distinguish explicit cancellation from errors:
- `Ok(None)` => user cancelled → return `Ok(None)`.
- `Err(e)` => prompt failed → return `Err(e.into())` (or `miette!`-wrap with context like "interactive selection failed").
3. Update the caller in `AuditArgs::run` to:
- Treat cancellation (`Ok(None)`) as the existing "nothing to do" behavior.
- Treat prompt errors as command failure (so CI doesn’t get a false green).

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



Remediation recommended

13. Terminal escape injection 🐞 Bug ⛨ Security ⭐ New
Description
interactive_select() and the --fix update summary interpolate registry-sourced advisory fields
directly into terminal output and dialoguer::MultiSelect labels without stripping control
characters/ANSI escapes. A malicious or compromised registry can inject escape sequences/newlines to
spoof the prompt/output and mislead users about what is being fixed or what remains vulnerable.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1692-1699]

+        labels.push(format!(
+            "[{}] {} {} ❯ {} {}",
+            severity_name(advisory.severity),
+            advisory.module_name,
+            advisory.vulnerable_versions,
+            patched,
+            advisory.github_advisory_id,
+        ));
Evidence
The review guide defines registry responses as attacker-controlled, and the new audit
fix/interactive code paths directly embed advisory fields into terminal output without sanitization,
enabling control-sequence spoofing.

REVIEW_GUIDE.md[30-46]
pacquet/crates/cli/src/cli_args/audit.rs[1675-1734]
pacquet/crates/cli/src/cli_args/audit.rs[1943-1984]
pacquet/crates/cli/src/cli_args/audit.rs[2010-2024]

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

## Issue description
New `audit --fix` output paths render registry-controlled strings (package name, vulnerable range, GHSA id, advisory title) directly into interactive UI labels and printed summaries. This allows ANSI escape/control-sequence injection (including embedded newlines) that can spoof prompts/output and mislead the user.

## Issue Context
REVIEW_GUIDE.md explicitly treats registry responses as attacker-controlled. These new output paths are introduced by this PR (`--interactive` selection and `--fix update` fixed/remaining summary).

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1675-1735]
- pacquet/crates/cli/src/cli_args/audit.rs[1943-1999]
- pacquet/crates/cli/src/cli_args/audit.rs[2010-2024]

## Suggested fix
- Add a small helper (e.g. `fn sanitize_tty(s: &str) -> Cow<'_, str>`) that strips/replaces ASCII control characters (at least `\x1b`, `\r`, `\n`, and other `char::is_control()`), and consider truncating very long fields.
- Apply it when constructing `labels` in `interactive_select()` and when formatting lines in `format_fix_with_update_output()` (and any other new fix-related output).
- Consider also sanitizing the `PackageVersionGuardDecision::Reject { reason }` string (or ensure the resolver/logging layer sanitizes), since it can flow into logs/errors.

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


14. Guard ranges not deduped 🐞 Bug ➹ Performance
Description
VulnerabilityGuard::check() linearly scans every stored vulnerable Range for a package on each
candidate version check, and classify_for_update() currently accumulates ranges without
deduplication; this can noticeably slow audit --fix update when many advisories/ranges exist for
the same package.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R2011-2016]

+    fn check<'a>(&'a self, name: &'a str, version: &'a str) -> PackageVersionGuardFuture<'a> {
+        Box::pin(async move {
+            let rejected = self.ranges_by_name.get(name).is_some_and(|ranges| {
+                version.parse::<Version>().is_ok_and(|version| {
+                    ranges.iter().any(|range| satisfies_including_prerelease(&version, range))
+                })
Evidence
classify_for_update() collects ranges into vectors per package without deduplication, and the
guard checks a candidate version by iterating through that full vector and calling the range
satisfaction check. This makes the cost per candidate proportional to the number of stored ranges,
including duplicates.

pacquet/crates/cli/src/cli_args/audit.rs[1751-1773]
pacquet/crates/cli/src/cli_args/audit.rs[2011-2017]

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 resolver-time vulnerability guard checks a candidate version against a `Vec<Range>` per package. Since `classify_for_update()` pushes every parsed range (including duplicates) into that vector, guard checks can do redundant work and slow down `audit --fix update` on large/pathological advisory sets.
## Issue Context
This only affects `pacquet audit --fix update` (where the guard is installed), but it is still on a potentially expensive resolve path.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1751-1773]
- pacquet/crates/cli/src/cli_args/audit.rs[2006-2026]
## Implementation notes
- Deduplicate vulnerable ranges per package during `classify_for_update()` (e.g., track a per-package `HashSet<String>` of the trimmed range strings before parsing, or dedup parsed `Range` values if `Eq/Hash` is available).
- Optionally, consider an upper bound on stored ranges per package for guard purposes (while still keeping correct fixed/remaining accounting), to prevent extreme slowdown from obviously pathological audit responses.

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


15. Whitespace GHSA bypasses error 🐞 Bug ⛨ Security
Description
ignore_vulnerabilities() checks github_advisory_id.is_empty() before normalization; a
whitespace-only GHSA from an untrusted registry normalizes to an empty string but is still
added/persisted and reported as ignored. Later ignore filtering drops empty ignore entries, so the
advisory is not actually ignored despite the command claiming it was.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1635-1643]

+            if advisory.github_advisory_id.is_empty() {
+                return Err(AuditError::MissingGhsa {
+                    id: advisory.id,
+                    module_name: advisory.module_name.clone(),
+                }
+                .into());
+            }
+            add(normalize_ghsa_id(&advisory.github_advisory_id), &mut ordered, &mut new_ignores);
+        }
Evidence
The --ignore-unfixable path only errors on github_advisory_id.is_empty(), but then adds the
normalized GHSA without checking if normalization trimmed it to empty. normalize_ghsa_id()
explicitly trims input and can yield an empty string. Ignore filtering later discards empty ignore
entries when building the ignore set, so persisting an empty string will not suppress any advisory
even though the command reports it as newly ignored.

pacquet/crates/cli/src/cli_args/audit.rs[1607-1647]
pacquet/crates/cli/src/cli_args/audit.rs[1404-1410]
pacquet/crates/cli/src/cli_args/audit.rs[1253-1274]

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

## Issue description
`--ignore-unfixable` currently validates `advisory.github_advisory_id` using `is_empty()` **before** normalization. If the registry returns a GHSA field that is non-empty but whitespace-only, `normalize_ghsa_id()` trims it to `""`, and the code persists/prints it as a newly ignored vulnerability. Subsequent runs will not treat that empty entry as an ignore (because ignore sets filter out empty strings), so the vulnerability is not actually suppressed.
## Issue Context
- Registry responses are untrusted input.
- `normalize_ghsa_id()` trims whitespace and can return an empty string.
- Ignore logic later filters out empty ignore entries, making the persisted entry ineffective.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[1607-1647]
- pacquet/crates/cli/src/cli_args/audit.rs[1404-1410]
## Suggested fix
- In the `ignore_unfixable` branch, normalize first and treat an empty normalized result as missing GHSA (return `AuditError::MissingGhsa`).
- In the `--ignore <GHSA>` branch, also reject/skip entries whose normalized GHSA is empty (prefer returning an error so the user knows their input is invalid).
- Optionally harden `add` to ignore empty strings defensively (even if callers validate), so future call sites can’t accidentally reintroduce this.

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


View more (1)
16. Pre-update config write 🐞 Bug ☼ Reliability
Description
fix_with_update() writes minimumReleaseAgeExclude to pnpm-workspace.yaml before running the
actual update, so a later update failure leaves behind persistent config changes despite no
successful fix. This can surprise users with a dirty workspace manifest and leaves maturity-cutoff
exceptions applied even though the command failed.
Code

pacquet/crates/cli/src/cli_args/audit.rs[R1791-1796]

+    let age_exclu...

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.84848% with 110 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.64%. Comparing base (6e45ce1) to head (0933819).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pacquet/crates/cli/src/cli_args/audit.rs 79.64% 92 Missing ⚠️
...cquet/crates/workspace-manifest-writer/src/edit.rs 93.93% 8 Missing ⚠️
...et/crates/package-manager/src/resolution_policy.rs 66.66% 4 Missing ⚠️
pacquet/crates/config/src/version_policy.rs 92.10% 3 Missing ⚠️
...acquet/crates/workspace-manifest-writer/src/lib.rs 94.23% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12653      +/-   ##
==========================================
- Coverage   88.67%   88.64%   -0.04%     
==========================================
  Files         340      341       +1     
  Lines       50080    50860     +780     
==========================================
+ Hits        44410    45085     +675     
- Misses       5670     5775     +105     

☔ 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

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.03      6.6±0.27ms   655.2 KB/sec    1.00      6.4±0.21ms   675.9 KB/sec

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

Copy link
Copy Markdown

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

@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 (3)
pacquet/crates/cli/src/cli_args/audit/tests.rs (1)

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

Assert the full formatter output.

format_fix_with_update_output() is deterministic and this PR treats audit strings as a pnpm-compat contract. These contains() checks would still pass if line order, punctuation, or severity/title formatting drifted. Prefer one exact assert_eq! (or a line-for-line snapshot) for the whole string here. As per path instructions, "Test expectations: add regression tests that prove behavior changes" and "pacquet must match pnpm for user-visible CLI behavior (flags, output strings, config/manifest writes, lockfile behavior)."

🤖 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 `@pacquet/crates/cli/src/cli_args/audit/tests.rs` around lines 1120 - 1154, The
test for format_fix_with_update_output is only checking fragments with
contains(), which can miss regressions in the exact pnpm-compat CLI text. Update
the format_fix_with_update_output test in audit/tests.rs to assert the entire
deterministic string with a single exact expectation (or a full snapshot) so
ordering, punctuation, and severity/title formatting are locked down. Use the
existing format_fix_with_update_output helper and the fixed-pkg/stuck-pkg
advisories as the reference point for the full expected output.

Source: Path instructions

pacquet/crates/cli/tests/audit.rs (2)

517-532: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Verify the manifest is actually unchanged.

This test name promises no on-disk changes, but it only checks stdout. If audit --fix rewrites pnpm-workspace.yaml anyway (for example by adding an empty section or reformatting the file), this regression still passes. Capture the manifest before the command and assert it is byte-for-byte identical afterward. As per path instructions, "Test expectations: add regression tests that prove behavior changes" and "pacquet must match pnpm for user-visible CLI behavior ... config/manifest writes, lockfile behavior."

🤖 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 `@pacquet/crates/cli/tests/audit.rs` around lines 517 - 532, The test
audit_fix_override_with_no_fixable_vulnerabilities_makes_no_changes only asserts
stdout, so it can miss unintended writes to the manifest. Update this test to
capture the workspace manifest content before running
pacquet.arg("audit").arg("--fix"), then assert the file is byte-for-byte
unchanged afterward in addition to the existing success and stdout checks. Use
the existing helpers in audit.rs such as CommandTempCwd::init,
write_audit_workspace, and the
audit_fix_override_with_no_fixable_vulnerabilities_makes_no_changes test body to
locate the assertion point.

Source: Path instructions


625-698: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add a minimumReleaseAge case for --fix update.

This is the only update-path e2e in the PR, but it never enables minimumReleaseAge, so it won't catch the exact cross-layer regression this feature is meant to prevent: the maturity gate blocking the safe version selected by the vulnerability guard. Please add a variant that sets minimumReleaseAge and asserts audit --fix update still rewrites the lockfile to the safe version. As per path instructions, "Test expectations: add regression tests that prove behavior changes." The PR objective explicitly adds minimumReleaseAge handling for both fix paths.

🤖 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 `@pacquet/crates/cli/tests/audit.rs` around lines 625 - 698, The
`audit_fix_update_moves_to_a_non_vulnerable_version` e2e test only covers `audit
--fix update` without `minimumReleaseAge`, so it misses the regression where the
maturity gate blocks the safe version chosen by the vulnerability guard. Add a
variant in `audit.rs` that enables `minimumReleaseAge` in the workspace config,
runs `pacquet_cmd(..., ["audit", "--fix", "update"])`, and asserts the lockfile
still rewrites to the non-vulnerable release. Use the existing
`audit_fix_update_moves_to_a_non_vulnerable_version` flow, `advisory_response`,
and the lockfile assertions as the template.

Source: Path instructions

🤖 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/workspace-manifest-writer/src/edit.rs`:
- Around line 157-165: The empty-ignore branch in edit.rs removes the entire
auditConfig block even when other sibling keys still exist. Update the logic in
the BLOCK handling path to only delete ignoreGhsas via the manifest writer
helpers, and after removal check whether auditConfig is now empty before
deciding to remove the whole block. Keep the existing behavior aligned with
ignore_ghsas_adds_key_to_existing_audit_config and ensure ignore_vulnerabilities
from cli_args/audit.rs can no-op without erasing unrelated auditConfig entries.

---

Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/audit/tests.rs`:
- Around line 1120-1154: The test for format_fix_with_update_output is only
checking fragments with contains(), which can miss regressions in the exact
pnpm-compat CLI text. Update the format_fix_with_update_output test in
audit/tests.rs to assert the entire deterministic string with a single exact
expectation (or a full snapshot) so ordering, punctuation, and severity/title
formatting are locked down. Use the existing format_fix_with_update_output
helper and the fixed-pkg/stuck-pkg advisories as the reference point for the
full expected output.

In `@pacquet/crates/cli/tests/audit.rs`:
- Around line 517-532: The test
audit_fix_override_with_no_fixable_vulnerabilities_makes_no_changes only asserts
stdout, so it can miss unintended writes to the manifest. Update this test to
capture the workspace manifest content before running
pacquet.arg("audit").arg("--fix"), then assert the file is byte-for-byte
unchanged afterward in addition to the existing success and stdout checks. Use
the existing helpers in audit.rs such as CommandTempCwd::init,
write_audit_workspace, and the
audit_fix_override_with_no_fixable_vulnerabilities_makes_no_changes test body to
locate the assertion point.
- Around line 625-698: The `audit_fix_update_moves_to_a_non_vulnerable_version`
e2e test only covers `audit --fix update` without `minimumReleaseAge`, so it
misses the regression where the maturity gate blocks the safe version chosen by
the vulnerability guard. Add a variant in `audit.rs` that enables
`minimumReleaseAge` in the workspace config, runs `pacquet_cmd(..., ["audit",
"--fix", "update"])`, and asserts the lockfile still rewrites to the
non-vulnerable release. Use the existing
`audit_fix_update_moves_to_a_non_vulnerable_version` flow, `advisory_response`,
and the lockfile assertions as the template.
🪄 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: 556c6a64-5aed-47b0-adb8-800b34f84bb2

📥 Commits

Reviewing files that changed from the base of the PR and between 0d50197 and 0933819.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (16)
  • pacquet/crates/cli/Cargo.toml
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/audit.rs
  • pacquet/crates/cli/src/cli_args/audit/tests.rs
  • pacquet/crates/cli/src/cli_args/update.rs
  • pacquet/crates/cli/tests/audit.rs
  • pacquet/crates/config/src/version_policy.rs
  • pacquet/crates/config/src/version_policy/tests.rs
  • pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pacquet/crates/package-manager/src/resolution_observer.rs
  • pacquet/crates/package-manager/src/resolution_policy.rs
  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/workspace-manifest-writer/src/edit.rs
  • pacquet/crates/workspace-manifest-writer/src/lib.rs
  • pacquet/crates/workspace-manifest-writer/src/model.rs
  • pacquet/crates/workspace-manifest-writer/src/tests.rs

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from 0933819 to 7f02571 Compare June 25, 2026 11:08
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7f02571

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7f02571

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 09338195d776

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.632 ± 0.212 4.449 5.113 1.62 ± 0.08
pacquet@main 4.639 ± 0.153 4.475 4.840 1.62 ± 0.06
pnpr@HEAD 2.919 ± 0.130 2.784 3.125 1.02 ± 0.05
pnpr@main 2.855 ± 0.054 2.798 2.936 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.632438197640001,
      "stddev": 0.21215630869138832,
      "median": 4.58244146404,
      "user": 3.71339934,
      "system": 3.4961156000000004,
      "min": 4.44850413304,
      "max": 5.11276073004,
      "times": [
        4.88965156404,
        5.11276073004,
        4.47160118104,
        4.59594589904,
        4.52373739204,
        4.45984463504,
        4.56893702904,
        4.59940861804,
        4.6539907950399995,
        4.44850413304
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.63852580364,
      "stddev": 0.15275100927599558,
      "median": 4.57537612204,
      "user": 3.7295925399999996,
      "system": 3.47084,
      "min": 4.47459332504,
      "max": 4.83952522004,
      "times": [
        4.81830087204,
        4.47459332504,
        4.81371820604,
        4.47592271404,
        4.54241666404,
        4.76913389604,
        4.83952522004,
        4.57005988904,
        4.50089489504,
        4.58069235504
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.91886335524,
      "stddev": 0.13014829171740344,
      "median": 2.88045518204,
      "user": 2.7244563399999997,
      "system": 3.027097,
      "min": 2.78438478704,
      "max": 3.12490657204,
      "times": [
        3.09564519004,
        2.83687417604,
        2.7935249020399997,
        3.0545883840399997,
        2.7943197390399996,
        2.78438478704,
        2.94347943804,
        3.12490657204,
        2.89964391204,
        2.8612664520399997
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.8550724465400004,
      "stddev": 0.054150802332235785,
      "median": 2.83728410754,
      "user": 2.7368216399999996,
      "system": 3.0131130999999995,
      "min": 2.79784832604,
      "max": 2.93614910904,
      "times": [
        2.89541451404,
        2.90198428604,
        2.8248327710399996,
        2.79784832604,
        2.79963974904,
        2.79787855504,
        2.93614910904,
        2.82526038604,
        2.84930782904,
        2.92240894004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 637.2 ± 13.2 617.8 654.3 1.02 ± 0.03
pacquet@main 625.7 ± 9.6 614.7 640.1 1.00
pnpr@HEAD 694.7 ± 13.8 675.7 712.5 1.11 ± 0.03
pnpr@main 684.2 ± 26.6 663.9 757.2 1.09 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6371545559199999,
      "stddev": 0.013169333536929029,
      "median": 0.64069781822,
      "user": 0.37295833999999994,
      "system": 1.33131906,
      "min": 0.61777332872,
      "max": 0.65432378272,
      "times": [
        0.63873279372,
        0.65432378272,
        0.61777332872,
        0.64271440972,
        0.62508076672,
        0.6245512147200001,
        0.6465991237200001,
        0.6426628427200001,
        0.62503827672,
        0.6540690197200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.62566148192,
      "stddev": 0.009571641730901734,
      "median": 0.62308955872,
      "user": 0.37990544000000004,
      "system": 1.3167241600000001,
      "min": 0.6147327237200001,
      "max": 0.6400784297200001,
      "times": [
        0.6400784297200001,
        0.61680014472,
        0.62568588672,
        0.6204932307200001,
        0.61939005572,
        0.6301359147200001,
        0.6147327237200001,
        0.6162955427200001,
        0.63873127872,
        0.63427161172
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.69466812792,
      "stddev": 0.013792174864138322,
      "median": 0.69778823672,
      "user": 0.39449293999999996,
      "system": 1.3618046599999998,
      "min": 0.67573832272,
      "max": 0.71251869572,
      "times": [
        0.70592442272,
        0.70302334672,
        0.70120264572,
        0.67573832272,
        0.71251869572,
        0.6759947337200001,
        0.69408814472,
        0.69437382772,
        0.7065965537200001,
        0.6772205857200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6842163455200001,
      "stddev": 0.026626925932529417,
      "median": 0.67775629772,
      "user": 0.39281913999999996,
      "system": 1.35456146,
      "min": 0.6638530867200001,
      "max": 0.7572360987200001,
      "times": [
        0.67757582672,
        0.6638530867200001,
        0.67183524472,
        0.68497183072,
        0.66688930672,
        0.6856965247200001,
        0.6811973317200001,
        0.6779367687200001,
        0.6749714357200001,
        0.7572360987200001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.718 ± 0.047 4.613 4.762 1.45 ± 0.04
pacquet@main 4.748 ± 0.023 4.709 4.781 1.46 ± 0.04
pnpr@HEAD 3.260 ± 0.169 3.030 3.498 1.00 ± 0.06
pnpr@main 3.257 ± 0.082 3.151 3.400 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.71751606686,
      "stddev": 0.04727905572815779,
      "median": 4.7213687885599995,
      "user": 3.77851,
      "system": 3.4016348199999995,
      "min": 4.61257817106,
      "max": 4.76195799206,
      "times": [
        4.758785411060001,
        4.75444699406,
        4.76195799206,
        4.75817098106,
        4.72396213406,
        4.69927482006,
        4.67249226906,
        4.71877544306,
        4.71471645306,
        4.61257817106
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.747556520460001,
      "stddev": 0.022989685394222675,
      "median": 4.75512959806,
      "user": 3.7893166000000003,
      "system": 3.4146631199999993,
      "min": 4.70859323506,
      "max": 4.78059226506,
      "times": [
        4.764563525060001,
        4.75439768706,
        4.72298384606,
        4.75586150906,
        4.75788616406,
        4.7196833400600005,
        4.78059226506,
        4.74748519106,
        4.7635184420600005,
        4.70859323506
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.2604560475600004,
      "stddev": 0.16893790751672258,
      "median": 3.1965849410600002,
      "user": 2.8276961,
      "system": 3.2145609199999994,
      "min": 3.0299213700600003,
      "max": 3.4978011830600004,
      "times": [
        3.19202887606,
        3.4070514590600003,
        3.12368808806,
        3.2011410060600003,
        3.09772470006,
        3.17962912806,
        3.47701554606,
        3.0299213700600003,
        3.39855911906,
        3.4978011830600004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.25714048896,
      "stddev": 0.0821414028014826,
      "median": 3.25209357706,
      "user": 2.8054276,
      "system": 3.26144432,
      "min": 3.15054836906,
      "max": 3.39969102006,
      "times": [
        3.37809355106,
        3.2497088780600003,
        3.2544782760600004,
        3.16639804306,
        3.2380386850600003,
        3.15054836906,
        3.39969102006,
        3.2648896740600004,
        3.18634768806,
        3.28321070506
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.342 ± 0.020 1.321 1.379 1.00
pacquet@main 1.370 ± 0.015 1.345 1.391 1.02 ± 0.02
pnpr@HEAD 1.452 ± 0.097 1.399 1.726 1.08 ± 0.07
pnpr@main 1.439 ± 0.037 1.408 1.510 1.07 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.3416735227399998,
      "stddev": 0.020228793094435107,
      "median": 1.3358218315400001,
      "user": 1.3228215799999998,
      "system": 1.6918980600000002,
      "min": 1.32113746254,
      "max": 1.37850527054,
      "times": [
        1.3252147465400002,
        1.32840429654,
        1.33104401254,
        1.3235945985400002,
        1.3477094605400002,
        1.34059965054,
        1.3722840655400002,
        1.34824166354,
        1.32113746254,
        1.37850527054
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.37038347994,
      "stddev": 0.015381830859935906,
      "median": 1.36727121354,
      "user": 1.3237162799999997,
      "system": 1.7302226600000001,
      "min": 1.34494320954,
      "max": 1.3913877195400002,
      "times": [
        1.36119152854,
        1.37078701354,
        1.3913877195400002,
        1.3854926225400002,
        1.3873285265400002,
        1.3561232195400001,
        1.34494320954,
        1.3616265515400001,
        1.36375541354,
        1.38119899454
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4524150720399998,
      "stddev": 0.09679348363999186,
      "median": 1.42505281354,
      "user": 0.5661198800000001,
      "system": 1.6095076599999998,
      "min": 1.3994041435400002,
      "max": 1.72589236754,
      "times": [
        1.42744320454,
        1.43231559854,
        1.72589236754,
        1.43389437854,
        1.4158199015400001,
        1.42266242254,
        1.4193238965400001,
        1.40988878354,
        1.3994041435400002,
        1.4375060235400001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.43880123324,
      "stddev": 0.037100325224749084,
      "median": 1.4213490795400001,
      "user": 0.5743642800000001,
      "system": 1.58825346,
      "min": 1.4084255115400002,
      "max": 1.5101993175400001,
      "times": [
        1.4952752575400001,
        1.46231010554,
        1.42819199654,
        1.5101993175400001,
        1.4208774315400001,
        1.4084255115400002,
        1.42182072754,
        1.4133838595400001,
        1.4151121935400002,
        1.4124159315400002
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.020 ± 0.075 2.979 3.231 2.12 ± 0.17
pacquet@main 3.023 ± 0.081 2.965 3.241 2.12 ± 0.17
pnpr@HEAD 1.434 ± 0.016 1.420 1.475 1.01 ± 0.08
pnpr@main 1.424 ± 0.106 1.348 1.720 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.0203495919199996,
      "stddev": 0.0747872541301386,
      "median": 2.99809091362,
      "user": 1.74439054,
      "system": 1.9667058200000003,
      "min": 2.97871316962,
      "max": 3.23141520062,
      "times": [
        2.98806386662,
        2.99501048762,
        3.01386838562,
        2.99236898262,
        3.00078529462,
        3.00284257762,
        3.00503142162,
        3.23141520062,
        2.97871316962,
        2.99539653262
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.0234330759200003,
      "stddev": 0.08146245407065432,
      "median": 2.99708920762,
      "user": 1.7373182399999998,
      "system": 1.98177922,
      "min": 2.96541365062,
      "max": 3.24107667262,
      "times": [
        3.01966989262,
        2.9936885916200002,
        3.00048982362,
        3.05985821562,
        3.01885806462,
        2.9786762226200003,
        2.96993366562,
        3.24107667262,
        2.96541365062,
        2.9866659596200003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.43421385722,
      "stddev": 0.016281204591561425,
      "median": 1.4269669126200002,
      "user": 0.5790950399999999,
      "system": 1.6238188199999999,
      "min": 1.4204557046200001,
      "max": 1.47540234262,
      "times": [
        1.44540799762,
        1.47540234262,
        1.4372319336200001,
        1.42245082562,
        1.42695522962,
        1.42595788562,
        1.42687276862,
        1.43442528862,
        1.4204557046200001,
        1.42697859562
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.4242318879200002,
      "stddev": 0.10596033922271761,
      "median": 1.39912705812,
      "user": 0.55539664,
      "system": 1.5719426199999997,
      "min": 1.34823564562,
      "max": 1.72032639762,
      "times": [
        1.40551315462,
        1.72032639762,
        1.40375922362,
        1.4162743716200001,
        1.37357571962,
        1.38015666462,
        1.38999272462,
        1.34823564562,
        1.40999008462,
        1.39449489262
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12653
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,717.52 ms
(-1.75%)Baseline: 4,801.62 ms
5,761.94 ms
(81.87%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,020.35 ms
(-0.90%)Baseline: 3,047.90 ms
3,657.48 ms
(82.58%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,341.67 ms
(-1.35%)Baseline: 1,360.01 ms
1,632.01 ms
(82.21%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,632.44 ms
(-2.02%)Baseline: 4,728.02 ms
5,673.62 ms
(81.65%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
637.15 ms
(-0.36%)Baseline: 639.48 ms
767.38 ms
(83.03%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12653
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,260.46 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,434.21 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,452.42 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,918.86 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
694.67 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from 7f02571 to be4d752 Compare June 25, 2026 11:53
@zkochan
zkochan enabled auto-merge June 25, 2026 11:56
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@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

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from be4d752 to 86e1993 Compare June 25, 2026 11:59
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 86e1993

@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

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from 86e1993 to aaa0739 Compare June 25, 2026 12:10
@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

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from aaa0739 to f161c7d Compare June 25, 2026 12:15
@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

1 similar comment
@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

@zkochan zkochan added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 25, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from f161c7d to d3ab833 Compare June 25, 2026 12:32
@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

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from d3ab833 to 00b2a9c Compare June 25, 2026 12:40
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 00b2a9c

@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

@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from 00b2a9c to 2a19f83 Compare June 25, 2026 12:58
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

Port the remaining `pnpm audit` fix/ignore features to pacquet, which
previously implemented only the read/report path.

- `--ignore <GHSA>` / `--ignore-unfixable`: suppress advisories and persist
  GHSAs to `auditConfig.ignoreGhsas`. Removing the list preserves sibling
  `auditConfig` keys.
- `--fix` (override): write `^patched` overrides to the `overrides:` block,
  refusing to clobber a non-string (parent-scoped object) value.
- `--fix update`: re-resolve to non-vulnerable versions via a resolver-time
  PackageVersionGuard carried through the existing ResolutionObserver seam;
  report fixed vs. remaining from the post-update lockfile. The registry is
  treated as untrusted: advisory package names and ranges are trimmed, the
  unfixable sentinel is matched after trimming, unparsable ranges and packages
  surviving only under non-semver keys count as remaining, and a missing
  post-update lockfile errors.
- `-i` / `--interactive`: pick advisories to fix via a dialoguer multi-select;
  prompt failures surface instead of reading as a clean audit.
- minimumReleaseAge handling for both fix paths: patched versions are merged
  into minimumReleaseAgeExclude (new merge_package_version_specs in the config
  crate) and injected into the in-process update's resolve.

New format-preserving writers (set_overrides, set_audit_ignore_ghsas,
set_minimum_release_age_excludes) land in the workspace-manifest writer. They
refuse an inline (flow) `overrides:` / `auditConfig:` value and any value with
control characters rather than corrupting the document.
@zkochan
zkochan force-pushed the feat/pacquet-audit-fix-ignore branch from 2a19f83 to cff255b Compare June 25, 2026 13:22
@zkochan
zkochan disabled auto-merge June 25, 2026 13:27
@zkochan
zkochan merged commit f6f6c5e into main Jun 25, 2026
8 of 9 checks passed
@zkochan
zkochan deleted the feat/pacquet-audit-fix-ignore branch June 25, 2026 13:28
Comment on lines +1834 to +1838
include_direct: vec![
DependencyGroup::Prod,
DependencyGroup::Dev,
DependencyGroup::Optional,
],

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. Update fix ignores scope 🐞 Bug ⛨ Security

fix_with_update() hard-codes include_direct to Prod+Dev+Optional, so `pacquet audit --fix
update` can update additional dependency groups (and run their scripts) even when the audit itself
was scoped with --prod/--dev/--no-optional, causing unexpected lockfile churn and a wider
execution surface.
Agent Prompt
## Issue description
`pacquet audit --fix update` currently invokes `Update` with `include_direct` set to all dependency groups (Prod/Dev/Optional) regardless of how the audit was scoped. This means a user running a production-only audit fix can still trigger updates (and script execution) in dev/optional dependencies and produce broader lockfile changes than requested.

## Issue Context
- `AuditArgs::run()` already computes the audit scope via `self.dependency_options`.
- The update engine uses `include_direct` to decide which direct dependencies participate in update planning.

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/audit.rs[156-240]
- pacquet/crates/cli/src/cli_args/audit.rs[1782-1846]

## Implementation notes
- Compute `include_direct = self.dependency_options.include_direct()` alongside `include`.
- Thread `include_direct` into `fix_with_update(...)` (add a parameter) and pass it through to the `Update { include_direct: ... }` struct literal instead of the current hard-coded `vec![Prod, Dev, Optional]`.
- Add/adjust a test to cover `pacquet audit --prod --fix update` (or equivalent) ensuring only prod direct deps are eligible for update planning.

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

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

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

KSXGitHub pushed a commit that referenced this pull request Jun 25, 2026
Bring the latest `main` (20 commits) into the pack port branch. The
notable incoming changes for this branch:

- #12644 (`test(git-fetcher): cover bundleDependencies closure
  depth cap`) added `bundle_dependencies_closure_stops_past_max_depth`
  to `git-fetcher/src/packlist/tests.rs`. This branch had already
  relocated that file to the standalone `fs-packlist` crate, so the
  change is a modify-vs-rename: git's rename detection carried the new
  test into `fs-packlist/src/tests.rs`, where it compiles and passes
  (the `MAX_BUNDLE_DEPTH` guard it covers lives there). fs-packlist now
  has 26 tests.
- New pacquet CLI commands landed on `main` — audit (#12637,
  #12653), global (#12638), link (#12589),
  fetch (#12588), and list. Their dispatch arms auto-merged
  into `cli_args.rs` alongside this branch's `Pack` arm; the cli crate
  compiles with all of them.

All four textual overlaps (`Cargo.toml`, `Cargo.lock`,
`cli/Cargo.toml`, `cli_args.rs`) auto-merged with no conflict markers.
The merged tree passes `cargo check --workspace --all-targets`; pack
(23), exportable-manifest (28), fs-packlist (26), and git-fetcher (61)
test suites all pass. No documentation in this PR went stale: `main`
did not touch `cli/README.md` or the pack / exportable-manifest /
fs-packlist crates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants