Search in sources :

Example 1 with UUIDTraceLogID

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));
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubLicenseScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubLicenseScanConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with UUIDTraceLogID

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);
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)

Example 3 with UUIDTraceLogID

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));
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with UUIDTraceLogID

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);
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) ProductIdentifier(com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier) UUID(java.util.UUID)

Example 5 with UUIDTraceLogID

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);
    }
}
Also used : SecHubExecutionException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException) UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)

Aggregations

UUIDTraceLogID (com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID)6 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)5 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)2 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)2 Test (org.junit.jupiter.api.Test)2 SecHubLicenseScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubLicenseScanConfiguration)1 TargetRegistry (com.mercedesbenz.sechub.domain.scan.TargetRegistry)1 ProductIdentifier (com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier)1 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)1 InetAddress (java.net.InetAddress)1 URI (java.net.URI)1 UUID (java.util.UUID)1