Skip to content

Commit

Permalink
Merge pull request #405 from checkmarx-ltd/develop
Browse files Browse the repository at this point in the history
Incremental Scan Issues
  • Loading branch information
satyamchaurasiapersistent authored May 28, 2024
2 parents fd52d57 + 1251546 commit 4dbc488
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.github.checkmarx-ltd</groupId>
<artifactId>cx-spring-boot-sdk</artifactId>
<version>0.6.7</version>
<version>0.6.8</version>


<name>cx-spring-boot-sdk</name>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/checkmarx/sdk/config/CxProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/checkmarx/sdk/service/CxService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> response = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, requestEntity, String.class);

Expand All @@ -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);
Expand Down

0 comments on commit 4dbc488

Please sign in to comment.