Repository navigation
Prove the patch mirror for Bun, vlt, PDM, Pipenv and Go, and read vlt pins under a mirror - #2256
Conversation
… 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>
PR SummaryMedium Risk Overview Core fix: vlt hosted pins were judged by stripping Tests: Docs: Reviewed by Cursor Bugbot for commit 7d7d014. Configure here. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[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.
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..npmrccredentialsvlt token add --registry=<base>)GOPROXY=<base>,https://proxy.golang.org. go sends no credentials over plainhttpcomposer.lock(monolog, guzzle, twig, symfony, commonmark, phpseclib at vulnerable versions) scans to zero patches through the public APIBug fixed: a mirror run skipped every vlt pin
vlt lockfile discovery is what
vex,list,rollbackandvendorread. It checked the name and version a pin embeds by stripping a leadingpatch/npmfrom 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, andscan --mode hosted --patch-mirror-urlskipped minimist withredirect_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 containsgopatchorpatch/<eco>is never mistaken for that level. A unit test invex/discover/vlt.rscovers 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 thatlistreads 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'sgo-importtag, 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. SoGOPROXY=<base>,https://proxy.golang.orgfetches every Socket module through Artifactory and the rest from the public proxy. The leg checks that fromgo 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-httpURL. So on this loopbackhttpArtifactory, only the anonymous repository can be tested. A realhttpsArtifactory takes netrc as usual.Docs
CLI_CONTRACT.md"Patch mirror (experimental)":docs/configuration.mdmentionsGOPROXY.Testing
Live run on this commit against Artifactory OSS 7.161 (
socket-patchwith credentials,socket-patch-anonanonymous), with every tool onPATH: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 onmain.cargo fmt --check: clean.Not covered
http. I checked it by hand (netrc, and userinfo inGOPROXY); no leg asserts it.vendoron 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 highreported five findings. All are fixed in the second commit:hosted_served_pathfound the serve level anywhere in the path. A mirror base like.../artifactory/gopatchwas 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.BUN_*andnpm_config_*settings.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 containsgopatchorpatch/<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.mdentry, per the repository rule.🤖 Generated with Claude Code