vex and vendor --check refuse a correctly vendored Maven reactor whose <parent><relativePath> names a directory (../corp-parent or ..), with "is not a regular file" / "unsafe path"
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 74/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 領域
- build-system, cli, devtools
研究方向
Start with local_parent_of in crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs and trace ProjectReader::read, entry_wired_checked, vex_sources.rs, and check_entry in apply.rs. Reproduce the stock maven_reactor fixture from e2e_vendor_jvm_build.rs using directory and parent relativePath values. Done means vex and vendor --check accept the correctly vendored reactor while the explicit pom.xml control remains passing.
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled Maven bug-hunt routine (ledger #318).
Summary
vendor patches a Maven reactor correctly, and the build resolves the vendored 1.10.0-socket.* jar. But when any module's <parent><relativePath> names a directory rather than a pom.xml file, socket-patch vex and socket-patch vendor --check then refuse it:
<relativePath>../corp-parent</relativePath>→cannot establish JVM wiring: corp-parent: <proj>/corp-parent is not a regular file<relativePath>..</relativePath>→cannot establish JVM wiring: unsafe path ""
Maven accepts both forms; it appends pom.xml to a directory. The repo's own reactor capstone uses the first one (B_POM in crates/socket-patch-cli/tests/e2e_vendor_jvm_build.rs), but the capstone never runs vex or vendor --check.
Impact
vexexits 1 withno_applicable_patchesand omits a patch that really is applied (vendor_jvm_shape_unsupported). Users can't produce a VEX document for a correctly patched reactor.vendor --checkexits 1 withvendor_check_failed, so a CI gate onvendor --checkgoes red on every correctly vendored reactor that uses a directoryrelativePath.- It fails closed (no false attestation), but it hits a common, valid layout.
<relativePath>..</relativePath>and<relativePath>../parent</relativePath>are widespread.
Root cause (suspect)
local_parent_of probes the bare relativePath before <path>/pom.xml:
https://github.com/SocketDev/socket-patch/blob/61cfb9b2bfa9d81a19a30618ad8da7fcfe5e7b68/crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs#L1164-L1174
During vendor, a directory read just counts as "missing", and the pom.xml candidate wins. During vex / vendor --check, the read goes through ProjectReader::read, which records any error other than NotFound (InvalidInput for a directory, unsafe path "" for the root) in read_error:
https://github.com/SocketDev/socket-patch/blob/61cfb9b2bfa9d81a19a30618ad8da7fcfe5e7b68/crates/socket-patch-core/src/vendor/jvm/apply.rs#L164-L181
entry_wired_checked then turns any recorded read error into a hard failure, even though the planner went on to find the parent through the next candidate:
https://github.com/SocketDev/socket-patch/blob/61cfb9b2bfa9d81a19a30618ad8da7fcfe5e7b68/crates/socket-patch-core/src/vendor/jvm/apply.rs#L700-L702 (used by vex at crates/socket-patch-cli/src/commands/vex_sources.rs:347 and by check_entry at apply.rs:770).
Repro
The stock reactor fixture from e2e_vendor_jvm_build::maven_reactor (aggregator root, corp-parent/, module a with commons-text:1.10.0 at <relativePath>../corp-parent/pom.xml</relativePath>, module b with <relativePath>../corp-parent</relativePath>), plus a staged patch manifest, the same as the capstone:
socket-patch vendor --json --offline # applied: 1
mvn -B package org.apache.maven.plugins:maven-dependency-plugin:3.5.0:build-classpath -Dmdep.outputFile=target/cp.txt
# a/target/cp.txt and b/target/cp.txt → .socket/vendor/maven2/.../commons-text-1.10.0-socket.1d3c1fd2.jar (patched)
socket-patch vex --json --offline --output vex.json
# exit 1, error.code no_applicable_patches, warning vendor_jvm_shape_unsupported:
# "cannot establish JVM wiring: corp-parent: <proj>/corp-parent is not a regular file"
socket-patch vendor --check --json --offline
# exit 1, event failed / vendor_check_failed: "corp-parent: <proj>/corp-parent is not a regular file"
Control: change only b's <relativePath> to ../corp-parent/pom.xml. Then vex exits 0 with not_affected, and vendor --check exits 0.
.. variant: module a inherits the root aggregator with <relativePath>..</relativePath> (b uses the pom.xml form). Then both vex and vendor --check fail with unsafe path "".
Expected vs actual
- Expected:
docs/design/maven-vendoring.mdsaysvendor --check"checks artifact hashes, recorded tree files, wiring…" and fails only on a real mismatch.vexshould attest a patch whose wiring is in place (the build demonstrably resolves the patched jar). Maven resolves a directoryrelativePathby appendingpom.xml, as the planner itself does when vendoring. - Actual: both commands fail with a filesystem error on the probe of the bare directory, which the planner then resolves anyway.
Matrix (Linux, JDK 21, main 61cfb9b)
| Maven | ../corp-parent (dir) |
.. |
../corp-parent/pom.xml (control) |
|---|---|---|---|
| 3.6.3 | fail (vex 1, check 1) | untested | — |
| 3.8.8 | fail (vex 1, check 1) | untested | — |
| 3.9.11 | fail (reproduced 2×) | fail (unsafe path "") |
pass (vex not_affected, check 0) |
| 4.0.0-rc-7 | fail (vex 1, check 1) | untested | — |
The defect is in path probing, not in Maven itself: the build resolves the patched jar on every line, so the Maven version only matters for the build oracle. macOS and Windows were not probed. The code path is OS-independent apart from the error kind for a directory read, which on Windows is PermissionDenied, not NotFound, so it's expected to fail the same way.
First bad commit
2463257 (#277, the v5 consolidation, which introduced ProjectReader::read_error and the JVM entry_wired_checked). It isn't in any release yet (latest release 4.0.0).
- 主要語言
- Rust
- 星號
- 8
- 分支
- 0
- 平均合併
- 22 小時 30 分鐘
- 30 天內合併 PR
- 329
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
`apply --check` drift report tells you to run `socket-patch apply` without the `-g` / `--global-prefix` / `--cwd` it was given, so following it patches nothing and exits 0可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:pipenv priority:p1
難度 2/5 1-3 小時 新手友好度 72/100
SocketDev/socket-patch#1219 · 1 則留言 ·
維護者通常 1 天內回覆
-
Human `scan --mode vendored --prune` silently skips the vendored GC when no remaining package has a patch, so an `npm uninstall`ed vendored entry is never reverted (exit 0), while `--json` reverts it and `vendor --check` keeps pointing at that same command可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:npm priority:p2
難度 2/5 1-3 小時 新手友好度 85/100
SocketDev/socket-patch#1127 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:bundler priority:p1
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1125 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:npm priority:p3
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1072 · 1 則留言 ·
維護者通常 1 天內回覆
-
scan exits 1 in human output but 0 with --json when every patch query returns nothing可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged arch-audit bug priority:p3
難度 2/5 1-3 小時 新手友好度 85/100
SocketDev/socket-patch#1062 · 1 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked files未關閉
難度 2/5 1-3 小時 新手友好度 70/100
maniator/verticopolis#880 ·
維護者通常 1 天內回覆
-
IO.get_env on Node truncates names at embedded NUL可能已有人在做 @Yi-111-a 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
HigherOrderCO/Bend#1449 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆