use of com.mercedesbenz.sechub.domain.scan.NetworkTargetType in project sechub by mercedes-benz.
the class TargetRegistryTest method nothing_registered_get_targets_for_any_type_returns_not_null_but_empty_list.
@Test
public void nothing_registered_get_targets_for_any_type_returns_not_null_but_empty_list() {
for (NetworkTargetType type : NetworkTargetType.values()) {
List<NetworkTarget> targetsFor = registryToTest.getTargetsFor(type);
assertNotNull("Type " + type + " results in null ", targetsFor);
assertTrue("Type " + type + " is not empty", targetsFor.isEmpty());
}
}
use of com.mercedesbenz.sechub.domain.scan.NetworkTargetType in project sechub by mercedes-benz.
the class PDSWebScanProductExecutor method executeByAdapter.
@Override
protected List<ProductResult> executeByAdapter(ProductExecutorData data) throws Exception {
ProductExecutorContext executorContext = data.getProductExecutorContext();
SecHubExecutionContext context = data.getSechubExecutionContext();
NetworkTargetInfo info = data.getCurrentNetworkTargetInfo();
/* we reuse config support created inside customize method */
PDSExecutorConfigSuppport configSupport = (PDSExecutorConfigSuppport) data.getNetworkTargetDataProvider();
URI targetURI = info.getURI();
if (targetURI == null) {
LOG.warn("NO target URI defined for PDS web scan execution");
return Collections.emptyList();
}
NetworkTargetType targetType = info.getTargetType();
if (configSupport.isTargetTypeForbidden(targetType)) {
LOG.info("PDS adapter does not accept target type:{} so cancel execution");
return Collections.emptyList();
}
LOG.debug("Trigger PDS adapter execution for target {} ", targetType);
List<ProductResult> results = new ArrayList<>();
/* @formatter:off */
executorContext.useFirstFormerResultHavingMetaData(PDSMetaDataID.KEY_TARGET_URI, targetURI);
PDSStorageContentProvider contentProvider = contentProviderFactory.createContentProvider(context, configSupport, getScanType());
ProductResult result = resilientActionExecutor.executeResilient(() -> {
try (InputStream sourceCodeZipFileInputStreamOrNull = contentProvider.getSourceZipFileInputStreamOrNull()) {
PDSWebScanConfig pdsWebScanConfig = PDSWebScanConfigImpl.builder().configure(PDSAdapterConfigurationStrategy.builder().setScanType(getScanType()).setProductExecutorData(data).setConfigSupport(configSupport).setSourceCodeZipFileInputStreamOrNull(sourceCodeZipFileInputStreamOrNull).setContentProvider(contentProvider).setInstallSetup(installSetup).build()).configure(new WebConfigBuilderStrategy(context)).configure(new NetworkTargetProductServerDataAdapterConfigurationStrategy(configSupport, data.getCurrentNetworkTargetInfo().getTargetType())).setTargetURI(targetURI).setTargetType(info.getTargetType().name()).build();
/* @formatter:on */
/* execute PDS by adapter and return product result */
String pdsResult = pdsAdapter.start(pdsWebScanConfig, executorContext.getCallback());
ProductResult currentProductResult = executorContext.getCurrentProductResult();
currentProductResult.setResult(pdsResult);
return currentProductResult;
}
});
results.add(result);
return results;
}
Aggregations