Repository navigation
Fix VEX attesting beside an unpatched same-lock copy (#935, #938, #939) - #940
Conversation
A lockfile-only `vex` attested a package as not_affected while the same lock also installed an unpatched copy of that exact name@version: - pnpm: a `file:` directory or tarball copy (#935) - yarn classic: a registry block left beside the Socket block, e.g. after `yarn add -W left-pad --exact` (#938) - yarn berry: a `file:` / url copy locked under another dependency name, which the `resolutions` pin never reaches (#939) The cross-lock contest only weighs OTHER locks, and each extractor wrote its own same-lock rule (npm and yarn classic git only). Discovery now has one shared same-lock rule: extractors record an unpatched copy and every ref of the same name@version in that lock is dropped with a patched_ref_unattributable diagnostic naming the copy. Yarn classic's git-copy filter moves onto it. The berry and pnpm extractors read the copy's real package from its package.json (directory or tarball) or from the registry tarball url. Assisted-by: Claude Code:claude-opus-5-5
main has failed socket-patch-core's lib tests since Gradle support (#646) and the digest helpers (#865) both landed. The guard test production_digests_go_through_the_helpers flags three files #646 added that still hash inline: crawlers/gradle_cache.rs, patch/jvm_jar.rs and patch/sidecars/maven.rs. That breaks test, test-release and coverage on every open PR. Each inline sha1/sha256 call now goes through sha1_hex_of or sha256_hex_of, which compute the same lowercase hex. Behaviour is unchanged. Assisted-by: Claude Code:claude-opus-5-5 (cherry picked from commit 659ac2c)
Every non-Socket yarn classic block is now recorded as a possible unpatched copy, and each record scanned the whole list for a duplicate first. On a 3000-package lock that made hosted scans and rescans about 17% slower in the scan benchmark. The list is already sorted and deduplicated once when discovery finishes, so the per-record scan goes. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
|
[agent]
The run is still in progress, so GitHub won't re-run the failed job yet (403 "already running"). I'll re-run it once when the run finishes. If it fails again, I'll pull Generated by Claude Code |
|
Ready for review at
Generated by Claude Code |
Conflicts: - vex/discover/mod.rs: kept both main's ContestedRef/`contested` and this branch's UnpatchedCopy/`unpatched_copies` (structs, fields, finalize); `contest_within_locks` still runs before `contest_across_locks`, after main's new sbt extractor. - vex/discover/testing/golden.rs: import and render both `contested` and `unpatched_copies`. - vex/discover/yarn.rs: kept main's ClassicBlockSource match and classic_block_purl; main's #921 `file:` directory copies and the git copies now go through the shared `Discovery::unpatched_copy` rule instead of main's local post-filter loop (same diagnostic: names the lock entry and "file: directory"). Co-Authored-By: Claude <noreply@anthropic.com>
|
bugbot run Generated by Claude Code |
- `scan --prune --dry-run` previewed the vendor GC's manifest drop with a qualifier-strip relation while the wet pass used PurlKey, so NuGet case, PEP 503 and composer padding variants were pruned for real but not in the preview. Both now call vendor::unused_vendored_manifest_keys. - LockfileSupplement.purls is a HashSet<PurlKey> built once, so the lockfile-only predicate is one hash lookup instead of re-keying the whole set on every miss. - Ledgers::hosted_vendored_overlap deduplicates by PurlKey, so two spellings of one release give one takeover warning. - get's hosted-claim set (rebased onto #940's new code) is a HashSet<PurlKey>; the new gem takeover pin lookup uses PurlKey::same. - composer_version: pin that the sentinel-free key PurlKey uses never lets a rejected spelling collide with an accepted one, and document it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merges cleanly; additionally routes the yarn berry url-copy VEX justification (added on main in #940) through redact_url so a credentialed tarball URL never reaches the published VEX document. Co-Authored-By: Claude <noreply@anthropic.com>
- `scan --prune --dry-run` previewed the vendor GC's manifest drop with a qualifier-strip relation while the wet pass used PurlKey, so NuGet case, PEP 503 and composer padding variants were pruned for real but not in the preview. Both now call vendor::unused_vendored_manifest_keys. - LockfileSupplement.purls is a HashSet<PurlKey> built once, so the lockfile-only predicate is one hash lookup instead of re-keying the whole set on every miss. - Ledgers::hosted_vendored_overlap deduplicates by PurlKey, so two spellings of one release give one takeover warning. - get's hosted-claim set (rebased onto #940's new code) is a HashSet<PurlKey>; the new gem takeover pin lookup uses PurlKey::same. - composer_version: pin that the sentinel-free key PurlKey uses never lets a rejected spelling collide with an accepted one, and document it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
bugbot run |
Resolve conflicts in vex/discover: keep main's same-lock contest (#940) alongside this branch's unwired-copy unattestation, pnpm bundled copies and berry registry-locator contest. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit acbac79. Configure here.
After merging main's #940 same-lock unpatched-copy contest into the #828 shadowing, a pin withheld because a pnpm file: dir/tarball, a yarn classic registry/file: block, or a berry other-name file:/url copy installs beside it is shadowed and restored like any other pin. Extend the CLI contract sentence that only named bundled, git and hasShrinkwrap-nested copies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
[agent] Merged at
Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #938
Refs #935
Refs #939
Summary
A lockfile-only
vexattested a package asnot_affectedeven though the same lock also installed an unpatched copy of that exactname@version:file:directory orfile:tarball copy of the patched package@version in the same pnpm-lock.yaml installs unpatched, and hosted/vendored scans give no warning for that copy #935): afile:directory orfile:tarball copy beside the Socket-wired registry entry.yarn add -W <pkg> --exact), though yarn installs only the unpatched registry copy #938): a registry block of the same version beside the Socket block, e.g. afteryarn add -W left-pad --exact. yarn 1 installs one copy per name@version, from whichever block it resolves first.file:/URL copy of the patched package locked under another dependency name, so lockfile VEX (and vendored VEX after install) attests not_affected while that copy installs unpatched #939): afile:/ url copy locked under another dependency name (lp2@file:…). Theresolutionspin never reaches it.Root cause (shared)
VEX discovery had no shared same-lock rule.
contest_across_locks(vex/discover/mod.rs) skips evidence from the ref's own lock (e.file != r.source_file), so each extractor wrote its own same-lock check. Only npm (push_uncontestedunwired) and yarn classic git copies had one.Change
Discovery::unpatched_copy+contest_within_locks(vex/discover/mod.rs): one same-lock rule every extractor shares. An extractor records a copy, and every ref of the same name@version in that lock is dropped withpatched_ref_unattributable. The diagnostic names the copy's lock entry and how it installs. The copy also counts asresolved_elsewhereevidence for the cross-lock contest. It runs beforecontest_across_locks.yarn add -W <pkg> --exact), though yarn installs only the unpatched registry copy #938). The git-copy post-filter (Hosted and vendored yarn classic modes rewire git-sourced yarn.lock entries, so every later yarn install fails while scan and VEX report success #363) now goes through the shared rule instead of its own loop.file:directory / tarball entries (v9name@file:keys and legacyfile:keys) become copies (pnpm VEX attests not_affected while afile:directory orfile:tarball copy of the patched package@version in the same pnpm-lock.yaml installs unpatched, and hosted/vendored scans give no warning for that copy #935). Name and version come from the key and thename:/version:fields, falling back to the directory's or tarball'spackage.json. A directory holding another version is not a copy.file:/ url locator becomes a copy of the package it really holds (Yarn berry hosted and vendored scans miss afile:/URL copy of the patched package locked under another dependency name, so lockfile VEX (and vendored VEX after install) attests not_affected while that copy installs unpatched #939). The name is read from thefile:tarball'spackage.json, thefile:directory'spackage.json(path resolved against thelocator=workspace), or the registry tarball url path (…/<name>/-/<name>-<version>.tgz). A copy whose package can't be read is left alone.vexgaps in Yarn classic VEX attests not_affected when yarn.lock also has a registry block for the patched name@version (e.g. afteryarn add -W <pkg> --exact), though yarn installs only the unpatched registry copy #938 / Yarn berry hosted and vendored scans miss afile:/URL copy of the patched package locked under another dependency name, so lockfile VEX (and vendored VEX after install) attests not_affected while that copy installs unpatched #939 close through the same path. Discovery still recognizes the uuid but emits no ref for it, so the vendor ledger's claim is dead (rule 11) and is not attested.7eda8d8, cherry-pick of659ac2c).mainfailsutils::digest::tests::production_digests_go_through_the_helpers(thecoverage/test-releasejobs), and Route Gradle digests through utils::digest #878 is the open fix. This becomes a no-op once Route Gradle digests through utils::digest #878 lands.Why #935 and #939 are
Refs, notFixesBoth issues also ask the hosted / vendored scans to warn about the unreached copy. That is a separate gap in four rewriters (pnpm and berry, hosted and vendored), not this discovery boundary. This PR fixes the false VEX attestation for both. The scan warnings are left as a follow-up on those issues.
Test evidence
Regression tests, red with
contest_within_locksdisabled and green with it:vex::discover::npm::tests::issue_935_same_lock_file_copy_contests_the_pnpm_ref: v9 dir, v9 tgz, legacy dir, plus controls (wiring alone; dir of another version)vex::discover::yarn::tests::issue_938_classic_registry_block_of_the_same_version_contests_the_ref: plus control (registry block of another version)vex::discover::yarn::tests::issue_939_berry_other_name_copy_contests_the_ref:file:tgz,file:dir, registry url, plus controls (wiring alone;file:copies holding another package)The existing
classic_git_pattern_copies_are_never_attestedalso went red with the shared pass disabled, which confirms git copies now go through it.Local runs:
cargo test -p socket-patch-core --all-features --lib: 5248 passed. 4 permission-based tests fail only because this sandbox runs as root (copy_treesymlinked root,vlt_healunremovable lock, poetry / requirements write failure). They pass in CI onmain's head. The 5th failure was the digest guard, fixed by the Route Gradle digests through utils::digest #878 port.cargo test -p socket-patch-cli --all-features --lib --test e2e_vex_lockfile --test e2e_vex_redirect --test e2e_vex_vendor --test e2e_vex --test covgap_commands_vex: all green (847 + 12 + 19 + 311 + 31 + 28).cargo clippy --workspace --all-features -- -D warnings: clean.redirect-npm.json): regenerated. The only change is an additiveunpatched_copiessection on yarn classic fixtures. No ref or diagnostic changed.cargo fmt: touched files are formatted.mainitself isn'tcargo fmt --checkclean (about 120 files), and CI doesn't run fmt.yarn-classic/hosted/rescanby 16–18% because of a quadratic per-insert dedup.980b7b6removes it. A localsocket-patch-bench compare --filter yarn-classicagainstmainthen shows +1.4% [-10.4, +8.1] and -3.0% [-8.1, +3.3], both ≈.The npm / PyPI / gem wrappers don't need changes: this is Rust-only discovery logic.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RpNijzXr9S3AZY6xHUDwVH
Note
Medium Risk
Changes VEX discovery and attestation eligibility for npm-family locks when duplicate same-version install paths exist; behavior is fail-closed (drops refs, emits diagnostics) but affects security-relevant VEX output.
Overview
Stops false VEX
not_affectedclaims when a lockfile both wires a package to a Socket patch and still installs an unpatched copy of the samename@versionin that same lock—something cross-lockcontest_across_locksnever saw because it ignores evidence from the ref’s own file.Discovery now has a shared
unpatched_copy/contest_within_lockspath: extractors record competing lock entries (with key + how they install), those copies also count asresolved_elsewhere, and matching refs are dropped withpatched_ref_unattributablediagnostics that name the copy. The pass runs after all extractors and before cross-lock contesting.pnpm (#935):
file:directory and tarball entries (v9 and legacy keys); package identity from lock fields or the copy’spackage.json/ tarball.Yarn classic (#938): non-Socket registry tarball blocks beside a Socket block (replacing a yarn-only post-filter); git and
file:directory copies go through the same API.Yarn berry (#939):
file:/ URL locators keyed under another dependency name; real package name from tarball, directory manifest, or registry URL path.Golden discovery output gains an
unpatched_copiessection; regression tests cover the three issues plus controls (wrong version, different package, wiring alone).Reviewed by Cursor Bugbot for commit acbac79. Configure here.