From 086842f301bb1ad25ddbd0c99c7fa858e527a02a Mon Sep 17 00:00:00 2001 From: swatipersistent <99341045+swatipersistent@users.noreply.github.com> Date: Tue, 23 Jul 2024 07:09:16 +0530 Subject: [PATCH] check For Threshold Error (#264) --- .../cx/restclient/configuration/CxScanConfig.java | 13 +++++++++++-- .../cx/restclient/dto/scansummary/ScanSummary.java | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cx/restclient/configuration/CxScanConfig.java b/src/main/java/com/cx/restclient/configuration/CxScanConfig.java index b4642bac..be27495b 100644 --- a/src/main/java/com/cx/restclient/configuration/CxScanConfig.java +++ b/src/main/java/com/cx/restclient/configuration/CxScanConfig.java @@ -103,7 +103,8 @@ public void setprojectCustomFields(String projectCustomFields) { private Boolean osaRunInstall = false; private Boolean osaThresholdsEnabled = false; private Boolean osaFailOnError = false; - private Integer osaHighThreshold; + private Integer osaCriticalThreshold; + private Integer osaHighThreshold; private Integer osaMediumThreshold; private Integer osaLowThreshold; private Properties osaFsaConfig; //for MAVEN @@ -638,6 +639,14 @@ public Boolean isOsaFailOnError() { public void setOsaFailOnError(Boolean osaFailOnError) { this.osaFailOnError = osaFailOnError; } + + public Integer getOsaCriticalThreshold() { + return osaCriticalThreshold; + } + + public void setOsaCriticalThreshold(Integer osaCriticalThreshold) { + this.osaCriticalThreshold = osaCriticalThreshold; + } public Integer getOsaHighThreshold() { return osaHighThreshold; @@ -684,7 +693,7 @@ public boolean isSASTThresholdEffectivelyEnabled() { public boolean isOSAThresholdEffectivelyEnabled() { return (isOsaEnabled() || isAstScaEnabled()) && getOsaThresholdsEnabled() && - (getOsaHighThreshold() != null || getOsaMediumThreshold() != null || getOsaLowThreshold() != null); + (getOsaCriticalThreshold() != null || getOsaHighThreshold() != null || getOsaMediumThreshold() != null || getOsaLowThreshold() != null); } public void setOsaDependenciesJson(String osaDependenciesJson) { diff --git a/src/main/java/com/cx/restclient/dto/scansummary/ScanSummary.java b/src/main/java/com/cx/restclient/dto/scansummary/ScanSummary.java index 65bfeb29..d2a1010d 100644 --- a/src/main/java/com/cx/restclient/dto/scansummary/ScanSummary.java +++ b/src/main/java/com/cx/restclient/dto/scansummary/ScanSummary.java @@ -127,6 +127,9 @@ private void addDependencyScanThresholdErrors(CxScanConfig config, OSAResults os } if (hasSummary) { + if (scaResults != null) { + checkForThresholdError(totalCritical, config.getOsaCriticalThreshold(), errorSource, Severity.CRITICAL); + } checkForThresholdError(totalHigh, config.getOsaHighThreshold(), errorSource, Severity.HIGH); checkForThresholdError(totalMedium, config.getOsaMediumThreshold(), errorSource, Severity.MEDIUM); checkForThresholdError(totalLow, config.getOsaLowThreshold(), errorSource, Severity.LOW);