Skip to content

Prove the patch mirror for Bun, vlt, PDM, Pipenv and Go, and read vlt pins under a mirror - #2256

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
mirror-live-legs
Nov 25, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
mirror-live-legs

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

What this does

The experimental patch mirror (--patch-mirror-url, #2180) had been run through a real Artifactory with npm, pnpm, yarn classic, yarn berry, pip, uv and Bundler. This PR adds live legs for Bun, vlt, PDM, Pipenv and Go and runs them against Artifactory OSS 7.161. It also fixes the one CLI bug those runs found.

Each leg locks a small real project whose dependency has a free Socket patch (minimist 1.2.2, urllib3 1.26.18, pgx v5.7.0). It then runs scan --mode hosted --patch-mirror-url <repository>, installs with the real package manager from cold caches, and checks that the installed code carries the patch. Every credentialed leg also checks that an install without credentials is refused.

Ecosystem Pinned through the mirror Cold install How the build gets read access
Bun 1.3.3 yes yes, anonymous repository Bun sends no credentials for a URL pin. The leg checks that the credentialed repository refuses the install even with .npmrc credentials
vlt 1.8.2 yes, after the fix below yes a keychain token stored for the mirror's base (vlt token add --registry=<base>)
PDM 2.29 yes yes netrc
Pipenv 2026.12 yes yes netrc
Go 1.26 pin left as the module path (by design) yes, anonymous repository GOPROXY=<base>,https://proxy.golang.org. go sends no credentials over plain http
Composer not testable — No Composer patch was available. A real 24-package composer.lock (monolog, guzzle, twig, symfony, commonmark, phpseclib at vulnerable versions) scans to zero patches through the public API

Bug fixed: a mirror run skipped every vlt pin

vlt lockfile discovery is what vex, list, rollback and vendor read. It checked the name and version a pin embeds by stripping a leading patch/npm from the URL's own path. Under a mirror that path starts with the mirror's base (/artifactory/socket-patch/patch/npm/...). So every mirrored vlt pin read as "not an artifact of" its package, and scan --mode hosted --patch-mirror-url skipped minimist with redirect_unattributable.

Discovery now reads the path as the patch server serves it, below the mirror's base or a deployment's path prefix. That is the new origin::hosted_served_path. Under a mirror, it looks for the serve level directly below the base, so a base path that itself contains gopatch or patch/<eco> is never mistaken for that level. A unit test in vex/discover/vlt.rs covers three cases: a mirrored pin is a hosted ref; a mirrored pin whose embedded version disagrees is not; without the mirror configured, the same URL is not hosted. The vlt leg also checks that list reads the mirrored pin.

Go through Artifactory

Socket's Go pin is replace … => patch.socket.dev/gopatch/<uuid>. go resolves that module through the patch server's go-import tag, which points at the server's root as a GOPROXY. A generic remote of the patch server serves that protocol at its base (<base>/patch.socket.dev/gopatch/<uuid>/@v/<v>.info|.mod|.zip) and answers 404 for every other module. So GOPROXY=<base>,https://proxy.golang.org fetches every Socket module through Artifactory and the rest from the public proxy. The leg checks that from go mod download -x all.

Artifactory OSS's own Go repository type is no alternative. Its YAML configuration accepts type: go, but the repository's GOPROXY endpoint /api/go/<repository> answers 404. I created a probe repository to check this and then removed it.

go refuses to send credentials (netrc, or userinfo in GOPROXY) to a plain-http URL. So on this loopback http Artifactory, only the anonymous repository can be tested. A real https Artifactory takes netrc as usual.

Docs

  • CLI_CONTRACT.md "Patch mirror (experimental)":
    • The list of tested managers now includes Bun, vlt, PDM, Pipenv and Go. Composer is listed as untested, because no Composer patch was available to test with.
    • New bullet, Installing through the mirror: how each package manager is handed the repository's credentials, which ones need anonymous reads, and what a Go build sets.
    • The Go bullet points to that new bullet.
    • The "already pinned on the patch server" bullet now includes vlt and Pipenv: an earlier direct pin is re-pinned onto the mirror by the same run, which I checked by hand on both. It also says a Go pin is never moved.
  • docs/configuration.md mentions GOPROXY.
  • The suite header lists the legs.

Testing

Live run on this commit against Artifactory OSS 7.161 (socket-patch with credentials, socket-patch-anon anonymous), with every tool on PATH:

SOCKET_PATCH_ARTIFACTORY_E2E_STRICT=1 cargo test -p socket-patch-cli --test e2e_artifactory_mirror -- --ignored bun_ vlt_ pdm_ pipenv_ go_
  5 passed
cargo test -p socket-patch-cli --test e2e_artifactory_mirror -- --ignored
  13 passed, no SKIP lines

Those numbers are from the second commit. The third commit only changes wording. The full suite was also run with STRICT=1.

Also:

  • cargo test -p socket-patch-core --lib: 8579 passed.
  • tests/patch_mirror.rs (hermetic): 5 passed.
  • cargo clippy --locked --workspace --all-features -- -D warnings: clean.
  • cargo check --workspace --all-targets --all-features: clean, apart from two unused-import warnings that are already on main.
  • cargo fmt --check: clean.

Not covered

  • Go's refusal to send credentials over plain http. I checked it by hand (netrc, and userinfo in GOPROXY); no leg asserts it.
  • Maven, Gradle and sbt through a mirror. This machine is rate-limited by Maven Central.
  • Composer, until a Composer patch is available to test with.
  • vendor on a Pipenv project pinned through a mirror, and the Pipenv rewriter's recognition of earlier pins by host and path shape. A separate PR covers both. The Pipenv leg here only scans and installs.

Code review

/code-review high reported five findings. All are fixed in the second commit:

  • hosted_served_path found the serve level anywhere in the path. A mirror base like .../artifactory/gopatch was read as that level, so vlt pins under it were rejected. It now starts directly below the base, and a unit test covers such bases.
  • The Go leg panicked on a machine without go. It now skips.
  • The vlt, PDM and Pipenv legs accepted any failure as the "refused without credentials" result. They now require the 401.
  • The Bun leg's children now drop ambient BUN_* and npm_config_* settings.
  • The contract's "already pinned" bullet now covers vlt, Pipenv and Go.

Not changed: the review suggested the same base-depth fix for the existing hosted_base_path, which the in-place takeover uses. That code came in with #2180, and this PR leaves it alone. The limitation is still open: if a mirror's base path contains gopatch or patch/<eco>, the base computed for taking over an earlier pin is wrong for yarn berry, Bun, Poetry and PDM. That needs its own follow-up.

No CHANGELOG.md entry, per the repository rule.

🤖 Generated with Claude Code

… pins under a mirror

The live Artifactory suite gains five legs, each run against Artifactory
OSS 7.161 with cold caches:

- Bun installs through an anonymous repository. It sends no credentials
  for a URL pin, and the leg checks that a repository that needs them
  refuses the install even with credentials in `.npmrc`.
- vlt installs with a keychain token stored for the mirror's base.
- PDM and Pipenv install with netrc credentials.
- Go fetches the Socket modules through a generic remote listed first in
  GOPROXY. The pin is a module path and is not moved. go sends no
  credentials over plain http, so the leg uses the anonymous repository.

Fix: vlt lockfile discovery read a pin's embedded name and version from
the URL path itself, which under a mirror starts with the mirror's base.
So every mirrored vlt pin was "not an artifact" of its package, and a
mirror scan skipped it with `redirect_unattributable`. It now reads the
path the patch server serves (`origin::hosted_served_path`), below the
base or the deployment's prefix. Unit test included.

The contract's mirror section lists the newly tested managers. A new
"Installing through the mirror" bullet says how each one gets the
repository's credentials, which ones need anonymous reads, and what a Go
build sets. Composer stays untested because Socket publishes no Composer
patch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he legs

- `hosted_served_path` now starts the serve level right below a patch
  mirror's base. Before, a base path that itself held `gopatch` or
  `patch/<eco>` (`.../artifactory/gopatch`) was read as the level, and
  every mirrored vlt pin under it was rejected. A unit test covers such
  bases.
- The Go leg probes `go version` through `has_command_with`, so a machine
  without go skips instead of panicking.
- The vlt, PDM and Pipenv legs require the 401 in an install refused for
  want of credentials, as the npm and Bun legs do.
- bun children drop ambient `BUN_*` and `npm_config_*` settings.
- The contract's "already pinned on the patch server" bullet names vlt
  and Pipenv (re-pinned onto the mirror by the same run, checked by hand)
  and says a Go pin is never moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 25, 2026 19:53
@cursor

cursor Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes hosted URL path parsing used by vlt VEX discovery (attestation/trust boundary), though scoped to mirror-aware path normalization with new unit tests; remainder is docs and ignored live E2E tests.

Overview
Adds live Artifactory E2E coverage for Bun, vlt, PDM, Pipenv, and Go patch-mirror flows, and fixes vlt lock discovery under --patch-mirror-url.

Core fix: vlt hosted pins were judged by stripping patch/npm from the URL’s full path, so mirrored URLs (<base>/patch/npm/…) failed attribution and were skipped. Discovery now uses new hosted_served_path in origin.rs (with mirror_base_depth so a base containing gopatch or patch/<eco> is not mistaken for the serve level). embedded_identity_agrees in vex/discover/vlt.rs calls that path via DiscoverCtx.

Tests: e2e_artifactory_mirror.rs gains mirror scan/install legs (anonymous vs credentialed auth: Bun/yarn-style URL pins, vlt keychain, Python netrc, Go GOPROXY with module-path pins unchanged). Helpers include scan_mirrored_with, Bun env scrubbing, and stricter 401 assertions.

Docs: CLI_CONTRACT.md documents tested managers, Installing through the mirror (credentials per tool, Go GOPROXY), and re-pin rules; configuration.md notes GOPROXY for mirrors.

Reviewed by Cursor Bugbot for commit 7d7d014. Configure here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

[agent] Reviewed the vlt pin read under a mirror and the five live legs. The read refuses empty, extra and encoded-slash segments below the base. One nit inline, not blocking.

Comment thread crates/socket-patch-core/src/origin.rs Resolved
Merged via the queue into main with commit e98feb7 Nov 25, 2026
80 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the mirror-live-legs branch November 25, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants