From 75813e7866af2cd4f11940c416fdeea3e3698f62 Mon Sep 17 00:00:00 2001 From: kyoty Date: Fri, 18 Jun 2021 19:10:57 +0800 Subject: [PATCH] [bug fix] Some password attributes can be viewd directly in the log (#5638) * fix the password display incorrectly * update * update * fic code style fic code style * Update SensitiveDataConverterTest.java * Update SensitiveDataConverter.java * Update SensitiveDataConverter.java * Update SensitiveDataConverterTest.java * Update pom.xml --- .../logback/logback-alert.xml | 7 +- .../dolphinscheduler/logback/logback-api.xml | 7 +- .../logback/logback-master.xml | 11 +- .../logback/logback-worker.xml | 11 +- .../src/main/resources/logback-alert.xml | 7 +- .../src/main/resources/logback-api.xml | 7 +- .../dolphinscheduler/common/Constants.java | 2 +- .../src/main/resources/logback-master.xml | 13 +- .../src/main/resources/logback-worker.xml | 11 +- .../log/SensitiveDataConverterTest.java | 179 ------------------ .../service}/log/SensitiveDataConverter.java | 13 +- .../log/SensitiveDataConverterTest.java | 137 ++++++++++++++ pom.xml | 2 +- 13 files changed, 182 insertions(+), 225 deletions(-) delete mode 100644 dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/log/SensitiveDataConverterTest.java rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server => dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service}/log/SensitiveDataConverter.java (93%) create mode 100644 dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/log/SensitiveDataConverterTest.java diff --git a/docker/build/conf/dolphinscheduler/logback/logback-alert.xml b/docker/build/conf/dolphinscheduler/logback/logback-alert.xml index 1718947dd1..5f1872969b 100644 --- a/docker/build/conf/dolphinscheduler/logback/logback-alert.xml +++ b/docker/build/conf/dolphinscheduler/logback/logback-alert.xml @@ -18,12 +18,13 @@ - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 @@ -38,7 +39,7 @@ - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 diff --git a/docker/build/conf/dolphinscheduler/logback/logback-api.xml b/docker/build/conf/dolphinscheduler/logback/logback-api.xml index bec3d9aa49..ead5403bd6 100644 --- a/docker/build/conf/dolphinscheduler/logback/logback-api.xml +++ b/docker/build/conf/dolphinscheduler/logback/logback-api.xml @@ -18,12 +18,13 @@ - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 @@ -42,7 +43,7 @@ - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 diff --git a/docker/build/conf/dolphinscheduler/logback/logback-master.xml b/docker/build/conf/dolphinscheduler/logback/logback-master.xml index f0d2c81df2..c8692b82c5 100644 --- a/docker/build/conf/dolphinscheduler/logback/logback-master.xml +++ b/docker/build/conf/dolphinscheduler/logback/logback-master.xml @@ -18,19 +18,18 @@ - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 - - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 - - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 @@ -38,7 +39,7 @@ - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 diff --git a/dolphinscheduler-api/src/main/resources/logback-api.xml b/dolphinscheduler-api/src/main/resources/logback-api.xml index ed655a0870..77d3226e99 100644 --- a/dolphinscheduler-api/src/main/resources/logback-api.xml +++ b/dolphinscheduler-api/src/main/resources/logback-api.xml @@ -18,12 +18,13 @@ - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 @@ -42,7 +43,7 @@ - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 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 d9e44c5092..898e39cc60 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 @@ -999,7 +999,7 @@ public final class Constants { /** * dataSource sensitive param */ - public static final String DATASOURCE_PASSWORD_REGEX = "(?<=(\"password\":\")).*?(?=(\"))"; + public static final String DATASOURCE_PASSWORD_REGEX = "(?<=((?i)password((\\\\\":\\\\\")|(=')))).*?(?=((\\\\\")|(')))"; /** * default worker group diff --git a/dolphinscheduler-server/src/main/resources/logback-master.xml b/dolphinscheduler-server/src/main/resources/logback-master.xml index a61d891b10..24d814718c 100644 --- a/dolphinscheduler-server/src/main/resources/logback-master.xml +++ b/dolphinscheduler-server/src/main/resources/logback-master.xml @@ -18,19 +18,20 @@ - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 - + + - + + - [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %message%n UTF-8 - **/server/log/TaskLogFilterTest.java @@ -1023,6 +1022,7 @@ **/service/queue/TaskUpdateQueueTest.java **/service/queue/PeerTaskInstancePriorityQueueTest.java **/service/log/LogClientServiceTest.java + **/service/log/SensitiveDataConverterTest.java **/service/alert/AlertClientServiceTest.java **/service/alert/ProcessAlertManagerTest.java **/dao/mapper/DataSourceUserMapperTest.java