use of com.checkmarx.flow.dto.ScanDetails in project cx-flow by checkmarx-ltd.
the class BugTrackerEventTrigger method triggerScanNotSubmittedBugTrackerEvent.
public void triggerScanNotSubmittedBugTrackerEvent(ScanRequest scanRequest, ScanResults scanResults) {
boolean eventsWereTriggered = true;
String description = "Existing scan in progress. Please try again after sometime.";
BugTracker.Type bugTrackerType = scanRequest.getBugTracker().getType();
switch(bugTrackerType) {
case GITLABMERGE:
gitLabService.sendMergeComment(scanRequest, SCAN_NOT_SUBMITTED_MESSAGE);
gitLabService.endBlockMerge(scanRequest);
break;
case GITLABCOMMIT:
gitLabService.sendCommitComment(scanRequest, SCAN_NOT_SUBMITTED_MESSAGE);
break;
case GITHUBPULL:
gitService.sendMergeComment(scanRequest, SCAN_NOT_SUBMITTED_MESSAGE);
String targetURL = cxProperties.getBaseUrl().concat(GitHubService.CX_USER_SCAN_QUEUE);
gitService.errorBlockMerge(scanRequest, targetURL, description);
break;
case BITBUCKETPULL:
bbService.sendMergeComment(scanRequest, SCAN_NOT_SUBMITTED_MESSAGE);
break;
case BITBUCKETSERVERPULL:
bbService.sendServerMergeComment(scanRequest, SCAN_NOT_SUBMITTED_MESSAGE);
String buildName = "Existing Checkmarx Scan in progress.";
String buildUrl = cxProperties.getBaseUrl().concat(BitBucketService.CX_USER_SCAN_QUEUE);
bbService.setBuildFailedStatus(scanRequest, buildName, buildUrl, description);
break;
case ADOPULL:
adoService.sendMergeComment(scanRequest, SCAN_NOT_SUBMITTED_MESSAGE);
adoService.startBlockMerge(scanRequest);
adoService.endBlockMerge(scanRequest, scanResults, new ScanDetails());
break;
case JIRA:
case CUSTOM:
eventsWereTriggered = false;
// No action is needed
break;
case NONE:
log.warn("Bug tracker events were not triggered, because bug tracker type is '{}'.", bugTrackerType);
break;
default:
eventsWereTriggered = false;
log.warn("Bug-Tracker type: {} is not supported", bugTrackerType);
}
if (eventsWereTriggered) {
log.debug("Completed triggering events for the '{}' bug tracker.", bugTrackerType);
} else {
log.debug("Bug tracker events were not triggered, because bug tracker type is '{}'.", bugTrackerType);
}
}
use of com.checkmarx.flow.dto.ScanDetails in project cx-flow by checkmarx-ltd.
the class ResultsService method processScanResultsAsync.
@Async("scanRequest")
public CompletableFuture<ScanResults> processScanResultsAsync(ScanRequest request, Integer projectId, Integer scanId, String osaScanId, FilterConfiguration filterConfiguration) throws MachinaException {
try {
CompletableFuture<ScanResults> future = new CompletableFuture<>();
// TODO async these, and join and merge after
ScanResults results = cxScannerService.getScannerClient().getReportContentByScanId(scanId, filterConfiguration);
logGetResultsJsonLogger(request, scanId, results);
results = getOSAScan(request, projectId, osaScanId, filterConfiguration, results);
sendEmailNotification(request, results);
processResults(request, results, new ScanDetails(projectId, scanId, osaScanId));
logScanDetails(request, projectId, results);
future.complete(results);
return future;
} catch (Exception e) {
log.error("Error occurred while processing results.", e);
CompletableFuture<ScanResults> x = new CompletableFuture<>();
x.completeExceptionally(e);
return x;
}
}
use of com.checkmarx.flow.dto.ScanDetails in project cx-flow by checkmarx-ltd.
the class ResultsService method publishCombinedResults.
@Async("scanRequest")
public CompletableFuture<ScanResults> publishCombinedResults(ScanRequest scanRequest, ScanResults scanResults) {
try {
CompletableFuture<ScanResults> future = new CompletableFuture<>();
if (scanResults.getProjectId() != null) {
Integer projectId = Integer.parseInt(scanResults.getProjectId());
if (projectId != UNKNOWN_INT) {
logGetResultsJsonLogger(scanRequest, scanResults.getSastScanId(), scanResults);
sendEmailNotification(scanRequest, scanResults);
processResults(scanRequest, scanResults, new ScanDetails(projectId, scanResults.getSastScanId(), null));
logScanDetails(scanRequest, projectId, scanResults);
} else {
processResults(scanRequest, scanResults, new ScanDetails(null, scanResults.getSastScanId(), null));
}
} else {
processResults(scanRequest, scanResults, new ScanDetails(null, scanResults.getSastScanId(), null));
}
future.complete(scanResults);
log.info("Finished processing the request");
return future;
} catch (Exception e) {
log.error("Error occurred while processing results.", e);
CompletableFuture<ScanResults> x = new CompletableFuture<>();
x.completeExceptionally(e);
return x;
}
}
Aggregations