mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-08-28 16:49:48 +02:00
Fix MongoDB uri showing in logs if set using system property (#3808)
This commit is contained in:
@@ -755,4 +755,14 @@ public final class ConfigKeys {
|
||||
return KEYS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the value at the given path should be censored in console/log output
|
||||
*
|
||||
* @param path the path
|
||||
* @return true if the value should be censored
|
||||
*/
|
||||
public static boolean shouldCensorValue(final String path) {
|
||||
return path.contains("password") || path.contains("uri");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.config.generic.adapter;
|
||||
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -50,7 +51,8 @@ public class EnvironmentVariableConfigAdapter extends StringBasedConfigurationAd
|
||||
|
||||
String value = System.getenv(key);
|
||||
if (value != null) {
|
||||
this.plugin.getLogger().info("Resolved configuration value from environment variable: " + key + " = " + (path.contains("password") ? "*****" : value));
|
||||
String printableValue = ConfigKeys.shouldCensorValue(path) ? "*****" : value;
|
||||
this.plugin.getLogger().info(String.format("Resolved configuration value from environment variable: %s = %s", key, printableValue));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
package me.lucko.luckperms.common.config.generic.adapter;
|
||||
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -46,7 +47,8 @@ public class SystemPropertyConfigAdapter extends StringBasedConfigurationAdapter
|
||||
|
||||
String value = System.getProperty(key);
|
||||
if (value != null) {
|
||||
this.plugin.getLogger().info("Resolved configuration value from system property: " + key + " = " + (path.contains("password") ? "*****" : value));
|
||||
String printableValue = ConfigKeys.shouldCensorValue(path) ? "*****" : value;
|
||||
this.plugin.getLogger().info(String.format("Resolved configuration value from system property: %s = %s", key, printableValue));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user