forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quarkus Gradle Plugin: allow encrypted configuration
As decribed in quarkusio#33135, using encrypted configuration values does not work with the current Gradle plugin since Quarkus 3.0.0. `smallrye-config-crypto` requires the `smallrye.config.secret-handler.aes-gcm-nopadding.encryption-key` to be present for _all_ builds, even those that do not use encrypted config values. It is probably not necessary to actually know the decrypted configuration values in the Gradle build, it might practically be a security risk, because the secret key could leak into build log files (could be prevented of course) and the Gradle cache, which has a high chance of being shared with others, likely publicly. This PR adds a "fake" secret keys handler that just returns the string `<REDACTED>` for all encrypted values. Fixes quarkusio#33135
- Loading branch information
Showing
7 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
...dle/gradle-application-plugin/src/test/java/io/quarkus/gradle/tasks/CryptoConfigTest.java
This file contains 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,31 @@ | ||
package io.quarkus.gradle.tasks; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.nio.file.Path; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.gradle.testkit.runner.GradleRunner; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
public class CryptoConfigTest { | ||
|
||
@TempDir | ||
Path testProjectDir; | ||
|
||
@Test | ||
void smallryeCrypto() throws Exception { | ||
URL url = getClass().getClassLoader().getResource("io/quarkus/gradle/tasks/crypto/main"); | ||
FileUtils.copyDirectory(new File(url.toURI()), testProjectDir.toFile()); | ||
FileUtils.copyFile(new File("../gradle.properties"), testProjectDir.resolve("gradle.properties").toFile()); | ||
|
||
GradleRunner.create() | ||
.withPluginClasspath() | ||
.withProjectDir(testProjectDir.toFile()) | ||
.withArguments("build", "--info", "--stacktrace", "--build-cache", "--configuration-cache") | ||
// .build() checks whether the build failed, which is good enough for this test | ||
.build(); | ||
|
||
} | ||
} |
This file contains 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
21 changes: 21 additions & 0 deletions
21
...pplication-plugin/src/test/resources/io/quarkus/gradle/tasks/crypto/main/build.gradle.kts
This file contains 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,21 @@ | ||
plugins { | ||
java | ||
id("io.quarkus") | ||
} | ||
|
||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(enforcedPlatform("io.quarkus:quarkus-bom:${project.property("version")}")) | ||
implementation("jakarta.inject:jakarta.inject-api:2.0.1") | ||
} |
1 change: 1 addition & 0 deletions
1
...ication-plugin/src/test/resources/io/quarkus/gradle/tasks/crypto/main/settings.gradle.kts
This file contains 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 @@ | ||
rootProject.name = "gradle-build-caching" |
4 changes: 4 additions & 0 deletions
4
...in/src/test/resources/io/quarkus/gradle/tasks/crypto/main/src/main/java/org/acme/Foo.java
This file contains 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,4 @@ | ||
package org.acme; | ||
|
||
public class Foo { | ||
} |
1 change: 1 addition & 0 deletions
1
...t/resources/io/quarkus/gradle/tasks/crypto/main/src/main/resources/application.properties
This file contains 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 @@ | ||
someValue = ${aes-gcm-nopadding::superSecret} |