Skip to content

Commit

Permalink
fix: 导出作业指定密文为空值后再导入作业后密文非空 TencentBlueKing#2348
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonwan committed Aug 21, 2023
1 parent 7076e01 commit b0919a9
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,18 @@ private void processVariableValue(ExportJobInfoDTO exportInfo, JobBackupInfoDTO
if (SecretHandlerEnum.SAVE_NULL == exportInfo.getSecretHandler()) {
logService.addExportLog(exportInfo.getAppId(), exportInfo.getId(),
i18nService.getI18n(LogMessage.PROCESS_FINISHED) + i18nService.getI18n(LogMessage.SAVE_NULL));
for (TaskTemplateVO taskTemplate : jobBackupInfo.getTemplateDetailInfoMap().values()) {
setBlankValueForCipherVariables(taskTemplate.getVariableList());
}

if (MapUtils.isNotEmpty(jobBackupInfo.getPlanDetailInfoMap())) {
for (TaskPlanVO taskPlan : jobBackupInfo.getPlanDetailInfoMap().values()) {
setBlankValueForCipherVariables(taskPlan.getVariableList());
}
}
return;
}

// SecretHandlerEnum.SAVE_REAL,保存真实值
for (TaskTemplateVO taskTemplate : jobBackupInfo.getTemplateDetailInfoMap().values()) {
extractVariableRealValue(exportInfo, taskTemplate.getId(), null, taskTemplate.getVariableList());
}
Expand All @@ -488,6 +497,22 @@ private void processVariableValue(ExportJobInfoDTO exportInfo, JobBackupInfoDTO
i18nService.getI18n(LogMessage.PROCESS_FINISHED) + i18nService.getI18n(LogMessage.SAVE_REAL));
}

private void setBlankValueForCipherVariables(List<TaskVariableVO> variableList) {
if (CollectionUtils.isEmpty(variableList)) {
return;
}

List<TaskVariableVO> needProcessVariableList = variableList.stream()
.filter(taskVariableVO -> taskVariableVO.getType().equals(TaskVariableTypeEnum.CIPHER.getType()))
.collect(Collectors.toList());

if (CollectionUtils.isEmpty(needProcessVariableList)) {
return;
}

needProcessVariableList.forEach(cipherVariable -> cipherVariable.setDefaultValue(""));
}

private void extractVariableRealValue(ExportJobInfoDTO exportInfo, Long templateId, Long planId,
List<TaskVariableVO> variableList) {
if (CollectionUtils.isEmpty(variableList)) {
Expand Down

0 comments on commit b0919a9

Please sign in to comment.