Search in sources :

Example 1 with ScanType

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

the class ScanTypeTest method scantypes_sechub_ids_are_all_found_in_pds_scantypes.

@Test
public void scantypes_sechub_ids_are_all_found_in_pds_scantypes() {
    // check every sechub scan type is recognized in pds
    for (ScanType scantype : ScanType.values()) {
        PDSScanType pdsSanType = PDSScanType.valueOf(scantype.name());
        assertNotNull("Should not happen - because of valueOf should throw exception in this case", pdsSanType);
        assertEquals("scan type ids differ!", scantype.getId(), pdsSanType.getId());
    }
}
Also used : PDSScanType(com.mercedesbenz.sechub.pds.config.PDSScanType) ScanType(com.mercedesbenz.sechub.commons.model.ScanType) PDSScanType(com.mercedesbenz.sechub.pds.config.PDSScanType) Test(org.junit.Test)

Example 2 with ScanType

use of com.mercedesbenz.sechub.commons.model.ScanType 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 ScanType

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

the class AbstractProductExecutionService method runOnAllAvailableExecutors.

/**
 * Executes product executors and stores results. If a result of an executor is
 * <code>null</code> an error will be logged but
 *
 * @param executors
 * @param context
 * @param traceLogID
 */
protected void runOnAllAvailableExecutors(List<? extends ProductExecutor> executors, SecHubExecutionContext context, UUIDTraceLogID traceLogID) {
    SecHubConfiguration configuration = context.getConfiguration();
    requireNonNull(configuration, "Configuration must be set");
    String projectId = configuration.getProjectId();
    requireNonNull(projectId, "Project id must be set");
    int countOfReportProductExecutor = 0;
    ProductExecutor serecoProductExecutor = null;
    for (ProductExecutor productExecutor : executors) {
        if (context.isCanceledOrAbandonded()) {
            return;
        }
        ProductIdentifier productIdentifier = productExecutor.getIdentifier();
        int executorVersion = productExecutor.getVersion();
        switch(productIdentifier) {
            case SERECO:
                serecoProductExecutor = productExecutor;
            /* fall through */
            default:
                LOG.debug("search config for project={}, executor={}, version={}", projectId, productIdentifier, executorVersion);
                List<ProductExecutorConfig> executorConfigurations = productExecutorConfigRepository.findExecutableConfigurationsForProject(projectId, productIdentifier, executorVersion);
                if (executorConfigurations.isEmpty()) {
                    LOG.debug("no config found for project={} so skipping executor={}, version={}", projectId, productIdentifier, executorVersion);
                    continue;
                }
                for (ProductExecutorConfig executorConfiguration : executorConfigurations) {
                    runOnExecutorWithOneConfiguration(executorConfiguration, productExecutor, context, projectId, traceLogID);
                    ScanType scanType = productExecutor.getScanType();
                    if (ScanType.REPORT.equals(scanType)) {
                        countOfReportProductExecutor++;
                    }
                }
        }
    }
    if (serecoProductExecutor != null && countOfReportProductExecutor == 0) {
        LOG.debug("no dedicated configuration for report execution was executed before, so fallback to sereco default behaviour");
        runOnExecutorWithOneConfiguration(SERECO_FALLBACK, serecoProductExecutor, context, projectId, traceLogID);
    }
}
Also used : ScanType(com.mercedesbenz.sechub.commons.model.ScanType) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)

Example 4 with ScanType

use of com.mercedesbenz.sechub.commons.model.ScanType 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 ScanType

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

the class PDSWorkspaceService method extractZipFileUploadsWhenConfigured.

public void extractZipFileUploadsWhenConfigured(UUID jobUUID, PDSJobConfiguration config) throws IOException {
    PDSProductSetup productSetup = resolveProductSetup(config);
    if (!productSetup.isExtractUploads()) {
        return;
    }
    ScanType scanType = productSetup.getScanType();
    SecHubFileStructureDataProvider provider = resolveFileStructureDataProviderOrNull(jobUUID, config, scanType);
    extractUploadedZipFiles(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)

Aggregations

ScanType (com.mercedesbenz.sechub.commons.model.ScanType)10 PDSProductSetup (com.mercedesbenz.sechub.pds.config.PDSProductSetup)3 SecHubFileStructureDataProvider (com.mercedesbenz.sechub.commons.archive.SecHubFileStructureDataProvider)2 PDSScanType (com.mercedesbenz.sechub.pds.config.PDSScanType)2 Test (org.junit.Test)2 SecHubCodeCallStack (com.mercedesbenz.sechub.commons.model.SecHubCodeCallStack)1 SecHubConfigurationModel (com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel)1 SecHubFinding (com.mercedesbenz.sechub.commons.model.SecHubFinding)1 ReportTransformationResult (com.mercedesbenz.sechub.domain.scan.ReportTransformationResult)1 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)1 FalsePositiveMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData)1 SerecoMetaData (com.mercedesbenz.sechub.sereco.metadata.SerecoMetaData)1 SerecoVulnerability (com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability)1 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)1 NotAcceptableException (com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException)1 UUID (java.util.UUID)1