Search in sources :

Example 1 with CLILocation

use of com.blackducksoftware.integration.hub.cli.CLILocation 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;
    }
}
Also used : UriCombiner(com.blackducksoftware.integration.hub.rest.UriCombiner) OfflineCLILocation(com.blackducksoftware.integration.hub.cli.OfflineCLILocation) CLILocation(com.blackducksoftware.integration.hub.cli.CLILocation) OfflineCLILocation(com.blackducksoftware.integration.hub.cli.OfflineCLILocation) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) HubServerConfig(com.blackducksoftware.integration.hub.configuration.HubServerConfig) IntLogger(com.blackducksoftware.integration.log.IntLogger) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) File(java.io.File) CIEnvironmentVariables(com.blackducksoftware.integration.util.CIEnvironmentVariables) SimpleScanUtility(com.blackducksoftware.integration.hub.cli.SimpleScanUtility)

Aggregations

CLILocation (com.blackducksoftware.integration.hub.cli.CLILocation)1 OfflineCLILocation (com.blackducksoftware.integration.hub.cli.OfflineCLILocation)1 SimpleScanUtility (com.blackducksoftware.integration.hub.cli.SimpleScanUtility)1 HubServerConfig (com.blackducksoftware.integration.hub.configuration.HubServerConfig)1 UriCombiner (com.blackducksoftware.integration.hub.rest.UriCombiner)1 IntLogger (com.blackducksoftware.integration.log.IntLogger)1 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)1 CIEnvironmentVariables (com.blackducksoftware.integration.util.CIEnvironmentVariables)1 File (java.io.File)1