use of com.blackducksoftware.integration.hub.detect.workflow.status.Status 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.");
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.status.Status in project hub-detect by blackducksoftware.
the class BlackDuckBinaryScannerTool method uploadBinaryScanFile.
public Set<String> uploadBinaryScanFile(final BinaryScannerService binaryService, final File file, final String projectName, final String projectVersionName, final String prefix, final String suffix) throws DetectUserFriendlyException {
final String codeLocationName = codeLocationNameManager.createBinaryScanCodeLocationName(file.getName(), projectName, projectVersionName, prefix, suffix);
try {
logger.info("Preparing to upload binary scan file: " + codeLocationName);
binaryService.scanBinary(file, projectName, projectVersionName, codeLocationName);
logger.info("Successfully uploaded binary scan file: " + codeLocationName);
eventSystem.publishEvent(Event.StatusSummary, new Status("BINARY_SCAN", StatusType.SUCCESS));
Set<String> names = new HashSet<String>();
names.add(codeLocationName);
return names;
} catch (IOException | IntegrationException | URISyntaxException e) {
logger.error("Failed to upload binary scan file: " + e.getMessage());
eventSystem.publishEvent(Event.StatusSummary, new Status("BINARY_SCAN", StatusType.FAILURE));
throw new DetectUserFriendlyException("Failed to upload binary scan file.", e, ExitCodeType.FAILURE_HUB_CONNECTIVITY);
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.status.Status in project hub-detect by blackducksoftware.
the class ToolRunner method publishExtractionResults.
private void publishExtractionResults(final EventSystem eventSystem, final RunResult runResult, final Extraction extractionResult) {
runResult.addToolNameVersionIfPresent(toolDetector.getToolEnum(), Optional.of(new NameVersion(extractionResult.projectName, extractionResult.projectVersion)));
Optional<Object> dockerTar = extractionResult.getMetaDataValue(DockerExtractor.DOCKER_TAR_META_DATA_KEY);
if (dockerTar.isPresent()) {
runResult.addDockerFile(Optional.of((File) dockerTar.get()));
}
runResult.addDetectCodeLocations(extractionResult.codeLocations);
if (extractionResult.result == Extraction.ExtractionResultType.SUCCESS) {
eventSystem.publishEvent(Event.StatusSummary, new Status(toolDetector.getToolEnum().toString(), StatusType.SUCCESS));
} else {
eventSystem.publishEvent(Event.StatusSummary, new Status(toolDetector.getToolEnum().toString(), StatusType.FAILURE));
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_GENERAL_ERROR, extractionResult.description));
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.status.Status in project hub-detect by blackducksoftware.
the class ToolRunner method publishNotExtractableResults.
private void publishNotExtractableResults(final EventSystem eventSystem, final DetectorResult extractableResult, final String toolName) {
logger.error(String.format("%s was not extractable: %s", toolName, extractableResult.toDescription()));
eventSystem.publishEvent(Event.StatusSummary, new Status(DetectTool.BAZEL.toString(), StatusType.FAILURE));
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_GENERAL_ERROR, extractableResult.toDescription()));
}
Aggregations