Search in sources :

Example 1 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class PDSInfraScanProductExecutor method customize.

@Override
protected void customize(ProductExecutorData data) {
    SecHubConfiguration secHubConfiguration = data.getSechubExecutionContext().getConfiguration();
    data.setNetworkLocationProvider(new InfraScanNetworkLocationProvider(secHubConfiguration));
    ProductExecutorContext executorContext = data.getProductExecutorContext();
    PDSExecutorConfigSuppport configSupport = PDSExecutorConfigSuppport.createSupportAndAssertConfigValid(executorContext.getExecutorConfig(), systemEnvironment);
    data.setNetworkTargetDataProvider(configSupport);
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ProductExecutorContext(com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext) InfraScanNetworkLocationProvider(com.mercedesbenz.sechub.domain.scan.InfraScanNetworkLocationProvider)

Example 2 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method includes_no_slash_infront_multiple.

@Test
public void includes_no_slash_infront_multiple() {
    /* prepare */
    List<String> includes = new LinkedList<>();
    includes.add("/abc");
    includes.add("contact.html");
    includes.add("/hidden");
    includes.add("ccb/bca");
    String json = createIncludesJson(includes);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    SecHubExecutionContext context = new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
    WebConfigBuilderStrategy strategyToTest = new WebConfigBuilderStrategy(context);
    TestAbstractWebScanAdapterConfigBuilder configBuilder = new TestAbstractWebScanAdapterConfigBuilder();
    /* execute */
    IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> {
        strategyToTest.configure(configBuilder);
    });
    /* test */
    assertEquals("The URL does not start with a slash '/'. URL: contact.html", exception.getMessage());
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 3 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method includes_no_slash_infront_single.

@Test
public void includes_no_slash_infront_single() {
    /* prepare */
    List<String> includes = new LinkedList<>();
    includes.add("contact.html");
    String json = createIncludesJson(includes);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    SecHubExecutionContext context = new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
    WebConfigBuilderStrategy strategyToTest = new WebConfigBuilderStrategy(context);
    TestAbstractWebScanAdapterConfigBuilder configBuilder = new TestAbstractWebScanAdapterConfigBuilder();
    /* execute */
    IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> {
        strategyToTest.configure(configBuilder);
    });
    /* test */
    assertEquals("The URL does not start with a slash '/'. URL: contact.html", exception.getMessage());
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 4 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method excludes_no_slash_infront_single.

@Test
public void excludes_no_slash_infront_single() {
    /* prepare */
    List<String> excludes = new LinkedList<>();
    excludes.add("contact.html");
    String json = createExcludesJson(excludes);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    SecHubExecutionContext context = new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
    WebConfigBuilderStrategy strategyToTest = new WebConfigBuilderStrategy(context);
    TestAbstractWebScanAdapterConfigBuilder configBuilder = new TestAbstractWebScanAdapterConfigBuilder();
    /* execute */
    IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> {
        strategyToTest.configure(configBuilder);
    });
    /* test */
    assertEquals("The URL does not start with a slash '/'. URL: contact.html", exception.getMessage());
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 5 with SecHubConfiguration

use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method createContext.

private SecHubExecutionContext createContext(String pathToTestConfig) {
    String json = ScanDomainTestFileSupport.getTestfileSupport().loadTestFile(pathToTestConfig);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    return new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)

Aggregations

SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)29 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)15 Test (org.junit.jupiter.api.Test)10 LinkedList (java.util.LinkedList)8 UUIDTraceLogID (com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID)6 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)3 UUID (java.util.UUID)3 Test (org.junit.Test)3 SecHubCodeScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration)2 InfraScanNetworkLocationProvider (com.mercedesbenz.sechub.domain.scan.InfraScanNetworkLocationProvider)2 WebScanNetworkLocationProvider (com.mercedesbenz.sechub.domain.scan.WebScanNetworkLocationProvider)2 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)2 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)2 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)2 JobStorage (com.mercedesbenz.sechub.storage.core.JobStorage)2 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SecHubDataConfigurationObject (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObject)1 SecHubDataConfigurationObjectInfo (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObjectInfo)1 SecHubFileSystemConfiguration (com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration)1 SecHubLicenseScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubLicenseScanConfiguration)1