Repository navigation
Commit 872b591
Stop hosted Go redirects claiming unpatched deps (#252)
* Stop hosted Go redirects claiming unpatched deps
Hosted mode counted a Go module as redirected whenever any project
file held the patch-server origin (an already hosted package-lock.json)
or leftover gopatch go.sum lines, even when the go.mod rewrite was
refused, so VEX attested modules that still built unpatched. Go deps
now count only when the rewriter reports the replace and both go.sum
lines in place. A module that go.mod does not require and go.sum does
not list (another project's module in the shared module cache) is
refused instead of getting an inert replace.
Switching a vendored Go module to hosted mode now reverts its vendored
copy and ledger entry first, as cargo and npm already did, so the next
vendor run no longer switches it back.
Replaces the CLI did not write are left alone: only ./.socket/... paths
and exactly patch.socket.dev/gopatch/<uuid> are socket-owned, not a
sibling checkout's .socket/vendor copy or a deeper gopatch path.
Duplicate socket replaces for one module collapse to one, a refreshed
directive keeps its trailing comment, quoted module paths are
recognized, and %2B-encoded +incompatible versions resolve in vendor
and apply.
Assisted-by: Claude Code:claude-opus-5-5
* Fix reconcile to use canonical_purl for percent-decoded Go version comparison
The reconcile_go_redirects function was using strip_purl_qualifiers to build
desired_bases, which doesn't decode percent-encoded characters. However,
parse_golang_purl now decodes characters like %2B to +, so on-disk copies
use the decoded version (+incompatible) while manifest keys still have the
encoded form (%2Bincompatible).
This mismatch caused reconciliation to treat valid copies as orphans and
remove them along with their go.mod replace directives.
The fix uses canonical_purl instead, which both strips qualifiers and
decodes, ensuring proper matching between manifest keys and disk-based PURLs.
Added test_reconcile_keeps_percent_encoded_version to prevent regression.
* Log the +incompatible reconcile fix
The previous commit stopped apply reconcile from deleting a freshly
applied +incompatible go-patches copy (manifest keys spell it
%2Bincompatible, the copy directory uses the decoded version). Record
it under Unreleased > Fixed.
Assisted-by: Claude Code:claude-opus-5-5
* Restore go.sum exactly on hosted Go rollback
Rolling back a hosted Go redirect appended the pruned upstream go.sum
lines to the end of the file, so go.sum did not come back byte for
byte and stayed out of go's order until the next go mod tidy. The
lines now go back where go sorts them: module path, then semver
version, then the /go.mod suffix.
CRLF projects also unwind cleanly. The socket module's go.sum lines
are removed line by line instead of as an LF-joined fragment, and
removing the replace line takes its CRLF with it, so no socket lines or
blank lines are left behind.
Assisted-by: Claude Code:claude-opus-5-5
* Unwind hosted Go redirects before vendoring
Vendoring a hosted-redirected Go module rewrote its replace in place
but kept the redirect-ledger record, the socket module's go.sum lines,
and the pruned upstream go.sum lines. The ledger kept claiming a
hosted redirect that was gone, and vendor --revert left go.sum without
the upstream lines.
Go now gets the same per-purl takeover revert as cargo and npm. The
module's replace and socket go.sum lines are removed, the upstream
lines come back in go's order, and the record is dropped before the
vendored replace is written. A replace that no longer matches the
recorded one refuses the takeover and leaves the files alone. Scoped
rollback and remove of one hosted Go module now work as well.
Assisted-by: Claude Code:claude-opus-5-5
* Honor GOPROXY off/direct and GOPRIVATE in fetch
When a vendored Go module was missing from the module cache, the
pristine fetch skipped off and direct entries in GOPROXY and fell back
to proxy.golang.org. That sent module paths to the public proxy even
when go itself would never ask one, including for GOPRIVATE modules.
The fetch now follows go: if the first GOPROXY element is off or
direct, or the module matches GONOPROXY (default GOPRIVATE), it is
refused with the usual unverifiable warning and not-installed skip.
An explicit SOCKET_GOPROXY still wins.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>1 parent cf8150b commit 872b591
17 files changed
Lines changed: 1690 additions & 130 deletions
File tree
- crates
- socket-patch-cli
- src/commands
- scan
- tests
- socket-patch-core/src
- crawlers
- patch/redirect
- utils
- vendor
- vex/discover
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
505 | 562 | | |
506 | 563 | | |
507 | 564 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
419 | 420 | | |
420 | 421 | | |
421 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1085 | 1084 | | |
1086 | 1085 | | |
1087 | 1086 | | |
| |||
1307 | 1306 | | |
1308 | 1307 | | |
1309 | 1308 | | |
1310 | | - | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1311 | 1313 | | |
1312 | 1314 | | |
1313 | 1315 | | |
| |||
1323 | 1325 | | |
1324 | 1326 | | |
1325 | 1327 | | |
1326 | | - | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
1327 | 1331 | | |
1328 | 1332 | | |
1329 | 1333 | | |
| |||
2326 | 2330 | | |
2327 | 2331 | | |
2328 | 2332 | | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
2329 | 2339 | | |
2330 | 2340 | | |
2331 | | - | |
2332 | | - | |
2333 | | - | |
| 2341 | + | |
2334 | 2342 | | |
2335 | 2343 | | |
2336 | 2344 | | |
2337 | 2345 | | |
2338 | 2346 | | |
2339 | | - | |
2340 | 2347 | | |
2341 | 2348 | | |
2342 | 2349 | | |
| |||
2352 | 2359 | | |
2353 | 2360 | | |
2354 | 2361 | | |
2355 | | - | |
2356 | 2362 | | |
2357 | 2363 | | |
2358 | 2364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1704 | 1704 | | |
1705 | 1705 | | |
1706 | 1706 | | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
1707 | 1710 | | |
1708 | 1711 | | |
1709 | 1712 | | |
| |||
0 commit comments