use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException in project sechub by mercedes-benz.
the class ScanService method executeScan.
protected void executeScan(SecHubExecutionContext context, DomainMessage request) throws SecHubExecutionException {
DomainDataTraceLogID sechubJobUUID = traceLogID(request);
LOG.info("start scan for {}", sechubJobUUID);
UUID logUUID = scanLogService.logScanStarted(context);
try {
BatchJobMessage jobIdMessage = request.get(MessageDataKeys.BATCH_JOB_ID);
if (jobIdMessage == null) {
throw new IllegalStateException("no batch job id set for sechub job:" + sechubJobUUID);
}
long batchJobId = jobIdMessage.getBatchJobId();
ProgressMonitor progressMonitor = monitorFactory.createProgressMonitor(batchJobId);
/* delegate execution : */
ScanJobExecutor executor = new ScanJobExecutor(this, context, progressMonitor, millisecondsToWaitBeforeCancelCheck);
executor.execute();
scanLogService.logScanEnded(logUUID);
} catch (Exception e) {
if (context.isAbandonded()) {
scanLogService.logScanAbandoned(logUUID);
} else {
scanLogService.logScanFailed(logUUID);
}
/* rethrow when already an execution exception */
if (e instanceof SecHubExecutionException) {
SecHubExecutionException exceptionToRethrow = (SecHubExecutionException) e;
throw exceptionToRethrow;
}
/* wrap it */
throw new SecHubExecutionException("Execute scan failed", e);
}
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException in project sechub by mercedes-benz.
the class SecHubReportProductTransformerService method createResult.
ReportTransformationResult createResult(UUID secHubJobUUID) throws SecHubExecutionException {
notNull(secHubJobUUID, "secHubJobUUID may not be null!");
List<ProductResult> reportProductResults = productResultRepository.findAllProductResults(secHubJobUUID, SERECO);
if (reportProductResults.isEmpty()) {
throw new SecHubExecutionException("No report result found for:" + secHubJobUUID);
}
int reportProductResultAmount = reportProductResults.size();
if (reportProductResultAmount > 1) {
LOG.warn("Found {} report product results, should normally be only one!", reportProductResultAmount);
}
ReportTransformationResult transformResult = null;
for (ProductResult reportProductResult : reportProductResults) {
for (ReportProductResultTransformer transformer : transformers) {
if (transformer.canTransform(reportProductResult.getProductIdentifier())) {
LOG.debug("Transformer {} is used to transform result", transformer.getClass().getSimpleName());
ReportTransformationResult transformedResult = transformer.transform(reportProductResult);
transformResult = resultMerger.merge(transformResult, transformedResult);
}
}
}
if (transformResult == null) {
throw new SecHubExecutionException("No transformable report result format found for:" + secHubJobUUID);
}
return transformResult;
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException in project sechub by mercedes-benz.
the class AbstractProductExecutionService method executeProductsAndStoreResults.
/**
* Executes product executors and stores results. If a result of an executor is
* <code>null</code> an error will be logged but
*
* @param context
* @throws SecHubExecutionException
*/
public void executeProductsAndStoreResults(SecHubExecutionContext context) throws SecHubExecutionException {
try {
UUIDTraceLogID traceLogID = traceLogID(context.getSechubJobUUID());
SecHubConfiguration configuration = context.getConfiguration();
if (context.isCanceledOrAbandonded()) {
LOG.debug("{} canceled or abandoned, so ignored by {}", traceLogID, getClass().getSimpleName());
return;
}
if (!isExecutionNecessary(context, traceLogID, configuration)) {
LOG.debug("{} NO execution necessary by {}", traceLogID, getClass().getSimpleName());
return;
}
runOnAllAvailableExecutors(getProductExecutors(), context, traceLogID);
} catch (RuntimeException e) {
/* catch runtime errors and move and wrapt in SecHubExecutionException */
throw new SecHubExecutionException("Product execution + store failed unexpected", e);
}
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException in project sechub by mercedes-benz.
the class AbstractInstallSetupProductExecutor method execute.
@Override
public final List<ProductResult> execute(SecHubExecutionContext context, ProductExecutorContext executorContext) throws SecHubExecutionException {
UUIDTraceLogID traceLogId = context.getTraceLogId();
LOG.debug("Executing {}", traceLogId);
SecHubConfiguration config = context.getConfiguration();
S setup = getInstallSetup();
TargetRegistry registry = createTargetRegistry();
List<URI> uris = resolveURIsForTarget(config);
registerURIs(traceLogId, setup, registry, uris);
List<InetAddress> inetAdresses = resolveInetAdressForTarget(config);
registerInetAdresses(traceLogId, setup, registry, inetAdresses);
customRegistration(traceLogId, setup, registry, config);
try {
return execute(context, executorContext, registry, setup);
} catch (SecHubExecutionException e) {
throw e;
} catch (Exception e) {
/*
* every other exception is wrapped to a SecHub execution exception which is
* handled
*/
throw new SecHubExecutionException(getIdentifier() + " execution failed." + traceLogId, e);
}
}
Aggregations