Search in sources :

Example 1 with NetsparkerAdapterConfig

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;
}
Also used : NetworkTargetType(com.mercedesbenz.sechub.domain.scan.NetworkTargetType) SecHubAdapterOptionsBuilderStrategy(com.mercedesbenz.sechub.domain.scan.SecHubAdapterOptionsBuilderStrategy) ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) NetworkTargetProductServerDataAdapterConfigurationStrategy(com.mercedesbenz.sechub.domain.scan.NetworkTargetProductServerDataAdapterConfigurationStrategy) ArrayList(java.util.ArrayList) ProductExecutorContext(com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext) WebConfigBuilderStrategy(com.mercedesbenz.sechub.domain.scan.WebConfigBuilderStrategy) URI(java.net.URI) NetworkTargetInfo(com.mercedesbenz.sechub.domain.scan.NetworkTargetRegistry.NetworkTargetInfo) NetsparkerAdapterConfig(com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapterConfig)

Example 2 with NetsparkerAdapterConfig

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;
}
Also used : ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) OneInstallSetupConfigBuilderStrategy(com.mercedesbenz.sechub.domain.scan.OneInstallSetupConfigBuilderStrategy) TargetType(com.mercedesbenz.sechub.domain.scan.TargetType) ArrayList(java.util.ArrayList) WebConfigBuilderStrategy(com.mercedesbenz.sechub.domain.scan.WebConfigBuilderStrategy) URI(java.net.URI) NetsparkerAdapterConfig(com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapterConfig)

Aggregations

NetsparkerAdapterConfig (com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapterConfig)2 WebConfigBuilderStrategy (com.mercedesbenz.sechub.domain.scan.WebConfigBuilderStrategy)2 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 NetworkTargetProductServerDataAdapterConfigurationStrategy (com.mercedesbenz.sechub.domain.scan.NetworkTargetProductServerDataAdapterConfigurationStrategy)1 NetworkTargetInfo (com.mercedesbenz.sechub.domain.scan.NetworkTargetRegistry.NetworkTargetInfo)1 NetworkTargetType (com.mercedesbenz.sechub.domain.scan.NetworkTargetType)1 OneInstallSetupConfigBuilderStrategy (com.mercedesbenz.sechub.domain.scan.OneInstallSetupConfigBuilderStrategy)1 SecHubAdapterOptionsBuilderStrategy (com.mercedesbenz.sechub.domain.scan.SecHubAdapterOptionsBuilderStrategy)1 TargetType (com.mercedesbenz.sechub.domain.scan.TargetType)1 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)1