-
Notifications
You must be signed in to change notification settings - Fork 907
Hardened Gradle builds with Gradle dependency verification and defined module restrictions on third-party maven repositories. #2174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
0-x-2-2
wants to merge
1
commit into
CaffeineMC:dev
Choose a base branch
from
0-x-2-2:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,12 +74,50 @@ jar { | |
| from sourceSets.api.output.resourcesDir | ||
| } | ||
|
|
||
| dependencies { | ||
| //to change the versions see the gradle.properties file | ||
| minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||
| mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" | ||
| modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||
| repositories { | ||
| // Log if any unknown repositories were added non-explicitly. | ||
| forEach { repo -> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed if you don't like it. |
||
| if (repo.name == 'Fabric' || repo.name == 'Mojang' || repo.name == 'MavenRepo') { | ||
| // We know these exist already. | ||
| return | ||
| } | ||
| var url = repo.url as URI | ||
| var protocol = url.getScheme() | ||
| if (protocol == "file") { | ||
| // Local repositories are most likely safe. | ||
| return | ||
| } | ||
| println("[Sodium] Unknown repository \"${repo.name}\" with URL \"${url}\"") | ||
| } | ||
| Mojang { | ||
| content { | ||
| includeGroup('com.mojang') | ||
| } | ||
| } | ||
| Fabric { | ||
| content { | ||
| includeGroup('net.fabricmc.fabric-api') | ||
| includeGroup('net.fabricmc.unpick') | ||
| includeGroup('net.fabricmc') | ||
| } | ||
| } | ||
| // Most dependencies should be downloaded from maven central since they have the most strict security policy and most dependencies are just mirrored from maven central. | ||
| MavenRepo { | ||
| content { | ||
| // OW2 ASM is an exception which we download directly from their maven server which is signed with their PGP key. | ||
| excludeGroup('org.ow2.asm') | ||
| } | ||
| } | ||
| maven { | ||
| name 'ObjectWeb' | ||
| url 'https://repository.ow2.org/nexus/content/repositories/releases' | ||
| content { | ||
| includeGroup('org.ow2.asm') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| // Fabric API | ||
| modIncludeImplementation(fabricApi.module("fabric-api-base", project.fabric_version)) | ||
| modIncludeImplementation(fabricApi.module("fabric-block-view-api-v2", project.fabric_version)) | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Do not commit the binary pgp keyring. | ||
| verification-keyring.gpg |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| @echo off | ||
| if not exist gradlew.bat ( | ||
| echo Not running in the base project directory. | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| gradlew.bat --refresh-dependencies --write-verification-metadata sha256 clean build && gradlew.bat --refresh-dependencies --write-verification-metadata pgp,sha256 --export-keys clean build | ||
|
|
||
| del %~dp0gradle\verification-keyring.gpg | ||
| echo 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| if [ ! -e gradlew ]; then | ||
| echo "Not running in the base project directory." | ||
| exit 1 | ||
| fi | ||
|
|
||
| ./gradlew --refresh-dependencies --write-verification-metadata sha256 clean build && ./gradlew --refresh-dependencies --write-verification-metadata pgp,sha256 --export-keys clean build | ||
|
|
||
| rm gradle/verification-keyring.gpg | ||
| echo "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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,27 @@ | ||
| pluginManagement { | ||
| repositories { | ||
| maven { | ||
| name = 'Fabric' | ||
| url = 'https://maven.fabricmc.net/' | ||
| name 'ObjectWeb' | ||
| url 'https://repository.ow2.org/nexus/content/repositories/releases' | ||
| content { | ||
| includeGroup('org.ow2.asm') | ||
| } | ||
| } | ||
| mavenCentral() // backup mirror for JCenter's Bintray, which is ordinarily used to resolve Eclipse's JGit | ||
| gradlePluginPortal() | ||
| maven { | ||
| name 'Fabric' | ||
| url 'https://maven.fabricmc.net' | ||
| content { | ||
| includeModule('fabric-loom', 'fabric-loom.gradle.plugin') | ||
| includeGroup('net.fabricmc.unpick') | ||
| includeGroup('net.fabricmc') | ||
| } | ||
| } | ||
| gradlePluginPortal { | ||
| content { | ||
| includeModule('io.github.juuxel.loom-vineflower', 'io.github.juuxel.loom-vineflower.gradle.plugin') | ||
| includeModule('io.github.juuxel', 'loom-vineflower') | ||
| } | ||
| } | ||
| mavenCentral() | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire
repositoriesblock is not strictly required either but prevents downloading artifacts from the wrong place.