Repository navigation
Commit 412796f
Add an experimental patch mirror for hosted mode behind an internal artifact host (#2180)
* Add an experimental patch mirror for hosted mode behind an internal artifact host
Hosted mode pins each patched dependency to a URL on Socket's patch
server. A build that may only download from an internal artifact host
cannot fetch from there. This adds an experimental setting that names a
mirror of the patch server (a caching proxy, such as an Artifactory
generic remote repository). Hosted mode then writes its pins under that
base, with the same path and the same integrity.
The setting is SOCKET_PATCH_MIRROR_URL, or the flag --patch-mirror-url,
which is hidden from --help. It is for Socket Enterprise customers and
is outside the semver policy while it is experimental. A repository file
cannot set it.
With the setting:
- scan and get in hosted mode move each granted reference onto the
mirror. A Go reference is untouched (its pin is a module path). Cargo
and NuGet are skipped with redirect_mirror_unsupported, because their
index names the patch server's own download URLs.
- Before a new mirrored pin is written, the run sends one HEAD for it and
follows no redirect. 2xx pins. 401, 403, 407 or a redirect pins with a
redirect_mirror_unverified warning. Anything else skips that pin with
redirect_mirror_unavailable. SOCKET_PATCH_MIRROR_AUTHORIZATION (env
only) authenticates the check and is scrubbed from child processes.
- The run's own downloads still read the patch server.
- list, vex, rollback, remove, vendor and repair read a pin on the
mirror's origin as a hosted patch.
- yarn berry, Bun, Bundler, Poetry and PDM cannot move a pin that is
already on the patch server in place. They warn
redirect_mirror_pin_not_moved and name the remedy.
For every hosted run, mirror or not: a pin of the same patch on a host
the run was not given is left alone (redirect_pin_on_unconfigured_host),
on disk and in the in-memory engine. A run without the setting never
moves a mirrored pin back onto the patch server.
Without the setting nothing else changes.
Tests: unit tests for the base parser, the candidate rewrite and the
guard. tests/patch_mirror.rs (hermetic) covers what a live mirror cannot
show. tests/e2e_artifactory_mirror.rs (ignored, live) pins a free patch
through a real Artifactory and installs it with npm, pnpm, yarn classic,
yarn berry, pip, uv and Bundler.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Apply the code review of the patch mirror
- A mirror is matched by its base, not its host. An allowlist entry for a
mirror (`mirror+<base>`) holds only the URLs at or below the base, so a
URL in another repository of the mirror's host is not a hosted pin for
list, vex, rollback or the unknown-host guard. A --patch-server-url
entry still holds its whole origin.
- The yarn berry, Bun, Poetry and PDM rewriters take over an earlier pin
under a mirror only when it sits under the mirror's base. A fork of the
same name and version elsewhere on that host stays the project's own
source.
- With a mirror, the patch server is always the first origin, so an
upstream restore (the yarn berry checksum) never asks the mirror.
- The unknown-host guard reads a composer.lock with escaped slashes as
the URL it is. A project pinned on the patch server that way was
skipped as pinned on a host called "https".
- The mirror check stops at the first request that gets no answer and
withholds the pins it has not asked about, instead of waiting out the
timeout for each one. It builds one HTTP client for the run.
- A pin the mirror refused stays withheld when a later request is
answered 401, 403, 407 or a redirect; the warning says so.
- A re-run does not ask the mirror again about a pin a composer.lock
holds with escaped slashes.
- apply ignores a mirror base it cannot use instead of exiting 2: it
does not use the mirror and runs unattended from install hooks.
- The Cargo and NuGet skip no longer says the package stays unpatched.
- The live suite's yarn berry and Bundler legs no longer depend on CI
defaults (immutable installs, lockfile checksums before Bundler 4).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Pass the mirror sources in the pixi stale-install test
The test landed on main while this branch changed the function it calls.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Use the shared envelope reader and break a module import cycle
Two repository hygiene tests failed in CI:
- The two new test files defined their own `warning_codes`. They read
the envelope through `common/envelope.rs` now.
- `vlt_heal` imported `hosted_unwind`, which imports it. It builds its
own origin list again, with the mirror listed as a mirror's base.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Compare parsed URLs in the mirror-base check, and test it for Bun and yarn berry
Review feedback on the check that an earlier pin sits under the mirror's
base before a rewriter takes it over:
- It compared text, so `<base>/../other/x` passed as a URL under the
base. It now reads both URLs as a client does: the earlier pin in any
spelling a lock uses, with `.` and `..` segments resolved.
- Poetry and PDM had a test for it. Bun and yarn berry call the same
check and had none; they have one now.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>1 parent e6c5f50 commit 412796f
28 files changed
Lines changed: 3851 additions & 58 deletions
File tree
- crates
- socket-patch-cli
- src
- commands
- scan
- hosted
- tests
- common
- get
- socket-patch-core/src
- api
- hosted
- memory
- patch/redirect
- utils
- vex/discover
- docs
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
175 | 195 | | |
176 | 196 | | |
177 | 197 | | |
| |||
626 | 646 | | |
627 | 647 | | |
628 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
629 | 685 | | |
630 | 686 | | |
631 | 687 | | |
| |||
728 | 784 | | |
729 | 785 | | |
730 | 786 | | |
| 787 | + | |
731 | 788 | | |
732 | 789 | | |
733 | 790 | | |
| |||
800 | 857 | | |
801 | 858 | | |
802 | 859 | | |
| 860 | + | |
803 | 861 | | |
804 | 862 | | |
805 | 863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
401 | 404 | | |
402 | 405 | | |
403 | 406 | | |
| |||
1202 | 1205 | | |
1203 | 1206 | | |
1204 | 1207 | | |
1205 | | - | |
1206 | | - | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
1207 | 1212 | | |
1208 | 1213 | | |
1209 | 1214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2321 | 2321 | | |
2322 | 2322 | | |
2323 | 2323 | | |
| 2324 | + | |
2324 | 2325 | | |
2325 | 2326 | | |
2326 | 2327 | | |
| |||
4209 | 4210 | | |
4210 | 4211 | | |
4211 | 4212 | | |
| 4213 | + | |
4212 | 4214 | | |
4213 | 4215 | | |
4214 | 4216 | | |
| |||
4960 | 4962 | | |
4961 | 4963 | | |
4962 | 4964 | | |
| 4965 | + | |
4963 | 4966 | | |
4964 | 4967 | | |
4965 | 4968 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
63 | 97 | | |
64 | 98 | | |
65 | 99 | | |
| |||
291 | 325 | | |
292 | 326 | | |
293 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
0 commit comments