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

Abierto Apto para principiantes
#2,319 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
security, testing

Línea de trabajo

Empieza con verify_member_copies en vex/verify.rs (alrededor de las líneas 390-407) y con la prueba maven_member_record_verifies_every_jar_copy (alrededor de las líneas 2970-3002). Construye el fixture de dos copias de forma que el jar original quede en un directorio de hash que ordene primero (0000…) y de nuevo en uno que ordene último (ffff…), esperando not_applied en ambos casos. Está terminado cuando las nuevas aserciones fallan contra el mutante take(1) descrito en el issue y pasan en main, usando cargo test -p socket-patch-core --lib -- maven_member_record_verifies_every_jar_copy.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Rust
Estrellas
9
Forks
2
Merge medio
1 d 11 h
PR fusionados (30 d)
282

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de SocketDev/socket-patch

Todos los issues de SocketDev/socket-patch

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.