From 71b4087421f8677318eca56cf197d2095247a19e Mon Sep 17 00:00:00 2001 From: jackfanwan <61672564+jackfanwan@users.noreply.github.com> Date: Fri, 16 Sep 2022 13:34:22 +0800 Subject: [PATCH] Example Change the regular expression of the data source password (#11459) --- .../org/apache/dolphinscheduler/common/Constants.java | 2 +- .../server/log/SensitiveDataConverterTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index c6eecb4212..3d7196bae0 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -734,7 +734,7 @@ public final class Constants { * dataSource sensitive param */ public static final String DATASOURCE_PASSWORD_REGEX = - "(?<=((?i)password((\\\\\":\\\\\")|(=')))).*?(?=((\\\\\")|(')))"; + "(?<=((?i)password((\":\")|(=')))).*?(?=((\")|(')))"; /** * default worker group diff --git a/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java b/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java index a8733f2df0..cd573cc51a 100644 --- a/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java +++ b/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java @@ -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)); }