use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.
the class SchedulerRestartJobService method sendPurgeJobResultsSynchronousRequest.
@IsSendingSyncMessage(MessageID.REQUEST_PURGE_JOB_RESULTS)
private void sendPurgeJobResultsSynchronousRequest(ScheduleSecHubJob secHubJob) {
DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.REQUEST_PURGE_JOB_RESULTS);
request.set(MessageDataKeys.SECHUB_UUID, secHubJob.getUUID());
request.set(MessageDataKeys.ENVIRONMENT_BASE_URL, sechubEnvironment.getServerBaseUrl());
DomainMessageSynchronousResult result = eventBus.sendSynchron(request);
if (result.hasFailed()) {
throw new SecHubRuntimeException("Purge failed!");
}
}
use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.
the class SecHubFileStructureDataProviderBuilder method addAllUsages.
private void addAllUsages(MutableSecHubFileStructureDataProvider data, Optional<? extends SecHubDataConfigurationUsageByName> scanDefinitionObject, boolean mustHave) {
if (!scanDefinitionObject.isPresent()) {
if (mustHave) {
new IllegalStateException("For scanType:" + scanType + " the configuration entry is missing.");
}
return;
}
SecHubDataConfigurationUsageByName usageByName = scanDefinitionObject.get();
Set<String> names = usageByName.getNamesOfUsedDataConfigurationObjects();
if (names.isEmpty()) {
if (mustHave) {
new SecHubRuntimeException("Confgiguration file problem. For scanType:" + scanType + " at least one data configuration must be referenced");
}
}
data.addAcceptedReferenceNames(names);
}
use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.
the class DefaultExecutorConfigSupport method getNamePatternIdProvider.
/**
* Resolves a name pattern provider for given id
*
* @param id
* @param failWhenNotConfigured when <code>false</code> missing name provider
* will be replaced by fallback implementation
* returning always null (nothing configured)
* @return provider never <code>null</code>
* @throws SecHubRuntimeException when name pattern provider cannot be resolved
*/
public NamePatternIdProvider getNamePatternIdProvider(String id, boolean failWhenNotConfigured) {
NamePatternIdProvider provider = namePatternIdProviders.get(id);
if (provider != null) {
return provider;
}
String parameterValue = getParameter(id);
if (parameterValue == null) {
if (failWhenNotConfigured) {
throw new SecHubRuntimeException("No parameter found for necessary mapping key:" + id);
} else {
return FALLBACK_NOT_FOUND_PROVIDER;
}
}
NamePatternIdProvider newProvider = providerFactory.createProvider(id, parameterValue);
namePatternIdProviders.put(id, newProvider);
LOG.debug("Created NamePatternIdProvider:{}", newProvider.getProviderId());
return newProvider;
}
use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.
the class PDSAdapterConfigurationStrategy method handlePdsParts.
private void handlePdsParts(PDSAdapterConfigurator pdsConfigurable) {
SecHubExecutionContext context = strategyConfig.productExecutorData.getSechubExecutionContext();
Map<String, String> jobParameters = strategyConfig.configSupport.createJobParametersToSendToPDS(context.getConfiguration());
pdsConfigurable.setJobParameters(jobParameters);
pdsConfigurable.setReusingSecHubStorage(PDSExecutorConfigSuppport.isReusingSecHubStorage(jobParameters));
pdsConfigurable.setScanType(strategyConfig.scanType);
pdsConfigurable.setPdsProductIdentifier(strategyConfig.configSupport.getPDSProductIdentifier());
pdsConfigurable.setSecHubJobUUID(context.getSechubJobUUID());
pdsConfigurable.setSecHubConfigurationModel(context.getConfiguration());
pdsConfigurable.setSourceCodeZipFileInputStreamOrNull(strategyConfig.sourceCodeZipFileInputStreamOrNull);
pdsConfigurable.setBinaryTarFileInputStreamOrNull(strategyConfig.binariesTarFileInputStreamOrNull);
pdsConfigurable.setSourceCodeZipFileRequired(strategyConfig.contentProvider.isSourceRequired());
pdsConfigurable.setBinaryTarFileRequired(strategyConfig.contentProvider.isBinaryRequired());
try {
String sourceZipFileChecksum = strategyConfig.contentProvider.getSourceZipFileUploadChecksumOrNull();
pdsConfigurable.setSourceCodeZipFileChecksumOrNull(sourceZipFileChecksum);
} catch (IOException e) {
throw new SecHubRuntimeException("Was not able to retrieve source zip upload checksum", e);
}
try {
String binaryTarFileChecksum = strategyConfig.contentProvider.getBinariesTarFileUploadChecksumOrNull();
pdsConfigurable.setBinariesTarFileChecksumOrNull(binaryTarFileChecksum);
} catch (IOException e) {
throw new SecHubRuntimeException("Was not able to retrieve tar file upload checksum", e);
}
}
use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.
the class DownloadSpdxScanReportService method getScanSpdxJsonReport.
public String getScanSpdxJsonReport(String projectId, UUID jobUUID) {
/* validate */
assertion.assertIsValidProjectId(projectId);
assertion.assertIsValidJobUUID(jobUUID);
scanAssertService.assertUserHasAccessToProject(projectId);
scanAssertService.assertProjectAllowsReadAccess(projectId);
/* audit */
auditLogService.log("starts download of SPDX Json report for job: {}", jobUUID);
List<ProductResult> productResults = productResultRepository.findAllProductResults(jobUUID, ProductIdentifier.SERECO);
if (productResults.size() != 1) {
throw new SecHubRuntimeException("Did not found exactly one SERECO product result. Instead, " + productResults.size() + " product results were found.");
}
ProductResult productResult = productResults.iterator().next();
String spdxJson = spdxJsonResolver.resolveSpdxJson(productResult);
if (spdxJson == null) {
throw new NotFoundException("There was no JSON SPDX report available for job: " + jobUUID);
}
return spdxJson;
}
Aggregations