Browse Source

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

3.2.0-release
jackfanwan 2 years ago committed by GitHub
parent
commit
71b4087421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
  2. 8
      dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java

2
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

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

8
dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java

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

Loading…
Cancel
Save