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


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java:
##########
@@ -121,25 +130,20 @@
         env.setCode(CodeGenerateUtils.genCode());
 
         if (environmentMapper.insert(env) > 0) {
-            if (!StringUtils.isEmpty(workerGroups)) {
-                List<String> workerGroupList = 
JSONUtils.parseObject(workerGroups, new TypeReference<List<String>>() {
+            if (CollectionUtils.isNotEmpty(workerGroupList)) {
+                workerGroupList.forEach(workerGroup -> {
+                    EnvironmentWorkerGroupRelation relation = new 
EnvironmentWorkerGroupRelation();
+                    relation.setEnvironmentCode(env.getCode());
+                    
relation.setWorkerGroupId(workerGroupMap.get(workerGroup).getId());
+                    relation.setWorkerGroup(workerGroup);
+                    relation.setOperator(loginUser.getId());
+                    relation.setCreateTime(new Date());
+                    relation.setUpdateTime(new Date());
+                    relationMapper.insert(relation);
+                    log.info(
+                            "Environment-WorkerGroup relation create complete, 
environmentName:{}, workerGroup:{}.",
+                            env.getName(), relation.getWorkerGroup());

Review Comment:
   ## CodeQL / Log Injection
   
   This log entry depends on a [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5811)



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java:
##########
@@ -121,25 +130,20 @@
         env.setCode(CodeGenerateUtils.genCode());
 
         if (environmentMapper.insert(env) > 0) {
-            if (!StringUtils.isEmpty(workerGroups)) {
-                List<String> workerGroupList = 
JSONUtils.parseObject(workerGroups, new TypeReference<List<String>>() {
+            if (CollectionUtils.isNotEmpty(workerGroupList)) {
+                workerGroupList.forEach(workerGroup -> {
+                    EnvironmentWorkerGroupRelation relation = new 
EnvironmentWorkerGroupRelation();
+                    relation.setEnvironmentCode(env.getCode());
+                    
relation.setWorkerGroupId(workerGroupMap.get(workerGroup).getId());
+                    relation.setWorkerGroup(workerGroup);
+                    relation.setOperator(loginUser.getId());
+                    relation.setCreateTime(new Date());
+                    relation.setUpdateTime(new Date());
+                    relationMapper.insert(relation);
+                    log.info(
+                            "Environment-WorkerGroup relation create complete, 
environmentName:{}, workerGroup:{}.",
+                            env.getName(), relation.getWorkerGroup());

Review Comment:
   ## CodeQL / Log Injection
   
   This log entry depends on a [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5812)



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