Skip to content

Commit

Permalink
ASPL-587 (#161)
Browse files Browse the repository at this point in the history
* Update ASEResultsProvider.java
  • Loading branch information
vishalhcl-5960 authored Jun 14, 2024
1 parent 094d179 commit f8119a6
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/main/java/com/hcl/appscan/sdk/results/ASEResultsProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* © Copyright HCL Technologies Ltd. 2019, 2020.
* © Copyright HCL Technologies Ltd. 2019, 2020, 2024.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down Expand Up @@ -161,40 +161,37 @@ private void loadResults() {
try {
m_status = getScanStatus(m_scanId);
// m_status = getStatisticsStatus(m_scanId);
if (m_status != null && m_status.equalsIgnoreCase("Ready")) {
m_message = "";
m_status=getReportPackStatus(m_scanId);
}
if(m_status != null && m_status.equalsIgnoreCase("Ready")) {
JSONObject obj = m_scanProvider.getScanDetails(m_scanId);
if (obj == null) {
if(m_status == null) {// In case of internet disconnect Status is set to null.
m_status = FAILED;
} else if (m_status.equalsIgnoreCase("Ready")) {
m_message = "";
m_status=getReportPackStatus(m_scanId);
JSONObject obj = m_scanProvider.getScanDetails(m_scanId);
if (obj == null) {
m_message = Messages.getMessage(RESULTS_UNAVAILABLE);
throw new NullPointerException(Messages.getMessage(RESULTS_UNAVAILABLE));
}

}
m_totalFindings = obj.getInt(TOTAL_ISSUES);
m_criticalFindings = obj.getInt(CRITICAL_ISSUES);
m_criticalFindings = obj.getInt(CRITICAL_ISSUES);
m_highFindings = obj.getInt(HIGH_ISSUES);
m_mediumFindings = obj.getInt(MEDIUM_ISSUES);
m_lowFindings = obj.getInt(LOW_ISSUES);
m_infoFindings = obj.getInt(INFO_ISSUES);
m_hasResults = true;
m_message = "";
}
if (RUNNING.equalsIgnoreCase(m_status)) {
} else if (RUNNING.equalsIgnoreCase(m_status)) {
m_message = "";
} else if (m_status != null && m_status.startsWith(SUSPENDED)) { // In case of Scan Failure ASE returns Suspended (With Reason) in Status
} else if (m_status.startsWith(SUSPENDED)) { // In case of Scan Failure ASE returns Suspended (With Reason) in Status
this.m_message = m_status;

String description = "";
boolean isSuspendedByUser = false;
if (m_status.contains("(") && m_status.contains(")")) {
description = m_status.substring(m_status.indexOf("(") + 1, m_status.indexOf(")"));
// If User Suspends(Pause) Job in ASE then it returns Suspended(By User) status message, Scan status is not set to FAILED
if ("by user".equals(description.toLowerCase())) {
m_progress.setStatus(new Message(Message.INFO, Messages.getMessage(SUSPEND_JOB_BYUSER, "Scan Name: " + m_scanName)));
m_message = Messages.getMessage(SUSPEND_JOB_BYUSER, "Scan Name: " + m_scanName);
isSuspendedByUser = true;
m_progress.setStatus(new Message(Message.INFO, Messages.getMessage(SUSPEND_JOB_BYUSER, "Scan Name: " + m_scanName)));
m_message = Messages.getMessage(SUSPEND_JOB_BYUSER, "Scan Name: " + m_scanName);
isSuspendedByUser = true;
}
}
// If Scan is not Paused by User and we get Suspended state from ASE, Job status is set to FAILED to determine Scan has FAILED in Jenkins
Expand All @@ -205,7 +202,7 @@ private void loadResults() {
}
}
} catch (IOException | JSONException | NullPointerException e) {
m_progress.setStatus(new Message(Message.ERROR, Messages.getMessage(ERROR_GETTING_DETAILS, e.getMessage())), e);
m_progress.setStatus(new Message(Message.ERROR, Messages.getMessage(ERROR_GETTING_DETAILS, e.getMessage())));
m_status = FAILED;
}
}
Expand Down

0 comments on commit f8119a6

Please sign in to comment.