use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.
the class SecHubConfigurationValidatorTest method empty_infrascanconfig_is_rejected.
@Test
public void empty_infrascanconfig_is_rejected() throws Exception {
/* prepare */
SecHubInfrastructureScanConfiguration infraScan = mock(SecHubInfrastructureScanConfiguration.class);
List<URI> list = new ArrayList<>();
when(infraScan.getUris()).thenReturn(list);
when(target.getInfraScan()).thenReturn(Optional.of(infraScan));
/* execute */
validatorToTest.validate(target, errors);
/* test */
assertError("api.error.infrascan.target.missing", Mockito.times(1));
}
use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.
the class SecHubConfigurationValidatorTest method infraconfig_with_uri_as_ftp_is_NOT_rejected.
@Test
public void infraconfig_with_uri_as_ftp_is_NOT_rejected() throws Exception {
/* prepare */
SecHubInfrastructureScanConfiguration webscan = mock(SecHubInfrastructureScanConfiguration.class);
List<URI> list = new ArrayList<>();
list.add(URI.create("http://www.example.com"));
when(webscan.getUris()).thenReturn(list);
when(target.getInfraScan()).thenReturn(Optional.of(webscan));
/* execute */
validatorToTest.validate(target, errors);
/* test */
assertNoIllegalSchemaError();
}
use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.
the class InfraScanNetworkLocationProvider method getURIs.
@Override
public List<URI> getURIs() {
/* assert INFRASCAN configuration available */
Optional<SecHubInfrastructureScanConfiguration> infraScan = config.getInfraScan();
if (!infraScan.isPresent()) {
throw new IllegalStateException("At this state there must be a infrascan setup!");
}
/* Fetch URI */
SecHubInfrastructureScanConfiguration infraScanConfiguration = infraScan.get();
List<URI> uris = infraScanConfiguration.getUris();
if (uris == null) {
throw new IllegalStateException("At this state URIs must be set - validation failed!");
}
return uris;
}
use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.
the class ProjectWhiteListSecHubConfigurationValidationService method assertAllowedForProject.
public void assertAllowedForProject(SecHubConfigurationModel configuration) {
List<URI> allowed = fetchAllowedUris(configuration);
Optional<SecHubInfrastructureScanConfiguration> infrascanOpt = configuration.getInfraScan();
if (infrascanOpt.isPresent()) {
SecHubInfrastructureScanConfiguration infraconf = infrascanOpt.get();
assertWhitelisted(allowed, infraconf.getUris());
assertWhitelisted(allowed, asUris(infraconf.getIps()));
}
Optional<SecHubWebScanConfiguration> webscanopt = configuration.getWebScan();
if (webscanopt.isPresent()) {
SecHubWebScanConfiguration webconf = webscanopt.get();
assertWhitelisted(allowed, webconf.getUri());
}
}
use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.
the class SecHubConfigurationValidator method validateInfraScan.
private void validateInfraScan(SecHubConfiguration configuration, Errors errors) {
if (errors.hasErrors()) {
return;
}
Optional<SecHubInfrastructureScanConfiguration> infraScanOption = configuration.getInfraScan();
if (!infraScanOption.isPresent()) {
return;
}
SecHubInfrastructureScanConfiguration infraScan = infraScanOption.get();
if (infraScan.getUris().isEmpty() && infraScan.getIps().isEmpty()) {
errors.reject("api.error.infrascan.target.missing", new Object[] {}, "Webscan configuration contains no target at all - but at least one URI or IP is necessary for scans!");
}
}
Aggregations