diff --git a/pom.xml b/pom.xml index a8740af2..1589708e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.github.checkmarx-ltd cx-spring-boot-sdk - 0.6.7 + 0.6.8 cx-spring-boot-sdk diff --git a/src/main/java/com/checkmarx/sdk/config/CxProperties.java b/src/main/java/com/checkmarx/sdk/config/CxProperties.java index 6e215f32..32b7594d 100644 --- a/src/main/java/com/checkmarx/sdk/config/CxProperties.java +++ b/src/main/java/com/checkmarx/sdk/config/CxProperties.java @@ -100,6 +100,9 @@ public class CxProperties extends CxPropertiesBase{ @Getter @Setter private Boolean overrideProjectSetting = true; + @Getter @Setter + private Boolean considerScanningStatus = false; + /** * Maps finding state ID (as returned in CxSAST report) to state name (as specified in filter configuration). diff --git a/src/main/java/com/checkmarx/sdk/service/CxService.java b/src/main/java/com/checkmarx/sdk/service/CxService.java index 20e46adb..994b37c4 100644 --- a/src/main/java/com/checkmarx/sdk/service/CxService.java +++ b/src/main/java/com/checkmarx/sdk/service/CxService.java @@ -284,13 +284,20 @@ public JSONObject getScanData(String scanId) { log.info("Finding last Scan Id for project Id {}", projectId); try { - UriComponents uriComponents = UriComponentsBuilder + + UriComponents uriComponents = cxProperties.getConsiderScanningStatus() ? (UriComponentsBuilder .fromHttpUrl(cxProperties.getUrl()) .path(SCAN) .queryParam("projectId", projectId.toString()) - .queryParam("scanStatus", SCAN_STATUS_FINISHED.toString()) - .queryParam("last",cxProperties.getIncrementalNumScans().toString()) - .build(); + .queryParam("last", cxProperties.getIncrementalNumScans().toString()) + .build()) : (UriComponentsBuilder + .fromHttpUrl(cxProperties.getUrl()) + .path(SCAN) + .queryParam("projectId", projectId.toString()) + .queryParam("scanStatus", + SCAN_STATUS_FINISHED.toString()) + .queryParam("last", cxProperties.getIncrementalNumScans().toString()) + .build()); ResponseEntity response = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, requestEntity, String.class); @@ -304,7 +311,8 @@ public JSONObject getScanData(String scanId) { //example: "finishedOn": "2018-06-18T01:09:12.707", Grab only first 19 digits due to inconsistency of checkmarx results LocalDateTime d; try { - String finishedOn = dateAndTime.getString("finishedOn"); + String finishedOn = + cxProperties.getConsiderScanningStatus() ? dateAndTime.getString("startedOn") : dateAndTime.getString("finishedOn"); finishedOn = finishedOn.substring(0, 19); log.debug("finishedOn: {}", finishedOn); d = LocalDateTime.parse(finishedOn, formatter);