diff options
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r-- | sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java | 2 | ||||
-rw-r--r-- | sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java | 10 |
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(); |