Search in sources :

Example 6 with ProductExecutorConfig

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.

the class AbstractProductExecutionServiceTest method before.

@Before
public void before() throws Exception {
    serviceToTest = new TestImplAbstractProductExecutionService();
    serviceToTest.allAvailableProductExecutors = new ArrayList<>();
    SecHubConfiguration configuration = new SecHubConfiguration();
    configuration.setProjectId("projectid1");
    sechubJobUUID = UUID.randomUUID();
    logger = mock(Logger.class);
    traceLogID = mock(UUIDTraceLogID.class);
    executors = new ArrayList<>();
    executor = mock(ProductExecutor.class);
    when(executor.getIdentifier()).thenReturn(USED_PRODUCT_IDENTIFIER);
    when(executor.getVersion()).thenReturn(USED_PRODUCT_EXECUTOR_VERSION);
    executors.add(executor);
    context = mock(SecHubExecutionContext.class);
    when(context.getSechubJobUUID()).thenReturn(sechubJobUUID);
    when(context.getConfiguration()).thenReturn(configuration);
    ProductExecutorConfigRepository productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
    serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
    config1 = new ProductExecutorConfig(USED_PRODUCT_IDENTIFIER, 0, new ProductExecutorConfigSetup());
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(any(), eq(USED_PRODUCT_IDENTIFIER), eq(USED_PRODUCT_EXECUTOR_VERSION))).thenReturn(Arrays.asList(config1));
    productResultRepository = mock(ProductResultRepository.class);
    serviceToTest.productResultRepository = productResultRepository;
    productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
    serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
    productExecutorContext = mock(ProductExecutorContext.class);
    when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) Logger(org.slf4j.Logger) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ProductExecutorConfigRepository(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup) Before(org.junit.Before)

Example 7 with ProductExecutorConfig

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.

the class PDSProductExecutorMinimumConfigValidationTest method createConfigWithNoParametersSet.

private ProductExecutorConfig createConfigWithNoParametersSet() {
    ProductExecutorConfigSetup setup = new ProductExecutorConfigSetup();
    ProductExecutorConfig config = new ProductExecutorConfig(ProductIdentifier.PDS_CODESCAN, 1, setup);
    return config;
}
Also used : ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)

Example 8 with ProductExecutorConfig

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.

the class PDSProductExecutorMinimumConfigValidationTest method when_all_mandatory_parameters_are_set_we_got_no_error_messages.

@Test
public void when_all_mandatory_parameters_are_set_we_got_no_error_messages() {
    /* prepare */
    ProductExecutorConfig config = createConfigWithAllMandatoryParametersSet();
    /* execute */
    ValidationResult result = validationToTest.validate(config);
    /* test */
    if (!result.isValid()) {
        fail("Result is not valid, failure message was:" + result.getErrorDescription());
    }
    assertEquals(0, result.getErrors().size());
}
Also used : ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ValidationResult(com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult) Test(org.junit.Test)

Example 9 with ProductExecutorConfig

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.

the class AbstractProductExecutionService method runOnAllAvailableExecutors.

/**
 * Executes product executors and stores results. If a result of an executor is
 * <code>null</code> an error will be logged but
 *
 * @param executors
 * @param context
 * @param traceLogID
 */
protected void runOnAllAvailableExecutors(List<? extends ProductExecutor> executors, SecHubExecutionContext context, UUIDTraceLogID traceLogID) {
    SecHubConfiguration configuration = context.getConfiguration();
    requireNonNull(configuration, "Configuration must be set");
    String projectId = configuration.getProjectId();
    requireNonNull(projectId, "Project id must be set");
    int countOfReportProductExecutor = 0;
    ProductExecutor serecoProductExecutor = null;
    for (ProductExecutor productExecutor : executors) {
        if (context.isCanceledOrAbandonded()) {
            return;
        }
        ProductIdentifier productIdentifier = productExecutor.getIdentifier();
        int executorVersion = productExecutor.getVersion();
        switch(productIdentifier) {
            case SERECO:
                serecoProductExecutor = productExecutor;
            /* fall through */
            default:
                LOG.debug("search config for project={}, executor={}, version={}", projectId, productIdentifier, executorVersion);
                List<ProductExecutorConfig> executorConfigurations = productExecutorConfigRepository.findExecutableConfigurationsForProject(projectId, productIdentifier, executorVersion);
                if (executorConfigurations.isEmpty()) {
                    LOG.debug("no config found for project={} so skipping executor={}, version={}", projectId, productIdentifier, executorVersion);
                    continue;
                }
                for (ProductExecutorConfig executorConfiguration : executorConfigurations) {
                    runOnExecutorWithOneConfiguration(executorConfiguration, productExecutor, context, projectId, traceLogID);
                    ScanType scanType = productExecutor.getScanType();
                    if (ScanType.REPORT.equals(scanType)) {
                        countOfReportProductExecutor++;
                    }
                }
        }
    }
    if (serecoProductExecutor != null && countOfReportProductExecutor == 0) {
        LOG.debug("no dedicated configuration for report execution was executed before, so fallback to sereco default behaviour");
        runOnExecutorWithOneConfiguration(SERECO_FALLBACK, serecoProductExecutor, context, projectId, traceLogID);
    }
}
Also used : ScanType(com.mercedesbenz.sechub.commons.model.ScanType) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)

Example 10 with ProductExecutorConfig

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.

the class AbstractProductExecutionService method createFallbackExecutorConfigForSereco.

private static ProductExecutorConfig createFallbackExecutorConfigForSereco() {
    ProductExecutorConfigSetup setup = new ProductExecutorConfigSetup();
    ProductExecutorConfig executorConfiguration = new ProductExecutorConfig(ProductIdentifier.SERECO, 1, setup);
    executorConfiguration.getSetup().setBaseURL("embedded");
    return executorConfiguration;
}
Also used : ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)

Aggregations

ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)16 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)9 Test (org.junit.Test)6 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)5 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)4 ProductExecutorConfigRepository (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository)3 ProductExecutorConfigSetupJobParameter (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter)3 ValidationResult (com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult)3 Before (org.junit.Before)3 AdapterException (com.mercedesbenz.sechub.adapter.AdapterException)2 AdapterLogId (com.mercedesbenz.sechub.adapter.AdapterLogId)2 ProductExecutorCallback (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorCallback)2 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)2 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SecHubInfrastructureScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration)1 SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)1