Search in sources :

Example 1 with CleanupZipExpander

use of com.synopsys.integration.util.CleanupZipExpander in project hub-detect by blackducksoftware.

the class ScanBatchRunnerFactory method withUserProvidedUrl.

public ScanBatchRunner withUserProvidedUrl(String userProvidedScannerInstallUrl, ConnectionManager connectionManager) throws DetectUserFriendlyException {
    // we will use the provided url to download/update the scanner
    final IntHttpClient restConnection = connectionManager.createUnauthenticatedRestConnection(userProvidedScannerInstallUrl);
    final CleanupZipExpander cleanupZipExpander = new CleanupZipExpander(slf4jIntLogger);
    final ScannerZipInstaller scannerZipInstaller = new ScannerZipInstaller(slf4jIntLogger, restConnection, cleanupZipExpander, scanPathsUtility, userProvidedScannerInstallUrl, operatingSystemType);
    return ScanBatchRunner.createComplete(slf4jIntLogger, intEnvironmentVariables, scannerZipInstaller, scanPathsUtility, scanCommandRunner);
}
Also used : IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) ScannerZipInstaller(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScannerZipInstaller) CleanupZipExpander(com.synopsys.integration.util.CleanupZipExpander)

Example 2 with CleanupZipExpander

use of com.synopsys.integration.util.CleanupZipExpander in project hub-detect by blackducksoftware.

the class PolarisTool method runPolaris.

public void runPolaris(final IntLogger logger, File projectDirectory) throws DetectUserFriendlyException {
    logger.info("Checking if Polaris can run.");
    PolarisEnvironmentCheck polarisEnvironmentCheck = new PolarisEnvironmentCheck();
    if (!polarisEnvironmentCheck.canRun(directoryManager.getUserHome())) {
        logger.info("Polaris determined it should not run.");
        logger.debug("Checked the following user directory: " + directoryManager.getUserHome().getAbsolutePath());
        return;
    }
    logger.info("Polaris determined it should attempt to run.");
    IntHttpClient restConnection = connectionManager.createUnauthenticatedRestConnection(PolarisDownloadUtility.DEFAULT_POLARIS_SERVER_URL);
    CleanupZipExpander cleanupZipExpander = new CleanupZipExpander(logger);
    File toolsDirectory = directoryManager.getPermanentDirectory();
    PolarisDownloadUtility polarisDownloadUtility = new PolarisDownloadUtility(logger, restConnection, cleanupZipExpander, PolarisDownloadUtility.DEFAULT_POLARIS_SERVER_URL, toolsDirectory);
    Optional<String> swipCliPath = polarisDownloadUtility.retrievePolarisCliExecutablePath();
    if (swipCliPath.isPresent()) {
        Map<String, String> environmentVariables = new HashMap<>();
        environmentVariables.put("COVERITY_UNSUPPORTED", "1");
        environmentVariables.put("SWIP_USER_INPUT_TIMEOUT_MINUTES", "1");
        logger.info("Found polaris cli: " + swipCliPath.get());
        List<String> arguments = new ArrayList<>();
        arguments.add("analyze");
        arguments.add("-w");
        Executable swipExecutable = new Executable(projectDirectory, environmentVariables, swipCliPath.get(), arguments);
        try {
            ExecutableOutput output = executableRunner.execute(swipExecutable);
            if (output.getReturnCode() == 0) {
                eventSystem.publishEvent(Event.StatusSummary, new Status("POLARIS", StatusType.SUCCESS));
            } else {
                logger.error("Polaris returned a non-zero exit code.");
                eventSystem.publishEvent(Event.StatusSummary, new Status("POLARIS", StatusType.FAILURE));
            }
        } catch (ExecutableRunnerException e) {
            eventSystem.publishEvent(Event.StatusSummary, new Status("POLARIS", StatusType.FAILURE));
            logger.error("Couldn't run the executable: " + e.getMessage());
        }
    } else {
        logger.error("Check the logs - the Polaris CLI could not be found.");
    }
}
Also used : Status(com.blackducksoftware.integration.hub.detect.workflow.status.Status) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExecutableRunnerException(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunnerException) CleanupZipExpander(com.synopsys.integration.util.CleanupZipExpander) ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) PolarisDownloadUtility(com.synopsys.integration.polaris.common.PolarisDownloadUtility) Executable(com.blackducksoftware.integration.hub.detect.util.executable.Executable) File(java.io.File)

Aggregations

IntHttpClient (com.synopsys.integration.rest.client.IntHttpClient)2 CleanupZipExpander (com.synopsys.integration.util.CleanupZipExpander)2 Executable (com.blackducksoftware.integration.hub.detect.util.executable.Executable)1 ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)1 ExecutableRunnerException (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunnerException)1 Status (com.blackducksoftware.integration.hub.detect.workflow.status.Status)1 ScannerZipInstaller (com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScannerZipInstaller)1 PolarisDownloadUtility (com.synopsys.integration.polaris.common.PolarisDownloadUtility)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1