github-advanced-security[bot] commented on code in PR #18293:
URL:
https://github.com/apache/dolphinscheduler/pull/18293#discussion_r3328596374
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectPreferenceServiceImpl.java:
##########
@@ -67,6 +77,27 @@
.selectOne(new
QueryWrapper<ProjectPreference>().lambda().eq(ProjectPreference::getProjectCode,
projectCode));
+ if (StringUtils.isNotEmpty(preferences)) {
+ try {
+ ProjectPreferencesDTO preferencesDTO =
JSONUtils.parseObject(preferences, ProjectPreferencesDTO.class);
+ if (preferencesDTO != null &&
StringUtils.isNotEmpty(preferencesDTO.getWorkerGroup())) {
+ WorkerGroupValidationContext workerGroupContext =
WorkerGroupValidationContext.builder()
+ .workerGroup(preferencesDTO.getWorkerGroup())
+ .projectCode(projectCode)
+ .build();
+ try {
+ workerGroupValidator.validate(workerGroupContext);
+ } catch (ServiceException e) {
+ putMsg(result,
Status.WORKER_GROUP_NOT_ASSIGNED_TO_PROJECT, preferencesDTO.getWorkerGroup());
+ return result;
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to parse preferences JSON: {}", preferences,
e);
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/5802)
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/WorkerGroupValidator.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.api.validator;
+
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ServiceException;
+import
org.apache.dolphinscheduler.api.service.ProjectWorkerGroupRelationService;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Validator for workerGroup validation
+ * Checks if the workerGroup is assigned to the project
+ */
+@Slf4j
+@Component
+public class WorkerGroupValidator implements
IValidator<WorkerGroupValidationContext> {
+
+ @Autowired
+ private ProjectWorkerGroupRelationService
projectWorkerGroupRelationService;
+
+ @Override
+ public void validate(final WorkerGroupValidationContext context) {
+ String workerGroup = context.getWorkerGroup();
+ long projectCode = context.getProjectCode();
+
+ if (StringUtils.isNotBlank(workerGroup)
+ &&
!projectWorkerGroupRelationService.isWorkerGroupAssignedToProject(projectCode,
workerGroup)) {
+ log.warn("Worker group {} is not assigned to project {}",
workerGroup, projectCode);
Review Comment:
## CodeQL / Log Injection
This log entry depends on a [user-provided value](1).
This log entry depends on a [user-provided value](2).
This log entry depends on a [user-provided value](3).
This log entry depends on a [user-provided value](4).
This log entry depends on a [user-provided value](5).
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5803)
--
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]