Repository navigation
Verify the Gradle distribution that the wrapper downloads against its SHA-256 - #34
Merged
Merged
Conversation
… SHA-256 gradle-wrapper.properties gets distributionSha256Sum for Gradle 9.9.2, Gradle's published gradle-9.9.2-bin.zip.sha256, so ./gradlew refuses a downloaded distribution that doesn't match. CI's validate-wrappers checks the committed gradle-wrapper.jar, not the distribution that it downloads. A Gradle upgrade now has to give the new version's checksum: ./gradlew wrapper --gradle-version alone fails, and leaves the file as it was. Validated: ./gradlew --version with an empty GRADLE_USER_HOME downloads, verifies and runs Gradle 9.9.2; with the checksum's last digit changed, it fails with "Verification of Gradle distribution failed!"; ./gradlew wrapper --gradle-version 9.9.1 without a checksum fails.
1 task done
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.
What
Adds
distributionSha256Sumfor Gradle 9.9.2 togradle/wrapper/gradle-wrapper.properties../gradlewthen verifies the distribution it downloads against Gradle's published checksum,gradle-9.9.2-bin.zip.sha256, and refuses one that doesn't match. That applies to every download, locally and in CI. A distribution already unpacked in a Gradle home isn't checked again.Why
CI already validates the wrapper (
setup-gradlewithvalidate-wrappers: true). That check compares the committedgradle-wrapper.jarwith Gradle's checksums. It doesn't cover the distribution that the JAR then downloads, which is what the checksum covers.Upgrading Gradle from now on
The upgrade has to give the new version's checksum:
Without
--gradle-distribution-sha256-sum, thewrappertask fails and leaves the file as it was: gradle-wrapper.properties contains distributionSha256Sum property, but the wrapper configuration does not have one. Changing onlydistributionUrlby hand fails the next download with Verification of Gradle distribution failed!Test
./gradlew --versionwith an emptyGRADLE_USER_HOME: the wrapper downloadsgradle-9.9.2-bin.zip, verifies it and runs Gradle 9.9.2.Verification of Gradle distribution failed!./gradlew wrapper --gradle-version 9.9.1without a checksum fails as described above.The last two ran in xtc-app-template; they test the wrapper's own checks, which are the same in all three repositories.