use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanCommandOutput in project hub-detect by blackducksoftware.
the class BlackDuckSignatureScanner method scanPaths.
private ScanBatchOutput scanPaths(final NameVersion projectNameVersion, File installDirectory, File dockerTarFile) throws IntegrationException, InterruptedException, IOException {
List<SignatureScanPath> signatureScanPaths = determinePathsAndExclusions(projectNameVersion, signatureScannerOptions.getMaxDepth(), dockerTarFile);
final ScanBatch scanJob = createScanBatch(projectNameVersion, installDirectory, signatureScanPaths, dockerTarFile);
List<ScanCommandOutput> scanCommandOutputs = new ArrayList<>();
final ScanBatchOutput scanJobOutput = scanJobManager.executeScans(scanJob);
if (scanJobOutput.getOutputs() != null) {
for (ScanCommandOutput scanCommandOutput : scanJobOutput.getOutputs()) {
scanCommandOutputs.add(scanCommandOutput);
}
}
reportResults(signatureScanPaths, scanCommandOutputs);
return scanJobOutput;
}
use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanCommandOutput in project hub-detect by blackducksoftware.
the class BlackDuckSignatureScanner method reportResults.
private void reportResults(List<SignatureScanPath> signatureScanPaths, List<ScanCommandOutput> scanCommandOutputList) {
boolean anyFailed = false;
boolean anyExitCodeIs64 = false;
for (final SignatureScanPath target : signatureScanPaths) {
Optional<ScanCommandOutput> targetOutput = scanCommandOutputList.stream().filter(output -> output.getScanTarget().equals(target.targetPath)).findFirst();
StatusType scanStatus;
if (!targetOutput.isPresent()) {
scanStatus = StatusType.FAILURE;
logger.info(String.format("Scanning target %s was never scanned by the BlackDuck CLI.", target.targetPath));
} else {
ScanCommandOutput output = targetOutput.get();
if (output.getResult() == Result.FAILURE) {
scanStatus = StatusType.FAILURE;
if (output.getException().isPresent() && output.getErrorMessage().isPresent()) {
logger.error(String.format("Scanning target %s failed: %s", target.targetPath, output.getErrorMessage().get()));
logger.debug(output.getErrorMessage().get(), output.getException().get());
} else if (output.getErrorMessage().isPresent()) {
logger.error(String.format("Scanning target %s failed: %s", target.targetPath, output.getErrorMessage().get()));
} else {
logger.error(String.format("Scanning target %s failed for an unknown reason.", target.targetPath));
}
if (output.getScanExitCode().isPresent()) {
anyExitCodeIs64 = anyExitCodeIs64 || output.getScanExitCode().get() == 64;
}
} else {
scanStatus = StatusType.SUCCESS;
logger.info(String.format("%s was successfully scanned by the BlackDuck CLI.", target.targetPath));
}
}
anyFailed = anyFailed || scanStatus == StatusType.FAILURE;
eventSystem.publishEvent(Event.StatusSummary, new SignatureScanStatus(target.targetPath, scanStatus));
}
if (anyFailed) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_SCAN));
}
if (anyExitCodeIs64) {
logger.error("");
logger.error("Signature scanner returned 64. The most likely cause is you are using an unsupported version of Black Duck (<5.0.0).");
logger.error("You should update your Black Duck or downgrade your version of detect.");
logger.error("If you are using the detect scripts, you can use DETECT_LATEST_RELEASE_VERSION.");
logger.error("");
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_BLACKDUCK_VERSION_NOT_SUPPORTED));
}
}
Aggregations