Search in sources :

Example 26 with SecHubConfiguration

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

the class PDSWebScanProductExecutor method customize.

@Override
protected void customize(ProductExecutorData data) {
    SecHubConfiguration secHubConfiguration = data.getSechubExecutionContext().getConfiguration();
    data.setNetworkLocationProvider(new WebScanNetworkLocationProvider(secHubConfiguration));
    ProductExecutorContext executorContext = data.getProductExecutorContext();
    PDSExecutorConfigSuppport configSupport = PDSExecutorConfigSuppport.createSupportAndAssertConfigValid(executorContext.getExecutorConfig(), systemEnvironment);
    data.setNetworkTargetDataProvider(configSupport);
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ProductExecutorContext(com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext) WebScanNetworkLocationProvider(com.mercedesbenz.sechub.domain.scan.WebScanNetworkLocationProvider)

Example 27 with SecHubConfiguration

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

the class WebConfigBuilderStrategy method configureImpl.

private <B extends AbstractWebScanAdapterConfigBuilder<B, C>, C extends AbstractWebScanAdapterConfig> void configureImpl(B configBuilder) {
    /* check precondition : login configured */
    SecHubConfiguration configuration = context.getConfiguration();
    if (configuration == null) {
        return;
    }
    Optional<SecHubWebScanConfiguration> webScan = configuration.getWebScan();
    if (!webScan.isPresent()) {
        return;
    }
    SecHubWebScanConfiguration webscanConfig = webScan.get();
    configBuilder.setTargetURI(webscanConfig.getUri());
    handleMaxScanDuration(configBuilder, webscanConfig);
    handleIncludes(configBuilder, webscanConfig);
    handleExcludes(configBuilder, webscanConfig);
    /* ----------------------- LOGIN ----------------------- */
    Optional<WebLoginConfiguration> loginOpt = webscanConfig.getLogin();
    if (!loginOpt.isPresent()) {
        return;
    }
    /* handle different web login configurations: */
    WebLoginConfiguration loginConfiguration = loginOpt.get();
    URL loginUrl = loginConfiguration.getUrl();
    /* ------ BASIC --------- */
    Optional<BasicLoginConfiguration> basic = loginConfiguration.getBasic();
    if (basic.isPresent()) {
        configureBasicAuth(configBuilder, loginUrl, basic.get());
        return;
    }
    /* ------ FORM --------- */
    Optional<FormLoginConfiguration> formLogin = loginConfiguration.getForm();
    if (!formLogin.isPresent()) {
        return;
    }
    FormLoginConfiguration formLoginConfig = formLogin.get();
    /* ------ FORM:SCRIPT--------- */
    if (formLoginConfig.getScript().isPresent()) {
        configureScriptAuth(configBuilder, loginUrl, formLoginConfig.getScript().get());
    }
}
Also used : WebLoginConfiguration(com.mercedesbenz.sechub.commons.model.login.WebLoginConfiguration) SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) FormLoginConfiguration(com.mercedesbenz.sechub.commons.model.login.FormLoginConfiguration) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) URL(java.net.URL) BasicLoginConfiguration(com.mercedesbenz.sechub.commons.model.login.BasicLoginConfiguration)

Example 28 with SecHubConfiguration

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

Example 29 with SecHubConfiguration

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

the class AbstractInstallSetupProductExecutor method execute.

@Override
public final List<ProductResult> execute(SecHubExecutionContext context, ProductExecutorContext executorContext) throws SecHubExecutionException {
    UUIDTraceLogID traceLogId = context.getTraceLogId();
    LOG.debug("Executing {}", traceLogId);
    SecHubConfiguration config = context.getConfiguration();
    S setup = getInstallSetup();
    TargetRegistry registry = createTargetRegistry();
    List<URI> uris = resolveURIsForTarget(config);
    registerURIs(traceLogId, setup, registry, uris);
    List<InetAddress> inetAdresses = resolveInetAdressForTarget(config);
    registerInetAdresses(traceLogId, setup, registry, inetAdresses);
    customRegistration(traceLogId, setup, registry, config);
    try {
        return execute(context, executorContext, registry, setup);
    } catch (SecHubExecutionException e) {
        throw e;
    } catch (Exception e) {
        /*
             * every other exception is wrapped to a SecHub execution exception which is
             * handled
             */
        throw new SecHubExecutionException(getIdentifier() + " execution failed." + traceLogId, e);
    }
}
Also used : SecHubExecutionException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException) UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) TargetRegistry(com.mercedesbenz.sechub.domain.scan.TargetRegistry) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) URI(java.net.URI) InetAddress(java.net.InetAddress) SecHubExecutionException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)

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