github-advanced-security[bot] commented on code in PR #18667:
URL: 
https://github.com/apache/dolphinscheduler/pull/18667#discussion_r4421099142


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -343,18 +449,29 @@
     /**
      * cancel k8s / yarn application
      *
+     * <p>The caller has to know whether the application was really cancelled: 
a stop which reports
+     * success while the application still runs leaves a detached job behind. 
A failure of the resource
+     * manager is therefore propagated instead of only being logged, the same 
way the process tree
+     * termination reports its failure.
+     *
      * @param taskExecutionContext
-     * @return
+     * @throws TaskException if the application could not be cancelled
      */
     public static void cancelApplication(TaskExecutionContext 
taskExecutionContext) {
         try {
             if 
(Objects.nonNull(taskExecutionContext.getK8sTaskExecutionContext())) {
                 if 
(!TASK_TYPE_SET_K8S.contains(taskExecutionContext.getTaskType())) {
                     // Set empty container name for Spark on K8S task
-                    applicationManagerMap.get(ResourceManagerType.KUBERNETES)
+                    boolean killed = 
applicationManagerMap.get(ResourceManagerType.KUBERNETES)
                             .killApplication(new 
KubernetesApplicationManagerContext(
                                     
taskExecutionContext.getK8sTaskExecutionContext(),
                                     taskExecutionContext.getTaskAppId(), ""));
+                    if (!killed) {
+                        // the driver pod is already in a failure or unknown 
state, there is nothing
+                        // left to cancel, so this is not a cancellation 
failure
+                        log.warn("The kubernetes application of task: {} is 
not running any more, it is not killed",
+                                taskExecutionContext.getTaskAppId());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [TaskExecutionContext.getTaskAppId](1) should be avoided because it 
has been deprecated.
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5887)



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/shell/BaseWindowsShellInterceptorBuilder.java:
##########
@@ -59,7 +59,7 @@
         Path shellAbsolutePath = shellAbsolutePath();
         FileUtils.createFileWith755(shellAbsolutePath);
         Files.write(shellAbsolutePath, finalScript.getBytes(), 
StandardOpenOption.APPEND);
-        log.info("Final Shell file is : \n{}", finalScript);
+        log.info("Final Shell file is : \n{}", 
BaseShellInterceptor.maskSensitiveOptions(finalScript));

Review Comment:
   ## CodeQL / Insertion of sensitive information into log files
   
   This [potentially sensitive information](1) is written to a log file.
   This [potentially sensitive information](2) is written to a log file.
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5885)



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/shell/BaseLinuxShellInterceptorBuilder.java:
##########
@@ -61,7 +61,8 @@
         Path shellAbsolutePath = shellAbsolutePath();
         FileUtils.createFileWith755(shellAbsolutePath);
         Files.write(shellAbsolutePath, finalScript.getBytes(), 
StandardOpenOption.APPEND);
-        log.info("Final Script 
Content:\n====================\n{}\n====================", finalScript);
+        log.info("Final Script 
Content:\n====================\n{}\n====================",
+                BaseShellInterceptor.maskSensitiveOptions(finalScript));

Review Comment:
   ## CodeQL / Insertion of sensitive information into log files
   
   This [potentially sensitive information](1) is written to a log file.
   This [potentially sensitive information](2) is written to a log file.
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5884)



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -178,10 +252,25 @@
         } else {
             log.error("Failed to kill process tree for task: {}, pid: {}",
                     taskRequest.getTaskAppId(), taskRequest.getProcessId());
+            cancelFailure = new TaskException(String.format(
+                    "Failed to kill the process tree of task: %s, pid: %s, it 
may still be running",
+                    taskRequest.getTaskAppId(), taskRequest.getProcessId()));

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [TaskExecutionContext.getTaskAppId](1) should be avoided because it 
has been deprecated.
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5886)



-- 
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