Search in sources :

Example 1 with SecHubWebScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration in project sechub by mercedes-benz.

the class AbstractWebScanProductExecutor method resolveURIsForTarget.

@Override
protected List<URI> resolveURIsForTarget(SecHubConfiguration config) {
    /* assert WEBSCAN configuration available */
    Optional<SecHubWebScanConfiguration> webscan = config.getWebScan();
    if (!webscan.isPresent()) {
        throw new IllegalStateException("At this state there must be a webscan setup!");
    }
    /* Fetch URL */
    SecHubWebScanConfiguration secHubWebScanConfiguration = webscan.get();
    URI uri = secHubWebScanConfiguration.getUri();
    if (uri == null) {
        throw new IllegalStateException("At this state the URI must be set - validation failed!");
    }
    return Arrays.asList(uri);
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) URI(java.net.URI)

Example 2 with SecHubWebScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration in project sechub by mercedes-benz.

the class AbstractWebScanProductExecutor method resolveURIForTarget.

protected URI resolveURIForTarget(SecHubConfiguration config) {
    /* assert WEBSCAN configuration available */
    Optional<SecHubWebScanConfiguration> webscan = config.getWebScan();
    if (!webscan.isPresent()) {
        throw new IllegalStateException("At this state there must be a webscan setup!");
    }
    /* Fetch URL */
    SecHubWebScanConfiguration secHubWebScanConfiguration = webscan.get();
    URI uri = secHubWebScanConfiguration.getUri();
    if (uri == null) {
        throw new IllegalStateException("At this state the URI must be set - validation failed!");
    }
    return uri;
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) URI(java.net.URI)

Example 3 with SecHubWebScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration in project sechub by mercedes-benz.

the class SecHubConfigurationValidator method validateWebScan.

private void validateWebScan(SecHubConfiguration configuration, Errors errors) {
    if (errors.hasErrors()) {
        return;
    }
    Optional<SecHubWebScanConfiguration> webscanOption = configuration.getWebScan();
    if (!webscanOption.isPresent()) {
        return;
    }
    SecHubWebScanConfiguration webscan = webscanOption.get();
    URI uri = webscan.getUri();
    if (SimpleNetworkUtils.isURINullOrEmpty(uri)) {
        errors.reject("api.error.webscan.target.missing", new Object[] {}, "Webscan configuration contains no target at all - but at one URI is necessary for a webscan!");
    } else {
        if (!SimpleNetworkUtils.isHttpProtocol(uri)) {
            errors.reject("api.error.webscan.uri.illegalschema", new Object[] { uri }, "Webscan configuration contains uri '{0}' which is not of supported protocolls (http,https)");
        }
    }
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) URI(java.net.URI)

Example 4 with SecHubWebScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration in project sechub by mercedes-benz.

the class SecHubConfigurationValidatorTest method webconfig_with_uri_as_ftp_is_rejected.

@Test
public void webconfig_with_uri_as_ftp_is_rejected() throws Exception {
    /* prepare */
    SecHubWebScanConfiguration webscan = mock(SecHubWebScanConfiguration.class);
    URI uri = URI.create("ftp://www.example.com");
    when(webscan.getUri()).thenReturn(uri);
    when(target.getWebScan()).thenReturn(Optional.of(webscan));
    /* execute */
    validatorToTest.validate(target, errors);
    /* test */
    assertIllegalSchemaError();
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) URI(java.net.URI) Test(org.junit.Test)

Example 5 with SecHubWebScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration in project sechub by mercedes-benz.

the class SecHubConfigurationValidatorTest method empty_webconfig_is_rejected.

@Test
public void empty_webconfig_is_rejected() throws Exception {
    /* prepare */
    SecHubWebScanConfiguration webscan = mock(SecHubWebScanConfiguration.class);
    URI uri = URI.create("");
    when(webscan.getUri()).thenReturn(uri);
    when(target.getWebScan()).thenReturn(Optional.of(webscan));
    /* execute */
    validatorToTest.validate(target, errors);
    /* test */
    assertError("api.error.webscan.target.missing", Mockito.times(1));
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) URI(java.net.URI) Test(org.junit.Test)

Aggregations

SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)28 URI (java.net.URI)11 Test (org.junit.Test)11 BasicLoginConfiguration (com.mercedesbenz.sechub.commons.model.login.BasicLoginConfiguration)7 WebLoginConfiguration (com.mercedesbenz.sechub.commons.model.login.WebLoginConfiguration)7 FormLoginConfiguration (com.mercedesbenz.sechub.commons.model.login.FormLoginConfiguration)6 URL (java.net.URL)6 Test (org.junit.jupiter.api.Test)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 Action (com.mercedesbenz.sechub.commons.model.login.Action)4 Script (com.mercedesbenz.sechub.commons.model.login.Script)4 AuthenticationType (com.mercedesbenz.sechub.owaspzapwrapper.config.auth.AuthenticationType)4 SecHubScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubScanConfiguration)3 CommandLineSettings (com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings)3 File (java.io.File)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MustExitRuntimeException (com.mercedesbenz.sechub.owaspzapwrapper.cli.MustExitRuntimeException)2 TextFileReader (com.mercedesbenz.sechub.commons.TextFileReader)1 SecHubInfrastructureScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration)1