Search in sources :

Example 1 with NetsparkerConfigBuilder

use of com.mercedesbenz.sechub.adapter.netsparker.NetsparkerConfig.NetsparkerConfigBuilder in project sechub by mercedes-benz.

the class NetsparkerAdapterTestApplication method main.

public static void main(String[] args) throws Exception {
    SecHubTimeUnitData maxScanDuration = null;
    String maxScanDurationDurationProperty = getSystemProperty("sechub.adapter.netsparker.maxscanduration.duration");
    String maxScanDurationUnitProperty = getSystemProperty("sechub.adapter.netsparker.maxscanduration.unit");
    if (maxScanDurationDurationProperty != null && maxScanDurationUnitProperty != null) {
        int duration = Integer.valueOf(maxScanDurationDurationProperty);
        SecHubTimeUnit unit = SecHubTimeUnit.valueOf(maxScanDurationUnitProperty);
        maxScanDuration = SecHubTimeUnitData.of(duration, unit);
    }
    /* @formatter:off */
    NetsparkerConfigBuilder builder = NetsparkerConfig.builder().setUser(getSystemProperty("sechub.adapter.netsparker.user")).setTrustAllCertificates(getSystemPropertyBooleanOrFalse("sechub.adapter.netsparker.trustall")).setAgentGroupName(getSystemProperty("sechub.adapter.netsparker.user.agent.groupname")).setPasswordOrAPIToken(getSystemProperty("sechub.adapter.netsparker.apitoken")).setPolicyID(getSystemProperty("sechub.adapter.netsparker.policyid")).setProductBaseUrl(getSystemProperty("sechub.adapter.netsparker.baseurl")).setLicenseID(getSystemProperty("sechub.adapter.netsparker.licenseid", "none")).setTargetURI(new URI(getSystemProperty("sechub.adapter.netsparker.targeturi"))).setMaxScanDuration(maxScanDuration);
    /* @formatter:on */
    String loginType = getSystemProperty("sechub.adapter.netsparker.login.type", "<none>");
    if ("basic".equalsIgnoreCase(loginType)) {
        handleBasicLogin(builder);
    } else if ("formAutodetect".equalsIgnoreCase(loginType)) {
        handleFormAutodetect(builder);
    } else if ("formScript".equalsIgnoreCase(loginType)) {
        handleFormScript(builder);
    } else if ("<none>".equalsIgnoreCase(loginType)) {
    /* ignore */
    } else {
        throw new IllegalArgumentException("login type:" + loginType + " not supported!");
    }
    NetsparkerAdapterConfig config = builder.build();
    NetsparkerAdapter netsparker = new NetsparkerAdapterV1();
    String result = netsparker.start(config, new AdapterMetaDataCallback() {

        AdapterMetaData metaData;

        @Override
        public void persist(AdapterMetaData metaData) {
            System.out.println("persist:" + metaData);
            this.metaData = metaData;
        }

        @Override
        public AdapterMetaData getMetaDataOrNull() {
            return metaData;
        }
    });
    System.out.println("result:");
    System.out.println(result);
}
Also used : NetsparkerConfigBuilder(com.mercedesbenz.sechub.adapter.netsparker.NetsparkerConfig.NetsparkerConfigBuilder) SecHubTimeUnitData(com.mercedesbenz.sechub.adapter.SecHubTimeUnitData) URI(java.net.URI) AdapterMetaDataCallback(com.mercedesbenz.sechub.adapter.AdapterMetaDataCallback) AdapterMetaData(com.mercedesbenz.sechub.adapter.AdapterMetaData) SecHubTimeUnit(com.mercedesbenz.sechub.commons.model.SecHubTimeUnit)

Aggregations

AdapterMetaData (com.mercedesbenz.sechub.adapter.AdapterMetaData)1 AdapterMetaDataCallback (com.mercedesbenz.sechub.adapter.AdapterMetaDataCallback)1 SecHubTimeUnitData (com.mercedesbenz.sechub.adapter.SecHubTimeUnitData)1 NetsparkerConfigBuilder (com.mercedesbenz.sechub.adapter.netsparker.NetsparkerConfig.NetsparkerConfigBuilder)1 SecHubTimeUnit (com.mercedesbenz.sechub.commons.model.SecHubTimeUnit)1 URI (java.net.URI)1