use of com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport in project synopsys-detect by blackducksoftware.
the class CreateSignatureScanReports method createReports.
public List<SignatureScannerReport> createReports(List<SignatureScanPath> signatureScanPaths, List<ScanCommandOutput> scanCommandOutputList) {
List<SignatureScannerReport> signatureScannerReports = new ArrayList<>();
for (SignatureScanPath signatureScanPath : signatureScanPaths) {
Optional<ScanCommandOutput> scanCommandOutput = scanCommandOutputList.stream().filter(output -> output.getScanTarget().equals(signatureScanPath.getTargetCanonicalPath())).findFirst();
SignatureScannerReport signatureScannerReport = createReport(signatureScanPath, scanCommandOutput.orElse(null));
signatureScannerReports.add(signatureScannerReport);
}
return signatureScannerReports;
}
use of com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport in project synopsys-detect by blackducksoftware.
the class CreateSignatureScanReports method createReport.
public static SignatureScannerReport createReport(SignatureScanPath signatureScanPath, @Nullable ScanCommandOutput scanCommandOutput) {
SignatureScanStatusType statusType;
if (scanCommandOutput == null) {
statusType = SignatureScanStatusType.FAILURE;
} else if (scanCommandOutput.getScanExitCode().isPresent() && scanCommandOutput.getScanExitCode().get() == 2) {
statusType = SignatureScanStatusType.SKIPPED;
} else if (Result.FAILURE.equals(scanCommandOutput.getResult())) {
statusType = SignatureScanStatusType.FAILURE;
} else {
statusType = SignatureScanStatusType.SUCCESS;
}
Optional<ScanCommandOutput> optionalOutput = Optional.ofNullable(scanCommandOutput);
boolean hasOutput = optionalOutput.isPresent();
Integer exitCode = optionalOutput.map(ScanCommandOutput::getScanExitCode).filter(Optional::isPresent).map(Optional::get).orElse(null);
Exception exception = optionalOutput.map(ScanCommandOutput::getException).filter(Optional::isPresent).map(Optional::get).orElse(null);
String errorMessage = optionalOutput.map(ScanCommandOutput::getErrorMessage).filter(Optional::isPresent).map(Optional::get).orElse(null);
String codeLocationName = optionalOutput.map(CodeLocationOutput::getCodeLocationName).orElse(null);
Integer notificationCounts = optionalOutput.map(CodeLocationOutput::getExpectedNotificationCount).orElse(null);
return new SignatureScannerReport(signatureScanPath, statusType, exitCode, exception, errorMessage, hasOutput, codeLocationName, notificationCounts);
}
use of com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport in project synopsys-detect by blackducksoftware.
the class PublishSignatureScanReports method publishReport.
private void publishReport(SignatureScannerReport signatureScannerReport) {
if (signatureScannerReport.isSuccessful() || (signatureScannerReport.isSkipped() && treatSkippedScanAsSuccess)) {
statusEventPublisher.publishStatusSummary(new SignatureScanStatus(signatureScannerReport.getSignatureScanPath().getTargetCanonicalPath(), StatusType.SUCCESS));
return;
}
String scanTargetPath = signatureScannerReport.getSignatureScanPath().getTargetCanonicalPath();
if (signatureScannerReport.isSkipped()) {
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.SIGNATURE_SCANNER, String.format("Scanning target %s was never scanned by the BlackDuck CLI.", scanTargetPath), Arrays.asList("The minimum scan interval was not met and this scan was skipped by the BlackDuck CLI.")));
} else if (!signatureScannerReport.hasOutput()) {
String errorMessage = String.format("Scanning target %s was never scanned by the BlackDuck CLI.", scanTargetPath);
logger.info(errorMessage);
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.SIGNATURE_SCANNER, "Black Duck Signature Scanner", Arrays.asList(errorMessage)));
} else {
String errorMessage = signatureScannerReport.getErrorMessage().map(message -> String.format("Scanning target %s failed: %s", scanTargetPath, message)).orElse(String.format("Scanning target %s failed for an unknown reason.", scanTargetPath));
logger.error(errorMessage);
signatureScannerReport.getException().ifPresent(exception -> logger.debug(errorMessage, exception));
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.SIGNATURE_SCANNER, "Black Duck Signature Scanner", Arrays.asList(errorMessage)));
}
statusEventPublisher.publishStatusSummary(new SignatureScanStatus(signatureScannerReport.getSignatureScanPath().getTargetCanonicalPath(), StatusType.FAILURE));
}
use of com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport in project synopsys-detect by blackducksoftware.
the class SignatureScanStepRunner method executeScan.
private List<SignatureScannerReport> executeScan(ScanBatch scanBatch, ScanBatchRunner scanBatchRunner, List<SignatureScanPath> scanPaths) throws OperationException {
SignatureScanOuputResult scanOuputResult = operationFactory.signatureScan(scanBatch, scanBatchRunner);
List<SignatureScannerReport> reports = operationFactory.createSignatureScanReport(scanPaths, scanOuputResult.getScanBatchOutput().getOutputs());
operationFactory.publishSignatureScanReport(reports);
return reports;
}
use of com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport in project synopsys-detect by blackducksoftware.
the class SignatureScanStepRunner method runSignatureScannerOnline.
public SignatureScannerCodeLocationResult runSignatureScannerOnline(BlackDuckRunData blackDuckRunData, NameVersion projectNameVersion, DockerTargetData dockerTargetData) throws DetectUserFriendlyException, OperationException {
ScanBatchRunner scanBatchRunner = resolveOnlineScanBatchRunner(blackDuckRunData);
List<SignatureScanPath> scanPaths = operationFactory.createScanPaths(projectNameVersion, dockerTargetData);
ScanBatch scanBatch = operationFactory.createScanBatchOnline(scanPaths, projectNameVersion, dockerTargetData, blackDuckRunData);
NotificationTaskRange notificationTaskRange = operationFactory.createCodeLocationRange(blackDuckRunData);
List<SignatureScannerReport> reports = executeScan(scanBatch, scanBatchRunner, scanPaths);
return operationFactory.calculateWaitableSignatureScannerCodeLocations(notificationTaskRange, reports);
}
Aggregations