Repository navigation
feat(pacquet-cli): port the pack-app command - #12669
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 a Changespack-app command and path containment
Sequence Diagram(s)sequenceDiagram
participant CliArgsRun
participant PackAppArgs
participant Config
participant NodeResolver
participant CommandRunner
participant MacSigner
CliArgsRun->>PackAppArgs: args.run(cfg, dir_ref)
PackAppArgs->>Config: read pnpm.app defaults
PackAppArgs->>NodeResolver: resolve runtime version
PackAppArgs->>CommandRunner: install cached node runtime
PackAppArgs->>CommandRunner: run --build-sea
PackAppArgs->>MacSigner: sign darwin outputs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 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 Qodofeat(cli): port pnpm Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1. Signer PATH hijack
|
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
pacquet/crates/cli/src/cli_args/pack_app.rs (1)
229-235: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftModel target components as closed enums instead of branded strings.
platform,arch, andlibcare closed string-literal sets afterparse_target, but they are stored as plainString, so invalid states can still be constructed inside the module and passed to runtime install/signing paths. Use enums such asTargetPlatform,TargetArch, andTargetLibc, then render them at command/path boundaries.As per coding guidelines, string-literal unions in upstream code should become Rust
enums, not newtype wrappers, since the set of valid values is closed.🤖 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/pack_app.rs` around lines 229 - 235, Model the parsed target components in ParsedTarget as closed enums instead of String fields: replace platform, arch, and libc with TargetPlatform, TargetArch, and TargetLibc so parse_target can only construct valid states. Update any consumers in pack_app.rs that read these fields to work with the enums, and only convert them back to strings at command/path boundaries where runtime install/signing logic needs text values.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pacquet/crates/cli/src/cli_args/pack_app.rs`:
- Around line 488-499: PackAppArgs::run is spawning pacquet add with only -C
install_dir, which drops the already-resolved Config and can lose project-local
proxy/TLS/registry settings for node@runtime installs. Update the child
invocation around Command::new and run_command in PackAppArgs::run to pass the
resolved config through, or refactor to invoke the install path directly with
the existing Config so behavior stays consistent with the parent resolution.
- Around line 282-300: The output-name validation in pack_app’s directory setup
is happening too late, causing dist-app to be created before invalid
--output-name or pnpm.app.outputName values fail. In the pack_app logic that
derives configured_output_name, output_name, and output_dir, move
derive_output_name_from_package and validate_output_name ahead of
fs::create_dir_all so validation stays fail-fast and side-effect-free, then only
create the output directory after the name is confirmed valid.
- Around line 756-760: The native macOS signing branch in pack_app’s command
handling returns a generic exit-status error instead of the pack-app diagnostic
code used by the Linux ldid path. Update the `run_command` handling for the
`codesign` branch in `pack_app` so failures are wrapped or remapped to
`ERR_PNPM_PACK_APP_MACOS_SIGN_FAILED`, matching the public error-code contract
already enforced by the signing logic.
- Around line 75-79: The CLI help text for PackApp::runtime currently misstates
the default as the “running runtime version,” but the actual default comes from
default_runtime_version() and should be documented as the minimum SEA-capable
version. Update the doc comment on runtime to match the real contract and keep
it aligned with default_runtime_version() so clap help does not mislead users.
- Around line 587-593: The parse_runtime helper currently accepts specs with
multiple @ separators because split_once('@') treats everything after the first
separator as the version, so malformed inputs can slip through. Update
parse_runtime to validate that the spec contains exactly one @ before accepting
it, and continue returning PackAppError::InvalidRuntime for any spec that is not
precisely in the node@version form. Use the parse_runtime function and the
InvalidRuntime variant as the main points to adjust the validation.
- Around line 649-674: Do not swallow config errors in read_project_app_config:
in pack_app.rs, the package.json read path should report unreadable files
instead of returning ReadProjectAppConfigResult::default(), and a present but
non-object pnpm.app should be treated as invalid config rather than ignored.
Update the logic around manifest_path, serde_json::from_str, and
validate_app_config so malformed or unreadable package.json/pnpm.app surfaces a
PackAppError with the real failure instead of falling back to missing-config
behavior.
---
Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/pack_app.rs`:
- Around line 229-235: Model the parsed target components in ParsedTarget as
closed enums instead of String fields: replace platform, arch, and libc with
TargetPlatform, TargetArch, and TargetLibc so parse_target can only construct
valid states. Update any consumers in pack_app.rs that read these fields to work
with the enums, and only convert them back to strings at command/path boundaries
where runtime install/signing logic needs text values.
🪄 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: 805c47dc-084f-45f7-b632-8fa2886ea0f8
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (4)
pacquet/crates/cli/Cargo.tomlpacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/pack_app.rspacquet/crates/cli/src/cli_args/pack_app/tests.rs
|
Code review by qodo was updated up to the latest commit 343b240 |
343b240 to
4d85831
Compare
|
Rebased onto latest Fixed (commit 4d85831):
Declined — these match pnpm's
CodeRabbit nitpick — model target components as enums: pnpm's Rust checks (clippy pedantic/nursery, dylint, cargo doc, taplo) pass via the pre-push hook; all 17 ported tests pass. Written by an agent (Claude Code, claude-opus-4-8). |
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit 4d85831 |
|
Code review by qodo was updated up to the latest commit 4d85831 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12669 +/- ##
==========================================
- Coverage 87.48% 87.19% -0.30%
==========================================
Files 370 371 +1
Lines 55767 56218 +451
==========================================
+ Hits 48789 49019 +230
- Misses 6978 7199 +221 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.7693337509,
"stddev": 0.16615210363362665,
"median": 4.6984310406,
"user": 3.8418117,
"system": 3.4511399799999998,
"min": 4.5723753336,
"max": 4.9937373666000004,
"times": [
4.9911368156,
4.6572542646,
4.7369401476,
4.9857599786,
4.6599219336,
4.9937373666000004,
4.5723753336,
4.6341991156,
4.8218102376,
4.6402023156
]
},
{
"command": "pacquet@main",
"mean": 4.7530895294,
"stddev": 0.1175754292433797,
"median": 4.7311557346,
"user": 3.9787855,
"system": 3.4912253799999986,
"min": 4.6198285836,
"max": 5.0340654836,
"times": [
4.6687591616,
5.0340654836,
4.6198285836,
4.6501652246,
4.7171728866,
4.8240191416,
4.7451385826,
4.7114338016,
4.7656613716,
4.7946510566
]
},
{
"command": "pnpr@HEAD",
"mean": 2.8124838078,
"stddev": 0.07857350186019622,
"median": 2.8071709026000002,
"user": 2.6547057999999994,
"system": 2.9487959799999994,
"min": 2.6650445356,
"max": 2.9470344746,
"times": [
2.7949250496,
2.9149783696,
2.7729079736,
2.8044702686000003,
2.8169488426,
2.8374411306000002,
2.8098715366,
2.7612158966,
2.9470344746,
2.6650445356
]
},
{
"command": "pnpr@main",
"mean": 2.8423863246000005,
"stddev": 0.11002169265386932,
"median": 2.8308299076,
"user": 2.7010451999999994,
"system": 2.972414079999999,
"min": 2.7321280876,
"max": 3.1023622226,
"times": [
2.7321280876,
2.7408010686,
2.8471649446000002,
2.7453079056,
2.8482646256,
2.9303707956,
2.8135884116,
2.8493803136,
3.1023622226,
2.8144948706
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.62737448662,
"stddev": 0.011018815523014966,
"median": 0.62425373102,
"user": 0.37912425999999994,
"system": 1.30897884,
"min": 0.61474019002,
"max": 0.64298205502,
"times": [
0.63400665102,
0.61860033902,
0.63846101602,
0.61474019002,
0.64138987002,
0.64298205502,
0.62806242202,
0.61568177602,
0.61937550702,
0.62044504002
]
},
{
"command": "pacquet@main",
"mean": 0.62595276822,
"stddev": 0.014087208212268627,
"median": 0.6217636415200001,
"user": 0.3656453599999999,
"system": 1.30379164,
"min": 0.60828264802,
"max": 0.65085501702,
"times": [
0.6248271360200001,
0.61744709302,
0.61632833302,
0.60828264802,
0.61870014702,
0.61419035602,
0.63623530102,
0.6456943980200001,
0.62696725302,
0.65085501702
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6920185452199998,
"stddev": 0.021350327397195282,
"median": 0.69338897602,
"user": 0.38911035999999993,
"system": 1.33829314,
"min": 0.65721811002,
"max": 0.73280772702,
"times": [
0.68659810202,
0.73280772702,
0.69278287302,
0.70389763102,
0.67069971702,
0.69399507902,
0.67440182102,
0.65721811002,
0.70561082002,
0.70217357202
]
},
{
"command": "pnpr@main",
"mean": 0.67650306342,
"stddev": 0.012780360554867741,
"median": 0.6782101435200001,
"user": 0.37639145999999996,
"system": 1.32731964,
"min": 0.65655380802,
"max": 0.6976771390200001,
"times": [
0.6976771390200001,
0.68067700202,
0.65655380802,
0.6764999740200001,
0.6804161320200001,
0.67612319302,
0.65813849202,
0.66893400802,
0.67992031302,
0.69009057302
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.618369347,
"stddev": 0.05729702791146454,
"median": 4.6189734228,
"user": 3.7217537399999996,
"system": 3.3156076,
"min": 4.5292488478,
"max": 4.6986376478,
"times": [
4.6409765878,
4.5408292997999995,
4.6305867678,
4.6774815848,
4.6073600778,
4.5988323998,
4.6986376478,
4.5838995908,
4.6758406658,
4.5292488478
]
},
{
"command": "pacquet@main",
"mean": 4.611046691,
"stddev": 0.07109755636580968,
"median": 4.6108443033,
"user": 3.77951404,
"system": 3.3134933,
"min": 4.499072926799999,
"max": 4.7161343618,
"times": [
4.5959573268,
4.7161343618,
4.6712422218,
4.6813325628,
4.6477832848,
4.499072926799999,
4.5173989578,
4.6257312798,
4.5950728638,
4.5607411238
]
},
{
"command": "pnpr@HEAD",
"mean": 3.1916784800999998,
"stddev": 0.1323096636286701,
"median": 3.1688303348,
"user": 2.7972218399999997,
"system": 3.1681662000000004,
"min": 3.0741267368000003,
"max": 3.5330606178000004,
"times": [
3.0744581448000003,
3.1112141198,
3.1354927978,
3.5330606178000004,
3.2383098598,
3.1780257468000004,
3.2040772528000003,
3.0741267368000003,
3.2083846018,
3.1596349228
]
},
{
"command": "pnpr@main",
"mean": 3.1737283835000003,
"stddev": 0.15979472363130626,
"median": 3.1020028603000003,
"user": 2.82501004,
"system": 3.1671254,
"min": 3.0789773038000003,
"max": 3.5654809788,
"times": [
3.0789773038000003,
3.1365910288000003,
3.0978422568000004,
3.1026577728,
3.5654809788,
3.0898316748,
3.3558408918000002,
3.1116050868,
3.1013479478000003,
3.0971088928
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4298564851199997,
"stddev": 0.016247335540470094,
"median": 1.43009047172,
"user": 1.4061776399999997,
"system": 1.76414232,
"min": 1.4118293297200002,
"max": 1.46372394972,
"times": [
1.4118293297200002,
1.42272741572,
1.43242693172,
1.46372394972,
1.4368480837200002,
1.43344561672,
1.44408701572,
1.42775401172,
1.41285762572,
1.4128648707200002
]
},
{
"command": "pacquet@main",
"mean": 1.3869426360200001,
"stddev": 0.08227787620613192,
"median": 1.3650674817200001,
"user": 1.33962304,
"system": 1.7037014199999998,
"min": 1.3394928807200002,
"max": 1.6181557807200002,
"times": [
1.3394928807200002,
1.36563926772,
1.6181557807200002,
1.3477082687200002,
1.34778254772,
1.36957453172,
1.3725521497200002,
1.36449569572,
1.3827538467200002,
1.36127139072
]
},
{
"command": "pnpr@HEAD",
"mean": 1.48330336832,
"stddev": 0.08905181258190788,
"median": 1.4628903697200002,
"user": 0.6198550399999999,
"system": 1.5867756199999998,
"min": 1.4255580167200002,
"max": 1.7303284837200001,
"times": [
1.7303284837200001,
1.46188080972,
1.43900316972,
1.4835490537200002,
1.4638999297200002,
1.4295841067200001,
1.4486851067200002,
1.4737017467200002,
1.47684325972,
1.4255580167200002
]
},
{
"command": "pnpr@main",
"mean": 1.43691601862,
"stddev": 0.031024512978005847,
"median": 1.43167768422,
"user": 0.5891289399999999,
"system": 1.5587906200000001,
"min": 1.40618435972,
"max": 1.5150457267200002,
"times": [
1.4399923707200002,
1.5150457267200002,
1.44881849572,
1.42581673572,
1.4170172497200002,
1.40618435972,
1.41160360572,
1.44540856672,
1.42173444272,
1.4375386327200002
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.1257719604200007,
"stddev": 0.038774749336220146,
"median": 3.12311648692,
"user": 1.8709797999999995,
"system": 2.06483392,
"min": 3.0689143634200002,
"max": 3.18405298042,
"times": [
3.16584624542,
3.11062831842,
3.1422452824200002,
3.18405298042,
3.0689143634200002,
3.09724386542,
3.12316587642,
3.16558841342,
3.12306709742,
3.0769671614200003
]
},
{
"command": "pacquet@main",
"mean": 3.0021577654200002,
"stddev": 0.03302959567831331,
"median": 2.99664743742,
"user": 1.7991496999999999,
"system": 1.9363788199999998,
"min": 2.94533613442,
"max": 3.06671037042,
"times": [
2.99708982342,
3.03239731842,
2.94533613442,
3.06671037042,
2.98334242142,
2.98105860342,
2.99962726442,
2.99620505142,
3.02605551742,
2.99375514942
]
},
{
"command": "pnpr@HEAD",
"mean": 1.42999112192,
"stddev": 0.016736718275428653,
"median": 1.43171022242,
"user": 0.6086886,
"system": 1.54808002,
"min": 1.3997822754200002,
"max": 1.4621617664200002,
"times": [
1.4621617664200002,
1.43761520842,
1.4299869064200001,
1.42246829142,
1.4260865204200002,
1.3997822754200002,
1.44155531042,
1.41313002242,
1.4336913794200001,
1.43343353842
]
},
{
"command": "pnpr@main",
"mean": 1.41524342692,
"stddev": 0.034868181022092846,
"median": 1.4075728919200001,
"user": 0.5714973999999999,
"system": 1.5626767199999998,
"min": 1.3825653474200001,
"max": 1.5027054584200001,
"times": [
1.43583507042,
1.41827374742,
1.5027054584200001,
1.41883796142,
1.3825653474200001,
1.3891355574200002,
1.4157424354200001,
1.39839818342,
1.3994033484200001,
1.3915371594200001
]
}
]
} |
|
| Branch | pr/12669 |
| 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,618.37 ms(-2.82%)Baseline: 4,752.54 ms | 5,703.05 ms (80.98%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 3,125.77 ms(+2.91%)Baseline: 3,037.45 ms | 3,644.94 ms (85.76%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,429.86 ms(+6.00%)Baseline: 1,348.97 ms | 1,618.76 ms (88.33%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,769.33 ms(+0.85%)Baseline: 4,729.29 ms | 5,675.15 ms (84.04%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 627.37 ms(-3.32%)Baseline: 648.92 ms | 778.70 ms (80.57%) |
|
| Branch | pr/12669 |
| 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,191.68 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 1,429.99 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 1,483.30 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,812.48 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 692.02 ms |
|
Code review by qodo was updated up to the latest commit 64bc017 |
|
Code review by qodo was updated up to the latest commit 64bc017 |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm11/releasing/commands/src/pack-app/packApp.ts (1)
158-176: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy liftClose the entry-path TOCTOU before handing it to SEA.
isWithinDir()only proves containment at validation time.seaConfig.mainlater still points atresolvedEntry, so a repo that swaps that path after Line 172 but beforenode --build-searuns can make the builder embed a file outside the project. Please stage the validated entry into a private temp file (or otherwise pin the inode) and pass that staged path to SEA instead. As per path instructions, REVIEW_GUIDE.md says to review path handling for TOCTOU and fail-closed 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 `@pnpm11/releasing/commands/src/pack-app/packApp.ts` around lines 158 - 176, The entry-path validation in packApp still leaves a TOCTOU window because seaConfig.main uses resolvedEntry after isWithinDir() succeeds, so a swapped file can be embedded later. Fix this by staging the validated entry to a private temp location (or otherwise pinning the inode) immediately after the checks, then use that staged path when setting seaConfig.main and invoking the SEA build. Keep the existing PnpmError checks in packApp() and preserve the fail-closed behavior for PACK_APP_ENTRY_NOT_FOUND, PACK_APP_ENTRY_NOT_FILE, and PACK_APP_ENTRY_OUTSIDE_PROJECT.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/cli/src/cli_args/pack_app.rs`:
- Around line 342-348: The current outputDir validation in pack_app.rs is only
lexical, so symlinked ancestors can still escape the project before
fs::create_dir_all and subsequent writes. Update the containment check in the
pack-app flow around escapes_project/output_dir to verify existing ancestors
using canonicalized paths (symlink-aware) before creating directories, and keep
the pnpm and pacquet path-handling logic aligned so both use the same robust
containment approach.
- Around line 605-608: The escapes_project helper is too permissive on Windows
because Path::is_absolute() does not catch root-relative and drive-relative
forms like \tmp or C:foo. Update escapes_project to also reject paths containing
Component::RootDir and Component::Prefix(_) in addition to Component::ParentDir,
so join-based path handling cannot escape the project root.
In `@pnpm11/releasing/commands/src/pack-app/packApp.ts`:
- Around line 194-202: The `outputDir` validation in `packApp` only blocks
absolute paths and `..` traversal, but it still allows symlink-based escapes
from the project root. Update the containment check used for `outputDirRaw` so
it is symlink-aware like the `entry` handling, and ensure `mkdir()`/writes only
proceed when the resolved target stays inside `opts.dir`. Add regression
coverage for a repo-local symlink such as `dist-app -> /tmp/out`, and make the
test fail fast in both stacks when the resolved output directory escapes the
project.
---
Outside diff comments:
In `@pnpm11/releasing/commands/src/pack-app/packApp.ts`:
- Around line 158-176: The entry-path validation in packApp still leaves a
TOCTOU window because seaConfig.main uses resolvedEntry after isWithinDir()
succeeds, so a swapped file can be embedded later. Fix this by staging the
validated entry to a private temp location (or otherwise pinning the inode)
immediately after the checks, then use that staged path when setting
seaConfig.main and invoking the SEA build. Keep the existing PnpmError checks in
packApp() and preserve the fail-closed behavior for PACK_APP_ENTRY_NOT_FOUND,
PACK_APP_ENTRY_NOT_FILE, and PACK_APP_ENTRY_OUTSIDE_PROJECT.
🪄 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: d2a0a1a4-6be7-49fb-9075-3781ab0052df
📒 Files selected for processing (5)
.changeset/pack-app-path-containment.mdpacquet/crates/cli/src/cli_args/pack_app.rspacquet/crates/cli/src/cli_args/pack_app/tests.rspnpm11/releasing/commands/src/pack-app/packApp.tspnpm11/releasing/commands/test/pack-app/index.test.ts
✅ Files skipped from review due to trivial changes (1)
- .changeset/pack-app-path-containment.md
|
Code review by qodo was updated up to the latest commit 18093dd |
The output-directory hardening was only lexical (rejecting absolute and `..` paths), so a repo-controlled symlink at `dist-app` (or `dist-app/<target>`) could still redirect build artifacts outside the project — and the changeset already claimed symlink escapes were rejected. Re-check containment against the symlink-resolved real path after each output directory is created, for both the top-level output dir and the per-target subdir, matching the entry handling. Also harden the lexical pre-check on the pacquet side to reject Windows root-relative (`\foo`) and drive-relative (`C:foo`) forms, which `Path::is_absolute` does not catch. Landed in both the TypeScript pnpm CLI and the Rust pacquet port with matching codes and tests (including symlink-escape regressions).
… TS guard `pathEscapesProject()` used `path.isAbsolute()`, which reports Windows drive-relative (`C:foo`) and root-relative (`\foo`) paths as relative, so on Windows such an `outputDir` would slip the lexical pre-check and the output directory would be created outside the project before the realpath containment check aborted. Use `path.parse().root` instead, which is non-empty for every host-rooted form, matching the pacquet port that rejects `Component::RootDir` / `Component::Prefix`. Kept platform-specific (host `path`) so a literal `C:foo` filename stays valid on POSIX, where it cannot escape — same as the Rust side.
|
Code review by qodo was updated up to the latest commit 38df4da |
38df4da to
7a0d513
Compare
|
Code review by qodo was updated up to the latest commit 7a0d513 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 7a0d513 |
The directory containment checks covered `outputDir` and the per-target
subdir but not the final executable path, so a repo could commit
`dist-app/<target>/<name>` as a symlink and `node --build-sea` would
follow it to overwrite an arbitrary file outside the project ("leaf
symlink" escape).
The output path is now checked before anything is downloaded — and again
right before the build — via `symlink_metadata` / `lstat`: if it already
exists and is not a regular file, abort with
`ERR_PNPM_PACK_APP_OUTPUT_FILE_NOT_REGULAR`. A regular file is still
overwritten as before.
Landed in both the TypeScript pnpm CLI and the Rust pacquet port with
matching codes and symlink-escape regression tests.
|
Code review by qodo was updated up to the latest commit 328f672 |
|
Code review by qodo was updated up to the latest commit 328f672 |
`ad_hoc_sign_mac_binary` spawned `codesign` / `ldid` by bare name, so a repo-controlled `node_modules/.bin` on the developer's PATH could get an attacker-provided signer executed when packaging a darwin target. `codesign` is now run by its absolute system path (`/usr/bin/codesign`), and `ldid` is resolved through PATH while skipping any match inside the project directory (returning the first trusted match, else `ERR_PNPM_PACK_APP_MACOS_SIGN_FAILED`). Landed in both the TypeScript pnpm CLI and the Rust pacquet port; the skip-project-local rule is covered by a pacquet unit test.
|
Code review by qodo was updated up to the latest commit 027007a |
1 similar comment
|
Code review by qodo was updated up to the latest commit 027007a |
Ports pnpm's `pack-app` command into pacquet. It packs a CommonJS entry file into a standalone executable for one or more target platforms, embedding a Node.js binary through the Node.js Single Executable Applications API. Reuses pacquet's node-version resolution, network client, detect-libc, and `node@runtime:` installs. Two intentional divergences from pnpm, both forced by pacquet being a Rust binary rather than a Node.js script: the SEA builder is always downloaded (pnpm reuses its running interpreter), and the runtime install spawns the pacquet binary (mirroring pnpm's runPnpmCli). Ports the upstream Jest validation suite (17 tests) covering the fail-fast branches. The download / SEA-injection / signing paths need network, Node.js, and subprocesses and are out of unit-test scope, matching upstream coverage. Ported from pnpm/pnpm@9f3df6b9b4.
) The Release job for 11.10.0 failed at the Publish `@pnpm/exe` step with ERR_PNPM_PACK_APP_ENTRY_OUTSIDE_PROJECT: the pack-app hardening from #12669 rejects entry/output paths that escape the project directory, and the `@pnpm/exe` build config used exactly that shape (entry "../../pnpm.cjs", outputDir ".." relative to pnpm11/pnpm/artifacts/exe). Move the pnpm.app config to pnpm11/pnpm/package.json (entry "pnpm.cjs", outputDir "artifacts") and run pack-app from the pnpm package root in build-artifacts.ts. Output paths are unchanged (pnpm11/pnpm/artifacts/<target>/pnpm), and the guard stays strict instead of being loosened to a workspace-root anchor, which would re-allow embedding files from outside the packed project.
Summary
Ports pnpm's
pack-appcommand into pacquet (pacquet pack-app). It packs a CommonJS entry file into a standalone executable for one or more target platforms, embedding a Node.js binary through the Node.js Single Executable Applications (SEA) API.The command reads defaults from
package.json'spnpm.appfield (entry,targets,runtime,outputDir,outputName), resolves the embedded Node.js version against nodejs.org, downloads the per-target runtime, runsnode --build-sea, and ad-hoc signs macOS binaries — matching pnpm's behavior, flags, defaults, andERR_PNPM_PACK_APP_*error codes.It reuses pacquet's existing infrastructure: node-version resolution (
parse_node_specifier/get_node_mirror/resolve_node_version),ThrottledClient(same proxy/TLS/timeout config as installs),detect-libcfor host platform/arch/libc, andnode@runtime:installs through pacquet's ownadd.Two intentional divergences from the pnpm source, both forced by pacquet being a Rust binary rather than a Node.js script (documented in the module doc comment):
process.execPath) when it already matches the embedded runtime version; pacquet has no host Node.js to reuse.std::env::current_exe()runningadd --os/--cpu/--libc node@runtime:<version>into an isolated directory under the pnpm home), mirroring pnpm'srunPnpmCli.Known gaps (noted in code):
Confighas nonode-download-mirrorsfield yet, so version resolution always uses the official nodejs.org mirror (matches pnpm's default when unset).addomits pnpm's--ignore-scripts/--ignore-workspace(pacquet'saddlacks those flags). Harmless fornode@runtimeunder the pnpm home.Ported from 9f3df6b9b4.
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.(
pack-appalready exists in the TypeScript CLI; this PR ports it to pacquet.)Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit
pack-appCLI command to bundle a CommonJS entry into standalone executables for supported targets, with configurable entry, targets, Node runtime, and output directory/name (auto output-name discovery frompackage.json).--entryand--output-dirhandling: absolute paths and paths escaping the project directory (including..and symlink escapes) are now rejected with new error codes.