The unit test for "every jar copy must be patched" passes when VEX checks only the first copy
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 vex/verify.rs(約第 390-407 行)的 verify_member_copies 與測試 maven_member_record_verifies_every_jar_copy(約第 2970-3002 行)開始。建立包含兩個副本的測試夾具,使未修改的 jar 分別位於排序最前的雜湊目錄(0000…)與排序最後的雜湊目錄(ffff…)中,兩種情況都預期結果為 not_applied。當新的斷言在 issue 中描述的 take(1) 變異體上失敗,並在 main 上通過時即完成,執行指令為 cargo test -p socket-patch-core --lib -- maven_member_record_verifies_every_jar_copy。
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the architecture refactor routine while running mutants of safety gates against the suites that claim them. Run on main at cfc870f. Small, test code only.
Problem
verify_member_copies (core vex/verify.rs, lines 390 to 407) decides whether a Maven or Gradle patch whose record is keyed by jar members may be attested: every copy of the jar must carry the patched members. A Gradle version directory can hold the same jar in two hash directories (a re-download whose bytes changed), and a statement while one of them is pristine is a false not_affected.
The one test of that rule over two copies is maven_member_record_verifies_every_jar_copy (the same file, lines 2970 to 3002). It cannot tell "every copy" from "the first copy". Its pristine copy goes into a hash directory named 1111…, and the copies are checked in directory order, so the pristine one is read first whenever the patched jar's own SHA-1 directory sorts after it. A check that stops after the first copy still returns not_applied, and the test passes.
Evidence
The mutant, never committed:
@@ async fn verify_member_copies(
- for dir in copies {
+ for dir in copies.into_iter().take(1) {
status_verdict(jvm_jar::verify_members(&dir, jar_leaf, &record.files).await)?;
}
$ cargo test -p socket-patch-core --lib -- vex:: # with the mutant
test result: ok. 935 passed; 0 failed; 0 ignored; 0 measured; 7707 filtered out
$ cargo test -p socket-patch-core --lib -- maven_member_record_verifies_every_jar_copy
test vex::verify::tests::maven_member_record_verifies_every_jar_copy ... ok
No other suite I ran catches it either: the vex CLI group (29 tests), gradle_agent_cli (37) and e2e_maven (2) pass with the mutant on.
By its layout the assertion does catch a check of the last copy only, and an "any copy" check: both would return Ok where it expects not_applied. I did not run those two.
Planned fix
Assert both orders in the same test: put the pristine jar in a hash directory that sorts first (0000…) and then in one that sorts last (ffff…), and expect not_applied each time. A copy of the test with that loop fails on the mutant and passes on main:
$ cargo test -p socket-patch-core --lib -- maven_member_record_verifies_every_jar_copy # with the mutant
test vex::verify::tests::maven_member_record_verifies_every_jar_copy ... ok
test vex::verify::tests::zz_maven_member_record_verifies_every_jar_copy_in_both_orders ... FAILED
assertion `left == right` failed: pristine copy in ffffffffffffffffffffffffffffffffffffffff
left: Ok(())
right: Err("not_applied")
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 8641 filtered out
$ cargo test -p socket-patch-core --lib -- maven_member_record_verifies_every_jar_copy # on main
test vex::verify::tests::maven_member_record_verifies_every_jar_copy ... ok
test vex::verify::tests::zz_maven_member_record_verifies_every_jar_copy_in_both_orders ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 8641 filtered out
It can ride along with the next change to that function, or go in as a test-only PR when a slot is free.
Generated by Claude Code
- 主要語言
- Rust
- 星號
- 9
- 分支
- 2
- 平均合併
- 1 天 11 小時
- 30 天內合併 PR
- 282
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:bundler priority:p1 ux
難度 2/5 1-3 小時 新手友好度 62/100
SocketDev/socket-patch#2326 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#2306 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p3
難度 2/5 1-3 小時 新手友好度 88/100
SocketDev/socket-patch#2296 ·
維護者通常 1 天內回覆
-
agent:needs-human agent:triaged ci-janitor priority:p1
難度 2/5 1-3 小時 新手友好度 72/100
SocketDev/socket-patch#2270 · 4 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p1
難度 2/5 1-3 小時 新手友好度 82/100
SocketDev/socket-patch#2259 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 68/100
521xueweihan/HelloGitHub#4598 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
compiler-explorer/compiler-explorer#9710 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
obi1kenobi/cargo-semver-checks#1842 ·
維護者通常 1 天內回覆
-
agentic-workflows
難度 1/5 1 小時以內 新手友好度 86/100