@Test public void testMaskSecrets() { assertEquals("pass=null", PropertiesUtils.maskSecrets("pass=null")); assertEquals("pass=[secure]", PropertiesUtils.maskSecrets("pass=pass")); assertEquals("ssh.pass=null", PropertiesUtils.maskSecrets("ssh.pass=null")); assertEquals("ssh_pass=[secure]", PropertiesUtils.maskSecrets("ssh_pass=pass")); assertEquals("keyname=null", PropertiesUtils.maskSecrets("keyname=null")); assertEquals("keyname=[secure]", PropertiesUtils.maskSecrets("keyname=pass")); assertEquals("username=null", PropertiesUtils.maskSecrets("username=null")); assertEquals("username=[secure]", PropertiesUtils.maskSecrets("username=pass")); }
public static String maskSecrets(final String text) { return "" + text .replaceAll("KEY=(?!null).*", "KEY=[secure]") .replaceAll("key=(?!null).*", "key=[secure]") .replaceAll("KEYNAME=(?!null).*", "KEYNAME=[secure]") .replaceAll("keyname=(?!null).*", "keyname=[secure]") .replaceAll("LOGIN=(?!null).*", "LOGIN=[secure]") .replaceAll("login=(?!null).*", "login=[secure]") .replaceAll("ORGANIZATION=(?!null).*", "ORGANIZATION=[secure]") .replaceAll("organization=(?!null).*", "organization=[secure]") .replaceAll("PASS=(?!null).*", "PASS=[secure]") .replaceAll("pass=(?!null).*", "pass=[secure]") .replaceAll("PASSWORD=(?!null).*", "PASSWORD=[secure]") .replaceAll("password=(?!null).*", "password=[secure]") .replaceAll("PASSPHRASE=(?!null).*", "PASSPHRASE=[secure]") .replaceAll("passphrase=(?!null).*", "passphrase=[secure]") .replaceAll("TOKEN=(?!null).*", "TOKEN=[secure]") .replaceAll("token=(?!null).*", "token=[secure]") .replaceAll("USER=(?!null).*", "USER=[secure]") .replaceAll("user=(?!null).*", "user=[secure]") .replaceAll("USERNAME=(?!null).*", "USERNAME=[secure]") .replaceAll("username=(?!null).*", "username=[secure]"); }
PropertiesUtils { public static String maskSecrets(final String text) { return "" + text .replaceAll("KEY=(?!null).*", "KEY=[secure]") .replaceAll("key=(?!null).*", "key=[secure]") .replaceAll("KEYNAME=(?!null).*", "KEYNAME=[secure]") .replaceAll("keyname=(?!null).*", "keyname=[secure]") .replaceAll("LOGIN=(?!null).*", "LOGIN=[secure]") .replaceAll("login=(?!null).*", "login=[secure]") .replaceAll("ORGANIZATION=(?!null).*", "ORGANIZATION=[secure]") .replaceAll("organization=(?!null).*", "organization=[secure]") .replaceAll("PASS=(?!null).*", "PASS=[secure]") .replaceAll("pass=(?!null).*", "pass=[secure]") .replaceAll("PASSWORD=(?!null).*", "PASSWORD=[secure]") .replaceAll("password=(?!null).*", "password=[secure]") .replaceAll("PASSPHRASE=(?!null).*", "PASSPHRASE=[secure]") .replaceAll("passphrase=(?!null).*", "passphrase=[secure]") .replaceAll("TOKEN=(?!null).*", "TOKEN=[secure]") .replaceAll("token=(?!null).*", "token=[secure]") .replaceAll("USER=(?!null).*", "USER=[secure]") .replaceAll("user=(?!null).*", "user=[secure]") .replaceAll("USERNAME=(?!null).*", "USERNAME=[secure]") .replaceAll("username=(?!null).*", "username=[secure]"); } }
PropertiesUtils { public static String maskSecrets(final String text) { return "" + text .replaceAll("KEY=(?!null).*", "KEY=[secure]") .replaceAll("key=(?!null).*", "key=[secure]") .replaceAll("KEYNAME=(?!null).*", "KEYNAME=[secure]") .replaceAll("keyname=(?!null).*", "keyname=[secure]") .replaceAll("LOGIN=(?!null).*", "LOGIN=[secure]") .replaceAll("login=(?!null).*", "login=[secure]") .replaceAll("ORGANIZATION=(?!null).*", "ORGANIZATION=[secure]") .replaceAll("organization=(?!null).*", "organization=[secure]") .replaceAll("PASS=(?!null).*", "PASS=[secure]") .replaceAll("pass=(?!null).*", "pass=[secure]") .replaceAll("PASSWORD=(?!null).*", "PASSWORD=[secure]") .replaceAll("password=(?!null).*", "password=[secure]") .replaceAll("PASSPHRASE=(?!null).*", "PASSPHRASE=[secure]") .replaceAll("passphrase=(?!null).*", "passphrase=[secure]") .replaceAll("TOKEN=(?!null).*", "TOKEN=[secure]") .replaceAll("token=(?!null).*", "token=[secure]") .replaceAll("USER=(?!null).*", "USER=[secure]") .replaceAll("user=(?!null).*", "user=[secure]") .replaceAll("USERNAME=(?!null).*", "USERNAME=[secure]") .replaceAll("username=(?!null).*", "username=[secure]"); }  }
PropertiesUtils { public static String maskSecrets(final String text) { return "" + text .replaceAll("KEY=(?!null).*", "KEY=[secure]") .replaceAll("key=(?!null).*", "key=[secure]") .replaceAll("KEYNAME=(?!null).*", "KEYNAME=[secure]") .replaceAll("keyname=(?!null).*", "keyname=[secure]") .replaceAll("LOGIN=(?!null).*", "LOGIN=[secure]") .replaceAll("login=(?!null).*", "login=[secure]") .replaceAll("ORGANIZATION=(?!null).*", "ORGANIZATION=[secure]") .replaceAll("organization=(?!null).*", "organization=[secure]") .replaceAll("PASS=(?!null).*", "PASS=[secure]") .replaceAll("pass=(?!null).*", "pass=[secure]") .replaceAll("PASSWORD=(?!null).*", "PASSWORD=[secure]") .replaceAll("password=(?!null).*", "password=[secure]") .replaceAll("PASSPHRASE=(?!null).*", "PASSPHRASE=[secure]") .replaceAll("passphrase=(?!null).*", "passphrase=[secure]") .replaceAll("TOKEN=(?!null).*", "TOKEN=[secure]") .replaceAll("token=(?!null).*", "token=[secure]") .replaceAll("USER=(?!null).*", "USER=[secure]") .replaceAll("user=(?!null).*", "user=[secure]") .replaceAll("USERNAME=(?!null).*", "USERNAME=[secure]") .replaceAll("username=(?!null).*", "username=[secure]"); }  static Properties toProperties(final Map<String, String> map); static Properties merge(final Properties properties, final Properties intoProperties); static Map<String, Object> mapFromProperties(final Properties properties); static String logProperties(final Logger logger, final String title, final Properties properties, final Pattern pattern); static String maskSecrets(final String text); static void setSystemPropertiesIfAbsent(
        final Properties systemProperties,
        final Properties input
    ); static String toString(final Map<String, String> properties, final Pattern pattern); }
PropertiesUtils { public static String maskSecrets(final String text) { return "" + text .replaceAll("KEY=(?!null).*", "KEY=[secure]") .replaceAll("key=(?!null).*", "key=[secure]") .replaceAll("KEYNAME=(?!null).*", "KEYNAME=[secure]") .replaceAll("keyname=(?!null).*", "keyname=[secure]") .replaceAll("LOGIN=(?!null).*", "LOGIN=[secure]") .replaceAll("login=(?!null).*", "login=[secure]") .replaceAll("ORGANIZATION=(?!null).*", "ORGANIZATION=[secure]") .replaceAll("organization=(?!null).*", "organization=[secure]") .replaceAll("PASS=(?!null).*", "PASS=[secure]") .replaceAll("pass=(?!null).*", "pass=[secure]") .replaceAll("PASSWORD=(?!null).*", "PASSWORD=[secure]") .replaceAll("password=(?!null).*", "password=[secure]") .replaceAll("PASSPHRASE=(?!null).*", "PASSPHRASE=[secure]") .replaceAll("passphrase=(?!null).*", "passphrase=[secure]") .replaceAll("TOKEN=(?!null).*", "TOKEN=[secure]") .replaceAll("token=(?!null).*", "token=[secure]") .replaceAll("USER=(?!null).*", "USER=[secure]") .replaceAll("user=(?!null).*", "user=[secure]") .replaceAll("USERNAME=(?!null).*", "USERNAME=[secure]") .replaceAll("username=(?!null).*", "username=[secure]"); }  static Properties toProperties(final Map<String, String> map); static Properties merge(final Properties properties, final Properties intoProperties); static Map<String, Object> mapFromProperties(final Properties properties); static String logProperties(final Logger logger, final String title, final Properties properties, final Pattern pattern); static String maskSecrets(final String text); static void setSystemPropertiesIfAbsent(
        final Properties systemProperties,
        final Properties input
    ); static String toString(final Map<String, String> properties, final Pattern pattern); static final Pattern PATTERN_VARS_ENV_DOT_CI; }