fix: upgrade spock-core and mockito-core to drop vulnerable assertj-core - #53
Open
gergo-papp wants to merge 1 commit into
Open
fix: upgrade spock-core and mockito-core to drop vulnerable assertj-core#53gergo-papp wants to merge 1 commit into
gergo-papp wants to merge 1 commit into
Conversation
`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>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Application CIhas been red onmasterfor months.Clean buildandFunctional testpass; the failing step isSnyk Test, which exits 1 on a single pre-existing issue:Test-only transitive dependency, but
snyk testdoesn't distinguish, so CI stays red.What
spock-core2.0-groovy-2.5 → 2.3-groovy-2.5.junit-platform-testkitis the sole source ofassertj-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. Chose2.3-groovy-2.5because 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-javawith8.x) doesn't have.Forcing
assertj-core:3.27.7via a constraint was the alternative. Worth noting it wouldn't have been a durable fix on its own:junit-platform-testkit:1.9.0still shipsassertj-core:3.23.1, so the constraint would need maintaining as an indefinite override of a dependency we don't otherwise want.mockito-core2.7.22 → 4.11.0. Not cosmetic — required by the change above. Dropping testkit also stopped Spock from pullingbyte-buddyup to 1.11.0, which exposed mockito 2.7.22's ownbyte-buddy:1.6.11. That version can't define classes on Java 11+, soCliDownloaderTestfailed withMockito cannot mock this class ... Cannot define class using reflectionfor anyone building on a modern JDK. 4.11.0 is the last mockito release supporting Java 8 and bringsbyte-buddy1.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,CliDownloaderTest2 tests / 0 failures./gradlew functionalTest— BUILD SUCCESSFUL, Groovy specs compile against Spock 2.3assertj-coreabsent, no version downgradesassertj-core@3.16.1was the only hit (GHSA-rqfh-9r24-8c9r)I could not get an authoritative local
snyk testagainst the production vuln DB (my CLI is pointed atapi.dev.snyk.io, which doesn't carry this advisory — it reports "no vulnerable paths" even on unmodifiedmaster). TheSnyk Teststep on this PR is the real confirmation.Pre-existing issue, deliberately not fixed here
functionalTestexecutes zero tests. Neitherbuild.gradlenorgradle/functional-test.gradlecallsuseJUnitPlatform(), 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 onmastertoday 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 separatespock-junit4module under Spock 2.x. That is its own change with its own failure modes and shouldn't ride along with a CI-unblocking fix.