use of com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel in project sechub by mercedes-benz.
the class PDSWorkspaceService method resolveFileStructureDataProviderOrNull.
SecHubFileStructureDataProvider resolveFileStructureDataProviderOrNull(UUID jobUUID, PDSJobConfiguration config, ScanType scanType) throws IOException {
SecHubConfigurationModel model = resolveAndEnsureSecHubConfigurationModel(config);
if (model == null) {
return null;
}
SecHubFileStructureDataProvider configuration = SecHubFileStructureDataProvider.builder().setScanType(scanType).setModel(model).build();
return configuration;
}
use of com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel in project sechub by mercedes-benz.
the class PDSWorkspaceService method createPreparationContext.
private PreparationContext createPreparationContext(PDSJobConfiguration config, PDSJobConfigurationSupport configurationSupport) {
PreparationContext preparationContext = new PreparationContext();
SecHubConfigurationModel model = configurationSupport.resolveSecHubConfigurationModel();
if (model != null) {
PDSProductSetup productSetup = serverConfigService.getProductSetupOrNull(config.getProductId());
if (productSetup == null) {
throw new IllegalStateException("PDS product setup for " + config.getProductId() + " not found!");
}
ScanType scanType = null;
if (productSetup != null) {
scanType = productSetup.getScanType();
}
if (scanType == null) {
throw new IllegalStateException("PDS product setup for " + config.getProductId() + " has no scan type defined!");
}
preparationContext.binaryAccepted = modelSupport.isBinaryRequired(scanType, model);
preparationContext.sourceAccepted = modelSupport.isSourceRequired(scanType, model);
} else {
/*
* necessary when PDS has been executed without SecHub - e.g. for testing. There
* is no model available, so we must accept everything.
*/
preparationContext.binaryAccepted = true;
preparationContext.sourceAccepted = true;
}
return preparationContext;
}
use of com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel in project sechub by mercedes-benz.
the class PDSJobConfigurationSupportTest method resolve_sechub_model_returns_model_when_parameter_defined.
@Test
void resolve_sechub_model_returns_model_when_parameter_defined() {
/* prepare */
SecHubScanConfiguration config = new SecHubScanConfiguration();
config.setProjectId("a-cool-project-id");
String json = config.toJSON();
addParameter(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_SCAN_CONFIGURATION, json);
/* execute */
SecHubConfigurationModel model = supportToTest.resolveSecHubConfigurationModel();
/* test */
assertNotNull(model);
assertEquals("a-cool-project-id", model.getProjectId());
}
use of com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel in project sechub by mercedes-benz.
the class SecHubFileStructureDataProviderBuilderTest method for_scanType_licensescan_and_empty_model_builder_creates_an_configuration.
@Test
void for_scanType_licensescan_and_empty_model_builder_creates_an_configuration() {
/* prepare */
SecHubConfigurationModel model = new SecHubConfigurationModel();
/* execute */
SecHubFileStructureDataProvider configuration = builderToTest.setModel(model).setScanType(ScanType.LICENSE_SCAN).build();
/* test */
assertNotNull(configuration);
assertTrue(configuration.getUnmodifiableSetOfAcceptedReferenceNames().isEmpty());
assertFalse(configuration.isRootFolderAccepted());
}
use of com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel in project sechub by mercedes-benz.
the class SecHubFileStructureDataProviderBuilderTest method for_scanType_codescan_and_empty_model_builder_creates_an_configuration.
@Test
void for_scanType_codescan_and_empty_model_builder_creates_an_configuration() {
/* prepare */
SecHubConfigurationModel model = new SecHubConfigurationModel();
/* execute */
SecHubFileStructureDataProvider configuration = builderToTest.setModel(model).setScanType(ScanType.CODE_SCAN).build();
/* test */
assertNotNull(configuration);
assertTrue(configuration.getUnmodifiableSetOfAcceptedReferenceNames().isEmpty());
assertTrue(configuration.isRootFolderAccepted());
}
Aggregations