Skip to content

Commit 1faf9f4

Browse files
committed
Test the Maven 3.9.4 trusted-checksum floor
The real-Maven hosted capstone treated every 3.9 release as enforcing the .mvn/checksums pin, but enforcement starts at 3.9.4. Fix the gate, pin the Maven under test through the wrapper so the capstone also checks the new warning, and add CI legs on 3.9.3 and 3.9.4. Refs #258. Assisted-by: Claude Code:claude-opus-5-5
1 parent 81e6a98 commit 1faf9f4

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,13 @@ jobs:
10651065
- {os: macos-latest, suite: e2e_vex_build, test_filter: 'pip:: --ignored', pip: '22 26'}
10661066
# Real-Maven hosted + vendored capstones, one leg per Maven line:
10671067
# 3.6 (pre http-blocker), 3.8 (resolver 1.6: no trusted checksums),
1068-
# 3.9 (trusted checksums), 4.0 rc.
1068+
# 3.9 (trusted checksums), 4.0 rc. Hosted also runs both sides of
1069+
# the trusted-checksums floor: 3.9.3 (last release that ignores
1070+
# the .mvn/checksums pin) and 3.9.4 (first that enforces it).
10691071
- {os: ubuntu-latest, suite: e2e_redirect_maven_build, maven: '3.6.3'}
10701072
- {os: ubuntu-latest, suite: e2e_redirect_maven_build, maven: '3.8.9'}
1073+
- {os: ubuntu-latest, suite: e2e_redirect_maven_build, maven: '3.9.3'}
1074+
- {os: ubuntu-latest, suite: e2e_redirect_maven_build, maven: '3.9.4'}
10711075
- {os: ubuntu-latest, suite: e2e_redirect_maven_build, maven: '3.9.16'}
10721076
- {os: ubuntu-latest, suite: e2e_redirect_maven_build, maven: '4.0.0-rc-6'}
10731077
- {os: macos-latest, suite: e2e_redirect_maven_build, maven: '3.9.16'}

‎crates/socket-patch-cli/tests/e2e_redirect_maven_build.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,19 @@ fn maven_scan_hosted_fresh_checkout_install_and_manifestless_vex() {
308308
return;
309309
};
310310
let pristine_pom = std::fs::read_to_string(proj.join("pom.xml")).unwrap();
311+
// The project pins the Maven under test through the Maven Wrapper, so
312+
// the rewriter's "your Maven ignores the Trusted Checksums pin" warning
313+
// is judged against the same release that step 5b drives (#258).
314+
std::fs::create_dir_all(proj.join(".mvn/wrapper")).unwrap();
315+
std::fs::write(
316+
proj.join(".mvn/wrapper/maven-wrapper.properties"),
317+
format!(
318+
"distributionUrl=https\\://repo.maven.apache.org/maven2/org/apache/maven/\
319+
apache-maven/{v}/apache-maven-{v}-bin.zip\n",
320+
v = mvn.version
321+
),
322+
)
323+
.unwrap();
311324

312325
// 2. Patched jar + served pom + the record (real before/after hashes).
313326
let (_orig, patched) = patched_member(&jar, UUID);
@@ -351,6 +364,17 @@ fn maven_scan_hosted_fresh_checkout_install_and_manifestless_vex() {
351364
assert_eq!(env["redirect"]["mode"], "hosted", "{env}");
352365
assert_eq!(env["redirect"]["redirected"], 1, "{env}");
353366
assert_eq!(env["vex"]["statements"], 1, "{env}");
367+
let unenforced = env["redirect"]["warnings"]
368+
.as_array()
369+
.into_iter()
370+
.flatten()
371+
.any(|w| w["code"] == "redirect_maven_trusted_checksums_unenforced");
372+
assert_eq!(
373+
unenforced,
374+
!mvn.enforces_trusted_checksums(),
375+
"Maven {}: the unenforced-pin warning must match what step 5b proves: {env}",
376+
mvn.version
377+
);
354378
let embedded: serde_json::Value =
355379
serde_json::from_slice(&std::fs::read(proj.join("embedded.vex.json")).unwrap()).unwrap();
356380
assert_attested(&embedded, &purl(), UUID, Marker::Redirected, &vulns());

‎crates/socket-patch-cli/tests/maven_build_common/mod.rs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,15 @@ impl Mvn {
179179
self.numeric()[0]
180180
}
181181

182-
/// Maven ≥ 3.9 (resolver ≥ 1.9) enforces the trusted-checksums summary
183-
/// file the hosted rewriter commits under `.mvn/checksums/`; older
184-
/// lines ignore the `aether.*` properties and only the transport
185-
/// `checksumPolicy=fail` sidecar check protects the download.
182+
/// Maven ≥ 3.9.4 enforces the trusted-checksums summary file the hosted
183+
/// rewriter commits under `.mvn/checksums/` (#258). 3.9.0 / 3.9.1 leave
184+
/// `${session.rootDirectory}` in `maven.config` uninterpolated, so the
185+
/// file is never found; 3.9.2 / 3.9.3 ignore `checksumAlgorithms=SHA-256`
186+
/// and check SHA-1 only; older lines have no trusted-checksums support.
187+
/// Below 3.9.4 only the transport `checksumPolicy=fail` sidecar check
188+
/// protects the download.
186189
pub fn enforces_trusted_checksums(&self) -> bool {
187-
let v = self.numeric();
188-
v[0] > 3 || (v[0] == 3 && v[1] >= 9)
190+
self.numeric() >= vec![3, 9, 4]
189191
}
190192

191193
/// `mvn -B <args>` in `cwd` against the local repository `m2`, with the

0 commit comments

Comments
 (0)