aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java14
2 files changed, 16 insertions, 2 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java
index 85b0fcd41bd..a766101f54a 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java
@@ -23,6 +23,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.concurrent.Immutable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.config.internal.Encryption;
import static org.sonar.api.CoreProperties.ENCRYPTION_SECRET_KEY_PATH;
@@ -33,6 +35,7 @@ import static org.sonar.api.CoreProperties.PROJECT_KEY_PROPERTY;
*/
@Immutable
public class ScannerProperties {
+ private static final Logger LOG = LoggerFactory.getLogger(ScannerProperties.class);
private final Map<String, String> properties;
private final Encryption encryption;
@@ -43,6 +46,7 @@ public class ScannerProperties {
for (Map.Entry<String, String> entry : properties.entrySet()) {
String value = entry.getValue();
if (value != null && encryption.isEncrypted(value)) {
+ LOG.warn("Property '{}' is encrypted. The encryption of scanner properties is deprecated and will soon be removed.", entry.getKey());
try {
value = encryption.decrypt(value);
} catch (Exception e) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java
index 358c5820467..cb218245de4 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java
@@ -20,12 +20,18 @@
package org.sonar.scanner.bootstrap;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTesterJUnit5;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-public class ScannerPropertiesTest {
+class ScannerPropertiesTest {
+
+ @RegisterExtension
+ LogTesterJUnit5 logTester = new LogTesterJUnit5();
@Test
public void initialization() {
@@ -60,6 +66,10 @@ public class ScannerPropertiesTest {
ScannerProperties underTest = new ScannerProperties(map);
assertThat(underTest.property("prop-1")).isEqualTo("foo");
+
+ assertThat(logTester.logs(Level.WARN))
+ .contains(
+ "Property 'prop-1' is encrypted. The encryption of scanner properties is deprecated and will soon be removed.");
}
}