Do not print sensitive properties' values in logs (#11120)

This commit is contained in:
kezhenxu94 2023-07-20 22:38:05 +08:00 committed by GitHub
parent 58352ce6dc
commit 1de70adb6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 26 deletions

View File

@ -50,6 +50,7 @@
* Apply MQE on Virtual-Cache layer UI-templates
* Add Echo component ID(5015) language: Golang.
* Fix `index out of bounds exception` in `aggregate_labels` MQE function.
* Do not print configurations values in logs to avoid sensitive info leaked.
* Move created the latest index before retrieval indexes by aliases to avoid the 404 exception. This just prevents some interference from manual operations.
#### UI

View File

@ -18,19 +18,20 @@
package org.apache.skywalking.oap.server.starter.config;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
import org.apache.skywalking.oap.server.library.module.ProviderNotFoundException;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.library.util.PropertyPlaceholderHelper;
import org.apache.skywalking.oap.server.library.util.ResourceUtils;
import org.yaml.snakeyaml.Yaml;
import java.io.FileNotFoundException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.library.util.PropertyPlaceholderHelper;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
import org.apache.skywalking.oap.server.library.module.ProviderNotFoundException;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.library.util.ResourceUtils;
import org.yaml.snakeyaml.Yaml;
/**
* Initialize collector settings with following sources. Use application.yml as primary setting, and fix missing setting
@ -76,7 +77,7 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
propertiesConfig.forEach((propertyName, propertyValue) -> {
if (propertyValue instanceof Map) {
Properties subProperties = new Properties();
((Map) propertyValue).forEach((key, value) -> {
((Map<String, ?>) propertyValue).forEach((key, value) -> {
subProperties.put(key, value);
replacePropertyAndLog(key, value, subProperties, providerName);
});
@ -102,26 +103,18 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
}
}
private void replacePropertyAndLog(final Object propertyName, final Object propertyValue, final Properties target,
private void replacePropertyAndLog(final String propertyName, final Object propertyValue, final Properties target,
final Object providerName) {
final String valueString = PropertyPlaceholderHelper.INSTANCE
.replacePlaceholders(propertyValue + "", target);
if (valueString != null) {
if (valueString.trim().length() == 0) {
target.replace(propertyName, valueString);
log.info("Provider={} config={} has been set as an empty string", providerName, propertyName);
} else {
// Use YAML to do data type conversion.
final Object replaceValue = convertValueString(valueString);
if (replaceValue != null) {
target.replace(propertyName, replaceValue);
log.info(
"Provider={} config={} has been set as {}",
providerName,
propertyName,
replaceValue.toString()
);
}
.replacePlaceholders(String.valueOf(propertyValue), target);
if (valueString.trim().length() == 0) {
target.replace(propertyName, valueString);
log.info("Provider={} config={} has been set as an empty string", providerName, propertyName);
} else {
// Use YAML to do data type conversion.
final Object replaceValue = convertValueString(valueString);
if (replaceValue != null) {
target.replace(propertyName, replaceValue);
}
}
}