Example Change the regular expression of the data source password (#11459) (#11990)

Co-authored-by: jackfanwan <61672564+jackfanwan@users.noreply.github.com>
This commit is contained in:
caishunfeng 2022-09-16 15:16:05 +08:00 committed by GitHub
parent 951f707b61
commit c4953e8660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -728,7 +728,7 @@ public final class Constants {
* dataSource sensitive param
*/
public static final String DATASOURCE_PASSWORD_REGEX =
"(?<=((?i)password((\\\\\":\\\\\")|(=')))).*?(?=((\\\\\")|(')))";
"(?<=((?i)password((\":\")|(=')))).*?(?=((\")|(')))";
/**
* default worker group

View File

@ -47,11 +47,11 @@ public class SensitiveDataConverterTest {
+ "\"database\":\"carbond\","
+ "\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\","
+ "\"user\":\"view\","
+ "\"password\":\"******\"}";
+ "\"password\":\"*****\"}";
@Test
public void convert() {
Assert.assertNotEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
Assert.assertEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
}
/**
@ -62,8 +62,8 @@ public class SensitiveDataConverterTest {
logger.info("parameter : {}", logMsg);
logger.info("parameter : {}", passwordHandler(pwdPattern, logMsg));
Assert.assertEquals(logMsg, passwordHandler(pwdPattern, logMsg));
Assert.assertNotEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
Assert.assertNotEquals(logMsg, passwordHandler(pwdPattern, logMsg));
Assert.assertEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
}