Vendored Go undo (vendor --revert, rollback, remove) stays silent about a stale vendor/modules.txt, so every build fails with "inconsistent vendoring"
維護者通常 1 天內回覆
已經有一個關聯 PR 被合併了。
- #1778 來自 @mikolalysenko —— 已合併
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 30/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 領域
- build-system, cli
研究方向
Start in crates/socket-patch-cli/src/commands/vendor.rs at run_revert, compare its forward warning path with go_consumer_sync::audit_warnings, then trace the vendored branches in rollback.rs and remove.rs. Read the apply --check / vendor --check handling to see why a stale vendor/modules.txt is not detected once no replacement entry remains. Done means all three undo paths emit go_vendor_modules_txt_out_of_sync and a later check fails until go mod vendor/go work vendor is run; check open PR #1778 before duplicating work.
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled Go modules bug-hunt routine (ledger #317).
Summary
Take a Go project with a committed vendor/ directory that was patched in vendored mode, with go mod vendor re-run as the forward warning asks. Undoing the patch with vendor --revert, rollback or remove <purl> drops the go.mod replace and exits 0 with status success. None of them warns go_vendor_modules_txt_out_of_sync, and vendor --check and apply --check both exit 0 afterwards. But vendor/modules.txt still records the removed replace, so the next default build fails:
go: inconsistent vendoring in …/c:
example.com/[email protected]: is marked as replaced in vendor/modules.txt, but not replaced in go.mod
Agent mode handles the same situation correctly. After apply → go mod vendor → rollback, the CLI warns go_vendor_modules_txt_out_of_sync and apply --check exits 1 with "still records a socket-patch replacement … run go mod vendor". This is the #343 fix. Only the vendored undo paths miss it.
Impact
Repos that commit vendor/ are the main audience for vendored mode (air-gapped and frozen CI). There, every vendored undo leaves the default build broken, and nothing tells the user to run go mod vendor. This includes the cleanup a user does when moving away from vendored mode. It's a rewrite that makes the next frozen build fail, while the CLI reports success and its own audits pass.
Expected vs actual
docs/ecosystems.md, "Files go derives from go.mod": apply, vendor, rollback and scan --mode hosted warn with the command that does the regeneration, and apply --check / vendor --check report the disagreement as drift until it is run. The warning covers a vendor/modules.txt that "does not record a socket replace, or still records one that was removed".
- Expected:
vendor --revert,rollbackandremovewarngo_vendor_modules_txt_out_of_syncwithgo mod vendor(orgo work vendor), as agentrollbackdoes, and a later check fails until the regeneration is done. - Actual: no warning (rollback only reports
reinstall_required), exit 0, and both checks exit 0.
Repro
This uses a hermetic HTTP GOPROXY and a local mock of the patch API. POST /v0/orgs/<org>/patches/package returns a granted tarball: an example.com/[email protected]/ module zip with a patched lib.go, plus sha512 integrity, in the vendor/golang.rs mount_go_granted shape. GET …/patches/view/<uuid> returns the record.
export GOFLAGS= GOENV=off GOTOOLCHAIN=local GOPROXY=http://127.0.0.1:$PORT/proxy GOSUMDB=sum.invalid.example
API="--api-url http://127.0.0.1:$PORT --org test-org --api-token fake"
# consumer: go 1.21, require example.com/upstream v1.0.0, go.sum has the upstream lines
go mod vendor && git add -A && git commit -qm vendored-dir
socket-patch get $UUID --mode vendored --yes $API # exit 0, warns go_vendor_modules_txt_out_of_sync (correct)
go mod vendor && go run . # OUT: PATCHED
git add -A && git commit -qm patched
socket-patch vendor --revert --json # exit 0, status success, warnings: []
socket-patch vendor --check # exit 0
socket-patch apply --check --offline # exit 0
go run . # exit 1: inconsistent vendoring (above)
# Same result from `git checkout . && git clean -fd` and then
# socket-patch rollback --offline --json -> exit 0, warnings: [reinstall_required]
# socket-patch remove pkg:golang/example.com/[email protected] --offline --json -> exit 0, warnings: []
# Control, agent mode on the same project shape:
# apply --offline; go mod vendor; rollback --offline --json -> warnings: [go_vendor_modules_txt_out_of_sync]
# apply --check -> exit 1 "still records a socket-patch replacement ..."
The same happens in a go.work workspace after go work vendor, both with use . at the root and in a non-root member (use ./a). The non-root member case overlaps #1766, which is agent mode. Its fix, #1767, only changes the audit in go_consumer_sync.rs, and vendored undo never calls that audit.
OS × version
| OS | go | vendor --revert | rollback | remove |
|---|---|---|---|---|
| Linux | 1.22.12 | silent, build broken | silent, build broken | silent, build broken |
| Linux | 1.24.7 (3 runs) | silent, build broken | silent, build broken | silent, build broken |
| Linux | 1.26.8 | silent, build broken | silent, build broken | silent, build broken |
| macOS / Windows | — | untested (the code path is OS-independent) |
It isn't a regression: the v5.0.1 release (npm @socketsecurity/[email protected]) behaves the same. Tested on main b787454.
Suspect code
crates/socket-patch-cli/src/commands/vendor.rs:4417(run_revert) never callsgo_consumer_sync::audit_warnings. The forward path does, atvendor.rs:4013-4026(#343, #618).crates/socket-patch-cli/src/commands/rollback.rs:3319-3329only audits when a resultis_local_go(the agent go-patches leg), so the vendored leg is skipped.crates/socket-patch-cli/src/commands/remove.rshas no Go consumer audit at all.apply --check/vendor --checknever look at a stale modules.txt when no vendored or manifest entry is left, so they pass after the revert.
No probe runs: the sandbox is Linux-only, and the go/modules.txt logic involved is OS-independent.
- 主要語言
- Rust
- 星號
- 8
- 分支
- 2
- 平均合併
- 19 小時 19 分鐘
- 30 天內合併 PR
- 697
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 83/100
SocketDev/socket-patch#1860 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 78/100
SocketDev/socket-patch#1838 ·
維護者通常 1 天內回覆
-
Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration tests可能已有人在做 @mikolalysenko 於 1 天前認領。 未關閉agent:claimed agent:triaged arch-audit priority:p3 refactor
難度 4/5 3-5 天 新手友好度 55/100
SocketDev/socket-patch#1889 · 2 則留言 ·
維護者通常 1 天內回覆
-
Memoize env-keyed subprocess probes through one helper: composer, python and ruby each define the same env key and drifted on when an answer is kept可能已有人在做 @mikolalysenko 於 1 天前認領。 未關閉agent:claimed agent:triaged arch-audit priority:p1 refactor
難度 4/5 1-2 天 新手友好度 25/100
SocketDev/socket-patch#1888 · 3 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 4/5 1-2 天 新手友好度 55/100
SocketDev/socket-patch#1887 · 1 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 77/100
yunfie-twitter/Palleria#474 ·
維護者通常 1 天內回覆
-
good first issue help wanted
難度 2/5 1-3 小時 新手友好度 72/100
servo/rust-smallvec#827 ·
維護者通常 1 天內回覆
-
bug tests
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆