added scan-resubmit functionality for CLI mode
added scan-resubmit functionality for CLI mode.
@@ -249,7 +249,34 @@ public abstract class AbstractVulnerabilityScanner implements VulnerabilityScann
CxScanParams params = getScanRequestConverter().prepareScanParamsObject(request, cxFile, ownerId, projectId);
+ log.info("Checking if there is any existing scan for Project: {}", projectId);
+ Integer existingScanId = getScannerClient().getScanIdOfExistingScanIfExists(projectId);
+ log.info("----------existingScanId---------: {}", existingScanId);
+ if (existingScanId != UNKNOWN_INT) {
+ if(!getCxPropertiesBase().getScanQueuing()) {
+ Boolean scanResubmit = false;
+ if (request.getScanResubmit() != null) {
+ scanResubmit = Boolean.parseBoolean(request.getScanResubmit());
+ } else if (flowProperties.getScanResubmit()){
+ scanResubmit = flowProperties.getScanResubmit();
+ }
+ if (scanResubmit) {
+ log.info("Existing ongoing scan with id {} found for Project : {}", existingScanId, projectId);
+ log.info("Aborting the ongoing scan with id {} for Project: {}", existingScanId, projectId);
+ getScannerClient().cancelScan(existingScanId);
+ log.info("Resubmitting the scan for Project: {}", projectId);
scanId = getScannerClient().createScan(params, getComment(request));
+ } else {
+ log.warn("Property scan-resubmit set to {} : New scan not submitted, due to existing ongoing scan for the same Project id {}", flowProperties.getScanResubmit(), projectId);
+ bugTrackers.getBugTrackerEventTrigger().triggerScanNotSubmittedBugTrackerEvent(request, getEmptyScanResults());
+ throw new CheckmarxException(String.format("Active Scan with Id %d already exists for Project: %d", existingScanId, projectId));
+ }
+ }else {
+ scanId = getScannerClient().createScan(params, getComment(request));
+ }
+ } else {
+ scanId = getScannerClient().createScan(params, getComment(request));
+ }
osaScanId = createOsaScan(request, projectId);
