use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class WebConfigBuilderStrategyTest method excludes_no_slash_infront_multiple.
@Test
public void excludes_no_slash_infront_multiple() {
/* prepare */
List<String> excludes = new LinkedList<>();
excludes.add("/abc");
excludes.add("contact.html");
excludes.add("/bca");
excludes.add("ccb/bca");
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());
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class AbstractProductExecutionServiceTest method before.
@Before
public void before() throws Exception {
serviceToTest = new TestImplAbstractProductExecutionService();
serviceToTest.allAvailableProductExecutors = new ArrayList<>();
SecHubConfiguration configuration = new SecHubConfiguration();
configuration.setProjectId("projectid1");
sechubJobUUID = UUID.randomUUID();
logger = mock(Logger.class);
traceLogID = mock(UUIDTraceLogID.class);
executors = new ArrayList<>();
executor = mock(ProductExecutor.class);
when(executor.getIdentifier()).thenReturn(USED_PRODUCT_IDENTIFIER);
when(executor.getVersion()).thenReturn(USED_PRODUCT_EXECUTOR_VERSION);
executors.add(executor);
context = mock(SecHubExecutionContext.class);
when(context.getSechubJobUUID()).thenReturn(sechubJobUUID);
when(context.getConfiguration()).thenReturn(configuration);
ProductExecutorConfigRepository productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
config1 = new ProductExecutorConfig(USED_PRODUCT_IDENTIFIER, 0, new ProductExecutorConfigSetup());
when(productExecutorConfigRepository.findExecutableConfigurationsForProject(any(), eq(USED_PRODUCT_IDENTIFIER), eq(USED_PRODUCT_EXECUTOR_VERSION))).thenReturn(Arrays.asList(config1));
productResultRepository = mock(ProductResultRepository.class);
serviceToTest.productResultRepository = productResultRepository;
productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
productExecutorContext = mock(ProductExecutorContext.class);
when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class LicenseScanProductExecutionServiceImplTest method isExecutionNecessary_necessary.
@Test
void isExecutionNecessary_necessary() {
/* prepare */
UUIDTraceLogID traceId = UUIDTraceLogID.traceLogID(UUID.randomUUID());
SecHubExecutionContext context = mock(SecHubExecutionContext.class);
SecHubConfiguration configuration = new SecHubConfiguration();
SecHubLicenseScanConfiguration licenseScanConfig = new SecHubLicenseScanConfiguration();
configuration.setLicenseScan(licenseScanConfig);
/* execute + test */
assertTrue(licenseScanServiceToTest.isExecutionNecessary(context, traceId, configuration));
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class ScanService method createExecutionContext.
private SecHubExecutionContext createExecutionContext(DomainMessage message) throws JSONConverterException {
UUID uuid = message.get(SECHUB_UUID);
String executedBy = message.get(EXECUTED_BY);
SecHubConfiguration configuration = message.get(SECHUB_CONFIG);
if (configuration == null) {
throw new IllegalStateException("SecHubConfiguration not found in message - so cannot execute!");
}
SecHubExecutionContext executionContext = new SecHubExecutionContext(uuid, configuration, executedBy);
buildOptions(executionContext);
return executionContext;
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class AbstractProductExecutor method execute.
@Override
public final List<ProductResult> execute(SecHubExecutionContext context, ProductExecutorContext executorContext) throws SecHubExecutionException {
UUIDTraceLogID traceLogId = context.getTraceLogId();
SecHubConfiguration config = context.getConfiguration();
if (!canExecute(config)) {
LOG.debug("Cannot execute given configuration {}", traceLogId);
return Collections.emptyList();
}
ProductExecutorData data = createExecutorData(context, executorContext, traceLogId);
configureSourceCodeHandlingIfNecessary(data);
configureNetworkTargetHandlingIfNecessary(data);
return startExecution(data);
}
Aggregations