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);
}
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());
}
}
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);
}
}
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);
}
}
Aggregations