Vendored Maven reactor reads -D properties from commented-out .mvn/maven.config lines, so a 1.11.0 build is silently downgraded to 1.10.0-socket.* (or a valid patch is refused)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust
- 领域
- build-system, cli
调研方向
Start in crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs at cli_properties around line 1250, then inspect the e2e_vendor_jvm_build::maven_reactor fixture and its existing controls. Reproduce the commented .mvn/maven.config cases, and add regression coverage showing commented-out properties are ignored while real Maven properties still behave correctly. Done means the fixture no longer downgrades or refuses the dependency because of a commented line.
由索引模型根据 Issue 内容生成。
描述
[agent] Found by the scheduled Maven bug-hunt routine (ledger #318).
Summary
Since Maven 3.9.0, a .mvn/maven.config line that starts with # is a comment, and Maven 4 keeps that rule. The reactor planner's cli_properties doesn't skip comments. It splits the whole file on whitespace and keeps every token that starts with -D and contains =:
So # -Dct.version=1.10.0 (an old pin someone commented out) still becomes the user property ct.version=1.10.0. Because lookup lets user properties beat model properties (maven_reactor.rs:939), that phantom value overrides the pom's real <ct.version>.
This is the reverse of #535. There, the parser misses properties that Maven applies. Here, it invents properties that Maven ignores. The cause sits in the same function, but the inputs and the regression test are different.
Impact
- Silent downgrade (the main case). A pom with
<ct.version>1.11.0</ct.version>and a commented-out# -Dct.version=1.10.0line builds 1.11.0. Aftervendor,${ct.version}in the module is replaced by the literal1.10.0-socket.<hex>.vendorexits 0 withapplied: 1, and the only warnings are the genericmaven_f_outside_root/maven_mirror_of_all.vendor --checkreportsvendor_check_ok, andvexattestsnot_affected. Every fix in 1.11.0 outside the patch is lost, and a later bump of the property no longer takes effect. - Spurious refusal (the reverse case). A pom with
<ct.version>1.10.0</ct.version>and a commented-out# -Dct.version=1.11.0line getsconflicting_literal_version, so nothing is pinned and the build keeps Central's unpatched 1.10.0. This direction fails closed (warned, andvendor --checkfails), but the patch is refused when it should apply.
Repro
This is the e2e_vendor_jvm_build::maven_reactor fixture (aggregator, corp-parent/, modules a and b), with:
corp-parent/pom.xml<properties>holding<ct.version>1.11.0</ct.version>.a/pom.xmldeclaring commons-text at<version>${ct.version}</version>.b/pom.xmlwithrelativePath../corp-parent/pom.xml, to stay clear of #534 for thevexstep.
mkdir -p .mvn && printf '# -Dct.version=1.10.0\n' > .mvn/maven.config
mvn -B package org.apache.maven.plugins:maven-dependency-plugin:3.5.0:build-classpath -Dmdep.outputFile=target/cp.txt
# a/target/cp.txt → commons-text-1.11.0.jar (Maven ignores the comment)
# stage the commons-text 1.10.0 patch manifest (as the capstone does), then
socket-patch vendor --json --offline
# applied: 1, warnings only maven_f_outside_root / maven_mirror_of_all
# a/pom.xml: <version>${ct.version}</version> → <version>1.10.0-socket.1d3c1fd2</version>
mvn -B package ...build-classpath...
# a/ and b/ cp.txt → .socket/vendor/maven2/.../commons-text-1.10.0-socket.1d3c1fd2.jar ← downgraded
socket-patch vendor --check --offline --json # verified: 1, vendor_check_ok
socket-patch vex --offline --output vex.json # not_affected / inline_mitigations_already_exist
# -Dct.version=1.10.0 old pin (extra spaces and trailing words) behaves the same way.
Controls:
- The same project without
.mvn/maven.configgetsconflicting_literal_version, no pin, and the build stays on 1.11.0. # just a notewith the pom at 1.10.0 is patched correctly.
Expected vs actual
- Expected: the planner models Maven's own user properties (
lookup: "User properties win over model properties, as in Maven"), so lines that Maven treats as comments define nothing.docs/design/maven-vendoring.mdsays that conflicting explicit versions "produce specific warnings; the backend does not silently claim those unsupported declarations are patched." With the comment ignored, the main case is aconflicting_literal_version(1.11.0 ≠ 1.10.0) with no pin, exactly like the no-config control. - Actual: the commented-out value is used. The resolved 1.11.0 is rewritten to
1.10.0-socket.*, andvendor --checkand VEX both confirm it.
Matrix (Linux, JDK 21, main 61cfb9b)
| Maven | pom 1.11.0 + # -Dct.version=1.10.0 |
pom 1.10.0 + # -Dct.version=1.11.0 |
no config / # just a note (controls) |
|---|---|---|---|
| 3.6.3 | n/a: Maven rejects # lines itself |
n/a | — |
| 3.8.8 | n/a: Maven rejects # lines itself |
n/a | — |
| 3.9.11 | fail: 1.11.0 → 1.10.0-socket.* (reproduced 3×) | fail: refused, unpatched | pass |
| 3.9.16 | fail (2×, one with the old pin variant) |
fail | pass |
| 4.0.0-rc-7 | fail (2×) | fail | pass |
macOS and Windows weren't probed. The parsing is OS-independent.
First bad commit
2463257 (#277, the v5 consolidation that added the reactor planner and cli_properties). It isn't in any release yet (latest release 4.0.0).
Suspect code: crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs:1250 (cli_properties, which drops no # lines before tokenising). A fix there would naturally handle #535 too: parse per line, skip # lines, and accept --define= / -D k=v.
- 主要语言
- Rust
- 星标
- 8
- 派生
- 1
- 平均合并
- 16 小时 39 分钟
- 30 天内合并 PR
- 584
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:pipenv priority:p1
难度 2/5 1-3 小时 新手友好度 78/100
SocketDev/socket-patch#1608 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:vlt priority:p1
难度 2/5 1-3 小时 新手友好度 62/100
SocketDev/socket-patch#1601 · 2 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:npm priority:p3 ux
难度 2/5 1-3 小时 新手友好度 75/100
SocketDev/socket-patch#1072 · 2 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
难度 2/5 1-3 小时 新手友好度 73/100
SocketDev/socket-patch#783 · 1 条评论 ·
维护者通常 1 天内回复
-
Vendored scan exits 0 when .gitignore covers `.socket/vendor/state.json`, so the commit silently drops the ledger and every other checkout's `rollback` fails with vendor_ledger_missing可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug bughunt pm:pnpm
难度 3/5 1-2 天 新手友好度 76/100
SocketDev/socket-patch#1638 · 1 条评论 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
proxy: include denial_category in the "proxy request denied" log line可能已有人在做 @sreyas-endor 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
metasequoiaime/msime#9113 ·
维护者通常 1 天内回复
-
area:desktop priority:p2 type:chore
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
area: supply-chain
难度 1/5 1 小时以内 新手友好度 73/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100