use of com.mercedesbenz.sechub.adapter.pds.PDSCodeScanConfig in project sechub by mercedes-benz.
the class PDSCodeScanProductExecutor method executeWithAdapter.
@Override
protected List<ProductResult> executeWithAdapter(SecHubExecutionContext context, ProductExecutorContext executorContext, PDSInstallSetup setup, TargetRegistryInfo info) throws Exception {
LOG.debug("Trigger PDS adapter execution");
PDSExecutorConfigSuppport configSupport = PDSExecutorConfigSuppport.createSupportAndAssertConfigValid(executorContext.getExecutorConfig(), systemEnvironment);
if (configSupport.isTargetTypeForbidden(info.getTargetType())) {
LOG.info("pds adapter does not accept target type:{} so cancel execution");
return Collections.emptyList();
}
UUID jobUUID = context.getSechubJobUUID();
String projectId = context.getConfiguration().getProjectId();
JobStorage storage = storageService.getJobStorage(projectId, jobUUID);
ProductResult result = resilientActionExecutor.executeResilient(() -> {
AdapterMetaData metaDataOrNull = executorContext.getCurrentMetaDataOrNull();
/* we reuse existing file upload checksum done by sechub */
String sourceZipFileChecksum = fetchFileUploadChecksumIfNecessary(storage, metaDataOrNull);
try (InputStream sourceCodeZipFileInputStream = fetchInputStreamIfNecessary(storage, metaDataOrNull)) {
/* @formatter:off */
Map<String, String> jobParams = configSupport.createJobParametersToSendToPDS(context.getConfiguration());
PDSCodeScanConfig pdsCodeScanConfig = PDSCodeScanConfigImpl.builder().setPDSProductIdentifier(configSupport.getPDSProductIdentifier()).setTrustAllCertificates(configSupport.isTrustAllCertificatesEnabled()).setProductBaseUrl(configSupport.getProductBaseURL()).setSecHubJobUUID(context.getSechubJobUUID()).setSecHubConfigModel(context.getConfiguration()).configure(createAdapterOptionsStrategy(context)).setTimeToWaitForNextCheckOperationInMilliseconds(configSupport.getTimeToWaitForNextCheckOperationInMilliseconds(setup)).setTimeOutInMinutes(configSupport.getTimeoutInMinutes(setup)).setFileSystemSourceFolders(info.getCodeUploadFileSystemFolders()).setSourceCodeZipFileInputStream(sourceCodeZipFileInputStream).setSourceZipFileChecksum(sourceZipFileChecksum).setUser(configSupport.getUser()).setPasswordOrAPIToken(configSupport.getPasswordOrAPIToken()).setProjectId(projectId).setTraceID(context.getTraceLogIdAsString()).setJobParameters(jobParams).build();
/* @formatter:on */
/* inspect */
MetaDataInspection inspection = scanMetaDataCollector.inspect(ProductIdentifier.PDS_CODESCAN.name());
inspection.notice(MetaDataInspection.TRACE_ID, pdsCodeScanConfig.getTraceID());
/* execute PDS by adapter and update product result */
String pdsResult = pdsAdapter.start(pdsCodeScanConfig, executorContext.getCallback());
// product result is set by callback
ProductResult productResult = executorContext.getCurrentProductResult();
productResult.setResult(pdsResult);
return productResult;
}
});
return Collections.singletonList(result);
}
use of com.mercedesbenz.sechub.adapter.pds.PDSCodeScanConfig in project sechub by mercedes-benz.
the class PDSCodeScanProductExecutor method executeByAdapter.
@Override
protected List<ProductResult> executeByAdapter(ProductExecutorData data) throws Exception {
LOG.debug("Trigger PDS adapter execution");
ProductExecutorContext executorContext = data.getProductExecutorContext();
PDSExecutorConfigSuppport configSupport = PDSExecutorConfigSuppport.createSupportAndAssertConfigValid(executorContext.getExecutorConfig(), systemEnvironment);
SecHubExecutionContext context = data.getSechubExecutionContext();
PDSStorageContentProvider contentProvider = contentProviderFactory.createContentProvider(context, configSupport, getScanType());
ProductResult result = resilientActionExecutor.executeResilient(() -> {
try (InputStream sourceCodeZipFileInputStreamOrNull = contentProvider.getSourceZipFileInputStreamOrNull();
InputStream binariesTarFileInputStreamOrNull = contentProvider.getBinariesTarFileInputStreamOrNull()) {
/* @formatter:off */
PDSCodeScanConfig pdsCodeScanConfig = PDSCodeScanConfigImpl.builder().configure(PDSAdapterConfigurationStrategy.builder().setScanType(getScanType()).setProductExecutorData(data).setConfigSupport(configSupport).setSourceCodeZipFileInputStreamOrNull(sourceCodeZipFileInputStreamOrNull).setBinariesTarFileInputStreamOrNull(binariesTarFileInputStreamOrNull).setContentProvider(contentProvider).setInstallSetup(installSetup).build()).build();
/* @formatter:on */
/* inspect */
MetaDataInspection inspection = scanMetaDataCollector.inspect(ProductIdentifier.PDS_CODESCAN.name());
inspection.notice(MetaDataInspection.TRACE_ID, pdsCodeScanConfig.getTraceID());
/* execute PDS by adapter and update product result */
String pdsResult = pdsAdapter.start(pdsCodeScanConfig, executorContext.getCallback());
// product result is set by callback
ProductResult productResult = executorContext.getCurrentProductResult();
productResult.setResult(pdsResult);
return productResult;
}
});
return Collections.singletonList(result);
}
Aggregations