Search in sources :

Example 1 with SecHubConfigurationModel

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

Example 2 with SecHubConfigurationModel

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;
}
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 SecHubConfigurationModel

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());
}
Also used : SecHubConfigurationModel(com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel) SecHubScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubScanConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with SecHubConfigurationModel

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());
}
Also used : SecHubConfigurationModel(com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel) Test(org.junit.jupiter.api.Test)

Example 5 with SecHubConfigurationModel

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());
}
Also used : SecHubConfigurationModel(com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel) Test(org.junit.jupiter.api.Test)

Aggregations

SecHubConfigurationModel (com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel)7 Test (org.junit.jupiter.api.Test)5 SecHubCodeScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration)2 SecHubFileSystemConfiguration (com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration)2 SecHubFileStructureDataProvider (com.mercedesbenz.sechub.commons.archive.SecHubFileStructureDataProvider)1 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SecHubDataConfiguration (com.mercedesbenz.sechub.commons.model.SecHubDataConfiguration)1 SecHubScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubScanConfiguration)1 SecHubSourceDataConfiguration (com.mercedesbenz.sechub.commons.model.SecHubSourceDataConfiguration)1 PDSProductSetup (com.mercedesbenz.sechub.pds.config.PDSProductSetup)1