Skip to content

fix: upgrade spock-core and mockito-core to drop vulnerable assertj-core - #53

Open
gergo-papp wants to merge 1 commit into
masterfrom
fix/drop-vulnerable-assertj-test-dependency
Open

fix: upgrade spock-core and mockito-core to drop vulnerable assertj-core#53
gergo-papp wants to merge 1 commit into
masterfrom
fix/drop-vulnerable-assertj-test-dependency

Conversation

@gergo-papp

Copy link
Copy Markdown
Contributor

Why

Application CI has been red on master for months. Clean build and Functional test pass; the failing step is Snyk Test, which exits 1 on a single pre-existing issue:

XML External Entity (XXE) Injection [High Severity]SNYK-JAVA-ORGASSERTJ-15102413
in org.assertj:assertj-core@3.16.1, introduced by
org.spockframework:spock-core@2.0-groovy-2.5 > org.junit.platform:junit-platform-testkit@1.7.2 > org.assertj:assertj-core@3.16.1

Test-only transitive dependency, but snyk test doesn't distinguish, so CI stays red.

What

spock-core 2.0-groovy-2.5 → 2.3-groovy-2.5. junit-platform-testkit is the sole source of assertj-core, and Spock 2.2 dropped it from its POM entirely — so this removes the vulnerable path at the source rather than pinning around it. Chose 2.3-groovy-2.5 because it's the newest release on the Groovy 2.5 line and still supports Java 8; Spock 2.4 requires Java 11, which CI (setup-java with 8.x) doesn't have.

Forcing assertj-core:3.27.7 via a constraint was the alternative. Worth noting it wouldn't have been a durable fix on its own: junit-platform-testkit:1.9.0 still ships assertj-core:3.23.1, so the constraint would need maintaining as an indefinite override of a dependency we don't otherwise want.

mockito-core 2.7.22 → 4.11.0. Not cosmetic — required by the change above. Dropping testkit also stopped Spock from pulling byte-buddy up to 1.11.0, which exposed mockito 2.7.22's own byte-buddy:1.6.11. That version can't define classes on Java 11+, so CliDownloaderTest failed with Mockito cannot mock this class ... Cannot define class using reflection for anyone building on a modern JDK. 4.11.0 is the last mockito release supporting Java 8 and brings byte-buddy 1.12.19, so nothing is downgraded relative to before this PR. The test source needed no changes.

Verification

Run locally with Gradle 6.1 on JDK 11 (Gradle 6.1 can't run on newer JDKs):

  • ./gradlew clean build -x functionalTest — BUILD SUCCESSFUL, CliDownloaderTest 2 tests / 0 failures
  • ./gradlew functionalTest — BUILD SUCCESSFUL, Groovy specs compile against Spock 2.3
  • Resolved test classpath: 20 → 13 dependencies, assertj-core absent, no version downgrades
  • All 13 remaining dependency versions are clean in OSV; assertj-core@3.16.1 was the only hit (GHSA-rqfh-9r24-8c9r)

I could not get an authoritative local snyk test against the production vuln DB (my CLI is pointed at api.dev.snyk.io, which doesn't carry this advisory — it reports "no vulnerable paths" even on unmodified master). The Snyk Test step on this PR is the real confirmation.

Pre-existing issue, deliberately not fixed here

functionalTest executes zero tests. Neither build.gradle nor gradle/functional-test.gradle calls useJUnitPlatform(), so Gradle 6.1 defaults to JUnit 4 and never discovers the Spock 2.x specs — the step compiles them, then finishes in ~0.1s green. That is true on master today and is unchanged by this PR.

Left out on purpose: enabling it would actually start running SnykTestFT / SnykMonitorFT, which download the Snyk CLI and invoke it against real projects, and the specs use JUnit 4 @Rule TemporaryFolder, which needs the separate spock-junit4 module under Spock 2.x. That is its own change with its own failure modes and shouldn't ride along with a CI-unblocking fix.

`snyk test` has been failing CI on master because of a High severity XXE
Injection issue (SNYK-JAVA-ORGASSERTJ-15102413) in
org.assertj:assertj-core@3.16.1, reached transitively via:

  spock-core:2.0-groovy-2.5 > junit-platform-testkit:1.7.2 > assertj-core:3.16.1

Rather than forcing a fixed assertj version, upgrade the real dependency:
Spock 2.2 dropped `junit-platform-testkit` from its POM entirely, so
spock-core:2.3-groovy-2.5 removes the vulnerable path at the source.
2.3-groovy-2.5 is the newest release on the Groovy 2.5 line and still
supports Java 8 (Spock 2.4 requires Java 11), so it stays compatible with
CI's Java 8 / Gradle 6.1 setup.

Dropping testkit also stopped Spock from pulling byte-buddy up to 1.11.0,
which exposed mockito-core:2.7.22's own byte-buddy:1.6.11. That version
cannot define classes on Java 11+ ("Cannot define class using reflection"),
breaking CliDownloaderTest for anyone building on a modern JDK. Bumping
mockito-core to 4.11.0 (the last release supporting Java 8) brings
byte-buddy 1.12.19, so no dependency is downgraded relative to before.

Verified with Gradle 6.1 on JDK 11:
- `./gradlew clean build -x functionalTest` and `./gradlew functionalTest` pass
- resolved test classpath shrinks from 20 to 13 dependencies with no downgrades
- assertj-core no longer appears in the dependency graph
- all 13 remaining dependency versions are clean in the OSV database

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gergo-papp
gergo-papp requested a review from a team as a code owner September 1, 2026 12:29
@snyk-io

snyk-io Bot commented Sep 1, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant