use of com.blackducksoftware.integration.hub.configuration.HubScanConfig in project hub-detect by blackducksoftware.
the class HubSignatureScanner method scanPaths.
public ProjectVersionView scanPaths(final HubServerConfig hubServerConfig, final SignatureScannerService signatureScannerService, final DetectProject detectProject) throws IntegrationException {
ProjectVersionView projectVersionView = null;
final ProjectRequest projectRequest = createProjectRequest(detectProject);
Set<String> canonicalPathsToScan = registeredPaths;
if (null != detectProject.getProjectName() && null != detectProject.getProjectVersionName() && null != detectConfiguration.getHubSignatureScannerPaths() && detectConfiguration.getHubSignatureScannerPaths().length > 0) {
canonicalPathsToScan = new HashSet<>();
for (final String path : detectConfiguration.getHubSignatureScannerPaths()) {
try {
canonicalPathsToScan.add(new File(path).getCanonicalPath());
} catch (final IOException e) {
throw new IntegrationException(e.getMessage(), e);
}
}
}
final List<ScanPathCallable> scanPathCallables = new ArrayList<>();
for (final String canonicalPath : canonicalPathsToScan) {
final HubScanConfigBuilder hubScanConfigBuilder = createScanConfigBuilder(detectProject, canonicalPath);
final HubScanConfig hubScanConfig = hubScanConfigBuilder.build();
final ScanPathCallable scanPathCallable = new ScanPathCallable(signatureScannerService, hubServerConfig, hubScanConfig, projectRequest, canonicalPath, scanSummaryResults);
scanPathCallables.add(scanPathCallable);
}
final ExecutorService pool = Executors.newFixedThreadPool(detectConfiguration.getHubSignatureScannerParallelProcessors());
try {
for (final ScanPathCallable scanPathCallable : scanPathCallables) {
pool.submit(scanPathCallable);
}
for (final ScanPathCallable scanPathCallable : scanPathCallables) {
final ProjectVersionWrapper projectVersionWrapperFromScan = scanPathCallable.call();
if (projectVersionWrapperFromScan != null) {
projectVersionView = projectVersionWrapperFromScan.getProjectVersionView();
}
}
} finally {
// get() was called on every java.util.concurrent.Future, no need to wait any longer
pool.shutdownNow();
}
return projectVersionView;
}
use of com.blackducksoftware.integration.hub.configuration.HubScanConfig in project hub-detect by blackducksoftware.
the class HubSignatureScanner method scanPathOffline.
private void scanPathOffline(final String canonicalPath, final DetectProject detectProject) {
try {
final HubScanConfigBuilder hubScanConfigBuilder = createScanConfigBuilder(detectProject, canonicalPath);
hubScanConfigBuilder.setDryRun(true);
if (StringUtils.isBlank(detectConfiguration.getHubSignatureScannerOfflineLocalPath())) {
final File toolsDirectory = detectFileManager.createDirectory("tools", false);
hubScanConfigBuilder.setToolsDir(toolsDirectory);
}
final HubScanConfig hubScanConfig = hubScanConfigBuilder.build();
final boolean pathWasScanned = offlineScanner.offlineScan(detectProject, hubScanConfig, detectConfiguration.getHubSignatureScannerOfflineLocalPath());
if (pathWasScanned) {
scanSummaryResults.put(canonicalPath, Result.SUCCESS);
logger.info(String.format("%s was successfully scanned by the BlackDuck CLI.", canonicalPath));
}
} catch (final Exception e) {
logger.error(String.format("%s/%s - %s was not scanned by the BlackDuck CLI: %s", detectProject.getProjectName(), detectProject.getProjectVersionName(), canonicalPath, e.getMessage()));
}
}
Aggregations