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