Search in sources :

Example 6 with Target

use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.

the class AbstractInstallSetupProductExecutor method registerInetAdresses.

private void registerInetAdresses(UUIDTraceLogID traceLogId, S setup, TargetRegistry registry, List<InetAddress> inetAdresses) {
    if (inetAdresses == null || inetAdresses.isEmpty()) {
        return;
    }
    for (InetAddress inetAdress : inetAdresses) {
        Target target = targetResolver.resolveTarget(inetAdress);
        if (!setup.isAbleToScan(target.getType())) {
            LOG.error("{}: setup not able to scan target {}", getIdentifier(), target);
            continue;
        }
        LOG.debug("{} register scan target:{}", traceLogId, target);
        registry.register(target);
    }
}
Also used : Target(com.mercedesbenz.sechub.domain.scan.Target) InetAddress(java.net.InetAddress)

Example 7 with Target

use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.

the class NetsparkerProductExecutorTest method before.

@Before
public void before() throws Exception {
    context = mock(SecHubExecutionContext.class);
    config = mock(SecHubConfiguration.class);
    executorContext = mock(ProductExecutorContext.class);
    target1 = new Target(URI_1_INTERNET, TargetType.INTERNET);
    target2 = new Target(URI_2_INTERNET, TargetType.INTERNET);
    target3 = new Target(URI_3_INTERNET, TargetType.INTERNET);
    targetResolver = mock(TargetResolver.class);
    when(targetResolver.resolveTarget(URI_1_INTERNET)).thenReturn(target1);
    when(targetResolver.resolveTarget(URI_2_INTERNET)).thenReturn(target2);
    when(targetResolver.resolveTarget(URI_3_INTERNET)).thenReturn(target3);
    netsparkerAdapter = mock(NetsparkerAdapter.class);
    when(context.getConfiguration()).thenReturn(config);
    UUID pseudoJobUUID = UUID.randomUUID();
    when(context.getSechubJobUUID()).thenReturn(pseudoJobUUID);
    when(executorContext.getCurrentProductResult()).thenReturn(new ProductResult(pseudoJobUUID, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.NETSPARKER), "resullt1"));
    executorToTest = new TestNetsparkerProductExecutor();
    executorToTest.netsparkerAdapter = netsparkerAdapter;
    installSetup = mock(NetsparkerInstallSetup.class);
    when(installSetup.getBaseURL()).thenReturn("http://www.example.com/netsparker");
    when(installSetup.getUserId()).thenReturn("user");
    when(installSetup.getPassword()).thenReturn("apitoken1");
    when(installSetup.getNetsparkerLicenseId()).thenReturn("license1");
    executorToTest.installSetup = installSetup;
}
Also used : NetsparkerAdapter(com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapter) Target(com.mercedesbenz.sechub.domain.scan.Target) ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ProductExecutorContext(com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext) UUID(java.util.UUID) TargetResolver(com.mercedesbenz.sechub.domain.scan.resolve.TargetResolver) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Before(org.junit.Before)

Example 8 with Target

use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.

the class TargetResolverServiceSpringBootTest method path_example_slash_src_is_CODE_UPLOAD.

@Test
public void path_example_slash_src_is_CODE_UPLOAD() throws Exception {
    /* prepare */
    String path = "example/src";
    /* execute */
    Target found = serviceToTest.resolveTargetForPath(path);
    /* test */
    assertEquals(new Target(path, TargetType.CODE_UPLOAD), found);
}
Also used : Target(com.mercedesbenz.sechub.domain.scan.Target) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 9 with Target

use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.

the class NessusProductExecutorTest method when_three_root_urls_are_configured_and_apter_can_handle_3_targets_with_two_different_types_the_adapter_is_called_1_time.

@Test
public void when_three_root_urls_are_configured_and_apter_can_handle_3_targets_with_two_different_types_the_adapter_is_called_1_time() throws Exception {
    /* prepare */
    when(executorConfig.getProductIdentifier()).thenReturn(ProductIdentifier.NETSPARKER);
    Target target2ButIntranet = new Target(URI_2, TargetType.INTRANET);
    when(targetResolver.resolveTarget(URI_2)).thenReturn(target2ButIntranet);
    when(installSetup.isAbleToScan(TargetType.INTERNET)).thenReturn(true);
    when(installSetup.isAbleToScan(TargetType.INTRANET)).thenReturn(true);
    prepareInfraScanWithThreeURIs();
    /* execute */
    executorToTest.execute(context, executorContext);
    /* test */
    verify(nessusAdapter, times(2)).start(any(), any());
}
Also used : Target(com.mercedesbenz.sechub.domain.scan.Target) Test(org.junit.Test)

Example 10 with Target

use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.

the class AbstractInstallSetupProductExecutor method registerURIs.

private void registerURIs(UUIDTraceLogID traceLogId, S setup, TargetRegistry registry, List<URI> uris) {
    if (uris == null || uris.isEmpty()) {
        return;
    }
    for (URI uri : uris) {
        Target target = targetResolver.resolveTarget(uri);
        if (!setup.isAbleToScan(target.getType())) {
            LOG.error("{}: setup not able to scan target {}", getIdentifier(), target);
            continue;
        }
        LOG.debug("{} register scan target:{}", traceLogId, target);
        registry.register(target);
    }
}
Also used : Target(com.mercedesbenz.sechub.domain.scan.Target) URI(java.net.URI)

Aggregations

Target (com.mercedesbenz.sechub.domain.scan.Target)10 Test (org.junit.Test)4 TargetResolver (com.mercedesbenz.sechub.domain.scan.resolve.TargetResolver)3 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)3 Before (org.junit.Before)3 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)2 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)2 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)2 URI (java.net.URI)2 NessusAdapter (com.mercedesbenz.sechub.adapter.nessus.NessusAdapter)1 NetsparkerAdapter (com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapter)1 InstallSetup (com.mercedesbenz.sechub.domain.scan.InstallSetup)1 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)1 WithoutProductExecutorConfigInfo (com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo)1 InetAddress (java.net.InetAddress)1 UUID (java.util.UUID)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1