aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorAurelien <100427063+aurelien-poscia-sonarsource@users.noreply.github.com>2022-08-11 12:05:44 +0200
committersonartech <sonartech@sonarsource.com>2022-08-11 20:03:47 +0000
commit056ad753c9c766a2441f66f181624c79227541a3 (patch)
tree4e3bb3188b7fd3e139c131f6d207f9c7d8619cd7 /sonar-plugin-api-impl
parentd60decc7c085fac107651dab2bf622f18de0679d (diff)
downloadsonarqube-056ad753c9c766a2441f66f181624c79227541a3.tar.gz
sonarqube-056ad753c9c766a2441f66f181624c79227541a3.zip
SONAR-17150 fix SSF-39
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java2
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java10
2 files changed, 11 insertions, 1 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java
index e3b2366621e..7802d757a67 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java
@@ -30,6 +30,7 @@ import javax.annotation.Nullable;
* @since 3.0
*/
public final class Encryption {
+ private static final Pattern ENCRYPTED_PATTERN = Pattern.compile("^\\{([^{^}]*)}(.*)$");
private static final String BASE64_ALGORITHM = "b64";
private static final String AES_ECB_ALGORITHM = "aes";
@@ -39,7 +40,6 @@ public final class Encryption {
private final AesGCMCipher aesGCMCipher;
private final Map<String, Cipher> ciphers;
- private static final Pattern ENCRYPTED_PATTERN = Pattern.compile("\\{(.*?)\\}(.*)");
public Encryption(@Nullable String pathToSecretKey) {
aesECBCipher = new AesECBCipher(pathToSecretKey);
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java
index 6a3fe819617..1f8651a9b1d 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java
@@ -91,6 +91,16 @@ public class EncryptionTest {
assertThat(encryption.decrypt("foo")).isEqualTo("foo");
}
+ @Test
+ public void should_notDecryptText_whenBadBraceSyntax(){
+ Encryption encryption = new Encryption(null);
+ assertThat(encryption.decrypt("}xxx{Zm9v")).isEqualTo("}xxx{Zm9v");
+ assertThat(encryption.decrypt("}dcd}59LK")).isEqualTo("}dcd}59LK");
+ assertThat(encryption.decrypt("}rrrRg6")).isEqualTo("}rrrRg6");
+ assertThat(encryption.decrypt("{closedjdk")).isEqualTo("{closedjdk");
+
+ }
+
private String pathToSecretKey() throws Exception {
URL resource = getClass().getResource("/org/sonar/api/config/internal/AesCipherTest/aes_secret_key.txt");
return new File(resource.toURI()).getCanonicalPath();