Search in sources :

Example 1 with SecHubDataConfigurationObject

use of com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObject 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)1 SecHubDataConfigurationObject (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObject)1 SecHubDataConfigurationObjectInfo (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationObjectInfo)1 SecHubSourceDataConfiguration (com.mercedesbenz.sechub.commons.model.SecHubSourceDataConfiguration)1 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)1 LinkedHashSet (java.util.LinkedHashSet)1