Skip to content

Commit 8dfe77e

Browse files
bigdazclaude
andauthored
Fix dependency vulnerabilities in buildscript classpath (#217)
## Summary Resolves 5 open Dependabot alerts for vulnerable transitive dependencies on the plugin buildscript classpath (alerts 21, 22, 25, 26, 27). The 6 `com.fasterxml.jackson.core` alerts are intentionally left untouched. ## Changes - **Update the Shadow plugin** from `com.github.johnrengelman.shadow:8.1.1` to `com.gradleup.shadow:8.3.6`, which pulls `plexus-utils` up to `4.0.2`, clearing that alert with no constraint. (Alert 25) - **Remove the `com.github.breadmoirai.github-release:2.5.2` plugin.** It was used only to create a bare GitHub release (no asset uploads), yet it was the sole source of `tika-core` and `okio` on the classpath. Its only patched version, `tika-core:3.2.2`, requires **JDK 11** and cannot load on the JDK 8 the build runs on in the CI matrix. It's replaced by a small `CreateGitHubRelease` task that shells out to `gh release create`, keeping the `githubRelease` task name so the external release workflow is unaffected. This removes `tika-core` and `okio` entirely. (Alert 21) - **Constrain the remaining vulnerable transitive of the Shadow plugin:** | Library | Resolved before | Now | |---|---|---| | `org.apache.logging.log4j:log4j-core` | 2.24.1 | **2.25.4** | (`commons-io` remains pinned to 2.21.0.) (Alerts 22, 26, 27) ## Why remove github-release rather than pin Tika? Tika 3.x is Java 11 bytecode, and Dependabot offers no patched 2.x. Since the build runs on JDK 8 in the `test-gradle-version` matrix, a patched Tika on the buildscript classpath is a JDK-8 landmine. The plugin created only a bare release, so Tika served no functional purpose — removing the plugin is the smallest change that both clears the CVEs and eliminates the JDK-8 conflict, rather than working around it. ## Verification - Resolved buildscript classpath confirms `tika-core` and `okio` are gone; `plexus-utils:4.0.2`, `log4j-core → 2.25.4`, `commons-io → 2.21.0`. - `:plugin:build`, `:plugin:shadowJar`, and `:plugin:test` all pass. - The new `githubRelease` task resolves, wires `dependsOn(createReleaseTag)`, and configures cleanly under the configuration cache (`--dry-run` verified). ## Note for the release workflow The replacement task relies on the `gh` CLI (preinstalled on GitHub runners) and reads the token from the existing `GITHUB_DEPENDENCY_GRAPH_GIT_TOKEN` env var (mapped to `GH_TOKEN`). The `gh release create` path is not exercised by CI, so it's worth confirming during the next staging release. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ddaf9f6 commit 8dfe77e

2 files changed

Lines changed: 34 additions & 16 deletions

File tree

gradle/libs.versions.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jackson-parameter-names = { group = "com.fasterxml.jackson.module", name = "jack
99
jackson-kotlin = { group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin" }
1010

1111
apache-commons-io = { group = "commons-io", name = "commons-io", version = "2.21.0" }
12+
apache-log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version = "2.25.4" }
1213

1314
github-packageurl = { group = "com.github.package-url", name = "packageurl-java", version = "1.5.0" }
14-
okio = { group = "com.squareup.okio", name = "okio", version = "3.17.0" }
1515

1616
### Test dependencies
1717

@@ -26,6 +26,5 @@ jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version
2626
google-gson = { group = "com.google.code.gson", name = "gson", version = "2.13.2" }
2727

2828
[plugins]
29-
shadow-jar = { id = "com.github.johnrengelman.shadow", version = "8.1.1"}
29+
shadow-jar = { id = "com.gradleup.shadow", version = "8.3.6"}
3030
plugin-publish = { id = "com.gradle.plugin-publish", version = "2.1.0" }
31-
github-release = { id = "com.github.breadmoirai.github-release", version = "2.5.2"}

plugin/build.gradle.kts

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ buildscript {
1212
}
1313
dependencies {
1414
constraints {
15-
// The plugin com.github.breadmoirai.github-release:2.5.2 depends on vulnerable library releases.
15+
// The com.gradleup.shadow plugin depends on vulnerable library releases.
1616
// We constrain these to newer, patched versions.
17-
classpath(libs.okio)
1817
classpath(libs.apache.commons.io)
18+
classpath(libs.apache.log4j.core)
1919
}
2020
}
2121
}
2222

2323
plugins {
2424
kotlin("jvm") version(libs.versions.kotlin)
2525
alias(libs.plugins.plugin.publish)
26-
alias(libs.plugins.github.release)
2726
signing
2827
groovy
2928
alias(libs.plugins.shadow.jar)
@@ -207,17 +206,11 @@ val createReleaseTag = tasks.register<CreateGitTag>("createReleaseTag") {
207206
tagName = releaseTag
208207
}
209208

210-
githubRelease {
211-
setToken(System.getenv("GITHUB_DEPENDENCY_GRAPH_GIT_TOKEN") ?: "")
212-
owner = "gradle"
213-
repo = "github-dependency-graph-gradle-plugin"
214-
releaseName = releaseVersion
215-
tagName = releaseTag
216-
body = releaseNotes
217-
}
218-
219-
tasks.named("githubRelease").configure {
209+
tasks.register<CreateGitHubRelease>("githubRelease") {
220210
dependsOn(createReleaseTag)
211+
tagName = releaseTag
212+
releaseName = releaseVersion
213+
notesFile = rootProject.layout.projectDirectory.file("release/changes.md")
221214
}
222215

223216
tasks.withType(PublishTask::class).configureEach {
@@ -242,3 +235,29 @@ abstract class CreateGitTag : DefaultTask() {
242235
}
243236
}
244237

238+
abstract class CreateGitHubRelease : DefaultTask() {
239+
240+
@get:Input abstract val tagName: Property<String>
241+
242+
@get:Input abstract val releaseName: Property<String>
243+
244+
@get:InputFile abstract val notesFile: RegularFileProperty
245+
246+
@get:Inject abstract val execOperations: ExecOperations
247+
248+
@TaskAction
249+
fun action() {
250+
val tag = tagName.get()
251+
logger.info("Creating GitHub release ${releaseName.get()} for tag $tag")
252+
execOperations.exec {
253+
commandLine(
254+
"gh", "release", "create", tag,
255+
"--title", releaseName.get(),
256+
"--notes-file", notesFile.get().asFile.absolutePath
257+
)
258+
// The github-release workflow provides the token via this environment variable.
259+
environment("GH_TOKEN", System.getenv("GITHUB_DEPENDENCY_GRAPH_GIT_TOKEN") ?: "")
260+
}
261+
}
262+
}
263+

0 commit comments

Comments
 (0)