1
0
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:
powercas_gamer
2024-01-06 12:31:59 +01:00
committed by GitHub
parent 0703b9856f
commit e6599a2662
3 changed files with 16 additions and 2 deletions

View File

@@ -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");
}
}

View File

@@ -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;
}

View File

@@ -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;
}