Search in sources :

Example 11 with ProductExecutorConfig

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

the class AbstractProductExecutionService method execute.

protected List<ProductResult> execute(ProductExecutor executor, ProductExecutorContext executorContext, SecHubExecutionContext context, UUIDTraceLogID traceLogID) throws SecHubExecutionException {
    ProductExecutorConfig executorConfig = executorContext.getExecutorConfig();
    UUID executorConfigUUID = executorConfig == null ? null : executorConfig.getUUID();
    LOG.info("Start executor:{} config:{} and wait for result. {}", executor.getIdentifier(), executorConfigUUID, traceLogID);
    List<ProductResult> productResults = executor.execute(context, executorContext);
    if (context.isCanceledOrAbandonded()) {
        return Collections.emptyList();
    }
    int amount = 0;
    if (productResults != null) {
        amount = productResults.size();
    }
    if (LOG.isTraceEnabled()) {
        int pos = 1;
        for (ProductResult result : productResults) {
            LOG.trace("Product '{}' returned for {} result {}/{}:\n{}", executor.getIdentifier(), traceLogID, pos++, amount, result);
        }
    }
    return productResults;
}
Also used : ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) UUID(java.util.UUID)

Example 12 with ProductExecutorConfig

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

the class CheckmarxProductExecutorMinimumConfigValidation method validate.

@Override
protected void validate(ValidationContext<ProductExecutorConfig> context) {
    /* check not null... */
    validateNotNull(context);
    ProductExecutorConfig configToValidate = getObjectToValidate(context);
    if (configToValidate == null) {
        return;
    }
    ProductExecutorConfigSetup setup = configToValidate.getSetup();
    validateNotNull(context, setup, "setup");
    if (setup == null) {
        return;
    }
    List<ProductExecutorConfigSetupJobParameter> jobParameters = setup.getJobParameters();
    validateNotNull(context, jobParameters, "jobParameters");
    if (jobParameters == null) {
        return;
    }
    validateMandatoryPartsSet(context, jobParameters);
}
Also used : ProductExecutorConfigSetupJobParameter(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)

Example 13 with ProductExecutorConfig

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

the class PDSProductExecutorMinimumConfigValidationTest method empty_parameters_has_message_with_product_identifier_not_set.

@Test
public void empty_parameters_has_message_with_product_identifier_not_set() {
    /* prepare */
    ProductExecutorConfig config = createConfigWithNoParametersSet();
    /* execute */
    ValidationResult result = validationToTest.validate(config);
    /* test */
    assertValidationResultContainsMissingProductIdentifier(result);
}
Also used : ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ValidationResult(com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult) Test(org.junit.Test)

Example 14 with ProductExecutorConfig

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

the class PDSProductExecutorMinimumConfigValidationTest method mandatory_parameters_set_but_empty_has_message_with_product_identifier_not_set.

@Test
public void mandatory_parameters_set_but_empty_has_message_with_product_identifier_not_set() {
    /* prepare */
    ProductExecutorConfig config = createConfigWithAllMandatoryParametersSetButEmpty();
    /* execute */
    ValidationResult result = validationToTest.validate(config);
    /* test */
    assertValidationResultContainsMissingProductIdentifier(result);
}
Also used : ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ValidationResult(com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult) Test(org.junit.Test)

Example 15 with ProductExecutorConfig

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

the class WebScanProductExecutionServiceImplTest method before.

@Before
public void before() throws Exception {
    uri = new URI("https://www.example.org");
    configuration = mock(SecHubConfiguration.class);
    when(configuration.getProjectId()).thenReturn(PROJECT_ID1);
    productExecutorContext = mock(ProductExecutorContext.class);
    webconfiguration = mock(SecHubWebScanConfiguration.class);
    context = mock(SecHubExecutionContext.class);
    ProductResultRepository productResultRepository = mock(ProductResultRepository.class);
    webscanner1 = mock(WebScanProductExecutor.class);
    when(webscanner1.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_1);
    when(webscanner1.getVersion()).thenReturn(1);
    webscanner2 = mock(WebScanProductExecutor.class);
    when(webscanner2.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_2);
    when(webscanner2.getVersion()).thenReturn(2);
    when(webconfiguration.getUri()).thenReturn(uri);
    when(context.getConfiguration()).thenReturn(configuration);
    List<WebScanProductExecutor> executors = new ArrayList<>();
    executors.add(webscanner1);
    executors.add(webscanner2);
    productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
    /* simulate default profile1 */
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(PRODUCT_IDENTIFIER_1), eq(1))).thenReturn(Arrays.asList(new ProductExecutorConfig(PRODUCT_IDENTIFIER_1, 1, new ProductExecutorConfigSetup())));
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(PRODUCT_IDENTIFIER_2), eq(2))).thenReturn(Arrays.asList(new ProductExecutorConfig(PRODUCT_IDENTIFIER_2, 2, new ProductExecutorConfigSetup())));
    serviceToTest = new WebScanProductExecutionServiceImpl(executors);
    serviceToTest.productResultRepository = productResultRepository;
    productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
    serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
    serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
    when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) ArrayList(java.util.ArrayList) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) URI(java.net.URI) 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)

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