feat: lock/digest integrity verification (aesh + resolver SPI)#2522
feat: lock/digest integrity verification (aesh + resolver SPI)#2522maxandersen wants to merge 3 commits into
Conversation
Port the lock file integrity verification feature from PR #2410 (picocli-based) to the current aesh-based CLI framework. New commands/options: - jbang lock <ref> -- generate lock entries with checksums - jbang run --locked=<none|lenient|strict> -- enforce lock checks - jbang run --lock-file=<path> -- custom lock file path New files: - Lock.java: aesh-based lock command - DigestUtil.java: shared digest/verification utilities (eliminates duplication between Lock and Run) - LockFileUtil.java: lock file read/write (properties format) Modified: - Run.java: lock verification during run - ProjectBuilder.java: locked sources override support - JBang.java, Main.java: register lock subcommand - reachability-metadata.json: native image support
…ksums Implement JBangTrustedChecksumsSource backed by .jbang.lock file, using the Maven Resolver's TrustedChecksumsSource SPI interface. This allows the same implementation to be injected into the resolver pipeline once MIMA adds an extension point for custom TC sources. Changes: - JBangTrustedChecksumsSource: implements TrustedChecksumsSource + Writer backed by lock file dep digest entries - Lock.java: uses Writer to record per-artifact checksums via the SPI - DigestUtil: uses ChecksumAlgorithmHelper.calculate() from maven-resolver-spi instead of custom MessageDigest code - build.gradle: add maven-resolver-spi and maven-resolver-impl as compile dependencies (were only transitive via MIMA runtime)
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
||
| implementation "eu.maveniverse.maven.mima:context:2.4.36" | ||
| implementation "org.apache.maven.resolver:maven-resolver-spi:1.9.24" | ||
| implementation "org.apache.maven.resolver:maven-resolver-impl:1.9.24" |
There was a problem hiding this comment.
compileOnly: as both are included into standalone-static fat jar below, plus, SPI is already transitive dep of context (it pull api, spi and util, the public APIs).
This PR adds lock-based integrity + reproducibility checks for JBang refs, ported to the aesh CLI framework and wired into the Maven Resolver trusted-checksums SPI.
Supersedes #2410 (which was picocli-based and predates the aesh migration).
p.s. The IKEA table from last time is holding up great.
What's included
jbang lock <ref>app.java) →app.java.lock.jbang.lock--lock-file=...--locked=<none|lenient|strict>none: ignore lock checkslenient(default): if lock data exists, enforce it; if lock missing, run normallystrict: require lock entry when lock file exists and enforce strict matchingref=sha256:...(main resource digest)ref.sources=...(resolved source manifest)ref.deps=...(resolved transitive dependency coordinates)ref.dep.<gav>=sha256:...(per-artifact dependency digests)Verification behavior
When lock data exists, JBang validates:
.sources) consistency.deps) consistency.dep.<gav>)Mismatch → fail with explicit error including resolved file path and fix guidance.
Maven Resolver integration
Per discussion with @cstamas, this implements the resolver's
TrustedChecksumsSourceSPI:JBangTrustedChecksumsSourceimplementsTrustedChecksumsSource+Writerbacked by.jbang.lockLockcommand uses theWriterinterface to record per-artifact checksumsDigestUtildelegates toChecksumAlgorithmHelper.calculate()frommaven-resolver-spiinstead of customMessageDigestcodesha256) and resolver format (SHA-256)Today the TC source is used standalone by
LockandRun. When MIMA gains an extension point for custom trusted-checksums sources (no such API exists through 2.4.45 or 3.0.0-alpha-3), the same implementation can be injected directly into the resolver pipeline — at which point the manual dep-digest verification loop inRuncan be deleted.Why this design
jbang lock) from execution (jbang run ...).DigestUtileliminates code duplication betweenLockandRun.Feedback requested
--lockedmode semantics (none|lenient|strict) right?<script>.lockthe right default for local file refs?TrustedChecksumsSourceSPI the right abstraction to build on for the MIMA integration path?Related issues
Relates to:
Supersedes / consolidates discussion from: