EricGao888 commented on code in PR #11589:
URL: https://github.com/apache/dolphinscheduler/pull/11589#discussion_r962136036


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskTest.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.sqoop;
+
+import org.apache.dolphinscheduler.spi.utils.StringUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SqoopTaskTest {
+
+    @Test
+    public void testMaskPassword() {
+        String script =
+                "sqoop import -D mapred.job.name=sqoop_task -m 1 --connect 
\"jdbc:mysql://localhost:3306/defuault\" --username root --password 
\"mypassword\" --table student --target-dir /sqoop_test --as-textfile";
+        String scriptPasswordMasking =

Review Comment:
   ```suggestion
           final String scriptPasswordMasking =
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskTest.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.sqoop;
+
+import org.apache.dolphinscheduler.spi.utils.StringUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SqoopTaskTest {
+
+    @Test
+    public void testMaskPassword() {
+        String script =

Review Comment:
   ```suggestion
           final String script =
   ```



##########
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/StringUtils.java:
##########
@@ -282,10 +284,17 @@ public static String replaceDoubleBrackets(String 
mainParameter) {
         mainParameter = mainParameter
                 .replace(Constants.DOUBLE_BRACKETS_LEFT, 
Constants.DOUBLE_BRACKETS_LEFT_SPACE)
                 .replace(Constants.DOUBLE_BRACKETS_RIGHT, 
Constants.DOUBLE_BRACKETS_RIGHT_SPACE);
-        if (mainParameter.contains(Constants.DOUBLE_BRACKETS_LEFT) || 
mainParameter.contains(Constants.DOUBLE_BRACKETS_RIGHT)) {
+        if (mainParameter.contains(Constants.DOUBLE_BRACKETS_LEFT)
+                || mainParameter.contains(Constants.DOUBLE_BRACKETS_RIGHT)) {
             return replaceDoubleBrackets(mainParameter);
         } else {
-            return  mainParameter;
+            return mainParameter;
         }
     }
+
+    public static String maskPassword(String originalString, String 
passwordRegex, String maskString) {

Review Comment:
   ```suggestion
       public static String maskPassword(final String originalString, final 
String passwordRegex, final String maskString) {
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java:
##########
@@ -112,6 +118,10 @@ protected void createCommandFileIfNotExists(String 
execCommand, String commandFi
                     }
                 }
             }
+
+            if (execCommand.startsWith("sqoop")) {

Review Comment:
   May I ask whether we could do this with some other ways in `sqoop task 
plugin` instead of add a specific condition here for `sqoop`? 
ShellCommandExecutor is shared across different task plugins, it might not be a 
good practice and uneasy to maintain if we need to change it every time we need 
to mask something for a task plugin. The same for line 55-56.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to