use of com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID in project sechub by mercedes-benz.
the class LicenseScanProductExecutionServiceImplTest method isExecutionNecessary_necessary.
@Test
void isExecutionNecessary_necessary() {
/* prepare */
UUIDTraceLogID traceId = UUIDTraceLogID.traceLogID(UUID.randomUUID());
SecHubExecutionContext context = mock(SecHubExecutionContext.class);
SecHubConfiguration configuration = new SecHubConfiguration();
SecHubLicenseScanConfiguration licenseScanConfig = new SecHubLicenseScanConfiguration();
configuration.setLicenseScan(licenseScanConfig);
/* execute + test */
assertTrue(licenseScanServiceToTest.isExecutionNecessary(context, traceId, configuration));
}
use of com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID in project sechub by mercedes-benz.
the class AbstractProductExecutor method execute.
@Override
public final List<ProductResult> execute(SecHubExecutionContext context, ProductExecutorContext executorContext) throws SecHubExecutionException {
UUIDTraceLogID traceLogId = context.getTraceLogId();
SecHubConfiguration config = context.getConfiguration();
if (!canExecute(config)) {
LOG.debug("Cannot execute given configuration {}", traceLogId);
return Collections.emptyList();
}
ProductExecutorData data = createExecutorData(context, executorContext, traceLogId);
configureSourceCodeHandlingIfNecessary(data);
configureNetworkTargetHandlingIfNecessary(data);
return startExecution(data);
}
use of com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID in project sechub by mercedes-benz.
the class LicenseScanProductExecutionServiceImplTest method isExecutionNecessary_unnecessary.
@Test
void isExecutionNecessary_unnecessary() {
/* prepare */
UUIDTraceLogID traceId = UUIDTraceLogID.traceLogID(UUID.randomUUID());
SecHubExecutionContext context = mock(SecHubExecutionContext.class);
SecHubConfiguration configuration = new SecHubConfiguration();
/* execute + test */
assertFalse(licenseScanServiceToTest.isExecutionNecessary(context, traceId, configuration));
}
use of com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID in project sechub by mercedes-benz.
the class SerecoReportProductExecutor method createReport.
private ProductResult createReport(SecHubExecutionContext context, ProductExecutorContext executorContext) {
if (context == null) {
throw new IllegalArgumentException("context may not be null!");
}
String projectId = context.getConfiguration().getProjectId();
UUID secHubJobUUID = context.getSechubJobUUID();
UUIDTraceLogID traceLogId = UUIDTraceLogID.traceLogID(secHubJobUUID);
LOG.debug("{} start sereco execution", traceLogId);
/* load the results by job uuid */
ProductIdentifier[] supportedProducts = getSupportedProducts();
List<ProductResult> foundProductResults = productResultRepository.findAllProductResults(secHubJobUUID, supportedProducts);
if (foundProductResults.isEmpty()) {
LOG.warn("{} no product results for {} found, will return an empty sereco JSON as result! ", traceLogId, getSupportedProducts());
return new ProductResult(secHubJobUUID, projectId, executorContext.getExecutorConfig(), "{}");
}
return createReport(projectId, secHubJobUUID, traceLogId, executorContext, foundProductResults);
}
use of com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID 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);
}
}
Aggregations