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

Ouverte Adaptée aux débutants
#2,319 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
75/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust
Domaine
security, testing

Piste de recherche

Commence par verify_member_copies dans vex/verify.rs (environ lignes 390-407) et par le test maven_member_record_verifies_every_jar_copy (environ lignes 2970-3002). Construis la fixture à deux copies de sorte que le jar non modifié se trouve dans un répertoire de hash qui se trie en premier (0000…) et à nouveau dans un répertoire qui se trie en dernier (ffff…), en attendant not_applied dans les deux cas. C'est terminé lorsque les nouvelles assertions échouent face au mutant take(1) décrit dans l'issue et passent sur main, en utilisant cargo test -p socket-patch-core --lib -- maven_member_record_verifies_every_jar_copy.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
Rust
Étoiles
9
Forks
2
Merge moyen
1 j 11 h
PR mergées (30 j)
282

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de SocketDev/socket-patch

Toutes les issues de SocketDev/socket-patch

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.