Repository navigation
Stop verifying and attesting a vendored NuGet package whose lock pins other bytes - #2453
Mikola Lysenko (mikolalysenko) wants to merge 9 commits into
Conversation
Refs #2381. Assisted-by: Claude Code
A vendored NuGet package keeps its id and version, so the `contentHash` in `packages.lock.json` is all that tells it from the upstream package in NuGet's global packages folder, which NuGet restores from before it asks any source. `vendor` pins that hash to the vendored nupkg. `dotnet restore --force-evaluate` over a folder that holds the upstream package, NuGet's remedy for the NU1403 the pin raises there, writes the upstream hash back. Every later restore then takes the upstream package, `--locked-mode` included. `vex` attested such a package `not_affected`: it read the pin for Bun's lock only. `nuget_feed::lock_pin_mismatch` reads it the way the writer's in-sync check does, over every lock a project under the root restores into, and `vex` omits the patch with `vendor_lock_pin_mismatch` when an entry of the patched version pins a hash that is not the committed nupkg's. Refs #2381. Assisted-by: Claude Code
`vendor --check` reported "committed artifact and wiring verified" for a vendored NuGet package whose lock pins the upstream `contentHash` again: the config still maps the id to the vendored feed, and nothing compared the pin. It now fails that package, names the lock, and says how to pin it again. The CLI tests vendor the NuGet fixture, put the upstream pins back as `dotnet restore --force-evaluate` does, and run `vendor --check` and `vex`: both packages fail and none is attested, one stale entry fails its own package only, and a wet `vendor` pins the lock again, after which both commands pass. Refs #2381. Assisted-by: Claude Code
Over a vendored NuGet package whose lock pins other bytes, `vendor --dry-run` said "already vendored; nothing to do" where the wet run pins the lock again, and the wet run explained itself with "the committed vendored nupkg was missing or stale", which it was not. The dry run counts such a package as one it would vendor: the ledger recording the patch is its tell for "in sync", and the lock pin is the one thing the ledger does not tell. The wet run's `vendor_artifact_rebuilt` warning says a lock pinned other bytes and was pinned again. Refs #2381. Assisted-by: Claude Code
The warning that NuGet's global packages folder holds the upstream copy of a vendored package (`vendor_nuget_stale_global_package`) was raised by the first vendor and by an in-sync re-run, and not by the run that rebuilds a wired package. That is the run which follows a `dotnet restore --force-evaluate`: it pinned the lock again and left the copy that made NuGet rewrite it unnamed, so the next restore failed NU1403 once more. The three paths raise the warning through one helper, `stale_global_package`. Refs #2381. Assisted-by: Claude Code
Brings in #2445, which changed `commands/vex.rs`, so that the omission phrase of a lock pin can be edited on its current text. Assisted-by: Claude Code
`vex` explains `vendor_lock_pin_mismatch` with one sentence, written when Bun's lock was the only one with a pin: "the lockfile pins the vendored tarball to a sha512". A NuGet lock now gets the same code, and its artifact is a nupkg. The sentence says "artifact". Refs #2381. Assisted-by: Claude Code
- The remedy named `socket-patch vendor` first, which does nothing in a project with no manifest (what `scan --mode vendored` leaves). It now leads with `socket-patch scan --mode vendored`, which pins the lock again in both. - `vendor --check` ran the pin check before the liveness rule, so a package whose config and lock were both put back was reported with the pin's text where `vex` says `vendor_unwired`. The pin is judged after liveness, on a package that is wired. - The dry run's tally asked the pin check for every NuGet package. NuGet's backend reports an in-sync package as `already_vendored` on a dry run too, so a `verified` preview of one is never in sync, and the tally says so without reading the tree. That also covers a package whose config was put back. - `pin_stale` was "the nupkg is in sync and the lock is not", wider than a lock that pins other bytes. The prelude and the check now share one predicate, `pins_other_bytes`. - The check does not read an artifact path that leaves the root, and the dead `./` trim is gone. Refs #2381. Assisted-by: Claude Code
A second review pass found the production change sound and three assertions that could not fail for the reason they named. - The row for an artifact path that leaves the root named a path with nothing at it, so it passed with or without the guard. It is a test of its own now, with a nupkg the lock does not pin at that path; with the guard removed it fails. - The unwired test put the config and the lock back together, a state the first dry-run rule already got right. It now checks the config put back alone, with the lock still pinned, and then both. - Nothing held the predicate the prelude's `pin_stale` goes by; `pins_other_bytes` has its rows. Refs #2381. Assisted-by: Claude Code
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Core adds New CLI and unit tests cover correct pins, upstream pins, per-package judgment, and unwired packages. The VEX user-facing text says “artifact” instead of “tarball” for this error. Reviewed by Cursor Bugbot for commit 2e5af57. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2e5af57. Configure here.
Assisted-by: Claude Code
|
[agent] PR shepherd: review brief for the approver What it does. Risk. Low. Every read failure in the new check, such as an unreadable or non-JSON lock, a missing nupkg, a hash-less entry or a path outside the root, returns no finding, so a malformed lock can't newly fail Look here.
Verified.
Changes I made. None. Open questions (not blocking, and both predate this PR):
Generated by Claude Code |

LLM Description written by Claude Code
Fixes #2381.
Problem
A vendored NuGet package keeps its id and version, so NuGet's global packages folder (
~/.nuget/packages) can already hold the upstream package, and NuGet restores from that folder before it asks any source. The only thing that ties a restore to the vendored nupkg is thecontentHashinpackages.lock.json, whichvendorpins.On a machine with the upstream copy in that folder, the next
dotnet restorefails NU1403. NuGet's own remedy isdotnet restore --force-evaluate. It succeeds: NuGet takes the upstream copy, never opens the vendored feed, and writes the upstreamcontentHashback into the lock. From then on every restore passes,--locked-modeincluded, the build loads the upstream assembly, and:socket-patch vendor --checkexits 0, "committed artifact and wiring verified";socket-patch vexattestsnot_affected;socket-patch vendor --dry-runsays "already vendored; nothing to do".nuget.configstill maps the id to the vendored feed and the nupkg is intact, so one hash line is all that changed. The machine that ranvendoris such a machine (it restored the project before), and so is a CI runner that restores a cached global packages folder.The writer has the rule: a wet
vendortreats a lock that pins other bytes as out of sync and pins it again. The two commands whose job is to check never read the pin. The same hole was closed for Bun's lock, and for Bun's lock only.Evidence on
mainThe real .NET SDK 8 (
mcr.microsoft.com/dotnet/sdk:8.0, no network), a library packed withdotnet packinto a folder feed, an app withRestorePackagesWithLockFile, and a patch that replaces the library's assembly. The binary is the one built frommainat 6eb4eb9:A CLI test, red on
mainand green here. It vendors the NuGet fixture, puts the upstream pins back as--force-evaluatedoes, and runsvendor --checkandvex:The fix
One rule, the writer's: a vendored NuGet package is wired only while every lock a project under the root restores into, and that locks the id at the patched version, pins the vendored nupkg's
contentHash.vendor::nuget_feed::lock_pin_mismatchreads the pin the way the writer's in-sync check does: the same locks (governed_locks_on_disk), the same entries (locked_at: id without regard to case, version normalized), the same tolerance (an entry with no hash, or no entry at that version, pins nothing).vex(corevex/verify.rs) omits the patch withvendor_lock_pin_mismatch, the code Bun's lock already has.vendor --checkfails the package, names the lock and the artifact, and says what to do. The pin is judged after the liveness rule, on a package that is wired.vendor --dry-runcounts the package as one it would vendor. Its tell for "in sync" was the ledger recording the patch. NuGet's backend reports an in-sync package asalready_vendoredon a dry run too, so averifiedpreview of a NuGet package is always one the wet run writes, and the tally says so.vendorthat pins the lock again now says so ("a lock pinned … to other bytes than the committed vendored nupkg's"), where it said the nupkg "was missing or stale". It also names the copy in the global packages folder (vendor_nuget_stale_global_package). The first vendor and an in-sync re-run raised that warning; the run that follows a--force-evaluatedid not, so the lock was pinned again and the next restore failed NU1403 once more.vex's sentence forvendor_lock_pin_mismatchsays "artifact" where it said "tarball".The same tree, the binary built from this branch (at 01383ce; the remedy sentence is the head's):
Tests
tests/vendor/vendor_nuget_lock_pin.rs, four CLI tests over the vendored NuGet fixture:vendorwrote is verified and attested, and a dry run has nothing to do;vexsaysvendor_unwired, never the pin's text, and the dry run would vendor two.What the review found
An independent review by a subagent given the diff and the issue:
/code-review high, then its own probes in a separate worktree. Each finding was run unless marked read.socket-patch vendorfirst. In a project with no manifest (whatscan --mode vendoredleaves) that command does nothing: exit 0, "No manifest to vendor from", the lock unchanged.socket-patch scan --mode vendored, whose wet run goes through the same backend.vendor --checkran the pin check before the liveness rule. With the config and the lock both put back it printed the pin's text wherevexsaidvendor_unwired.pin_stalewas wider than the check: an entry with no hash beside one pinned at the nupkg made the wet run say "a lock pinned … to other bytes".pins_other_bytes.lock_pin_mismatchhashed whateverentry.artifact.pathnamed,../../etc/passwdincluded. Its callers validate the path first../trim is gone.tests/vendor/main.rsloadsprebuilt_commontwice.#[allow(clippy::duplicate_mod)], as the other suites do.vex --no-verifystill attests over a stale pin, for NuGet as for Bun onmain. I ran it again on the real-SDK tree.--no-verify, so it is a defect; the fix moves the pin into the wiring gates for both ecosystems. Filed as #2455.SOCKET_OFFLINE=1 socket-patch vendorexits 1 and the lock stays stale. Run again on the real-SDK tree.scan --mode vendored --dry-runandget --mode vendored --dry-runpreview from the ledger's uuid alone (read).dotnetdoes not write such a lock.vendor --checkreports that lock through the liveness rule, as onmain. In #2455.vendor_lock_pin_mismatch(bun)" (read).A second, shorter pass on the fixes (read only) found the production change sound and three assertions that could not fail for their reason: the row for a path that leaves the root, the dry-run state of the unwired test, and nothing on the shared predicate. All three are fixed; the first was checked by removing the guard.
Deleted
Two inline copies of the stale-global-package warning; the three paths that raise it share
stale_global_package.Behavior change
For a vendored NuGet package whose lock pins a
contentHashthat is not the committed nupkg's:vendor --checkexits 1 for it (was 0, "verified").vexomits it withvendor_lock_pin_mismatch(wasnot_affected). The contract names that code for Bun; it now covers NuGet's lock too.vendor --dry-runsays "Would vendor N packages" (was "already vendored; nothing to do"). Its JSON events are unchanged.vendorwords itsvendor_artifact_rebuiltwarning differently and addsvendor_nuget_stale_global_packagewhen the global folder holds other bytes.For Bun, the sentence
vexprints forvendor_lock_pin_mismatchsays "artifact" where it said "tarball". No JSON shape, flag, code or exit-code meaning is new.Risk
A project whose lock legitimately pins other bytes than the vendored nupkg would now fail
vendor --check. I know of no such state: the writer already calls it out of sync and rewrites the pin on every wet run, and under it NuGet either restores another copy or fails NU1403. The check reads the project tree for its project files once per vendored NuGet package, as the writer does.Not in this PR
CLI_CONTRACT.mdsays "vendor_lock_pin_mismatch(bun)". It should name NuGet's lock too. Fix vendored gem directories losing files git ignores (#2348) #2451, an openagent/PR, changes that file, and the routine does not edit a file another agent's open PR holds, so the sentence waits for it.vex --no-verifyattests a vendored NuGet or Bun package whose lock pins other bytes, and a stale NuGet pin is pinned again only with the patch service reachable #2455 holds what the review found beyond this change:vex --no-verify, the re-pin that needs the patch service, and thescanandgetpreviews.--force-evaluatewas not run.Verification
Local, on ca76141 (this branch with
mainat 2440352 merged in):cargo clippy --locked --workspace --all-features -- -D warnings: clean.vendor,e2e_vex_vendor,vex,e2e_nuget,vendor_revert_tamper_e2e,vendor_ledger_schema_e2e,vendor_group_commit_e2e,in_process_vendor,cli,vendor_eject,scan_vendor_e2e,vendor_crash_safety_e2e,vendor_partial_staging_e2e,e2e_vex,e2e_vex_lockfile,in_process_rollback_vendoredandrepair. Two tests ofrepairfailed:repair_cleanup_failure_is_reported_in_json_and_silent_modesandrepair_exits_zero_and_stays_quiet_when_lock_file_unremovable. Both make a file unwritable with chmod, which does not stop root, the user this sandbox runs as; they pass in CI.On the head (2e5af57, tests only since): the 136 unit tests of
vendor::nuget_feedand the 162 tests of thevendorsuite.The real .NET SDK 8 for the transcripts above. SDK 10, Windows, macOS and the Docker suites were not run here. No
cfg(windows)orcfg(unix)code changed.CI on 2e5af57 at 16:41Z: 54 checks pass, 71 are skipped (45 of them by a run that the push started while the PR was a draft, the rest by path), none failed.
Cursor Bugbot reviewed 2e5af57 and raised one finding (medium): the pin check takes an unreadable lock for "no mismatch". Not changed: run, the state does not pass. A symlinked lock is read through the link, and a lock that is not UTF-8 or not a regular file fails the liveness rule first (
vendor --checkexits 1 with "wiring missing",vexomits withvendor_unwired), because discovery calls every governed lock it cannot read unusable and the pin is judged only on a package that rule calls wired. The three runs are on its thread, which is resolved.git diff --stat: 6 files, +645 −53. Production +171 −53 (vendor/nuget_feed.rs,vex/verify.rs, CLIcommands/vendor.rs,commands/vex.rs). Tests +474 −0.Generated by Claude Code