Search in sources :

Example 1 with CIEnvironmentVariables

use of com.blackducksoftware.integration.util.CIEnvironmentVariables in project hub-docker-inspector by blackducksoftware.

the class HubClient method phoneHomeNoHubConnection.

private void phoneHomeNoHubConnection(final String dockerEngineVersion) {
    try {
        final IntLogger intLogger = new Slf4jIntLogger(logger);
        final ProxyInfo proxyInfo = new ProxyInfo(config.getHubProxyHost(), Integer.parseInt(config.getHubProxyPort()), new Credentials(config.getHubProxyUsername(), config.getHubProxyPassword()), null, null, null);
        final boolean alwaysTrustServerCertificate = config.isHubAlwaysTrustCert();
        final PhoneHomeClient phClient = new PhoneHomeClient(intLogger, 15, proxyInfo, alwaysTrustServerCertificate);
        final Map<String, String> infoMap = new HashMap<>();
        infoMap.put("blackDuckName", BlackDuckName.HUB.getName());
        infoMap.put("blackDuckVersion", "None");
        infoMap.put("thirdPartyName", THIRD_PARTY_NAME_DOCKER);
        infoMap.put("thirdPartyVersion", dockerEngineVersion);
        infoMap.put("pluginVersion", programVersion.getProgramVersion());
        if (!StringUtils.isBlank(config.getCallerName())) {
            infoMap.put(PHONE_HOME_METADATA_NAME_CALLER_NAME, config.getCallerName());
        }
        if (!StringUtils.isBlank(config.getCallerVersion())) {
            infoMap.put(PHONE_HOME_METADATA_NAME_CALLER_VERSION, config.getCallerVersion());
        }
        final PhoneHomeRequestBody phoneHomeRequestBody = new PhoneHomeRequestBody("None", "Integrations", infoMap);
        phClient.postPhoneHomeRequest(phoneHomeRequestBody, new CIEnvironmentVariables());
    } catch (final Throwable t) {
        logger.debug(String.format("Unable to phone home: %s", t.getMessage()));
    }
}
Also used : PhoneHomeRequestBody(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody) ProxyInfo(com.blackducksoftware.integration.hub.proxy.ProxyInfo) PhoneHomeClient(com.blackducksoftware.integration.phonehome.PhoneHomeClient) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) HashMap(java.util.HashMap) IntLogger(com.blackducksoftware.integration.log.IntLogger) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) Credentials(com.blackducksoftware.integration.hub.Credentials) CIEnvironmentVariables(com.blackducksoftware.integration.util.CIEnvironmentVariables)

Example 2 with CIEnvironmentVariables

use of com.blackducksoftware.integration.util.CIEnvironmentVariables 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

IntLogger (com.blackducksoftware.integration.log.IntLogger)2 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)2 CIEnvironmentVariables (com.blackducksoftware.integration.util.CIEnvironmentVariables)2 Credentials (com.blackducksoftware.integration.hub.Credentials)1 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 ProxyInfo (com.blackducksoftware.integration.hub.proxy.ProxyInfo)1 UriCombiner (com.blackducksoftware.integration.hub.rest.UriCombiner)1 PhoneHomeClient (com.blackducksoftware.integration.phonehome.PhoneHomeClient)1 PhoneHomeRequestBody (com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody)1 File (java.io.File)1 HashMap (java.util.HashMap)1