Source:
public boolean validateSecretConfigReferences(ScmMaterial scmMaterial) { List<CaseInsensitiveString> pipelines = goConfigService.pipelinesWithMaterial(scmMaterial.getFingerprint()); HashMap<CaseInsensitiveString, StringBuilder> pipelinesWithErrors = new HashMap<>(); pipelines.forEach(pipelineName -> { MaterialConfig materialConfig = goConfigService .findPipelineByName(pipelineName) .materialConfigs() .getByMaterialFingerPrint(scmMaterial.getFingerprint()); if (materialConfig instanceof ScmMaterialConfig) { PipelineConfigs group = goConfigService.findGroupByPipeline(pipelineName); ScmMaterialConfig scmMaterialConfig = (ScmMaterialConfig) materialConfig; SecretParams secretParams = SecretParams.parse(scmMaterialConfig.getPassword()); secretParams.forEach(secretParam -> { String secretConfigId = secretParam.getSecretConfigId(); SecretConfig secretConfig = goConfigService.getSecretConfigById(secretConfigId); if (secretConfig == null) { addError(pipelinesWithErrors, pipelineName, format("\nPipeline '%s' is referring to none-existent secret config '%s'.", pipelineName, secretConfigId)); } else if (!secretConfig.canRefer(group.getClass(), group.getGroup())) { addError(pipelinesWithErrors, pipelineName, format("\nPipeline '%s' does not have permission to refer to secrets using secret config '%s'", pipelineName, secretConfigId)); } }); } }); StringBuilder errorMessage = new StringBuilder(); if (!pipelinesWithErrors.isEmpty()) { errorMessage.append(StringUtils.join(pipelinesWithErrors.values(), '\n').trim()); LOGGER.error("[Material Update] Failure: {}", errorMessage.toString()); } if (pipelines.size() == pipelinesWithErrors.size()) { throw new RulesViolationException(errorMessage.toString()); } return true; }

Target:
public boolean validateSecretConfigReferences(ScmMaterial scmMaterial) { List<CaseInsensitiveString> pipelines = goConfigService.pipelinesWithMaterial(scmMaterial.getFingerprint()); HashMap<CaseInsensitiveString, StringBuilder> pipelinesWithErrors = new HashMap<>(); pipelines.forEach(pipelineName -> { MaterialConfig materialConfig = goConfigService .findPipelineByName(pipelineName) .materialConfigs() .getByMaterialFingerPrint(scmMaterial.getFingerprint()); PipelineConfigs group = goConfigService.findGroupByPipeline(pipelineName); ScmMaterialConfig scmMaterialConfig = (ScmMaterialConfig) materialConfig; SecretParams secretParams = SecretParams.parse(scmMaterialConfig.getPassword()); secretParams.forEach(secretParam -> { String secretConfigId = secretParam.getSecretConfigId(); SecretConfig secretConfig = goConfigService.getSecretConfigById(secretConfigId); if (secretConfig == null) { addError(pipelinesWithErrors, pipelineName, format("Pipeline '%s' is referring to none-existent secret config '%s'.", pipelineName, secretConfigId)); } else if (!secretConfig.canRefer(group.getClass(), group.getGroup())) { addError(pipelinesWithErrors, pipelineName, format("Pipeline '%s' does not have permission to refer to secrets using secret config '%s'", pipelineName, secretConfigId)); } }); }); StringBuilder errorMessage = new StringBuilder(); if (!pipelinesWithErrors.isEmpty()) { errorMessage.append(StringUtils.join(pipelinesWithErrors.values(), '\n').trim()); LOGGER.error("[Material Update] Failure: {}", errorMessage.toString()); } if (pipelines.size() == pipelinesWithErrors.size()) { throw new RulesViolationException(errorMessage.toString()); } return true; }