use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class WebConfigBuilderStrategyTest method too_many_excludes.
@Test
public void too_many_excludes() {
/* prepare */
List<String> excludes = new LinkedList<>();
for (int i = 1; i <= 501; i++) {
excludes.add("/myapp" + i);
}
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("A maximum of 500 excludes are allowed.", exception.getMessage());
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class WebConfigBuilderStrategyTest method exclude_too_long.
@Test
public void exclude_too_long() {
/* prepare */
// create long string
StringBuilder sb = new StringBuilder();
sb.append("/");
for (int i = 0; i < 64; i++) {
sb.append("abcdefghijklmnopqrstuvwxyz012345");
}
List<String> excludes = new LinkedList<>();
excludes.add(sb.toString());
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 */
assertThat(exception.getMessage(), startsWith("Maximum URL length is 2048 characters. The first 2048 characters of the URL in question: /abcdefghijklmnopqrst"));
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class LicenseScanProductExecutionServiceImplTest method isExecutionNecessary_unnecessary.
@Test
void isExecutionNecessary_unnecessary() {
/* prepare */
UUIDTraceLogID traceId = UUIDTraceLogID.traceLogID(UUID.randomUUID());
SecHubExecutionContext context = mock(SecHubExecutionContext.class);
SecHubConfiguration configuration = new SecHubConfiguration();
/* execute + test */
assertFalse(licenseScanServiceToTest.isExecutionNecessary(context, traceId, configuration));
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class ScanService method cleanupStorage.
/*
* Cleans storage for current job
*/
private void cleanupStorage(SecHubExecutionContext context) {
if (context == null) {
LOG.warn("No context available so no cleanup possible");
return;
}
SecHubConfiguration configuration = context.getConfiguration();
if (configuration == null) {
LOG.warn("No configuration available so no cleanup possible");
return;
}
String projectId = configuration.getProjectId();
UUID jobUUID = context.getSechubJobUUID();
JobStorage storage = storageService.getJobStorage(projectId, jobUUID);
try {
storage.deleteAll();
} catch (IOException e) {
LOG.error("Was not able to delete storage for job {}", jobUUID, e);
}
}
use of com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration in project sechub by mercedes-benz.
the class PDSStorageContentProviderFactory method createContentProvider.
public PDSStorageContentProvider createContentProvider(SecHubExecutionContext context, ReuseSecHubStorageInfoProvider reuseSecHubStorageProvider, ScanType scanType) {
JobStorage storage = null;
SecHubConfiguration model = context.getConfiguration();
boolean reuseSecHubStorage = reuseSecHubStorageProvider.isReusingSecHubStorage();
if (!reuseSecHubStorage) {
String projectId = model.getProjectId();
UUID jobUUID = context.getSechubJobUUID();
storage = storageService.getJobStorage(projectId, jobUUID);
}
return new PDSStorageContentProvider(storage, reuseSecHubStorage, scanType, modelSupport, model);
}
Aggregations