Search in sources :

Example 1 with SecHubCodeScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration in project sechub by mercedes-benz.

the class CheckmarxProductExecutorMockTest method createExecutionContextForPseudoCodeScan.

private SecHubExecutionContext createExecutionContextForPseudoCodeScan() {
    SecHubExecutionContext context = mock(SecHubExecutionContext.class);
    SecHubConfiguration config = new SecHubConfiguration();
    config.setProjectId(PROJECT_EXAMPLE);
    SecHubCodeScanConfiguration codeScan = new SecHubCodeScanConfiguration();
    SecHubFileSystemConfiguration fileSystemConfig = new SecHubFileSystemConfiguration();
    fileSystemConfig.getFolders().add(PATH_EXAMPLE1);
    codeScan.setFileSystem(fileSystemConfig);
    config.setCodeScan(codeScan);
    when(context.getConfiguration()).thenReturn(config);
    return context;
}
Also used : SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubCodeScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration) SecHubFileSystemConfiguration(com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration)

Example 2 with SecHubCodeScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration in project sechub by mercedes-benz.

the class SecHubFileStructureDataProviderBuilderTest method for_scanType_codescan_and_model_with_codescan_embedded_filesystem_builder_creates_a_configuration.

@Test
void for_scanType_codescan_and_model_with_codescan_embedded_filesystem_builder_creates_a_configuration() {
    /* prepare */
    SecHubConfigurationModel model = new SecHubConfigurationModel();
    SecHubCodeScanConfiguration codeScan = new SecHubCodeScanConfiguration();
    SecHubFileSystemConfiguration fileSystemConfiguration = new SecHubFileSystemConfiguration();
    codeScan.setFileSystem(fileSystemConfiguration);
    fileSystemConfiguration.getFolders().add("myfolder");
    model.setCodeScan(codeScan);
    /* 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) SecHubCodeScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration) SecHubFileSystemConfiguration(com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with SecHubCodeScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration in project sechub by mercedes-benz.

the class SecHubFileStructureDataProviderBuilderTest method for_scanType_codescan_and_model_with_codescan_by_data_section_filesystem_builder_creates_a_configuration.

@Test
void for_scanType_codescan_and_model_with_codescan_by_data_section_filesystem_builder_creates_a_configuration() {
    /* prepare */
    SecHubConfigurationModel model = new SecHubConfigurationModel();
    SecHubCodeScanConfiguration codeScan = new SecHubCodeScanConfiguration();
    codeScan.getNamesOfUsedDataConfigurationObjects().add("test-ref-1");
    SecHubFileSystemConfiguration fileSystemConfiguration = new SecHubFileSystemConfiguration();
    fileSystemConfiguration.getFolders().add("myfolder1");
    SecHubSourceDataConfiguration sourceConfig1 = new SecHubSourceDataConfiguration();
    sourceConfig1.setFileSystem(fileSystemConfiguration);
    sourceConfig1.setUniqueName("test-ref-1");
    SecHubDataConfiguration data = new SecHubDataConfiguration();
    data.getSources().add(sourceConfig1);
    model.setData(data);
    codeScan.setFileSystem(fileSystemConfiguration);
    model.setCodeScan(codeScan);
    /* execute */
    SecHubFileStructureDataProvider configuration = builderToTest.setModel(model).setScanType(ScanType.CODE_SCAN).build();
    /* test */
    assertNotNull(configuration);
    assertTrue(configuration.getUnmodifiableSetOfAcceptedReferenceNames().contains("test-ref-1"));
    assertTrue(configuration.isRootFolderAccepted());
}
Also used : SecHubSourceDataConfiguration(com.mercedesbenz.sechub.commons.model.SecHubSourceDataConfiguration) SecHubConfigurationModel(com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel) SecHubCodeScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration) SecHubFileSystemConfiguration(com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration) SecHubDataConfiguration(com.mercedesbenz.sechub.commons.model.SecHubDataConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with SecHubCodeScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration in project sechub by mercedes-benz.

the class AbstractProductExecutor method configureSourceCodeHandlingIfNecessary.

private void configureSourceCodeHandlingIfNecessary(ProductExecutorData data) {
    if (scanType != ScanType.CODE_SCAN) {
        return;
    }
    // the information about paths is interesting for debugging but also necessary
    // for our integration tests - see mocked_setup.json
    Set<String> paths = new LinkedHashSet<>();
    data.codeUploadFileSystemFolderPaths = paths;
    SecHubConfiguration configuration = data.getSechubExecutionContext().getConfiguration();
    Optional<SecHubCodeScanConfiguration> codeScanOpt = configuration.getCodeScan();
    if (!codeScanOpt.isPresent()) {
        return;
    }
    SecHubCodeScanConfiguration codeScan = codeScanOpt.get();
    addFileSystemParts(paths, codeScan);
    Set<String> usedNames = codeScan.getNamesOfUsedDataConfigurationObjects();
    if (usedNames.isEmpty()) {
        return;
    }
    List<SecHubDataConfigurationObjectInfo> found = configObjectFinder.findDataObjectsByName(configuration, usedNames);
    for (SecHubDataConfigurationObjectInfo info : found) {
        if (info.getType() != SecHubDataConfigurationType.SOURCE) {
            continue;
        }
        SecHubDataConfigurationObject config = info.getDataConfigurationObject();
        if (!(config instanceof SecHubSourceDataConfiguration)) {
            LOG.warn("source object data was not expected {} but {}", SecHubSourceDataConfiguration.class, config.getClass());
            continue;
        }
        SecHubSourceDataConfiguration sourceDataConfig = (SecHubSourceDataConfiguration) config;
        addFileSystemParts(paths, sourceDataConfig);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SecHubSourceDataConfiguration(com.mercedesbenz.sechub.commons.model.SecHubSourceDataConfiguration) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubCodeScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration) SecHubDataConfigurationObject(com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObject) SecHubDataConfigurationObjectInfo(com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObjectInfo)

Aggregations

SecHubCodeScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubCodeScanConfiguration)4 SecHubFileSystemConfiguration (com.mercedesbenz.sechub.commons.model.SecHubFileSystemConfiguration)3 SecHubConfigurationModel (com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel)2 SecHubSourceDataConfiguration (com.mercedesbenz.sechub.commons.model.SecHubSourceDataConfiguration)2 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)2 Test (org.junit.jupiter.api.Test)2 SecHubDataConfiguration (com.mercedesbenz.sechub.commons.model.SecHubDataConfiguration)1 SecHubDataConfigurationObject (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObject)1 SecHubDataConfigurationObjectInfo (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObjectInfo)1 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)1 LinkedHashSet (java.util.LinkedHashSet)1