use of com.blackducksoftware.integration.hub.cli.OfflineCLILocation in project hub-detect by blackducksoftware.
the class OfflineScanner method offlineScan.
boolean offlineScan(final DetectProject detectProject, final HubScanConfig hubScanConfig, final String hubSignatureScannerOfflineLocalPath) throws IllegalArgumentException, IntegrationException, DetectUserFriendlyException, InterruptedException {
final IntLogger intLogger = new Slf4jIntLogger(logger);
final HubServerConfig hubServerConfig = new HubServerConfig(null, 0, (String) null, null, false, new UriCombiner());
final CIEnvironmentVariables ciEnvironmentVariables = new CIEnvironmentVariables();
ciEnvironmentVariables.putAll(System.getenv());
final SimpleScanUtility simpleScanUtility = new SimpleScanUtility(intLogger, gson, hubServerConfig, ciEnvironmentVariables, hubScanConfig, detectProject.getProjectName(), detectProject.getProjectVersionName());
CLILocation cliLocation = new CLILocation(intLogger, hubScanConfig.getToolsDir());
if (StringUtils.isNotBlank(hubSignatureScannerOfflineLocalPath)) {
cliLocation = new OfflineCLILocation(intLogger, new File(hubSignatureScannerOfflineLocalPath));
}
boolean cliInstalledOkay = checkCliInstall(cliLocation, intLogger);
if (!cliInstalledOkay && StringUtils.isNotBlank(detectConfiguration.getHubSignatureScannerHostUrl())) {
installSignatureScannerFromUrl(intLogger, hubScanConfig, ciEnvironmentVariables);
cliInstalledOkay = checkCliInstall(cliLocation, intLogger);
}
if (!cliInstalledOkay && StringUtils.isNotBlank(hubSignatureScannerOfflineLocalPath)) {
OfflineScanner.logger.warn(String.format("The signature scanner is not correctly installed at %s", hubSignatureScannerOfflineLocalPath));
return false;
} else if (!cliInstalledOkay) {
OfflineScanner.logger.warn(String.format("The signature scanner is not correctly installed at %s", hubScanConfig.getToolsDir()));
return false;
} else {
simpleScanUtility.setupAndExecuteScan(cliLocation);
OfflineScanner.logger.info(String.format("The scan dry run files can be found in : %s", simpleScanUtility.getDataDirectory()));
return true;
}
}
Aggregations