use of com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapterConfig in project sechub by mercedes-benz.
the class NetsparkerProductExecutor method executeByAdapter.
@Override
protected List<ProductResult> executeByAdapter(ProductExecutorData data) throws Exception {
NetworkTargetInfo info = data.getCurrentNetworkTargetInfo();
URI targetURI = info.getURI();
if (targetURI == null) {
/* no targets defined */
return Collections.emptyList();
}
NetworkTargetType targetType = info.getTargetType();
LOG.debug("Trigger netsparker adapter execution for target {}", targetType);
List<ProductResult> results = new ArrayList<>();
/* NETSPARKER is not able to scan multiple targets */
/*
* special behavior, because having multiple results here, we must find former
* result corresponding to target URI.
*/
/* @formatter:off */
ProductExecutorContext productExecutorContext = data.getProductExecutorContext();
productExecutorContext.useFirstFormerResultHavingMetaData(NetsparkerMetaDataID.KEY_TARGET_URI, targetURI);
NetsparkerAdapterConfig netsparkerConfig = NetsparkerConfig.builder().configure(new SecHubAdapterOptionsBuilderStrategy(data, getScanType())).configure(new WebConfigBuilderStrategy(data.getSechubExecutionContext())).configure(new NetworkTargetProductServerDataAdapterConfigurationStrategy(installSetup, targetType)).setTimeToWaitForNextCheckOperationInMinutes(installSetup.getScanResultCheckPeriodInMinutes()).setTimeOutInMinutes(installSetup.getScanResultCheckTimeOutInMinutes()).setTraceID(data.getTraceLogIdAsString()).setAgentName(installSetup.getAgentName()).setAgentGroupName(data.getNetworkTargetProductServerDataSupport().getIdentifier(targetType)).setPolicyID(installSetup.getDefaultPolicyId()).setLicenseID(installSetup.getNetsparkerLicenseId()).setTargetType(info.getTargetType().name()).setTargetURI(targetURI).build();
/* @formatter:on */
/* execute NETSPARKER by adapter and return product result */
String xml = netsparkerAdapter.start(netsparkerConfig, productExecutorContext.getCallback());
ProductResult currentProductResult = productExecutorContext.getCurrentProductResult();
currentProductResult.setResult(xml);
results.add(currentProductResult);
return results;
}
use of com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapterConfig in project sechub by mercedes-benz.
the class NetsparkerProductExecutor method executeWithAdapter.
@Override
protected List<ProductResult> executeWithAdapter(SecHubExecutionContext context, ProductExecutorContext executorContext, NetsparkerInstallSetup setup, TargetRegistryInfo info) throws Exception {
URI targetURI = info.getURI();
if (targetURI == null) {
/* no targets defined */
return Collections.emptyList();
}
TargetType targetType = info.getTargetType();
LOG.debug("Trigger netsparker adapter execution for target {} and setup {} ", targetType, setup);
List<ProductResult> results = new ArrayList<>();
/* NETSPARKER is not able to scan multiple targets */
/*
* special behavior, because having multiple results here, we must find former
* result corresponding to target URI.
*/
/* @formatter:off */
executorContext.useFirstFormerResultHavingMetaData(NetsparkerMetaDataID.KEY_TARGET_URI, targetURI);
NetsparkerAdapterConfig netsparkerConfig = NetsparkerConfig.builder().configure(createAdapterOptionsStrategy(context)).configure(new WebConfigBuilderStrategy(context)).configure(new OneInstallSetupConfigBuilderStrategy(setup)).setTimeToWaitForNextCheckOperationInMinutes(setup.getScanResultCheckPeriodInMinutes()).setTimeOutInMinutes(setup.getScanResultCheckTimeOutInMinutes()).setTraceID(context.getTraceLogIdAsString()).setAgentName(setup.getAgentName()).setAgentGroupName(setup.getIdentifier(targetType)).setPolicyID(setup.getDefaultPolicyId()).setLicenseID(setup.getNetsparkerLicenseId()).setTargetURI(targetURI).build();
/* @formatter:on */
/* execute NETSPARKER by adapter and return product result */
String xml = netsparkerAdapter.start(netsparkerConfig, executorContext.getCallback());
ProductResult currentProductResult = executorContext.getCurrentProductResult();
currentProductResult.setResult(xml);
results.add(currentProductResult);
return results;
}
Aggregations