Skip to content

Commit 3a45284

Browse files
authored
Merge pull request #15 from Deep-CodeAI/fix/858-verification-metadata-sources
fix(#858): add SHA256 entries for sources jars and Gradle distribution
2 parents b99643b + b066b34 commit 3a45284

2 files changed

Lines changed: 119 additions & 0 deletions

File tree

build.gradle.kts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,97 @@ pitest {
5050
excludedGroups.set(setOf("live-llm", "live-mcp"))
5151
}
5252

53+
// #858 — supply-chain hygiene. After bumping a dependency, Gradle wrapper, or
54+
// plugin, run `./gradlew updateVerificationMetadata` (or `gradlew.bat ...` on
55+
// Windows) to refresh gradle/verification-metadata.xml.
56+
//
57+
// Why a Gradle task instead of a shell script: this works the same on macOS,
58+
// Linux, and Windows. `gradlew` itself is the cross-platform entry point.
59+
//
60+
// What it does: invokes a second `gradlew` process with the right
61+
// --write-verification-metadata flag and the task list that exercises every
62+
// classpath the build actually uses (the bare `help` task only resolves the
63+
// runtime classpath; plugin classpaths, test classpath, and Kotlin compiler
64+
// plugin classpaths get missed).
65+
//
66+
// Sources/javadoc jars are exempted via <trusted-artifacts> in the metadata
67+
// file — they're IDE-only, never on the runtime classpath.
68+
tasks.register("updateVerificationMetadata") {
69+
description = "Regenerates gradle/verification-metadata.xml after a dependency or Gradle update."
70+
group = "verification"
71+
72+
doLast {
73+
val isWindows = System.getProperty("os.name").lowercase().contains("windows")
74+
val gradlewCommand = if (isWindows) "gradlew.bat" else "./gradlew"
75+
76+
val metadataFile = rootProject.file("gradle/verification-metadata.xml")
77+
require(metadataFile.exists()) {
78+
"gradle/verification-metadata.xml not found at ${metadataFile.absolutePath}"
79+
}
80+
81+
val backup = File.createTempFile("verification-metadata", ".bak")
82+
metadataFile.copyTo(backup, overwrite = true)
83+
try {
84+
println("→ Snapshotted current metadata to ${backup.absolutePath}")
85+
println("→ Regenerating with --write-verification-metadata sha256")
86+
println(" (re-resolves the dependency graph; can take a few minutes")
87+
println(" on a first run after a Gradle update.)")
88+
println()
89+
90+
val process = ProcessBuilder(
91+
gradlewCommand,
92+
"--write-verification-metadata", "sha256",
93+
"--refresh-dependencies",
94+
"help",
95+
":dependencies", "--configuration", "runtimeClasspath",
96+
":buildEnvironment",
97+
":compileKotlin",
98+
":compileTestKotlin",
99+
)
100+
.directory(rootProject.projectDir)
101+
.inheritIO()
102+
.start()
103+
val exitCode = process.waitFor()
104+
if (exitCode != 0) {
105+
throw GradleException("Gradle regeneration exited with code $exitCode")
106+
}
107+
108+
// Defensive: confirm the trusted-artifacts block survived. Gradle's
109+
// merge behavior should preserve <configuration>, but if a future
110+
// Gradle version regresses we want a loud signal, not a silent
111+
// weakening of the verification posture.
112+
val regenerated = metadataFile.readText()
113+
if (!regenerated.contains("trusted-artifacts")) {
114+
println()
115+
println("⚠ <trusted-artifacts> block is missing from the regenerated file.")
116+
println(" Restoring from backup. Investigate the regeneration step.")
117+
backup.copyTo(metadataFile, overwrite = true)
118+
throw GradleException("regeneration stripped trusted-artifacts; aborted")
119+
}
120+
121+
println()
122+
println("".repeat(60))
123+
if (regenerated == backup.readText()) {
124+
println("✓ No changes — verification metadata is up to date.")
125+
} else {
126+
println("→ Metadata changed.")
127+
println()
128+
println("Review the diff:")
129+
println(" git diff gradle/verification-metadata.xml")
130+
println()
131+
println("If the new entries look reasonable (only artifacts you")
132+
println("expected to appear, with origin=\"Generated by Gradle\"):")
133+
println(" git add gradle/verification-metadata.xml")
134+
println()
135+
println("If anything looks off:")
136+
println(" git restore gradle/verification-metadata.xml")
137+
}
138+
} finally {
139+
backup.delete()
140+
}
141+
}
142+
}
143+
53144
tasks.register<Test>("integrationTest") {
54145
description = "Runs integration tests that require a live LLM (Ollama)"
55146
group = "verification"

gradle/verification-metadata.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<configuration>
44
<verify-metadata>true</verify-metadata>
55
<verify-signatures>false</verify-signatures>
6+
<trusted-artifacts>
7+
<trust file=".*-javadoc[.]jar" regex="true"/>
8+
<trust file=".*-sources[.]jar" regex="true"/>
9+
</trusted-artifacts>
610
</configuration>
711
<components>
812
<component group="antlr" name="antlr" version="2.7.7">
@@ -39,6 +43,11 @@
3943
<sha256 value="fa81829d049559df6927f9c9a6fd6bbd09f8b50e6d4736ae72c8300b6c3d7654" origin="Generated by Gradle"/>
4044
</artifact>
4145
</component>
46+
<component group="gradle" name="gradle" version="9.4.1">
47+
<artifact name="gradle-9.4.1-src.zip">
48+
<sha256 value="e07d5ab9a5ee05064d2cea472ad2d8b46144c75d598080e5f77660d18c0e3020" origin="Computed by shasum -a 256 of cached artifact (#858)"/>
49+
</artifact>
50+
</component>
4251
<component group="info.solidsoft.gradle.pitest" name="gradle-pitest-plugin" version="1.19.0">
4352
<artifact name="gradle-pitest-plugin-1.19.0.jar">
4453
<sha256 value="66a38ba3b716febf217f2d44a30d1d7da12ac1eb9e90a5bec0a949cbbd1b26dc" origin="Generated by Gradle"/>
@@ -108,6 +117,9 @@
108117
</artifact>
109118
</component>
110119
<component group="org.apache.groovy" name="groovy-bom" version="4.0.11">
120+
<artifact name="groovy-bom-4.0.11.module">
121+
<sha256 value="6aeb51768ac49d58bf515a570f966a4cd6cf823a8a919e9e87dfdde4152101e4" origin="Generated by Gradle"/>
122+
</artifact>
111123
<artifact name="groovy-bom-4.0.11.pom">
112124
<sha256 value="27553a483d0f46df6aa86a1ce1f4126dca34aa957b2f88aaeb63136fd847fe18" origin="Generated by Gradle"/>
113125
</artifact>
@@ -360,6 +372,11 @@
360372
<sha256 value="57905524274a00ae028aaccc27283f6bc5925a934a046c1cc5d06c8ee4d6d5a9" origin="Generated by Gradle"/>
361373
</artifact>
362374
</component>
375+
<component group="org.jetbrains.kotlin" name="kotlin-reflect" version="2.3.0">
376+
<artifact name="kotlin-reflect-2.3.0.pom">
377+
<sha256 value="f3d1768ef2fb5310483dbe91e30e9fa36c7b3e2fdee6945a08bba310142d29c1" origin="Computed by shasum -a 256 of cached artifact (#858)"/>
378+
</artifact>
379+
</component>
363380
<component group="org.jetbrains.kotlin" name="kotlin-reflect" version="2.3.21">
364381
<artifact name="kotlin-reflect-2.3.21.jar">
365382
<sha256 value="33e37d9dfa86c7a29ab34e975b5f4a1287b458878611051f3485652220c1a2cb" origin="Generated by Gradle"/>
@@ -408,6 +425,11 @@
408425
<sha256 value="580b2c9857f3a662c53a3deb4851d7a1afa3bd5f4abbe9905f5b55fb5221f816" origin="Generated by Gradle"/>
409426
</artifact>
410427
</component>
428+
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="2.3.0">
429+
<artifact name="kotlin-stdlib-2.3.0.module">
430+
<sha256 value="0910a8a3b6960fc792c45c56a91d7c3a3f26286f03295554b519cff378756da2" origin="Computed by shasum -a 256 of cached artifact (#858)"/>
431+
</artifact>
432+
</component>
411433
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="2.3.21">
412434
<artifact name="kotlin-stdlib-2.3.21.jar">
413435
<sha256 value="6f64eac736db9434dd6925b4a518b9d1d17177652320c37916cf9ba3ce7d7d7a" origin="Generated by Gradle"/>
@@ -522,6 +544,9 @@
522544
</artifact>
523545
</component>
524546
<component group="org.junit" name="junit-bom" version="5.13.1">
547+
<artifact name="junit-bom-5.13.1.module">
548+
<sha256 value="33c07ab9724790a6e5859ba07d69117ac530439724545a81c4179e3272c75de8" origin="Generated by Gradle"/>
549+
</artifact>
525550
<artifact name="junit-bom-5.13.1.pom">
526551
<sha256 value="fa68451ea830572ed43ffe51d75b6a05f7a5e665a602a51f49d6be02063a65f3" origin="Generated by Gradle"/>
527552
</artifact>
@@ -530,6 +555,9 @@
530555
<artifact name="junit-bom-5.9.2.module">
531556
<sha256 value="ab137ba5a8e32c9b066bf9126a1c76dd5614b724ba5c0b02549772b5e9f4cf1f" origin="Generated by Gradle"/>
532557
</artifact>
558+
<artifact name="junit-bom-5.9.2.pom">
559+
<sha256 value="2ed07d65845131f5336a86476c9a4056b59d0b58b9815ab3679bb0f36f35f705" origin="Generated by Gradle"/>
560+
</artifact>
533561
</component>
534562
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.10.1">
535563
<artifact name="junit-jupiter-api-5.10.1.jar">

0 commit comments

Comments
 (0)