use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.
the class ScanService method createExecutionContext.
private SecHubExecutionContext createExecutionContext(DomainMessage message) throws JSONConverterException {
UUID uuid = message.get(SECHUB_UUID);
String executedBy = message.get(EXECUTED_BY);
SecHubConfiguration configuration = message.get(SECHUB_CONFIG);
if (configuration == null) {
throw new IllegalStateException("SecHubConfiguration not found in message - so cannot execute!");
}
SecHubExecutionContext executionContext = new SecHubExecutionContext(uuid, configuration, executedBy);
buildOptions(executionContext);
return executionContext;
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.
the class DefaultAdapterConfigurationStrategy method configure.
@Override
public <B extends AdapterConfigBuilder, C extends AdapterConfig> void configure(B configBuilder) {
/* @formatter:off */
SecHubExecutionContext context = data.getSechubExecutionContext();
String projectId = context.getConfiguration().getProjectId();
configBuilder.configure(new SecHubAdapterOptionsBuilderStrategy(data, scanType));
configBuilder.setProductBaseUrl(configSupport.getProductBaseURL());
configBuilder.setUser(configSupport.getUser());
configBuilder.setPasswordOrAPIToken(configSupport.getPasswordOrAPIToken());
configBuilder.setProjectId(projectId);
configBuilder.setTraceID(context.getTraceLogIdAsString());
/* @formatter:on */
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext 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;
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.
the class PDSAdapterConfigurationStrategy method handlePdsParts.
private void handlePdsParts(PDSAdapterConfigurator pdsConfigurable) {
SecHubExecutionContext context = strategyConfig.productExecutorData.getSechubExecutionContext();
Map<String, String> jobParameters = strategyConfig.configSupport.createJobParametersToSendToPDS(context.getConfiguration());
pdsConfigurable.setJobParameters(jobParameters);
pdsConfigurable.setReusingSecHubStorage(PDSExecutorConfigSuppport.isReusingSecHubStorage(jobParameters));
pdsConfigurable.setScanType(strategyConfig.scanType);
pdsConfigurable.setPdsProductIdentifier(strategyConfig.configSupport.getPDSProductIdentifier());
pdsConfigurable.setSecHubJobUUID(context.getSechubJobUUID());
pdsConfigurable.setSecHubConfigurationModel(context.getConfiguration());
pdsConfigurable.setSourceCodeZipFileInputStreamOrNull(strategyConfig.sourceCodeZipFileInputStreamOrNull);
pdsConfigurable.setBinaryTarFileInputStreamOrNull(strategyConfig.binariesTarFileInputStreamOrNull);
pdsConfigurable.setSourceCodeZipFileRequired(strategyConfig.contentProvider.isSourceRequired());
pdsConfigurable.setBinaryTarFileRequired(strategyConfig.contentProvider.isBinaryRequired());
try {
String sourceZipFileChecksum = strategyConfig.contentProvider.getSourceZipFileUploadChecksumOrNull();
pdsConfigurable.setSourceCodeZipFileChecksumOrNull(sourceZipFileChecksum);
} catch (IOException e) {
throw new SecHubRuntimeException("Was not able to retrieve source zip upload checksum", e);
}
try {
String binaryTarFileChecksum = strategyConfig.contentProvider.getBinariesTarFileUploadChecksumOrNull();
pdsConfigurable.setBinariesTarFileChecksumOrNull(binaryTarFileChecksum);
} catch (IOException e) {
throw new SecHubRuntimeException("Was not able to retrieve tar file upload checksum", e);
}
}
use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.
the class PDSInfraScanProductExecutor method executeByAdapter.
@Override
protected List<ProductResult> executeByAdapter(ProductExecutorData data) throws Exception {
NetworkTargetInfo info = data.getCurrentNetworkTargetInfo();
Set<URI> targetURIs = info.getURIs();
if (targetURIs.isEmpty()) {
/* no targets defined */
return Collections.emptyList();
}
NetworkTargetType targetType = info.getTargetType();
ProductExecutorContext executorContext = data.getProductExecutorContext();
/* we reuse config support created inside customize method */
PDSExecutorConfigSuppport configSupport = (PDSExecutorConfigSuppport) data.getNetworkTargetDataProvider();
if (configSupport.isTargetTypeForbidden(targetType)) {
LOG.info("pds adapter does not accept target type:{} so cancel execution");
return Collections.emptyList();
}
LOG.debug("Trigger pds infra scan adapter execution for target {}", targetType);
List<ProductResult> results = new ArrayList<>();
SecHubExecutionContext context = data.getSechubExecutionContext();
PDSStorageContentProvider contentProvider = contentProviderFactory.createContentProvider(context, configSupport, getScanType());
for (URI targetURI : targetURIs) {
/* @formatter:off */
/* special behavior, because having multiple results here, we must find former result corresponding to
* target URI.
*/
executorContext.useFirstFormerResultHavingMetaData(PDSMetaDataID.KEY_TARGET_URI, targetURI);
PDSInfraScanConfig pdsInfraScanConfig = PDSInfraScanConfigImpl.builder().configure(PDSAdapterConfigurationStrategy.builder().setScanType(getScanType()).setProductExecutorData(data).setConfigSupport(configSupport).setContentProvider(contentProvider).setInstallSetup(installSetup).build()).configure(new NetworkTargetProductServerDataAdapterConfigurationStrategy(configSupport, data.getCurrentNetworkTargetInfo().getTargetType())).setTargetIPs(info.getIPs()).setTargetURIs(info.getURIs()).build();
/* @formatter:on */
/* execute PDS by adapter and return product result */
String xml = pdsAdapter.start(pdsInfraScanConfig, executorContext.getCallback());
ProductResult currentProductResult = executorContext.getCurrentProductResult();
currentProductResult.setResult(xml);
results.add(currentProductResult);
}
return results;
}
Aggregations