use of com.mercedesbenz.sechub.pds.config.PDSProductSetup in project sechub by mercedes-benz.
the class PDSExecutionEnvironmentServiceTest method a_job_with_two_configured_keys_is_is_handling_them_but_third_one_is_ignored.
@Test
void a_job_with_two_configured_keys_is_is_handling_them_but_third_one_is_ignored() {
/* prepare */
// create job configuration
PDSJobConfiguration config = new PDSJobConfiguration();
config.setProductId("productid1");
PDSExecutionParameterEntry entry1 = new PDSExecutionParameterEntry();
entry1.setKey("p1.keya");
entry1.setValue("value1");
PDSExecutionParameterEntry entry2 = new PDSExecutionParameterEntry();
entry2.setKey("p1.keyb");
entry2.setValue("value2");
config.getParameters().add(entry1);
config.getParameters().add(entry2);
// create product setup configuration
PDSProductSetup setup = new PDSProductSetup();
setup.setId("productid1");
PDSProdutParameterDefinition def1 = new PDSProdutParameterDefinition();
def1.setKey("p1.keya");
PDSProdutParameterDefinition def2 = new PDSProdutParameterDefinition();
def2.setKey("p1.keyb");
setup.getParameters().getMandatory().add(def1);
setup.getParameters().getOptional().add(def2);
when(serverConfigService.getProductSetupOrNull("productid1")).thenReturn(setup);
// fake key conversion
when(converter.convertKeyToEnv("p1.keya")).thenReturn("KEY_A");
when(converter.convertKeyToEnv("p1.keyb")).thenReturn("KEY_B");
when(converter.convertKeyToEnv("p1.keyc.unknown")).thenReturn("KEY_C");
/* execute */
Map<String, String> result = serviceToTest.buildEnvironmentMap(config);
/* test */
assertEquals("value1", result.get("KEY_A"));
assertEquals("value2", result.get("KEY_B"));
assertEquals(null, result.get("KEY_C"));
}
use of com.mercedesbenz.sechub.pds.config.PDSProductSetup 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.pds.config.PDSProductSetup in project sechub by mercedes-benz.
the class PDSExecutionEnvironmentService method buildEnvironmentMap.
public Map<String, String> buildEnvironmentMap(PDSJobConfiguration config) {
Map<String, String> map = new LinkedHashMap<>();
String productId = config.getProductId();
PDSProductSetup productSetup = serverConfigService.getProductSetupOrNull(productId);
if (productSetup != null) {
List<PDSExecutionParameterEntry> jobParams = config.getParameters();
for (PDSExecutionParameterEntry jobParam : jobParams) {
addJobParamDataWhenAccepted(productSetup, jobParam, map);
}
} else {
LOG.error("No product setup found for product id:{}", productId);
}
addSecHubJobUUIDAsEnvironmentEntry(config, map);
return map;
}
use of com.mercedesbenz.sechub.pds.config.PDSProductSetup in project sechub by mercedes-benz.
the class PDSWorkspaceService method extractTarFileUploadsWhenConfigured.
public void extractTarFileUploadsWhenConfigured(UUID jobUUID, PDSJobConfiguration config) throws IOException {
PDSProductSetup productSetup = resolveProductSetup(config);
if (!productSetup.isExtractUploads()) {
return;
}
ScanType scanType = productSetup.getScanType();
SecHubFileStructureDataProvider provider = resolveFileStructureDataProviderOrNull(jobUUID, config, scanType);
exractUploadedTarFiles(jobUUID, true, provider);
}
use of com.mercedesbenz.sechub.pds.config.PDSProductSetup in project sechub by mercedes-benz.
the class PDSWorkspaceService method getProductPathFor.
public String getProductPathFor(PDSJobConfiguration config) {
String productId = config.getProductId();
PDSProductSetup productSetup = serverConfigService.getProductSetupOrNull(productId);
if (productSetup == null) {
return null;
}
return productSetup.getPath();
}
Aggregations