Search in sources :

Example 1 with PDSProductSetup

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"));
}
Also used : PDSJobConfiguration(com.mercedesbenz.sechub.pds.job.PDSJobConfiguration) PDSProductSetup(com.mercedesbenz.sechub.pds.config.PDSProductSetup) PDSProdutParameterDefinition(com.mercedesbenz.sechub.pds.config.PDSProdutParameterDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with PDSProductSetup

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;
}
Also used : ScanType(com.mercedesbenz.sechub.commons.model.ScanType) SecHubConfigurationModel(com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel) PDSProductSetup(com.mercedesbenz.sechub.pds.config.PDSProductSetup)

Example 3 with PDSProductSetup

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;
}
Also used : PDSProductSetup(com.mercedesbenz.sechub.pds.config.PDSProductSetup) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with PDSProductSetup

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);
}
Also used : ScanType(com.mercedesbenz.sechub.commons.model.ScanType) SecHubFileStructureDataProvider(com.mercedesbenz.sechub.commons.archive.SecHubFileStructureDataProvider) PDSProductSetup(com.mercedesbenz.sechub.pds.config.PDSProductSetup)

Example 5 with PDSProductSetup

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();
}
Also used : PDSProductSetup(com.mercedesbenz.sechub.pds.config.PDSProductSetup)

Aggregations

PDSProductSetup (com.mercedesbenz.sechub.pds.config.PDSProductSetup)10 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)3 SecHubFileStructureDataProvider (com.mercedesbenz.sechub.commons.archive.SecHubFileStructureDataProvider)2 PDSProdutParameterDefinition (com.mercedesbenz.sechub.pds.config.PDSProdutParameterDefinition)2 PDSJobConfiguration (com.mercedesbenz.sechub.pds.job.PDSJobConfiguration)2 Test (org.junit.jupiter.api.Test)2 SecHubConfigurationModel (com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel)1 PDSNotFoundException (com.mercedesbenz.sechub.pds.PDSNotFoundException)1 PDSProductIdentifierValidator (com.mercedesbenz.sechub.pds.config.PDSProductIdentifierValidator)1 PDSServerConfigurationService (com.mercedesbenz.sechub.pds.config.PDSServerConfigurationService)1 PDSExecutionParameterEntry (com.mercedesbenz.sechub.pds.execution.PDSExecutionParameterEntry)1 LinkedHashMap (java.util.LinkedHashMap)1 Before (org.junit.Before)1