status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
import org.apache.dolphinscheduler.api.dto.task.TaskUpdateRequest; import org.apache.dolphinscheduler.api.dto.taskRelation.TaskRelationUpdateUpstreamRequest; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.permission.PermissionCheck; import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProcessTaskRelationService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.TaskDefinitionService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.vo.TaskDefinitionVo; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.ConditionType; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.TaskExecuteType; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskMainInfo;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.repository.ProcessTaskRelationLogDao; import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao; import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager; import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; /** * task definition service impl */ @Service public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDefinitionService { private static final Logger logger = LoggerFactory.getLogger(TaskDefinitionServiceImpl.class); private static final String RELEASESTATE = "releaseState"; @Autowired private ProjectMapper projectMapper; @Autowired private ProjectService projectService; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private TaskDefinitionDao taskDefinitionDao; @Autowired private TaskDefinitionLogMapper taskDefinitionLogMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private ProcessTaskRelationLogDao processTaskRelationLogDao; @Autowired private ProcessTaskRelationService processTaskRelationService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
private ProcessService processService; @Autowired private TaskPluginManager taskPluginManager; @Autowired private ProcessDefinitionService processDefinitionService; /** * create task definition * * @param loginUser login user * @param projectCode project code * @param taskDefinitionJson task definition json */ @Transactional @Override public Map<String, Object> createTaskDefinition(User loginUser, long projectCode, String taskDefinitionJson) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_CREATE); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { return result; } List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); if (CollectionUtils.isEmpty(taskDefinitionLogs)) { logger.warn("Parameter taskDefinitionJson is invalid."); putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJson); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() .taskType(taskDefinitionLog.getTaskType()) .taskParams(taskDefinitionLog.getTaskParams()) .dependence(taskDefinitionLog.getDependence()) .build())) { logger.warn("Task definition {} parameters are invalid.", taskDefinitionLog.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); return result; } } int saveTaskResult = processService.saveTaskDefine(loginUser, projectCode, taskDefinitionLogs, Boolean.TRUE); if (saveTaskResult == Constants.DEFINITION_FAILURE) { logger.error("Create task definition error, projectCode:{}.", projectCode); putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); } Map<String, Object> resData = new HashMap<>(); resData.put("total", taskDefinitionLogs.size()); resData.put("code", StringUtils .join(taskDefinitionLogs.stream().map(TaskDefinition::getCode).collect(Collectors.toList()), ",")); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, resData); return result; } private TaskDefinitionLog persist2TaskDefinitionLog(User user, TaskDefinition taskDefinition) { TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition); taskDefinitionLog.setOperator(user.getId()); taskDefinitionLog.setOperateTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
int result = taskDefinitionLogMapper.insert(taskDefinitionLog); if (result <= 0) { throw new ServiceException(Status.CREATE_TASK_DEFINITION_LOG_ERROR, taskDefinitionLog.getName()); } return taskDefinitionLog; } private void checkTaskDefinitionValid(User user, TaskDefinition taskDefinition, String permissions) { Project project = projectMapper.queryByCode(taskDefinition.getProjectCode()); projectService.checkProjectAndAuthThrowException(user, project, permissions); if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() .taskType(taskDefinition.getTaskType()) .taskParams(taskDefinition.getTaskParams()) .dependence(taskDefinition.getDependence()) .build())) { throw new ServiceException(Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinition.getName()); } } private List<ProcessTaskRelation> updateTaskUpstreams(User user, long workflowCode, long taskCode, String upstreamCodes) { TaskRelationUpdateUpstreamRequest taskRelationUpdateUpstreamRequest = new TaskRelationUpdateUpstreamRequest(); taskRelationUpdateUpstreamRequest.setWorkflowCode(workflowCode); if (upstreamCodes != null) { taskRelationUpdateUpstreamRequest.setUpstreams(upstreamCodes); } return processTaskRelationService.updateUpstreamTaskDefinitionWithSyncDag(user, taskCode, Boolean.FALSE, taskRelationUpdateUpstreamRequest); } private ProcessDefinition updateWorkflowLocation(User user, ProcessDefinition processDefinition) { WorkflowUpdateRequest workflowUpdateRequest = new WorkflowUpdateRequest();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
workflowUpdateRequest.setLocation(null); return processDefinitionService.updateSingleProcessDefinition(user, processDefinition.getCode(), workflowUpdateRequest); } /** * Create resource task definition * * @param loginUser login user * @param taskCreateRequest task definition json * @return new TaskDefinition have created */ @Override @Transactional public TaskDefinition createTaskDefinitionV2(User loginUser, TaskCreateRequest taskCreateRequest) { TaskDefinition taskDefinition = taskCreateRequest.convert2TaskDefinition(); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(taskCreateRequest.getWorkflowCode()); if (processDefinition == null) { throw new ServiceException(Status.PROCESS_DEFINE_NOT_EXIST, taskCreateRequest.getWorkflowCode()); } if (taskDefinition.getProjectCode() == 0L) { taskDefinition.setProjectCode(processDefinition.getProjectCode()); } this.checkTaskDefinitionValid(loginUser, taskDefinition, TASK_DEFINITION_CREATE); long taskDefinitionCode; try { taskDefinitionCode = CodeGenerateUtils.getInstance().genCode(); } catch (CodeGenerateException e) { throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} taskDefinition.setCode(taskDefinitionCode); int create = taskDefinitionMapper.insert(taskDefinition); if (create <= 0) { throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); } this.persist2TaskDefinitionLog(loginUser, taskDefinition); this.updateTaskUpstreams(loginUser, taskCreateRequest.getWorkflowCode(), taskDefinition.getCode(), taskCreateRequest.getUpstreamTasksCodes()); this.updateWorkflowLocation(loginUser, processDefinition); return taskDefinition; } /** * create single task definition that binds the workflow * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param taskDefinitionJsonObj task definition json object * @param upstreamCodes upstream task codes, sep comma * @return create result code */ @Transactional @Override public Map<String, Object> createTaskBindsWorkFlow(User loginUser, long projectCode, long processDefinitionCode, String taskDefinitionJsonObj,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
String upstreamCodes) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_CREATE); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { logger.error("Process definition does not exist, processDefinitionCode:{}.", processDefinitionCode); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(processDefinitionCode)); return result; } if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { logger.warn("Task definition can not be created due to process definition is {}, processDefinitionCode:{}.", ReleaseState.ONLINE.getDescp(), processDefinition.getCode()); putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE, String.valueOf(processDefinitionCode)); return result; } TaskDefinitionLog taskDefinition = JSONUtils.parseObject(taskDefinitionJsonObj, TaskDefinitionLog.class); if (taskDefinition == null) { logger.warn("Parameter taskDefinitionJsonObj is invalid json."); putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJsonObj); return result; } if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() .taskType(taskDefinition.getTaskType()) .taskParams(taskDefinition.getTaskParams())
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
.dependence(taskDefinition.getDependence()) .build())) { logger.error("Task definition {} parameters are invalid", taskDefinition.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinition.getName()); return result; } long taskCode = taskDefinition.getCode(); if (taskCode == 0) { taskDefinition.setCode(CodeGenerateUtils.getInstance().genCode()); } List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode) .stream() .map(ProcessTaskRelationLog::new) .collect(Collectors.toList()); if (StringUtils.isNotBlank(upstreamCodes)) { Set<Long> upstreamTaskCodes = Arrays.stream(upstreamCodes.split(Constants.COMMA)).map(Long::parseLong) .collect(Collectors.toSet()); List<TaskDefinition> upstreamTaskDefinitionList = taskDefinitionMapper.queryByCodeList(upstreamTaskCodes); Set<Long> queryUpStreamTaskCodes = upstreamTaskDefinitionList.stream().map(TaskDefinition::getCode).collect(Collectors.toSet()); Set<Long> diffCode = upstreamTaskCodes.stream().filter(code -> !queryUpStreamTaskCodes.contains(code)) .collect(Collectors.toSet()); if (CollectionUtils.isNotEmpty(diffCode)) { String taskCodes = StringUtils.join(diffCode, Constants.COMMA); logger.error("Some task definitions with parameter upstreamCodes do not exist, taskDefinitionCodes:{}.", taskCodes); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCodes); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} for (TaskDefinition upstreamTask : upstreamTaskDefinitionList) { ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(); processTaskRelationLog.setPreTaskCode(upstreamTask.getCode()); processTaskRelationLog.setPreTaskVersion(upstreamTask.getVersion()); processTaskRelationLog.setPostTaskCode(taskCode); processTaskRelationLog.setPostTaskVersion(Constants.VERSION_FIRST); processTaskRelationLog.setConditionType(ConditionType.NONE); processTaskRelationLog.setConditionParams("{}"); processTaskRelationLogList.add(processTaskRelationLog); } } else { ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(); processTaskRelationLog.setPreTaskCode(0); processTaskRelationLog.setPreTaskVersion(0); processTaskRelationLog.setPostTaskCode(taskCode); processTaskRelationLog.setPostTaskVersion(Constants.VERSION_FIRST); processTaskRelationLog.setConditionType(ConditionType.NONE); processTaskRelationLog.setConditionParams("{}"); processTaskRelationLogList.add(processTaskRelationLog); } int insertResult = processService.saveTaskRelation(loginUser, projectCode, processDefinition.getCode(), processDefinition.getVersion(), processTaskRelationLogList, Lists.newArrayList(), Boolean.TRUE); if (insertResult != Constants.EXIT_CODE_SUCCESS) { logger.error( "Save new version process task relations error, processDefinitionCode:{}, processDefinitionVersion:{}.", processDefinition.getCode(), processDefinition.getVersion()); putMsg(result, Status.CREATE_PROCESS_TASK_RELATION_ERROR); throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} else logger.info( "Save new version process task relations complete, processDefinitionCode:{}, processDefinitionVersion:{}.", processDefinition.getCode(), processDefinition.getVersion()); int saveTaskResult = processService.saveTaskDefine(loginUser, projectCode, Lists.newArrayList(taskDefinition), Boolean.TRUE); if (saveTaskResult == Constants.DEFINITION_FAILURE) { logger.error("Save task definition error, projectCode:{}, taskDefinitionCode:{}.", projectCode, taskDefinition.getCode()); putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); } else logger.info("Save task definition complete, projectCode:{}, taskDefinitionCode:{}.", projectCode, taskDefinition.getCode()); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, taskDefinition); return result; } /** * query task definition * * @param loginUser login user * @param projectCode project code * @param processCode process code * @param taskName task name */ @Override public Map<String, Object> queryTaskDefinitionByName(User loginUser, long projectCode, long processCode, String taskName) { Project project = projectMapper.queryByCode(projectCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(project.getCode(), processCode, taskName); if (taskDefinition == null) { logger.error("Task definition does not exist, taskName:{}.", taskName); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskName); } else { result.put(Constants.DATA_LIST, taskDefinition); putMsg(result, Status.SUCCESS); } return result; } /** * Whether task definition can be deleted or not */ private void taskCanDeleteValid(User user, TaskDefinition taskDefinition, User loginUser) { Project project = projectMapper.queryByCode(taskDefinition.getProjectCode()); projectService.checkProjectAndAuthThrowException(user, project, TASK_DEFINITION_DELETE); Map<String, Object> result = new HashMap<>(); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { throw new ServiceException(Status.TASK_DEFINE_STATE_ONLINE, taskDefinition.getCode()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
if (processService.isTaskOnline(taskDefinition.getCode()) && taskDefinition.getFlag() == Flag.YES) { throw new ServiceException(Status.TASK_DEFINE_STATE_ONLINE, taskDefinition.getCode()); } List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryDownstreamByTaskCode(taskDefinition.getCode()); if (CollectionUtils.isNotEmpty(processTaskRelationList)) { Set<Long> postTaskCodes = processTaskRelationList .stream() .map(ProcessTaskRelation::getPostTaskCode) .collect(Collectors.toSet()); String postTaskCodesStr = StringUtils.join(postTaskCodes, Constants.COMMA); throw new ServiceException(Status.TASK_HAS_DOWNSTREAM, postTaskCodesStr); } } /** * Delete resource task definition by code * * Only task release state offline and no downstream tasks can be deleted, will also remove the exists * task relation [upstreamTaskCode, taskCode] * * @param loginUser login user * @param taskCode task code */ @Transactional @Override public void deleteTaskDefinitionByCode(User loginUser, long taskCode) { TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null) { throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, taskCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} this.taskCanDeleteValid(loginUser, taskDefinition, loginUser); int delete = taskDefinitionMapper.deleteByCode(taskCode); if (delete <= 0) { throw new ServiceException(Status.DELETE_TASK_DEFINE_BY_CODE_MSG_ERROR, taskDefinition.getCode()); } List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(taskDefinition.getProjectCode(), taskCode); if (CollectionUtils.isNotEmpty(taskRelationList)) { logger.debug( "Task definition has upstream tasks, start handle them after delete task, taskDefinitionCode:{}.", taskCode); long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode(); List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper .queryByProcessCode(taskDefinition.getProjectCode(), processDefinitionCode); List<ProcessTaskRelation> relationList = processTaskRelations.stream() .filter(r -> r.getPostTaskCode() != taskCode).collect(Collectors.toList()); updateDag(loginUser, processDefinitionCode, relationList, Lists.newArrayList()); } } public void updateDag(User loginUser, long processDefinitionCode, List<ProcessTaskRelation> processTaskRelationList, List<TaskDefinitionLog> taskDefinitionLogs) { ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); if (processDefinition == null) { logger.error("Process definition does not exist, processDefinitionCode:{}.", processDefinitionCode); throw new ServiceException(Status.PROCESS_DEFINE_NOT_EXIST); } int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
if (insertVersion <= 0) { logger.error("Update process definition error, projectCode:{}, processDefinitionCode:{}.", processDefinition.getProjectCode(), processDefinitionCode); throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } else logger.info( "Save new version process definition complete, projectCode:{}, processDefinitionCode:{}, newVersion:{}.", processDefinition.getProjectCode(), processDefinitionCode, insertVersion); List<ProcessTaskRelationLog> relationLogs = processTaskRelationList.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()); int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion, relationLogs, taskDefinitionLogs, Boolean.TRUE); if (insertResult == Constants.EXIT_CODE_SUCCESS) { logger.info( "Save new version task relations complete, projectCode:{}, processDefinitionCode:{}, newVersion:{}.", processDefinition.getProjectCode(), processDefinitionCode, insertVersion); } else { logger.error("Update task relations error, projectCode:{}, processDefinitionCode:{}.", processDefinition.getProjectCode(), processDefinitionCode); throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } } /** * update task definition * * @param loginUser login user * @param projectCode project code * @param taskCode task code * @param taskDefinitionJsonObj task definition json object
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
*/ @Transactional @Override public Map<String, Object> updateTaskDefinition(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj) { Map<String, Object> result = new HashMap<>(); TaskDefinitionLog taskDefinitionToUpdate = updateTask(loginUser, projectCode, taskCode, taskDefinitionJsonObj, result); if (taskDefinitionToUpdate == null) { return result; } List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode); if (CollectionUtils.isNotEmpty(taskRelationList)) { logger.info( "Task definition has upstream tasks, start handle them after update task, taskDefinitionCode:{}.", taskCode); long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode(); List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode); updateDag(loginUser, processDefinitionCode, processTaskRelations, Lists.newArrayList(taskDefinitionToUpdate)); } logger.info("Update task definition complete, projectCode:{}, taskDefinitionCode:{}.", projectCode, taskCode); result.put(Constants.DATA_LIST, taskCode); putMsg(result, Status.SUCCESS); return result; } private void TaskDefinitionUpdateValid(TaskDefinition taskDefinitionOriginal, TaskDefinition taskDefinitionUpdate) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
if (processService.isTaskOnline(taskDefinitionOriginal.getCode()) && taskDefinitionOriginal.getFlag() == Flag.YES) { if (taskDefinitionOriginal.getTaskExecuteType() != TaskExecuteType.STREAM) { throw new ServiceException(Status.NOT_SUPPORT_UPDATE_TASK_DEFINITION); } } if (taskDefinitionOriginal.equals(taskDefinitionUpdate)) { throw new ServiceException(Status.TASK_DEFINITION_NOT_CHANGE, taskDefinitionOriginal.getCode()); } Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskDefinitionOriginal.getCode()); if (version == null || version == 0) { throw new ServiceException(Status.DATA_IS_NOT_VALID, taskDefinitionOriginal.getCode()); } } /** * update task definition * * @param loginUser login user * @param taskCode task code * @param taskUpdateRequest task definition json object * @return new TaskDefinition have updated */ @Transactional @Override public TaskDefinition updateTaskDefinitionV2(User loginUser, long taskCode, TaskUpdateRequest taskUpdateRequest) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
TaskDefinition taskDefinitionOriginal = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinitionOriginal == null) { throw new ServiceException(Status.TASK_DEFINITION_NOT_EXISTS, taskCode); } TaskDefinition taskDefinitionUpdate; try { taskDefinitionUpdate = taskUpdateRequest.mergeIntoTaskDefinition(taskDefinitionOriginal); } catch (InvocationTargetException | IllegalAccessException | InstantiationException | NoSuchMethodException e) { throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, taskUpdateRequest.toString()); } this.checkTaskDefinitionValid(loginUser, taskDefinitionUpdate, TASK_DEFINITION_UPDATE); this.TaskDefinitionUpdateValid(taskDefinitionOriginal, taskDefinitionUpdate); int update = taskDefinitionMapper.updateById(taskDefinitionUpdate); if (update <= 0) { throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); } TaskDefinitionLog taskDefinitionLog = this.persist2TaskDefinitionLog(loginUser, taskDefinitionUpdate); List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(taskDefinitionUpdate.getProjectCode(), taskCode); if (CollectionUtils.isNotEmpty(taskRelationList)) { logger.info( "Task definition has upstream tasks, start handle them after update task, taskDefinitionCode:{}.", taskCode); long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode(); List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper .queryByProcessCode(taskDefinitionUpdate.getProjectCode(), processDefinitionCode); updateDag(loginUser, processDefinitionCode, processTaskRelations, Lists.newArrayList(taskDefinitionLog)); } this.updateTaskUpstreams(loginUser, taskUpdateRequest.getWorkflowCode(), taskDefinitionUpdate.getCode(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
taskUpdateRequest.getUpstreamTasksCodes()); return taskDefinitionUpdate; } /** * Get resource task definition by code * * @param loginUser login user * @param taskCode task code * @return TaskDefinition */ @Override public TaskDefinition getTaskDefinition(User loginUser, long taskCode) { TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null) { throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, taskCode); } Project project = projectMapper.queryByCode(taskDefinition.getProjectCode()); projectService.checkProjectAndAuthThrowException(loginUser, project, TASK_DEFINITION); return taskDefinition; } /** * Get resource task definition according to query parameter * * @param loginUser login user * @param taskFilterRequest taskFilterRequest object you want to filter the resource task definitions * @return TaskDefinitions of page */ @Override public PageInfo<TaskDefinition> filterTaskDefinition(User loginUser,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
TaskFilterRequest taskFilterRequest) { TaskDefinition taskDefinition = taskFilterRequest.convert2TaskDefinition(); if (taskDefinition.getProjectName() != null) { Project project = projectMapper.queryByName(taskDefinition.getProjectName()); projectService.checkProjectAndAuthThrowException(loginUser, project, WORKFLOW_DEFINITION); taskDefinition.setProjectCode(project.getCode()); } Page<TaskDefinition> page = new Page<>(taskFilterRequest.getPageNo(), taskFilterRequest.getPageSize()); IPage<TaskDefinition> taskDefinitionIPage = taskDefinitionMapper.filterTaskDefinition(page, taskDefinition); PageInfo<TaskDefinition> pageInfo = new PageInfo<>(taskFilterRequest.getPageNo(), taskFilterRequest.getPageSize()); pageInfo.setTotal((int) taskDefinitionIPage.getTotal()); pageInfo.setTotalList(taskDefinitionIPage.getRecords()); return pageInfo; } private TaskDefinitionLog updateTask(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj, Map<String, Object> result) { Project project = projectMapper.queryByCode(projectCode); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { return null; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null) { logger.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
return null; } if (processService.isTaskOnline(taskCode) && taskDefinition.getFlag() == Flag.YES) { if (taskDefinition.getTaskExecuteType() != TaskExecuteType.STREAM) { logger.warn("Only {} type task can be updated without online check, taskDefinitionCode:{}.", TaskExecuteType.STREAM, taskCode); putMsg(result, Status.NOT_SUPPORT_UPDATE_TASK_DEFINITION); return null; } } TaskDefinitionLog taskDefinitionToUpdate = JSONUtils.parseObject(taskDefinitionJsonObj, TaskDefinitionLog.class); if (TimeoutFlag.CLOSE == taskDefinition.getTimeoutFlag()) { taskDefinition.setTimeoutNotifyStrategy(null); } if (taskDefinition.equals(taskDefinitionToUpdate)) { logger.warn("Task definition does not need update because no change, taskDefinitionCode:{}.", taskCode); putMsg(result, Status.TASK_DEFINITION_NOT_MODIFY_ERROR, String.valueOf(taskCode)); return null; } if (taskDefinitionToUpdate == null) { logger.warn("Parameter taskDefinitionJson is invalid."); putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJsonObj); return null; } if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() .taskType(taskDefinitionToUpdate.getTaskType()) .taskParams(taskDefinitionToUpdate.getTaskParams()) .dependence(taskDefinitionToUpdate.getDependence())
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
.build())) { logger.warn("Task definition parameters are invalid, taskDefinitionName:{}.", taskDefinitionToUpdate.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionToUpdate.getName()); return null; } Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode); if (version == null || version == 0) { logger.error("Max version task definitionLog can not be found in database, taskDefinitionCode:{}.", taskCode); putMsg(result, Status.DATA_IS_NOT_VALID, taskCode); return null; } Date now = new Date(); taskDefinitionToUpdate.setCode(taskCode); taskDefinitionToUpdate.setId(taskDefinition.getId()); taskDefinitionToUpdate.setProjectCode(projectCode); taskDefinitionToUpdate.setUserId(taskDefinition.getUserId()); taskDefinitionToUpdate.setVersion(++version); taskDefinitionToUpdate.setTaskType(taskDefinitionToUpdate.getTaskType().toUpperCase()); taskDefinitionToUpdate.setResourceIds(processService.getResourceIds(taskDefinitionToUpdate)); taskDefinitionToUpdate.setUpdateTime(now); int update = taskDefinitionMapper.updateById(taskDefinitionToUpdate); taskDefinitionToUpdate.setOperator(loginUser.getId()); taskDefinitionToUpdate.setOperateTime(now); taskDefinitionToUpdate.setCreateTime(now); taskDefinitionToUpdate.setId(null); int insert = taskDefinitionLogMapper.insert(taskDefinitionToUpdate); if ((update & insert) != 1) { logger.error("Update task definition or definitionLog error, projectCode:{}, taskDefinitionCode:{}.",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
projectCode, taskCode); putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); } else logger.info( "Update task definition and definitionLog complete, projectCode:{}, taskDefinitionCode:{}, newTaskVersion:{}.", projectCode, taskCode, taskDefinitionToUpdate.getVersion()); List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper .queryByTaskCode(taskDefinitionToUpdate.getCode()); if (CollectionUtils.isNotEmpty(processTaskRelations)) { for (ProcessTaskRelation processTaskRelation : processTaskRelations) { if (taskCode == processTaskRelation.getPreTaskCode()) { processTaskRelation.setPreTaskVersion(version); } else if (taskCode == processTaskRelation.getPostTaskCode()) { processTaskRelation.setPostTaskVersion(version); } int count = processTaskRelationMapper.updateProcessTaskRelationTaskVersion(processTaskRelation); if (count != 1) { logger.error("batch update process task relation error, projectCode:{}, taskDefinitionCode:{}.", projectCode, taskCode); putMsg(result, Status.PROCESS_TASK_RELATION_BATCH_UPDATE_ERROR); throw new ServiceException(Status.PROCESS_TASK_RELATION_BATCH_UPDATE_ERROR); } } } return taskDefinitionToUpdate; } /** * update task definition and upstream
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
* * @param loginUser login user * @param projectCode project code * @param taskCode task definition code * @param taskDefinitionJsonObj task definition json object * @param upstreamCodes upstream task codes, sep comma * @return update result code */ @Override public Map<String, Object> updateTaskWithUpstream(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj, String upstreamCodes) { Map<String, Object> result = new HashMap<>(); TaskDefinitionLog taskDefinitionToUpdate = updateTask(loginUser, projectCode, taskCode, taskDefinitionJsonObj, result); if (result.get(Constants.STATUS) != Status.SUCCESS && taskDefinitionToUpdate == null) { return result; } List<ProcessTaskRelation> upstreamTaskRelations = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode); Set<Long> upstreamCodeSet = upstreamTaskRelations.stream().map(ProcessTaskRelation::getPreTaskCode).collect(Collectors.toSet()); Set<Long> upstreamTaskCodes = Collections.emptySet(); if (StringUtils.isNotEmpty(upstreamCodes)) { upstreamTaskCodes = Arrays.stream(upstreamCodes.split(Constants.COMMA)).map(Long::parseLong) .collect(Collectors.toSet()); } if (CollectionUtils.isEqualCollection(upstreamCodeSet, upstreamTaskCodes) && taskDefinitionToUpdate == null) { putMsg(result, Status.SUCCESS); return result; } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
if (taskDefinitionToUpdate == null) { taskDefinitionToUpdate = JSONUtils.parseObject(taskDefinitionJsonObj, TaskDefinitionLog.class); } } Map<Long, TaskDefinition> queryUpStreamTaskCodeMap; if (CollectionUtils.isNotEmpty(upstreamTaskCodes)) { List<TaskDefinition> upstreamTaskDefinitionList = taskDefinitionMapper.queryByCodeList(upstreamTaskCodes); queryUpStreamTaskCodeMap = upstreamTaskDefinitionList.stream() .collect(Collectors.toMap(TaskDefinition::getCode, taskDefinition -> taskDefinition)); upstreamTaskCodes.removeAll(queryUpStreamTaskCodeMap.keySet()); if (CollectionUtils.isNotEmpty(upstreamTaskCodes)) { String notExistTaskCodes = StringUtils.join(upstreamTaskCodes, Constants.COMMA); logger.error("Some task definitions in parameter upstreamTaskCodes do not exist, notExistTaskCodes:{}.", notExistTaskCodes); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, notExistTaskCodes); return result; } } else { queryUpStreamTaskCodeMap = new HashMap<>(); } if (MapUtils.isNotEmpty(queryUpStreamTaskCodeMap)) { ProcessTaskRelation taskRelation = upstreamTaskRelations.get(0); List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, taskRelation.getProcessDefinitionCode()); updateUpstreamTask(new HashSet<>(queryUpStreamTaskCodeMap.keySet()), taskCode, projectCode, taskRelation.getProcessDefinitionCode(), loginUser); List<ProcessTaskRelation> processTaskRelationList = Lists.newArrayList(processTaskRelations); List<ProcessTaskRelation> relationList = Lists.newArrayList();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
for (ProcessTaskRelation processTaskRelation : processTaskRelationList) { if (processTaskRelation.getPostTaskCode() == taskCode) { if (queryUpStreamTaskCodeMap.containsKey(processTaskRelation.getPreTaskCode()) && processTaskRelation.getPreTaskCode() != 0L) { queryUpStreamTaskCodeMap.remove(processTaskRelation.getPreTaskCode()); } else { processTaskRelation.setPreTaskCode(0L); processTaskRelation.setPreTaskVersion(0); relationList.add(processTaskRelation); } } } processTaskRelationList.removeAll(relationList); for (Map.Entry<Long, TaskDefinition> queryUpStreamTask : queryUpStreamTaskCodeMap.entrySet()) { taskRelation.setPreTaskCode(queryUpStreamTask.getKey()); taskRelation.setPreTaskVersion(queryUpStreamTask.getValue().getVersion()); processTaskRelationList.add(taskRelation); } if (MapUtils.isEmpty(queryUpStreamTaskCodeMap) && CollectionUtils.isNotEmpty(processTaskRelationList)) { processTaskRelationList.add(processTaskRelationList.get(0)); } } logger.info( "Update task with upstream tasks complete, projectCode:{}, taskDefinitionCode:{}, upstreamTaskCodes:{}.", projectCode, taskCode, upstreamTaskCodes); result.put(Constants.DATA_LIST, taskCode); putMsg(result, Status.SUCCESS); return result; } private void updateUpstreamTask(Set<Long> allPreTaskCodeSet, long taskCode, long projectCode,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
long processDefinitionCode, User loginUser) { List<ProcessTaskRelation> hadProcessTaskRelationList = processTaskRelationMapper .queryUpstreamByCode(projectCode, taskCode); Set<Long> removePreTaskSet = new HashSet<>(); List<ProcessTaskRelation> removePreTaskList = new ArrayList<>(); Set<Long> addPreTaskSet = new HashSet<>(); List<ProcessTaskRelation> addPreTaskList = new ArrayList<>(); List<ProcessTaskRelationLog> processTaskRelationLogList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(hadProcessTaskRelationList)) { for (ProcessTaskRelation processTaskRelation : hadProcessTaskRelationList) { if (processTaskRelation.getPreTaskCode() == 0) { continue; } if (allPreTaskCodeSet.contains(processTaskRelation.getPreTaskCode())) { allPreTaskCodeSet.remove(processTaskRelation.getPreTaskCode()); } else { removePreTaskSet.add(processTaskRelation.getPreTaskCode()); processTaskRelation.setPreTaskCode(0); processTaskRelation.setPreTaskVersion(0); removePreTaskList.add(processTaskRelation); processTaskRelationLogList.add(createProcessTaskRelationLog(loginUser, processTaskRelation)); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
if (allPreTaskCodeSet.size() != 0) { addPreTaskSet.addAll(allPreTaskCodeSet); } allPreTaskCodeSet.add(Long.valueOf(taskCode)); List<TaskDefinition> taskDefinitionList = taskDefinitionMapper.queryByCodeList(allPreTaskCodeSet); Map<Long, TaskDefinition> taskCodeMap = taskDefinitionList.stream().collect(Collectors .toMap(TaskDefinition::getCode, Function.identity(), (a, b) -> a)); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); TaskDefinition taskDefinition = taskCodeMap.get(taskCode); for (Long preTaskCode : addPreTaskSet) { TaskDefinition preTaskRelation = taskCodeMap.get(preTaskCode); ProcessTaskRelation processTaskRelation = new ProcessTaskRelation( null, processDefinition.getVersion(), projectCode, processDefinition.getCode(), preTaskRelation.getCode(), preTaskRelation.getVersion(), taskDefinition.getCode(), taskDefinition.getVersion(), ConditionType.NONE, "{}"); addPreTaskList.add(processTaskRelation); processTaskRelationLogList.add(createProcessTaskRelationLog(loginUser, processTaskRelation)); } int insert = 0; int remove = 0; int log = 0; if (CollectionUtils.isNotEmpty(addPreTaskList)) { insert = processTaskRelationMapper.batchInsert(addPreTaskList); } if (CollectionUtils.isNotEmpty(removePreTaskList)) { for (ProcessTaskRelation processTaskRelation : removePreTaskList) { remove += processTaskRelationMapper.updateById(processTaskRelation);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} } if (CollectionUtils.isNotEmpty(processTaskRelationLogList)) { log = processTaskRelationLogDao.batchInsert(processTaskRelationLogList); } if (insert + remove != log) { throw new RuntimeException("updateUpstreamTask error"); } } private ProcessTaskRelationLog createProcessTaskRelationLog(User loginUser, ProcessTaskRelation processTaskRelation) { Date now = new Date(); ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(processTaskRelation); processTaskRelationLog.setOperator(loginUser.getId()); processTaskRelationLog.setOperateTime(now); processTaskRelationLog.setCreateTime(now); processTaskRelationLog.setUpdateTime(now); return processTaskRelationLog; } /** * switch task definition * * @param loginUser login user * @param projectCode project code * @param taskCode task code * @param version the version user want to switch */ @Transactional @Override public Map<String, Object> switchVersion(User loginUser, long projectCode, long taskCode, int version) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_SWITCH_TO_THIS_VERSION); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (processService.isTaskOnline(taskCode)) { logger.warn( "Task definition version can not be switched due to process definition is {}, taskDefinitionCode:{}.", ReleaseState.ONLINE.getDescp(), taskCode); putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) { logger.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode)); return result; } TaskDefinitionLog taskDefinitionUpdate = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, version); taskDefinitionUpdate.setUserId(loginUser.getId()); taskDefinitionUpdate.setUpdateTime(new Date()); taskDefinitionUpdate.setId(taskDefinition.getId()); int switchVersion = taskDefinitionMapper.updateById(taskDefinitionUpdate); if (switchVersion > 0) { List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode); if (CollectionUtils.isNotEmpty(taskRelationList)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
logger.info( "Task definition has upstream tasks, start handle them after switch task, taskDefinitionCode:{}.", taskCode); long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode(); List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode); updateDag(loginUser, processDefinitionCode, processTaskRelations, Lists.newArrayList(taskDefinitionUpdate)); } else { logger.info( "Task definition version switch complete, switch task version to {}, taskDefinitionCode:{}.", version, taskCode); putMsg(result, Status.SUCCESS); } } else { logger.error("Task definition version switch error, taskDefinitionCode:{}.", taskCode); putMsg(result, Status.SWITCH_TASK_DEFINITION_VERSION_ERROR); } return result; } @Override public Result queryTaskDefinitionVersions(User loginUser, long projectCode, long taskCode, int pageNo, int pageSize) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_VERSION_VIEW); Status resultStatus = (Status) checkResult.get(Constants.STATUS); if (resultStatus != Status.SUCCESS) { putMsg(result, resultStatus); return result; } PageInfo<TaskDefinitionLog> pageInfo = new PageInfo<>(pageNo, pageSize); Page<TaskDefinitionLog> page = new Page<>(pageNo, pageSize); IPage<TaskDefinitionLog> taskDefinitionVersionsPaging = taskDefinitionLogMapper.queryTaskDefinitionVersionsPaging(page, taskCode, projectCode); List<TaskDefinitionLog> taskDefinitionLogs = taskDefinitionVersionsPaging.getRecords(); pageInfo.setTotalList(taskDefinitionLogs); pageInfo.setTotal((int) taskDefinitionVersionsPaging.getTotal()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> deleteByCodeAndVersion(User loginUser, long projectCode, long taskCode, int version) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_DELETE); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null) { logger.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode)); } else { if (taskDefinition.getVersion() == version) { logger.warn( "Task definition can not be deleted due to version is being used, projectCode:{}, taskDefinitionCode:{}, version:{}.", projectCode, taskCode, version); putMsg(result, Status.MAIN_TABLE_USING_VERSION); return result; } int delete = taskDefinitionLogMapper.deleteByCodeAndVersion(taskCode, version); if (delete > 0) { logger.info( "Task definition version delete complete, projectCode:{}, taskDefinitionCode:{}, version:{}.", projectCode, taskCode, version); putMsg(result, Status.SUCCESS); } else { logger.error("Task definition version delete error, projectCode:{}, taskDefinitionCode:{}, version:{}.", projectCode, taskCode, version); putMsg(result, Status.DELETE_TASK_DEFINITION_VERSION_ERROR); } } return result; } @Override public Map<String, Object> queryTaskDefinitionDetail(User loginUser, long projectCode, long taskCode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION); if (result.get(Constants.STATUS) != Status.SUCCESS) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) { logger.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode)); } else { List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper .queryByCode(projectCode, 0, 0, taskCode); if (CollectionUtils.isNotEmpty(taskRelationList)) { taskRelationList = taskRelationList.stream() .filter(v -> v.getPreTaskCode() != 0).collect(Collectors.toList()); } TaskDefinitionVo taskDefinitionVo = TaskDefinitionVo.fromTaskDefinition(taskDefinition); taskDefinitionVo.setProcessTaskRelationList(taskRelationList); result.put(Constants.DATA_LIST, taskDefinitionVo); putMsg(result, Status.SUCCESS); } return result; } @Override public Result queryTaskDefinitionListPaging(User loginUser, long projectCode, String searchTaskName, String taskType, TaskExecuteType taskExecuteType, Integer pageNo, Integer pageSize) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION); Status resultStatus = (Status) checkResult.get(Constants.STATUS); if (resultStatus != Status.SUCCESS) { putMsg(result, resultStatus); return result; } taskType = taskType == null ? StringUtils.EMPTY : taskType; Page<TaskMainInfo> page = new Page<>(pageNo, pageSize); IPage<TaskMainInfo> taskMainInfoIPage = taskDefinitionMapper.queryDefineListPaging(page, projectCode, searchTaskName, taskType, taskExecuteType); fillRecords(projectCode, taskMainInfoIPage); PageInfo<TaskMainInfo> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int) taskMainInfoIPage.getTotal()); pageInfo.setTotalList(taskMainInfoIPage.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } private void fillRecords(long projectCode, IPage<TaskMainInfo> taskMainInfoIPage) { List<TaskMainInfo> records = Collections.emptyList(); if (CollectionUtils.isNotEmpty(taskMainInfoIPage.getRecords())) { records = taskDefinitionMapper.queryDefineListByCodeList(projectCode, taskMainInfoIPage.getRecords().stream().map(TaskMainInfo::getTaskCode) .collect(Collectors.toList())); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
taskMainInfoIPage.setRecords(Collections.emptyList()); if (CollectionUtils.isNotEmpty(records)) { Map<Long, TaskMainInfo> taskMainInfoMap = new HashMap<>(); for (TaskMainInfo info : records) { taskMainInfoMap.compute(info.getTaskCode(), (k, v) -> { if (v == null) { Map<Long, String> upstreamTaskMap = new HashMap<>(); if (info.getUpstreamTaskCode() != 0) { upstreamTaskMap.put(info.getUpstreamTaskCode(), info.getUpstreamTaskName()); info.setUpstreamTaskCode(0L); info.setUpstreamTaskName(StringUtils.EMPTY); } info.setUpstreamTaskMap(upstreamTaskMap); v = info; } if (info.getUpstreamTaskCode() != 0) { v.getUpstreamTaskMap().put(info.getUpstreamTaskCode(), info.getUpstreamTaskName()); } return v; }); } List<TaskMainInfo> resultRecords = Lists.newArrayList(taskMainInfoMap.values()); resultRecords.sort((o1, o2) -> o2.getTaskUpdateTime().compareTo(o1.getTaskUpdateTime())); taskMainInfoIPage.setRecords(resultRecords); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} private void fillWorkflowInfo(long projectCode, IPage<TaskMainInfo> taskMainInfoIPage) { } @Override public Map<String, Object> genTaskCodeList(Integer genNum) { Map<String, Object> result = new HashMap<>(); if (genNum == null || genNum < 1 || genNum > 100) { logger.warn("Parameter genNum must be great than 1 and less than 100."); putMsg(result, Status.DATA_IS_NOT_VALID, genNum); return result; } List<Long> taskCodes = new ArrayList<>(); try { for (int i = 0; i < genNum; i++) { taskCodes.add(CodeGenerateUtils.getInstance().genCode()); } } catch (CodeGenerateException e) { logger.error("Generate task definition code error.", e); putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code"); } putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, taskCodes); return result; } /** * release task definition * * @param loginUser login user * @param projectCode project code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
* @param code task definition code * @param releaseState releaseState * @return update result code */ @Transactional @Override public Map<String, Object> releaseTaskDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, null); Status resultStatus = (Status) result.get(Constants.STATUS); if (resultStatus != Status.SUCCESS) { return result; } if (null == releaseState) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(code); if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) { putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(code)); return result; } TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(code, taskDefinition.getVersion()); if (taskDefinitionLog == null) { logger.error("Task definition does not exist, taskDefinitionCode:{}.", code); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(code)); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
} switch (releaseState) { case OFFLINE: taskDefinition.setFlag(Flag.NO); taskDefinitionLog.setFlag(Flag.NO); break; case ONLINE: String resourceIds = taskDefinition.getResourceIds(); if (StringUtils.isNotBlank(resourceIds)) { Integer[] resourceIdArray = Arrays.stream(resourceIds.split(",")).map(Integer::parseInt).toArray(Integer[]::new); PermissionCheck<Integer> permissionCheck = new PermissionCheck(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger); try { permissionCheck.checkPermission(); } catch (Exception e) { logger.error("Resources permission check error, resourceIds:{}.", resourceIds, e); putMsg(result, Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION); return result; } } taskDefinition.setFlag(Flag.YES); taskDefinitionLog.setFlag(Flag.YES); break; default: logger.warn("Parameter releaseState is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } int update = taskDefinitionMapper.updateById(taskDefinition);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,421
[Bug] [dolphinscheduler-api] in the task definition list, when the task details are not modified, the predecessor node cannot be modified
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### What you expected to happen the task detail are not modify, only the process pre code for modify ### How to reproduce in the task definition list, edit node, the task detail are not modify, only the process pre code for modify ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13421
https://github.com/apache/dolphinscheduler/pull/13422
8be32d4145c851a01d7300cd5a854be9b4a27055
3b54de0c90083aaf0857362e7c237fb85ba3976c
2023-01-18T05:48:15Z
java
2023-01-18T12:08:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
int updateLog = taskDefinitionLogMapper.updateById(taskDefinitionLog); if ((update == 0 && updateLog == 1) || (update == 1 && updateLog == 0)) { logger.error("Update taskDefinition state or taskDefinitionLog state error, taskDefinitionCode:{}.", code); putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); } logger.error("Update taskDefinition state or taskDefinitionLog state to complete, taskDefinitionCode:{}.", code); putMsg(result, Status.SUCCESS); return result; } @Override public void deleteTaskByWorkflowDefinitionCode(long workflowDefinitionCode, int workflowDefinitionVersion) { List<ProcessTaskRelation> processTaskRelations = processTaskRelationService .queryByWorkflowDefinitionCode(workflowDefinitionCode, workflowDefinitionVersion); if (CollectionUtils.isEmpty(processTaskRelations)) { return; } Set<Long> needToDeleteTaskDefinitionCodes = new HashSet<>(); for (ProcessTaskRelation processTaskRelation : processTaskRelations) { needToDeleteTaskDefinitionCodes.add(processTaskRelation.getPreTaskCode()); needToDeleteTaskDefinitionCodes.add(processTaskRelation.getPostTaskCode()); } taskDefinitionDao.deleteByTaskDefinitionCodes(needToDeleteTaskDefinitionCodes); processTaskRelationService.deleteByWorkflowDefinitionCode(workflowDefinitionCode, workflowDefinitionVersion); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
/* * 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.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
* See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.controller; import static org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_DATA_SOURCE; import static org.apache.dolphinscheduler.api.enums.Status.CONNECTION_TEST_FAILURE; import static org.apache.dolphinscheduler.api.enums.Status.CONNECT_DATASOURCE_FAILURE; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_DATASOURCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_DATA_SOURCE_FAILURE; import static org.apache.dolphinscheduler.api.enums.Status.GET_DATASOURCE_TABLES_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GET_DATASOURCE_TABLE_COLUMNS_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.KERBEROS_STARTUP_STATE; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_DATASOURCE; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_DATASOURCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_DATASOURCE_NAME_FAILURE; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.DataSourceService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; import java.util.Map;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; /** * data source controller */ @Tag(name = "DATA_SOURCE_TAG") @RestController @RequestMapping("datasources") public class DataSourceController extends BaseController { @Autowired private DataSourceService dataSourceService; /** * create data source *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
* @param loginUser login user * @param jsonStr datasource param * example: {"type":"MYSQL","name":"txx","note":"","host":"localhost","port":3306,"principal":"","javaSecurityKrb5Conf":"","loginUserKeytabUsername":"","loginUserKeytabPath":"","userName":"root","password":"xxx","database":"ds","connectType":"","other":{"serverTimezone":"GMT-8"},"id":2,"testFlag":0,"bindTestId":1} * @return create result code */ @Operation(summary = "createDataSource", description = "CREATE_DATA_SOURCE_NOTES") @PostMapping() @ResponseStatus(HttpStatus.CREATED) @ApiException(CREATE_DATASOURCE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result createDataSource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "dataSourceParam", description = "DATA_SOURCE_PARAM", required = true) @RequestBody String jsonStr) { BaseDataSourceParamDTO dataSourceParam = DataSourceUtils.buildDatasourceParam(jsonStr); return dataSourceService.createDataSource(loginUser, dataSourceParam); } /** * updateProcessInstance data source * * @param loginUser login user * @param id datasource id * @param jsonStr datasource param * example: {"type":"MYSQL","name":"txx","note":"","host":"localhost","port":3306,"principal":"","javaSecurityKrb5Conf":"","loginUserKeytabUsername":"","loginUserKeytabPath":"","userName":"root","password":"xxx","database":"ds","connectType":"","other":{"serverTimezone":"GMT-8"},"id":2,"testFlag":0,"bindTestId":1} * @return update result code */ @Operation(summary = "updateDataSource", description = "UPDATE_DATA_SOURCE_NOTES") @Parameters({ @Parameter(name = "id", description = "DATA_SOURCE_ID", required = true, schema = @Schema(implementation = int.class)), @Parameter(name = "dataSourceParam", description = "DATA_SOURCE_PARAM", required = true, schema = @Schema(implementation = BaseDataSourceParamDTO.class)) }) @PutMapping(value = "/{id}")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
@ResponseStatus(HttpStatus.OK) @ApiException(UPDATE_DATASOURCE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result updateDataSource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @PathVariable(value = "id") Integer id, @RequestBody String jsonStr) { BaseDataSourceParamDTO dataSourceParam = DataSourceUtils.buildDatasourceParam(jsonStr); dataSourceParam.setId(id); return dataSourceService.updateDataSource(dataSourceParam.getId(), loginUser, dataSourceParam); } /** * query data source detail * * @param loginUser login user * @param id datasource id * @return data source detail */ @Operation(summary = "queryDataSource", description = "QUERY_DATA_SOURCE_NOTES") @Parameters({ @Parameter(name = "id", description = "DATA_SOURCE_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/{id}") @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_DATASOURCE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryDataSource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @PathVariable("id") int id) { Map<String, Object> result = dataSourceService.queryDataSource(id); return returnDataList(result); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
/** * query online/testDatasource by type * * @param loginUser login user * @param type data source type * @return data source list page */ @Operation(summary = "queryDataSourceList", description = "QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES") @Parameters({ @Parameter(name = "type", description = "DB_TYPE", required = true, schema = @Schema(implementation = DbType.class)), @Parameter(name = "testFlag", description = "DB_TEST_FLAG", required = true, schema = @Schema(implementation = int.class)) }) @GetMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_DATASOURCE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryDataSourceList(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("type") DbType type, @RequestParam("testFlag") int testFlag) { Map<String, Object> result = dataSourceService.queryDataSourceList(loginUser, type.ordinal(), testFlag); return returnDataList(result); } /** * query datasource with paging * * @param loginUser login user * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return data source list page
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
*/ @Operation(summary = "queryDataSourceListPaging", description = "QUERY_DATA_SOURCE_LIST_PAGING_NOTES") @Parameters({ @Parameter(name = "searchVal", description = "SEARCH_VAL", schema = @Schema(implementation = String.class)), @Parameter(name = "pageNo", description = "PAGE_NO", required = true, schema = @Schema(implementation = int.class, example = "1")), @Parameter(name = "pageSize", description = "PAGE_SIZE", required = true, schema = @Schema(implementation = int.class, example = "20")) }) @GetMapping() @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_DATASOURCE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryDataSourceListPaging(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) { Result result = checkPageParams(pageNo, pageSize); if (!result.checkResult()) { return result; } searchVal = ParameterUtils.handleEscapes(searchVal); return dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize); } /** * connect datasource * * @param loginUser login user * @param jsonStr datasource param * example: {"type":"MYSQL","name":"txx","note":"","host":"localhost","port":3306,"principal":"","javaSecurityKrb5Conf":"","loginUserKeytabUsername":"","loginUserKeytabPath":"","userName":"root","password":"xxx","database":"ds","connectType":"","other":{"serverTimezone":"GMT-8"},"id":2} * @return connect result code */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
@Operation(summary = "connectDataSource", description = "CONNECT_DATA_SOURCE_NOTES") @PostMapping(value = "/connect") @ResponseStatus(HttpStatus.OK) @ApiException(CONNECT_DATASOURCE_FAILURE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result connectDataSource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "dataSourceParam") @RequestBody String jsonStr) { BaseDataSourceParamDTO dataSourceParam = DataSourceUtils.buildDatasourceParam(jsonStr); DataSourceUtils.checkDatasourceParam(dataSourceParam); ConnectionParam connectionParams = DataSourceUtils.buildConnectionParams(dataSourceParam); return dataSourceService.checkConnection(dataSourceParam.getType(), connectionParams); } /** * connection test * * @param loginUser login user * @param id data source id * @return connect result code */ @Operation(summary = "connectionTest", description = "CONNECT_DATA_SOURCE_TEST_NOTES") @Parameters({ @Parameter(name = "id", description = "DATA_SOURCE_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/{id}/connect-test") @ResponseStatus(HttpStatus.OK) @ApiException(CONNECTION_TEST_FAILURE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result connectionTest(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @PathVariable("id") int id) { return dataSourceService.connectionTest(id);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
} /** * delete datasource by id * * @param loginUser login user * @param id datasource id * @return delete result */ @Operation(summary = "deleteDataSource", description = "DELETE_DATA_SOURCE_NOTES") @Parameters({ @Parameter(name = "id", description = "DATA_SOURCE_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @DeleteMapping(value = "/{id}") @ResponseStatus(HttpStatus.OK) @ApiException(DELETE_DATA_SOURCE_FAILURE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result deleteDataSource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @PathVariable("id") int id) { return dataSourceService.delete(loginUser, id); } /** * verify datasource name * * @param loginUser login user * @param name data source name * @return true if data source name not exists.otherwise return false */ @Operation(summary = "verifyDataSourceName", description = "VERIFY_DATA_SOURCE_NOTES") @Parameters({ @Parameter(name = "name", description = "DATA_SOURCE_NAME", required = true, schema = @Schema(implementation = String.class))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
}) @GetMapping(value = "/verify-name") @ResponseStatus(HttpStatus.OK) @ApiException(VERIFY_DATASOURCE_NAME_FAILURE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result verifyDataSourceName(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "name") String name) { return dataSourceService.verifyDataSourceName(name); } /** * unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ @Operation(summary = "unauthDatasource", description = "UNAUTHORIZED_DATA_SOURCE_NOTES") @Parameters({ @Parameter(name = "userId", description = "USER_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/unauth-datasource") @ResponseStatus(HttpStatus.OK) @ApiException(UNAUTHORIZED_DATASOURCE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result unauthDatasource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { Map<String, Object> result = dataSourceService.unauthDatasource(loginUser, userId); return returnDataList(result); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
* authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ @Operation(summary = "authedDatasource", description = "AUTHORIZED_DATA_SOURCE_NOTES") @Parameters({ @Parameter(name = "userId", description = "USER_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/authed-datasource") @ResponseStatus(HttpStatus.OK) @ApiException(AUTHORIZED_DATA_SOURCE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result authedDatasource(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { Map<String, Object> result = dataSourceService.authedDatasource(loginUser, userId); return returnDataList(result); } /** * get user info * * @param loginUser login user * @return user info data */ @Operation(summary = "getKerberosStartupState", description = "GET_USER_INFO_NOTES") @GetMapping(value = "/kerberos-startup-state") @ResponseStatus(HttpStatus.OK) @ApiException(KERBEROS_STARTUP_STATE) @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
public Result getKerberosStartupState(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { return success(Status.SUCCESS.getMsg(), CommonUtils.getKerberosStartupState()); } @Operation(summary = "tables", description = "GET_DATASOURCE_TABLES_NOTES") @Parameters({ @Parameter(name = "datasourceId", description = "DATA_SOURCE_ID", required = true, schema = @Schema(implementation = int.class, example = "1")) }) @GetMapping(value = "/tables") @ResponseStatus(HttpStatus.OK) @ApiException(GET_DATASOURCE_TABLES_ERROR) public Result getTables(@RequestParam("datasourceId") Integer datasourceId) { Map<String, Object> result = dataSourceService.getTables(datasourceId); return returnDataList(result); } @Operation(summary = "tableColumns", description = "GET_DATASOURCE_TABLE_COLUMNS_NOTES") @Parameters({ @Parameter(name = "datasourceId", description = "DATA_SOURCE_ID", required = true, schema = @Schema(implementation = int.class, example = "1")), @Parameter(name = "tableName", description = "TABLE_NAME", required = true, schema = @Schema(implementation = String.class, example = "test")) }) @GetMapping(value = "/tableColumns") @ResponseStatus(HttpStatus.OK) @ApiException(GET_DATASOURCE_TABLE_COLUMNS_ERROR) public Result getTableColumns(@RequestParam("datasourceId") Integer datasourceId, @RequestParam("tableName") String tableName) { Map<String, Object> result = dataSourceService.getTableColumns(datasourceId, tableName); return returnDataList(result); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
/* * 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.service; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; import java.util.Map; /** * data source service */ public interface DataSourceService {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
/** * create data source * * @param loginUser login user * @param datasourceParam datasource parameter * @return create result code */ Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam); /** * updateProcessInstance datasource * * @param loginUser login user * @param id data source id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
* @param dataSourceParam data source params * @return update result code */ Result<Object> updateDataSource(int id, User loginUser, BaseDataSourceParamDTO dataSourceParam); /** * updateProcessInstance datasource * * @param id datasource id * @return data source detail */ Map<String, Object> queryDataSource(int id); /** * query datasource list by keyword * * @param loginUser login user * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return data source list page */ Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize); /** * query online/test data resource list * * @param loginUser login user * @param type data source type * @return data source list page */ Map<String, Object> queryDataSourceList(User loginUser, Integer type, int testFlag); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
* verify datasource exists * * @param name datasource name * @return true if data datasource not exists, otherwise return false */ Result<Object> verifyDataSourceName(String name); /** * check connection * * @param type data source type * @param parameter data source parameters * @return true if connect successfully, otherwise false */ Result<Object> checkConnection(DbType type, ConnectionParam parameter); /** * test connection * * @param id datasource id * @return connect result code */ Result<Object> connectionTest(int id); /** * delete datasource * * @param loginUser login user * @param datasourceId data source id * @return delete result code */ Result<Object> delete(User loginUser, int datasourceId); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
* unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ Map<String, Object> unauthDatasource(User loginUser, Integer userId); /** * authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ Map<String, Object> authedDatasource(User loginUser, Integer userId); /** * get tables * @param datasourceId * @return */ Map<String, Object> getTables(Integer datasourceId); /** * get table columns * @param datasourceId * @param tableName * @return */ Map<String, Object> getTableColumns(Integer datasourceId, String tableName); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
/* * 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
* * 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.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_UPDATE; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.DataSourceService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereo.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.node.ObjectNode; /** * data source service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
public class DataSourceServiceImpl extends BaseServiceImpl implements DataSourceService { private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceImpl.class); @Autowired private DataSourceMapper dataSourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; private static final String TABLE = "TABLE"; private static final String VIEW = "VIEW"; private static final String[] TABLE_TYPES = new String[]{TABLE, VIEW}; private static final String TABLE_NAME = "TABLE_NAME"; private static final String COLUMN_NAME = "COLUMN_NAME"; /** * create data source * * @param loginUser login user * @param datasourceParam datasource parameters * @return create result code */ @Override @Transactional public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) { DataSourceUtils.checkDatasourceParam(datasourceParam);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
Result<Object> result = new Result<>(); if (!canOperatorPermissions(loginUser, null, AuthorizationType.DATASOURCE, ApiFuncIdentificationConstant.DATASOURCE_CREATE_DATASOURCE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (checkName(datasourceParam.getName())) { logger.warn("Datasource with the same name already exists, name:{}.", datasourceParam.getName()); putMsg(result, Status.DATASOURCE_EXIST); return result; } if (checkDescriptionLength(datasourceParam.getNote())) { logger.warn("Parameter description is too long, description:{}.", datasourceParam.getNote()); putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(datasourceParam); DataSource dataSource = new DataSource(); Date now = new Date(); dataSource.setName(datasourceParam.getName().trim()); dataSource.setNote(datasourceParam.getNote()); dataSource.setUserId(loginUser.getId()); dataSource.setUserName(loginUser.getUserName()); dataSource.setType(datasourceParam.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setCreateTime(now); dataSource.setUpdateTime(now); dataSource.setTestFlag(datasourceParam.getTestFlag());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
dataSource.setBindTestId(datasourceParam.getBindTestId()); try { dataSourceMapper.insert(dataSource); putMsg(result, Status.SUCCESS); permissionPostHandle(AuthorizationType.DATASOURCE, loginUser.getId(), Collections.singletonList(dataSource.getId()), logger); logger.info("Datasource create complete, dbType:{}, datasourceName:{}.", dataSource.getType().getDescp(), dataSource.getName()); } catch (DuplicateKeyException ex) { logger.error("Datasource create error.", ex); putMsg(result, Status.DATASOURCE_EXIST); } return result; } /** * updateProcessInstance datasource * * @param loginUser login user * @param id data source id * @return update result code */ @Override public Result<Object> updateDataSource(int id, User loginUser, BaseDataSourceParamDTO dataSourceParam) { DataSourceUtils.checkDatasourceParam(dataSourceParam); Result<Object> result = new Result<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { logger.error("Datasource does not exist, id:{}.", id); putMsg(result, Status.RESOURCE_NOT_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
return result; } if (!canOperatorPermissions(loginUser, new Object[]{dataSource.getId()}, AuthorizationType.DATASOURCE, DATASOURCE_UPDATE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!dataSourceParam.getName().trim().equals(dataSource.getName()) && checkName(dataSourceParam.getName())) { logger.warn("Datasource with the same name already exists, name:{}.", dataSource.getName()); putMsg(result, Status.DATASOURCE_EXIST); return result; } if (checkDescriptionLength(dataSourceParam.getNote())) { logger.warn("Parameter description is too long, description:{}.", dataSourceParam.getNote()); putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams(dataSourceParam); String password = connectionParam.getPassword(); if (StringUtils.isBlank(password)) { String oldConnectionParams = dataSource.getConnectionParams(); ObjectNode oldParams = JSONUtils.parseObject(oldConnectionParams); connectionParam.setPassword(oldParams.path(Constants.PASSWORD).asText()); } Date now = new Date(); dataSource.setName(dataSourceParam.getName().trim()); dataSource.setNote(dataSourceParam.getNote());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
dataSource.setUserName(loginUser.getUserName()); dataSource.setType(dataSource.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setUpdateTime(now); if (dataSource.getTestFlag() == 1 && dataSourceParam.getTestFlag() == 0) { clearBindTestId(id); } dataSource.setTestFlag(dataSourceParam.getTestFlag()); dataSource.setBindTestId(dataSourceParam.getBindTestId()); try { dataSourceMapper.updateById(dataSource); logger.info("Update datasource complete, datasourceId:{}, datasourceName:{}.", dataSource.getId(), dataSource.getName()); putMsg(result, Status.SUCCESS); } catch (DuplicateKeyException ex) { logger.error("Update datasource error, datasourceId:{}, datasourceName:{}.", dataSource.getId(), dataSource.getName()); putMsg(result, Status.DATASOURCE_EXIST); } return result; } private boolean checkName(String name) { List<DataSource> queryDataSource = dataSourceMapper.queryDataSourceByName(name.trim()); return queryDataSource != null && !queryDataSource.isEmpty(); } /** * updateProcessInstance datasource * * @param id datasource id * @return data source detail
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override public Map<String, Object> queryDataSource(int id) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { logger.error("Datasource does not exist, id:{}.", id); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } // BaseDataSourceParamDTO baseDataSourceParamDTO = DataSourceUtils.buildDatasourceParamDTO( dataSource.getType(), dataSource.getConnectionParams()); baseDataSourceParamDTO.setId(dataSource.getId()); baseDataSourceParamDTO.setName(dataSource.getName()); baseDataSourceParamDTO.setNote(dataSource.getNote()); baseDataSourceParamDTO.setTestFlag(dataSource.getTestFlag()); baseDataSourceParamDTO.setBindTestId(dataSource.getBindTestId()); result.put(Constants.DATA_LIST, baseDataSourceParamDTO); putMsg(result, Status.SUCCESS); return result; } /** * query datasource list by keyword * * @param loginUser login user * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return data source list page
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override public Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); IPage<DataSource> dataSourceList = null; Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize); PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize); if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { dataSourceList = dataSourceMapper.selectPaging(dataSourcePage, UserType.ADMIN_USER.equals(loginUser.getUserType()) ? 0 : loginUser.getId(), searchVal); } else { Set<Integer> ids = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger); if (ids.isEmpty()) { result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal); } List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>(); handlePasswd(dataSources); pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L)); pageInfo.setTotalList(dataSources); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * handle datasource connection password for safety
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ private void handlePasswd(List<DataSource> dataSourceList) { for (DataSource dataSource : dataSourceList) { String connectionParams = dataSource.getConnectionParams(); ObjectNode object = JSONUtils.parseObject(connectionParams); object.put(Constants.PASSWORD, getHiddenPassword()); dataSource.setConnectionParams(object.toString()); } } /** * get hidden password (resolve the security hotspot) * * @return hidden password */ private String getHiddenPassword() { return Constants.XXXXXX; } /** * query data resource list * * @param loginUser login user * @param data source * @return data source list page */ @Override public Map<String, Object> queryDataSourceList(User loginUser, Integer , int testFlag) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList = null; if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { datasourceList = dataSourceMapper.queryDataSourceByType(0, , testFlag);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} else { Set<Integer> ids = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger); if (ids.isEmpty()) { result.put(Constants.DATA_LIST, Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } datasourceList = dataSourceMapper.selectBatchIds(ids).stream() .filter(dataSource -> dataSource.getType().getCode() == ) .filter(dataSource -> dataSource.getTestFlag() == testFlag).collect(Collectors.toList()); } result.put(Constants.DATA_LIST, datasourceList); putMsg(result, Status.SUCCESS); return result; } /** * verify datasource exists * * @param name datasource name * @return true if data datasource not exists, otherwise return false */ @Override public Result<Object> verifyDataSourceName(String name) { Result<Object> result = new Result<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name); if (dataSourceList != null && !dataSourceList.isEmpty()) { logger.warn("Datasource with the same name already exists, dataSourceName:{}.", dataSourceList.get(0).getName()); putMsg(result, Status.DATASOURCE_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} else { putMsg(result, Status.SUCCESS); } return result; } /** * check connection * * @param data source * @param connectionParam connectionParam * @return true if connect successfully, otherwise false * @return true if connect successfully, otherwise false */ @Override public Result<Object> checkConnection(DbType , ConnectionParam connectionParam) { Result<Object> result = new Result<>(); try (Connection connection = DataSourceClientProvider.getInstance().getConnection(, connectionParam)) { if (connection == null) { logger.error("Connection test to {} datasource failed, connectionParam:{}.", .getDescp(), connectionParam); putMsg(result, Status.CONNECTION_TEST_FAILURE); return result; } logger.info("Connection test to {} datasource success, connectionParam:{}", .getDescp(), connectionParam); putMsg(result, Status.SUCCESS); return result; } catch (Exception e) { String message = Optional.of(e).map(Throwable::getCause) .map(Throwable::getMessage)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
.orElse(e.getMessage()); logger.error("Datasource test connection error, dbType:{}, connectionParam:{}, message:{}.", , connectionParam, message); return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(), message); } } /** * test connection * * @param id datasource id * @return connect result code */ @Override public Result<Object> connectionTest(int id) { DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { Result<Object> result = new Result<>(); logger.error("Datasource does not exist, datasourceId:{}.", id); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } return checkConnection(dataSource.getType(), DataSourceUtils.buildConnectionParams(dataSource.getType(), dataSource.getConnectionParams())); } /** * delete datasource * * @param loginUser login user * @param datasourceId data source id * @return delete result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override @Transactional public Result<Object> delete(User loginUser, int datasourceId) { Result<Object> result = new Result<>(); try { // DataSource dataSource = dataSourceMapper.selectById(datasourceId); if (dataSource == null) { logger.warn("Datasource does not exist, datasourceId:{}.", datasourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!canOperatorPermissions(loginUser, new Object[]{dataSource.getId()}, AuthorizationType.DATASOURCE, DATASOURCE_DELETE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } dataSourceMapper.deleteById(datasourceId); datasourceUserMapper.deleteByDatasourceId(datasourceId); clearBindTestId(datasourceId); logger.info("Delete datasource complete, datasourceId:{}.", datasourceId); putMsg(result, Status.SUCCESS); } catch (Exception e) { logger.error("Delete datasource complete, datasourceId:{}.", datasourceId, e); throw new ServiceException(Status.DELETE_DATA_SOURCE_FAILURE); } return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
* unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ @Override public Map<String, Object> unauthDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList; if (canOperatorPermissions(loginUser, null, AuthorizationType.DATASOURCE, null)) { // datasourceList = dataSourceMapper.queryDatasourceExceptUserId(userId); } else { // datasourceList = dataSourceMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId())); } List<DataSource> resultList = new ArrayList<>(); Set<DataSource> datasourceSet; if (datasourceList != null && !datasourceList.isEmpty()) { datasourceSet = new HashSet<>(datasourceList); List<DataSource> authedDataSourceList = dataSourceMapper.queryAuthedDatasource(userId); Set<DataSource> authedDataSourceSet; if (authedDataSourceList != null && !authedDataSourceList.isEmpty()) { authedDataSourceSet = new HashSet<>(authedDataSourceList); datasourceSet.removeAll(authedDataSourceSet); } resultList = new ArrayList<>(datasourceSet); } result.put(Constants.DATA_LIST, resultList);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
putMsg(result, Status.SUCCESS); return result; } /** * authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authedDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<DataSource> authedDatasourceList = dataSourceMapper.queryAuthedDatasource(userId); result.put(Constants.DATA_LIST, authedDatasourceList); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> getTables(Integer datasourceId) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(datasourceId); List<String> tableList = null; BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( dataSource.getType(), dataSource.getConnectionParams()); if (null == connectionParam) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} Connection connection = DataSourceUtils.getConnection(dataSource.getType(), connectionParam); ResultSet tables = null; try { if (null == connection) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } DatabaseMetaData metaData = connection.getMetaData(); String schema = null; try { schema = metaData.getConnection().getSchema(); } catch (SQLException e) { logger.error("Cant not get the schema, datasourceId:{}.", datasourceId, e); } tables = metaData.getTables( connectionParam.getDatabase(), getDbSchemaPattern(dataSource.getType(), schema, connectionParam), "%", TABLE_TYPES); if (null == tables) { logger.error("Get datasource tables error, datasourceId:{}.", datasourceId); putMsg(result, Status.GET_DATASOURCE_TABLES_ERROR); return result; } tableList = new ArrayList<>(); while (tables.next()) { String name = tables.getString(TABLE_NAME); tableList.add(name); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} catch (Exception e) { logger.error("Get datasource tables error, datasourceId:{}.", datasourceId, e); putMsg(result, Status.GET_DATASOURCE_TABLES_ERROR); return result; } finally { closeResult(tables); releaseConnection(connection); } List<ParamsOptions> options = getParamsOptions(tableList); result.put(Constants.DATA_LIST, options); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> getTableColumns(Integer datasourceId, String tableName) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(datasourceId); BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( dataSource.getType(), dataSource.getConnectionParams()); if (null == connectionParam) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } Connection connection = DataSourceUtils.getConnection(dataSource.getType(), connectionParam); List<String> columnList = new ArrayList<>(); ResultSet rs = null; try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
String database = connectionParam.getDatabase(); if (null == connection) { return result; } DatabaseMetaData metaData = connection.getMetaData(); if (dataSource.getType() == DbType.ORACLE) { database = null; } rs = metaData.getColumns(database, null, tableName, "%"); if (rs == null) { return result; } while (rs.next()) { columnList.add(rs.getString(COLUMN_NAME)); } } catch (Exception e) { logger.error("Get datasource table columns error, datasourceId:{}.", dataSource.getId(), e); } finally { closeResult(rs); releaseConnection(connection); } List<ParamsOptions> options = getParamsOptions(columnList); result.put(Constants.DATA_LIST, options); putMsg(result, Status.SUCCESS); return result; } private List<ParamsOptions> getParamsOptions(List<String> columnList) { List<ParamsOptions> options = null; if (CollectionUtils.isNotEmpty(columnList)) { options = new ArrayList<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
for (String column : columnList) { ParamsOptions childrenOption = new ParamsOptions(column, column, false); options.add(childrenOption); } } return options; } private String getDbSchemaPattern(DbType dbType, String schema, BaseConnectionParam connectionParam) { if (dbType == null) { return null; } String schemaPattern = null; switch (dbType) { case HIVE: schemaPattern = connectionParam.getDatabase(); break; case ORACLE: schemaPattern = connectionParam.getUser(); if (null != schemaPattern) { schemaPattern = schemaPattern.toUpperCase(); } break; case SQLSERVER: schemaPattern = "dbo"; break; case CLICKHOUSE: case PRESTO: if (!StringUtils.isEmpty(schema)) { schemaPattern = schema;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} break; default: break; } return schemaPattern; } private static void releaseConnection(Connection connection) { if (null != connection) { try { connection.close(); } catch (Exception e) { logger.error("Connection release error", e); } } } private static void closeResult(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (Exception e) { logger.error("ResultSet close error", e); } } } private void clearBindTestId(Integer bindTestId) { dataSourceMapper.clearBindTestId(bindTestId); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
/* * 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.service; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl; import org.apache.dolphinscheduler.api.service.impl.DataSourceServiceImpl; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.DataSourceConstants; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.datasource.hive.param.HiveDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.mysql.param.MySQLDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.oracle.param.OracleDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.postgresql.param.PostgreSQLDataSourceParamDTO; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbConnectType; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.commons.collections4.CollectionUtils; import java.sql.Connection; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockedStatic; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * data source service test */ @ExtendWith(MockitoExtension.class) public class DataSourceServiceTest { private static final Logger baseServiceLogger = LoggerFactory.getLogger(BaseServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceTest.class); private static final Logger dataSourceServiceLogger = LoggerFactory.getLogger(DataSourceServiceImpl.class); @InjectMocks private DataSourceServiceImpl dataSourceService; @Mock private DataSourceMapper dataSourceMapper; @Mock private DataSourceUserMapper datasourceUserMapper; @Mock private ResourcePermissionCheckService resourcePermissionCheckService; private void passResourcePermissionCheckService() { Mockito.when(resourcePermissionCheckService.operationPermissionCheck(Mockito.any(), Mockito.anyInt(), Mockito.anyString(), Mockito.any())).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(Mockito.any(), Mockito.any(), Mockito.anyInt(), Mockito.any())).thenReturn(true); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
public void createDataSourceTest() throws ExecutionException { User loginUser = getAdminUser(); String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; PostgreSQLDataSourceParamDTO postgreSqlDatasourceParam = new PostgreSQLDataSourceParamDTO(); postgreSqlDatasourceParam.setDatabase(dataSourceName); postgreSqlDatasourceParam.setNote(dataSourceDesc); postgreSqlDatasourceParam.setHost("172.16.133.200"); postgreSqlDatasourceParam.setPort(5432); postgreSqlDatasourceParam.setDatabase("dolphinscheduler"); postgreSqlDatasourceParam.setUserName("postgres"); postgreSqlDatasourceParam.setPassword(""); postgreSqlDatasourceParam.setName(dataSourceName); Result result = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), result.getCode().intValue()); List<DataSource> dataSourceList = new ArrayList<>(); DataSource dataSource = new DataSource(); dataSource.setName(dataSourceName); dataSourceList.add(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(dataSourceList); passResourcePermissionCheckService(); Result dataSourceExitsResult = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceExitsResult.getCode().intValue()); try ( MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = Mockito.mockStatic(DataSourceClientProvider.class)) { DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(null); Result success = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue()); } } @Test public void updateDataSourceTest() throws ExecutionException { User loginUser = getAdminUser(); int dataSourceId = 12; String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; String dataSourceUpdateName = "dataSource01-update"; PostgreSQLDataSourceParamDTO postgreSqlDatasourceParam = new PostgreSQLDataSourceParamDTO(); postgreSqlDatasourceParam.setDatabase(dataSourceName); postgreSqlDatasourceParam.setNote(dataSourceDesc); postgreSqlDatasourceParam.setHost("172.16.133.200"); postgreSqlDatasourceParam.setPort(5432); postgreSqlDatasourceParam.setDatabase("dolphinscheduler"); postgreSqlDatasourceParam.setUserName("postgres"); postgreSqlDatasourceParam.setPassword(""); postgreSqlDatasourceParam.setName(dataSourceUpdateName); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Result resourceNotExits = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.RESOURCE_NOT_EXIST.getCode(), resourceNotExits.getCode().intValue()); DataSource dataSource = new DataSource(); dataSource.setUserId(0);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Result userNoOperationPerm = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), userNoOperationPerm.getCode().intValue()); dataSource.setName(dataSourceName); dataSource.setType(DbType.POSTGRESQL); dataSource.setConnectionParams( JSONUtils.toJsonString(DataSourceUtils.buildConnectionParams(postgreSqlDatasourceParam))); DataSource anotherDataSource = new DataSource(); anotherDataSource.setName(dataSourceUpdateName); List<DataSource> dataSourceList = new ArrayList<>(); dataSourceList.add(anotherDataSource); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(postgreSqlDatasourceParam.getName())) .thenReturn(dataSourceList); passResourcePermissionCheckService(); Result dataSourceNameExist = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceNameExist.getCode().intValue()); try ( MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = Mockito.mockStatic(DataSourceClientProvider.class)) { DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider); Mockito.when(dataSourceMapper.queryDataSourceByName(postgreSqlDatasourceParam.getName())).thenReturn(null); Result success = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
} } @Test public void queryDataSourceListPagingTest() { User loginUser = getAdminUser(); String searchVal = ""; int pageNo = 1; int pageSize = 10; Result result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize); Assertions.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode()); } @Test public void connectionTest() { int dataSourceId = -1; Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Result result = dataSourceService.connectionTest(dataSourceId); Assertions.assertEquals(Status.RESOURCE_NOT_EXIST.getCode(), result.getCode().intValue()); } @Test public void deleteTest() { User loginUser = getAdminUser(); int dataSourceId = 1; Result result = new Result(); dataSourceService.putMsg(result, Status.RESOURCE_NOT_EXIST); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.USER_NO_OPERATION_PERM); DataSource dataSource = new DataSource();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
dataSource.setUserId(0); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.SUCCESS); dataSource.setUserId(-1); loginUser.setUserType(UserType.ADMIN_USER); loginUser.setId(1); dataSource.setId(22); passResourcePermissionCheckService(); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); } @Test public void unauthDatasourceTest() { User loginUser = getAdminUser(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); int userId = 3; Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, null, 0, baseServiceLogger)).thenReturn(true); Mockito.when(dataSourceMapper.queryAuthedDatasource(userId)).thenReturn(getSingleDataSourceList()); Mockito.when(dataSourceMapper.queryDatasourceExceptUserId(userId)).thenReturn(getDataSourceList()); Map<String, Object> result = dataSourceService.unauthDatasource(loginUser, userId); logger.info(result.toString()); List<DataSource> dataSources = (List<DataSource>) result.get(Constants.DATA_LIST); Assertions.assertTrue(CollectionUtils.isNotEmpty(dataSources));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
loginUser.setId(2); loginUser.setUserType(UserType.GENERAL_USER); Mockito.when(dataSourceMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId()))) .thenReturn(getDataSourceList()); result = dataSourceService.unauthDatasource(loginUser, userId); logger.info(result.toString()); dataSources = (List<DataSource>) result.get(Constants.DATA_LIST); Assertions.assertTrue(CollectionUtils.isNotEmpty(dataSources)); } @Test public void authedDatasourceTest() { User loginUser = getAdminUser(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); int userId = 3; Mockito.when(dataSourceMapper.queryAuthedDatasource(userId)).thenReturn(getSingleDataSourceList()); Map<String, Object> result = dataSourceService.authedDatasource(loginUser, userId); logger.info(result.toString()); List<DataSource> dataSources = (List<DataSource>) result.get(Constants.DATA_LIST); Assertions.assertTrue(CollectionUtils.isNotEmpty(dataSources)); loginUser.setId(2); loginUser.setUserType(UserType.GENERAL_USER); Map<String, Object> success = dataSourceService.authedDatasource(loginUser, userId); logger.info(result.toString()); Assertions.assertEquals(Status.SUCCESS, success.get(Constants.STATUS)); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
public void queryDataSourceListTest() { User loginUser = new User(); loginUser.setUserType(UserType.GENERAL_USER); Set<Integer> dataSourceIds = new HashSet<>(); dataSourceIds.add(1); Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), dataSourceServiceLogger)).thenReturn(dataSourceIds); DataSource dataSource = new DataSource(); dataSource.setType(DbType.MYSQL); Mockito.when(dataSourceMapper.selectBatchIds(dataSourceIds)).thenReturn(Collections.singletonList(dataSource)); Map<String, Object> map = dataSourceService.queryDataSourceList(loginUser, DbType.MYSQL.ordinal(), Constants.TEST_FLAG_NO); Assertions.assertEquals(Status.SUCCESS, map.get(Constants.STATUS)); } @Test public void verifyDataSourceNameTest() { User loginUser = new User(); loginUser.setUserType(UserType.GENERAL_USER); String dataSourceName = "dataSource1"; Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(getDataSourceList()); Result result = dataSourceService.verifyDataSourceName(dataSourceName); Assertions.assertEquals(Status.DATASOURCE_EXIST.getMsg(), result.getMsg()); } @Test public void queryDataSourceTest() { Mockito.when(dataSourceMapper.selectById(Mockito.anyInt())).thenReturn(null); Map<String, Object> result = dataSourceService.queryDataSource(Mockito.anyInt()); Assertions.assertEquals(((Status) result.get(Constants.STATUS)).getCode(), Status.RESOURCE_NOT_EXIST.getCode()); Mockito.when(dataSourceMapper.selectById(Mockito.anyInt())).thenReturn(getOracleDataSource()); result = dataSourceService.queryDataSource(Mockito.anyInt());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Assertions.assertEquals(((Status) result.get(Constants.STATUS)).getCode(), Status.SUCCESS.getCode()); } private List<DataSource> getDataSourceList() { List<DataSource> dataSources = new ArrayList<>(); dataSources.add(getOracleDataSource(1)); dataSources.add(getOracleDataSource(2)); dataSources.add(getOracleDataSource(3)); return dataSources; } private List<DataSource> getSingleDataSourceList() { return Collections.singletonList(getOracleDataSource(3)); } private DataSource getOracleDataSource() { DataSource dataSource = new DataSource(); dataSource.setName("test"); dataSource.setNote("Note"); dataSource.setType(DbType.ORACLE); dataSource.setConnectionParams( "{\"connectType\":\"ORACLE_SID\",\"address\":\"jdbc:oracle:thin:@192.168.xx.xx:49161\",\"database\":\"XE\"," + "\"jdbcUrl\":\"jdbc:oracle:thin:@192.168.xx.xx:49161/XE\",\"user\":\"system\",\"password\":\"oracle\"}"); return dataSource; } private DataSource getOracleDataSource(int dataSourceId) { DataSource dataSource = new DataSource(); dataSource.setId(dataSourceId); dataSource.setName("test"); dataSource.setNote("Note"); dataSource.setType(DbType.ORACLE); dataSource.setConnectionParams( "{\"connectType\":\"ORACLE_SID\",\"address\":\"jdbc:oracle:thin:@192.168.xx.xx:49161\",\"database\":\"XE\","
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
+ "\"jdbcUrl\":\"jdbc:oracle:thin:@192.168.xx.xx:49161/XE\",\"user\":\"system\",\"password\":\"oracle\"}"); return dataSource; } @Test public void buildParameter() { OracleDataSourceParamDTO oracleDatasourceParamDTO = new OracleDataSourceParamDTO(); oracleDatasourceParamDTO.setHost("192.168.9.1"); oracleDatasourceParamDTO.setPort(1521); oracleDatasourceParamDTO.setDatabase("im"); oracleDatasourceParamDTO.setUserName("test"); oracleDatasourceParamDTO.setPassword("test"); oracleDatasourceParamDTO.setConnectType(DbConnectType.ORACLE_SERVICE_NAME); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(oracleDatasourceParamDTO); String expected = "{\"user\":\"test\",\"password\":\"test\",\"address\":\"jdbc:oracle:thin:@//192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:oracle:thin:@//192.168.9.1:1521/im\"," + "\"driverClassName\":\"oracle.jdbc.OracleDriver\",\"validationQuery\":\"select 1 from dual\",\"connectType\":\"ORACLE_SERVICE_NAME\"}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); try (MockedStatic<CommonUtils> mockedStaticCommonUtils = Mockito.mockStatic(CommonUtils.class)) { mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(true); HiveDataSourceParamDTO hiveDataSourceParamDTO = new HiveDataSourceParamDTO(); hiveDataSourceParamDTO.setHost("192.168.9.1"); hiveDataSourceParamDTO.setPort(10000); hiveDataSourceParamDTO.setDatabase("im"); hiveDataSourceParamDTO.setPrincipal("hive/[email protected]"); hiveDataSourceParamDTO.setUserName("test"); hiveDataSourceParamDTO.setPassword("test"); hiveDataSourceParamDTO.setJavaSecurityKrb5Conf("/opt/krb5.conf"); hiveDataSourceParamDTO.setLoginUserKeytabPath("/opt/hdfs.headless.keytab"); hiveDataSourceParamDTO.setLoginUserKeytabUsername("test2/[email protected]"); connectionParam = DataSourceUtils.buildConnectionParams(hiveDataSourceParamDTO);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
expected = "{\"user\":\"test\",\"password\":\"test\",\"address\":\"jdbc:hive2://192.168.9.1:10000\",\"database\":\"im\"," + "\"jdbcUrl\":\"jdbc:hive2://192.168.9.1:10000/im\",\"driverClassName\":\"org.apache.hive.jdbc.HiveDriver\",\"validationQuery\":\"select 1\"," + "\"principal\":\"hive/[email protected]\",\"javaSecurityKrb5Conf\":\"/opt/krb5.conf\",\"loginUserKeytabUsername\":\"test2/[email protected]\"," + "\"loginUserKeytabPath\":\"/opt/hdfs.headless.keytab\"}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } } @Test public void buildParameterWithDecodePassword() { try (MockedStatic<PropertyUtils> mockedStaticPropertyUtils = Mockito.mockStatic(PropertyUtils.class)) { mockedStaticPropertyUtils .when(() -> PropertyUtils.getBoolean(DataSourceConstants.DATASOURCE_ENCRYPTION_ENABLE, false)) .thenReturn(true); Map<String, String> other = new HashMap<>(); other.put("autoDeserialize", "yes"); other.put("allowUrlInLocalInfile", "true"); other.put("useSSL", "true"); MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO(); mysqlDatasourceParamDTO.setHost("192.168.9.1"); mysqlDatasourceParamDTO.setPort(1521); mysqlDatasourceParamDTO.setDatabase("im"); mysqlDatasourceParamDTO.setUserName("test"); mysqlDatasourceParamDTO.setPassword("123456"); mysqlDatasourceParamDTO.setOther(other); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(mysqlDatasourceParamDTO); String expected = "{\"user\":\"test\",\"password\":\"bnVsbE1USXpORFUy\",\"address\":\"jdbc:mysql://192.168.9.1:1521\"," + "\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\",\"driverClassName\":\"com.mysql.cj.jdbc.Driver\","
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
+ "\"validationQuery\":\"select 1\",\"other\":{\"autoDeserialize\":\"yes\",\"allowUrlInLocalInfile\":\"true\",\"useSSL\":\"true\"}}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO(); mysqlDatasourceParamDTO.setHost("192.168.9.1"); mysqlDatasourceParamDTO.setPort(1521); mysqlDatasourceParamDTO.setDatabase("im"); mysqlDatasourceParamDTO.setUserName("test"); mysqlDatasourceParamDTO.setPassword("123456"); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(mysqlDatasourceParamDTO); String expected = "{\"user\":\"test\",\"password\":\"123456\",\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\"," + "\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\",\"driverClassName\":\"com.mysql.cj.jdbc.Driver\",\"validationQuery\":\"select 1\"}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } /** * get Mock Admin User * * @return admin user */ private User getAdminUser() { User loginUser = new User(); loginUser.setId(-1); loginUser.setUserName("admin"); loginUser.setUserType(UserType.GENERAL_USER); return loginUser; } /** * test check connection
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,828
[Bug] [api] User can query unauthorized datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened User can query unauthorized datasource ### What you expected to happen User can not query unauthorized datasource ### How to reproduce 1. send GET request `.../dolphinscheduler/dasources/<id>` 2. and get the datasource without permission check <img width="1916" alt="截屏2022-11-09 11 21 47" src="https://user-images.githubusercontent.com/38122586/200731130-acd4d848-13a3-4ced-9899-2994c2ac741c.png"> ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12828
https://github.com/apache/dolphinscheduler/pull/12830
78e5569afd557de547a122e81a3993be012a4ae8
80da35e39cae8edd5d228d4d189f1eb3d4013aee
2022-11-09T03:28:02Z
java
2023-02-01T02:41:05Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
*/ @Test public void testCheckConnection() throws Exception { DbType dataSourceType = DbType.POSTGRESQL; String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; PostgreSQLDataSourceParamDTO postgreSqlDatasourceParam = new PostgreSQLDataSourceParamDTO(); postgreSqlDatasourceParam.setDatabase(dataSourceName); postgreSqlDatasourceParam.setNote(dataSourceDesc); postgreSqlDatasourceParam.setHost("172.16.133.200"); postgreSqlDatasourceParam.setPort(5432); postgreSqlDatasourceParam.setDatabase("dolphinscheduler"); postgreSqlDatasourceParam.setUserName("postgres"); postgreSqlDatasourceParam.setPassword(""); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(postgreSqlDatasourceParam); try ( MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = Mockito.mockStatic(DataSourceClientProvider.class)) { DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider); Result result = dataSourceService.checkConnection(dataSourceType, connectionParam); Assertions.assertEquals(Status.CONNECTION_TEST_FAILURE.getCode(), result.getCode().intValue()); Connection connection = Mockito.mock(Connection.class); Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(connection); result = dataSourceService.checkConnection(dataSourceType, connectionParam); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
/* * 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.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_START; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_START_NODES; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; import static org.apache.dolphinscheduler.common.constants.Constants.COMMA; import static org.apache.dolphinscheduler.common.constants.Constants.MAX_TASK_TIMEOUT; import static org.apache.dolphinscheduler.common.constants.Constants.SCHEDULE_TIME_MAX_LENGTH; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowExecuteResponse; import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.MonitorService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.WorkerGroupService; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.ApiTriggerType; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ComplementDependentMode; import org.apache.dolphinscheduler.common.enums.CycleEnum; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode; import org.apache.dolphinscheduler.common.enums.T; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.model.Server;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand; import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand; import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.cron.CronUtils; import org.apache.dolphinscheduler.service.exceptions.CronParseException; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.process.TriggerRelationService; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.collect.Lists; /** * executor service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorService { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceImpl.class); @Autowired private ProjectMapper projectMapper; @Autowired private ProjectService projectService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired ProcessDefinitionMapper processDefineMapper; @Autowired private MonitorService monitorService; @Autowired private ProcessInstanceMapper processInstanceMapper; @Lazy() @Autowired private ProcessService processService; @Autowired private CommandService commandService; @Autowired