The unit test for "every jar copy must be patched" passes when VEX checks only the first copy

未关闭 适合新手
#2,319 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
security, testing

调研方向

从 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:triaged arch-audit priority:p3 refactor

[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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SocketDev/socket-patch 的其他 Issue

查看 SocketDev/socket-patch 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。