Skip to content

Commit

Permalink
Added code for prscans-not-triggered (#1372)
Browse files Browse the repository at this point in the history
Co-authored-by: Satyam Chaurasia <[email protected]>
  • Loading branch information
1 parent bdd9985 commit b04dd63
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public ScanResults scan(ScanRequest scanRequest) {
logRequest(scanRequest, internalResults, OperationResult.successful());
result = toScanResults(internalResults);
} catch (Exception e) {
bugTrackerEventTrigger.triggerOffScanStartedEvent(scanRequest);
treatError(scanRequest, internalResults, e);

}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ public ScanResults scan(ScanRequest scanRequest) {
//usually should occur during push event occurring on delete branch
//therefore need to eliminate the scan process but do not want to create
//an error stack trace in the log
bugTrackers.getBugTrackerEventTrigger().triggerOffScanStartedEvent(scanRequest);
return getEmptyScanResults();

} catch (Exception e) {
log.error("SAST scan failed", e);
OperationResult scanCreationFailure = new OperationResult(OperationStatus.FAILURE, e.getMessage());
ScanReport report = new ScanReport(-1, scanRequest, scanRequest.getRepoUrl(), scanCreationFailure);
report.log();
bugTrackers.getBugTrackerEventTrigger().triggerOffScanStartedEvent(scanRequest);
return getEmptyScanResults();
}
}
Expand Down Expand Up @@ -290,6 +292,8 @@ private ScanResults getEmptyScanResults() {
scanResults.setProjectId(UNKNOWN);
scanResults.setProject(UNKNOWN);
scanResults.setScanType(SCAN_TYPE);


return scanResults;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public BugTracker.Type triggerScanStartedEvent(ScanRequest request) {
case GITHUBPULL:
if (gitService.isScanSubmittedComment() && request.getScanSubmittedComment()) {
gitService.sendMergeComment(request, SCAN_MESSAGE,gitService.isCommentUpdate());
gitService.startBlockMerge(request, cxProperties.getUrl());
}
gitService.startBlockMerge(request, cxProperties.getUrl());
break;

case BITBUCKETPULL:
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/checkmarx/flow/service/FlowService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ private void runScanRequest(ScanRequest scanRequest, List<VulnerabilityScanner>
resultsService.publishCombinedResults(scanRequest, combinedResults);
}



private List<VulnerabilityScanner> getEnabledScanners(ScanRequest scanRequest) {
List<VulnerabilityScanner> enabledScanners = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public void startBlockMerge(ScanRequest request, String url){
log.error(URL_INVALID, e);
}
}

HttpEntity<?> httpEntity = new HttpEntity<>(
getJSONStatus(PULL_REQUEST_STATUS, url, "Checkmarx Scan Initiated").toString(),
createAuthHeaders(request)
Expand Down

0 comments on commit b04dd63

Please sign in to comment.