Search in sources :

Example 11 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration 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 12 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class ScanServiceTest method event_handling_FAILED_when_configuration_is_set_but_contains_no_projectId.

@Test
public void event_handling_FAILED_when_configuration_is_set_but_contains_no_projectId() {
    /* prepare */
    SecHubConfiguration configNoProjectId = prepareValidConfiguration();
    configNoProjectId.setProjectId(null);
    DomainMessage request = prepareRequest(configNoProjectId);
    /* execute */
    DomainMessageSynchronousResult result = simulateEventSend(request, serviceToTest);
    /* test */
    assertEquals(MessageID.SCAN_FAILED, result.getMessageId());
}
Also used : DomainMessageSynchronousResult(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Example 13 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class CheckmarxProductExecutorMockTest method createExecutionContextForPseudoCodeScan.

private SecHubExecutionContext createExecutionContextForPseudoCodeScan() {
    SecHubExecutionContext context = mock(SecHubExecutionContext.class);
    SecHubConfiguration config = new SecHubConfiguration();
    config.setProjectId(PROJECT_EXAMPLE);
    SecHubCodeScanConfiguration codeScan = new SecHubCodeScanConfiguration();
    SecHubFileSystemConfiguration fileSystemConfig = new SecHubFileSystemConfiguration();
    fileSystemConfig.getFolders().add(PATH_EXAMPLE1);
    codeScan.setFileSystem(fileSystemConfig);
    config.setCodeScan(codeScan);
    when(context.getConfiguration()).thenReturn(config);
    return context;
}
Also used : SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubCodeScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration) SecHubFileSystemConfiguration(com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration)

Example 14 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class NessusProductExecutor method customize.

@Override
protected void customize(ProductExecutorData data) {
    SecHubConfiguration secHubConfiguration = data.getSechubExecutionContext().getConfiguration();
    data.setNetworkLocationProvider(new InfraScanNetworkLocationProvider(secHubConfiguration));
    data.setNetworkTargetDataProvider(installSetup);
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) InfraScanNetworkLocationProvider(com.mercedesbenz.sechub.domain.scan.InfraScanNetworkLocationProvider)

Example 15 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class NetsparkerProductExecutor method customize.

@Override
protected void customize(ProductExecutorData data) {
    SecHubConfiguration sechubConfiguration = data.getSechubExecutionContext().getConfiguration();
    data.setNetworkLocationProvider(new WebScanNetworkLocationProvider(sechubConfiguration));
    data.setNetworkTargetDataProvider(installSetup);
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) WebScanNetworkLocationProvider(com.mercedesbenz.sechub.domain.scan.WebScanNetworkLocationProvider)

Aggregations

SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)29 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)15 Test (org.junit.jupiter.api.Test)10 LinkedList (java.util.LinkedList)8 UUIDTraceLogID (com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID)6 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)3 UUID (java.util.UUID)3 Test (org.junit.Test)3 SecHubCodeScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration)2 InfraScanNetworkLocationProvider (com.mercedesbenz.sechub.domain.scan.InfraScanNetworkLocationProvider)2 WebScanNetworkLocationProvider (com.mercedesbenz.sechub.domain.scan.WebScanNetworkLocationProvider)2 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)2 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)2 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)2 JobStorage (com.mercedesbenz.sechub.storage.core.JobStorage)2 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SecHubDataConfigurationObject (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObject)1 SecHubDataConfigurationObjectInfo (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObjectInfo)1 SecHubFileSystemConfiguration (com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration)1 SecHubLicenseScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubLicenseScanConfiguration)1