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());
}
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations