Search in sources :

Example 1 with SignatureScanStatus

use of com.synopsys.integration.detect.workflow.status.SignatureScanStatus 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));
}
Also used : ExitCodeType(com.synopsys.integration.detect.configuration.enumeration.ExitCodeType) Arrays(java.util.Arrays) StatusEventPublisher(com.synopsys.integration.detect.workflow.status.StatusEventPublisher) Logger(org.slf4j.Logger) DetectIssue(com.synopsys.integration.detect.workflow.status.DetectIssue) LoggerFactory(org.slf4j.LoggerFactory) SignatureScannerReport(com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport) StatusType(com.synopsys.integration.detect.workflow.status.StatusType) List(java.util.List) DetectIssueType(com.synopsys.integration.detect.workflow.status.DetectIssueType) SignatureScanStatus(com.synopsys.integration.detect.workflow.status.SignatureScanStatus) ExitCodePublisher(com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher) ExitCodeRequest(com.synopsys.integration.detect.lifecycle.shutdown.ExitCodeRequest) DetectIssue(com.synopsys.integration.detect.workflow.status.DetectIssue) SignatureScanStatus(com.synopsys.integration.detect.workflow.status.SignatureScanStatus)

Aggregations

ExitCodeType (com.synopsys.integration.detect.configuration.enumeration.ExitCodeType)1 ExitCodePublisher (com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher)1 ExitCodeRequest (com.synopsys.integration.detect.lifecycle.shutdown.ExitCodeRequest)1 SignatureScannerReport (com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport)1 DetectIssue (com.synopsys.integration.detect.workflow.status.DetectIssue)1 DetectIssueType (com.synopsys.integration.detect.workflow.status.DetectIssueType)1 SignatureScanStatus (com.synopsys.integration.detect.workflow.status.SignatureScanStatus)1 StatusEventPublisher (com.synopsys.integration.detect.workflow.status.StatusEventPublisher)1 StatusType (com.synopsys.integration.detect.workflow.status.StatusType)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1