Repository navigation
feat(pacquet): port audit --fix, --ignore, and --interactive - #12653
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds 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. ChangesAudit fix and ignore flow
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoPort pnpm audit fix/ignore/interactive flows to pacquet (Rust) Description
Diagram
High-Level Assessment
Files changed (16)
|
Code Review by Qodo
1. Update fix ignores scope
|
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit 0933819 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
pacquet/crates/cli/src/cli_args/audit/tests.rs (1)
1120-1154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the full formatter output.
format_fix_with_update_output()is deterministic and this PR treats audit strings as a pnpm-compat contract. Thesecontains()checks would still pass if line order, punctuation, or severity/title formatting drifted. Prefer one exactassert_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 winVerify the manifest is actually unchanged.
This test name promises no on-disk changes, but it only checks stdout. If
audit --fixrewritespnpm-workspace.yamlanyway (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 winAdd a
minimumReleaseAgecase 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 setsminimumReleaseAgeand assertsaudit --fix updatestill rewrites the lockfile to the safe version. As per path instructions, "Test expectations: add regression tests that prove behavior changes." The PR objective explicitly addsminimumReleaseAgehandling 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
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (16)
pacquet/crates/cli/Cargo.tomlpacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/audit.rspacquet/crates/cli/src/cli_args/audit/tests.rspacquet/crates/cli/src/cli_args/update.rspacquet/crates/cli/tests/audit.rspacquet/crates/config/src/version_policy.rspacquet/crates/config/src/version_policy/tests.rspacquet/crates/package-manager/src/install_with_fresh_lockfile.rspacquet/crates/package-manager/src/resolution_observer.rspacquet/crates/package-manager/src/resolution_policy.rspacquet/crates/package-manager/src/update.rspacquet/crates/workspace-manifest-writer/src/edit.rspacquet/crates/workspace-manifest-writer/src/lib.rspacquet/crates/workspace-manifest-writer/src/model.rspacquet/crates/workspace-manifest-writer/src/tests.rs
0933819 to
7f02571
Compare
|
Code review by qodo was updated up to the latest commit 7f02571 |
|
Code review by qodo was updated up to the latest commit 7f02571 |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
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
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
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
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
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
]
}
]
} |
|
| Branch | pr/12653 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark 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%) |
|
| Branch | pr/12653 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 3,260.46 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 1,434.21 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 1,452.42 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,918.86 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 694.67 ms |
7f02571 to
be4d752
Compare
|
Code review by qodo was updated up to the latest commit be4d752 |
be4d752 to
86e1993
Compare
|
Code review by qodo was updated up to the latest commit 86e1993 |
86e1993 to
aaa0739
Compare
aaa0739 to
f161c7d
Compare
1 similar comment
|
Code review by qodo was updated up to the latest commit f161c7d |
f161c7d to
d3ab833
Compare
d3ab833 to
00b2a9c
Compare
|
Code review by qodo was updated up to the latest commit d3ab833 |
|
Code review by qodo was updated up to the latest commit 00b2a9c |
00b2a9c to
2a19f83
Compare
|
Code review by qodo was updated up to the latest commit 2a19f83 |
1 similar comment
|
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.
2a19f83 to
cff255b
Compare
| include_direct: vec![ | ||
| DependencyGroup::Prod, | ||
| DependencyGroup::Dev, | ||
| DependencyGroup::Optional, | ||
| ], |
There was a problem hiding this comment.
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
|
Code review by qodo was updated up to the latest commit cff255b |
1 similar comment
|
Code review by qodo was updated up to the latest commit cff255b |
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.
Summary
Ports the remaining
pnpm auditfix/ignore features to the pacquet (Rust) port, which previously implemented only the read/report path ofaudit. 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 toauditConfig.ignoreGhsasinpnpm-workspace.yaml. Portsignore.ts(GHSA normalization, merge-with-existing, unfixable detection via missing patched range,ERR_PNPM_AUDIT_MISSING_GHSA).--fix(override) — writes^patchedoverrides to theoverrides:block. Portsfix.ts.--fix update— re-resolves the lockfile to non-vulnerable versions using a resolver-timePackageVersionGuardthat rejects vulnerable versions (so the picker falls back to a safe one), then reports fixed vs. remaining from the post-update lockfile. PortsfixWithUpdate.ts.-i/--interactive— pick which advisories to fix via adialoguermulti-select (flat list, matching the conventionupdate --interactivealready uses).minimumReleaseAgehandling for both fix paths — patched versions are merged intominimumReleaseAgeExclude(newmerge_package_version_specsin the config crate) and, for--fix update, injected into the in-process resolve so the maturity cutoff can't block the fix.Supporting changes:
workspace-manifest-writer:set_overrides,set_audit_ignore_ghsas(nested block sequence),set_minimum_release_age_excludes(top-level block sequence).ResolutionObserverseam (a new defaulted trait method), so noInstallcall sites change. Normal installs are unaffected: the resolve override isNoneunless an audit-fix observer is present (verified by the full install/update suites).audit signaturesremains 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
Checklist
pacquet/port, or the description notes what still needs porting.(pacquet-side catch-up port; the features already exist in the TS CLI.)
Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit
auditadds--fix(including--interactive),--ignore(repeatable), and--ignore-unfixable; it can persist fixes and ignored advisories topnpm-workspace.yaml, including updates tominimumReleaseAgeExclude.updatenow honors additional minimum release-age exclude overrides during version selection.auditConfig.ignoreGhsasandminimumReleaseAgeExclude.audit --fixreporting and behavior, including validation errors for invalid fix methods and safer “update-fix” handling to avoid vulnerable resolutions.overridesand refuses to overwrite them.