Browse Source

[improve-#13966] mask datax log (#13969)

Co-authored-by: fuchanghai <‘2875334588@qq.com’>
3.2.0-release
fuchanghai 2 years ago committed by GitHub
parent
commit
ec29220977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverterTest.java
  2. 8
      dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java

10
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverterTest.java

@ -52,4 +52,14 @@ public class SensitiveDataConverterTest {
} }
@Test
public void testPostJdbcInfoLogMsgConverter() {
String POST_JDBC_INFO_REGEX = "(?<=(post jdbc info:)).*(?=)";
SensitiveDataConverter.addMaskPattern(POST_JDBC_INFO_REGEX);
String postJdbcInfoLogMsg = "post jdbc info:clickhouse,jdbc:clickhouse://127.0.0.1:8123/td_cdp,admin,123%@@56";
final String maskedLog = SensitiveDataConverter.maskSensitiveData(postJdbcInfoLogMsg);
String expectedMsg = "post jdbc info:*****************************************************************";
Assertions.assertEquals(expectedMsg, maskedLog);
}
} }

8
dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java

@ -21,6 +21,7 @@ import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUt
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RWXR_XR_X; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RWXR_XR_X;
import org.apache.dolphinscheduler.common.log.SensitiveDataConverter;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider;
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
@ -92,6 +93,11 @@ public class DataxTask extends AbstractTask {
* select all * select all
*/ */
private static final String SELECT_ALL_CHARACTER = "*"; private static final String SELECT_ALL_CHARACTER = "*";
/**
* post jdbc info regex
*/
private static final String POST_JDBC_INFO_REGEX = "(?<=(post jdbc info:)).*(?=)";
/** /**
* datax path * datax path
*/ */
@ -142,7 +148,7 @@ public class DataxTask extends AbstractTask {
if (dataXParameters == null || !dataXParameters.checkParameters()) { if (dataXParameters == null || !dataXParameters.checkParameters()) {
throw new RuntimeException("datax task params is not valid"); throw new RuntimeException("datax task params is not valid");
} }
SensitiveDataConverter.addMaskPattern(POST_JDBC_INFO_REGEX);
dataxTaskExecutionContext = dataxTaskExecutionContext =
dataXParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper()); dataXParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper());
} }

Loading…
Cancel
Save