diff --git a/src/main/java/com/cx/restclient/ast/AstSastClient.java b/src/main/java/com/cx/restclient/ast/AstSastClient.java index 5a55f0cb..1ed93144 100644 --- a/src/main/java/com/cx/restclient/ast/AstSastClient.java +++ b/src/main/java/com/cx/restclient/ast/AstSastClient.java @@ -463,7 +463,10 @@ private static void setFindingCountsPerSeverity(List nativeCoun Severity parsedSeverity = EnumUtils.getEnum(Severity.class, counter.getSeverity()); int value = counter.getCounter(); if (parsedSeverity != null) { - if (parsedSeverity == Severity.HIGH) { + if (parsedSeverity == Severity.CRITICAL) { + target.setCriticalVulnerabilityCount(value); + } + else if (parsedSeverity == Severity.HIGH) { target.setHighVulnerabilityCount(value); } else if (parsedSeverity == Severity.MEDIUM) { target.setMediumVulnerabilityCount(value); diff --git a/src/main/java/com/cx/restclient/ast/AstScaClient.java b/src/main/java/com/cx/restclient/ast/AstScaClient.java index ba4c05e3..58d81383 100644 --- a/src/main/java/com/cx/restclient/ast/AstScaClient.java +++ b/src/main/java/com/cx/restclient/ast/AstScaClient.java @@ -1223,6 +1223,7 @@ private void printSummary(AstScaSummaryResults summary, String scanId) { log.info("----CxSCA risk report summary----"); log.info("Created on: {}", summary.getCreatedOn()); log.info("Direct packages: {}", summary.getDirectPackages()); + log.info("Critical vulnerabilities: {}", summary.getCriticalVulnerabilityCount()); log.info("High vulnerabilities: {}", summary.getHighVulnerabilityCount()); log.info("Medium vulnerabilities: {}", summary.getMediumVulnerabilityCount()); log.info("Low vulnerabilities: {}", summary.getLowVulnerabilityCount()); diff --git a/src/main/java/com/cx/restclient/ast/dto/common/SummaryResults.java b/src/main/java/com/cx/restclient/ast/dto/common/SummaryResults.java index 8fc296e4..cf9a6bfc 100644 --- a/src/main/java/com/cx/restclient/ast/dto/common/SummaryResults.java +++ b/src/main/java/com/cx/restclient/ast/dto/common/SummaryResults.java @@ -6,6 +6,7 @@ @Getter @Setter public class SummaryResults { + private int criticalVulnerabilityCount = 0; private int highVulnerabilityCount = 0; private int mediumVulnerabilityCount = 0; private int lowVulnerabilityCount = 0; diff --git a/src/main/java/com/cx/restclient/ast/dto/sca/AstScaResults.java b/src/main/java/com/cx/restclient/ast/dto/sca/AstScaResults.java index bc31bf12..c3d51848 100644 --- a/src/main/java/com/cx/restclient/ast/dto/sca/AstScaResults.java +++ b/src/main/java/com/cx/restclient/ast/dto/sca/AstScaResults.java @@ -170,7 +170,7 @@ public void calculateVulnerableAndOutdatedPackages() { int sum; if (this.packages != null) { for (Package pckg : this.packages) { - sum = pckg.getHighVulnerabilityCount() + pckg.getMediumVulnerabilityCount() + pckg.getLowVulnerabilityCount(); + sum = pckg.getCriticalVulnerabilityCount() + pckg.getHighVulnerabilityCount() + pckg.getMediumVulnerabilityCount() + pckg.getLowVulnerabilityCount(); if (sum == 0) { this.nonVulnerableLibraries++; } else if (sum > 0 && pckg.isOutdated()) { diff --git a/src/main/java/com/cx/restclient/ast/dto/sca/report/AstScaSummaryResults.java b/src/main/java/com/cx/restclient/ast/dto/sca/report/AstScaSummaryResults.java index a8435cca..e2275954 100644 --- a/src/main/java/com/cx/restclient/ast/dto/sca/report/AstScaSummaryResults.java +++ b/src/main/java/com/cx/restclient/ast/dto/sca/report/AstScaSummaryResults.java @@ -9,6 +9,7 @@ public class AstScaSummaryResults implements Serializable { private String createdOn; private double riskScore; private int totalOutdatedPackages; + private int criticalVulnerabilityCount = 0; private int highVulnerabilityCount = 0; private int mediumVulnerabilityCount = 0; private int lowVulnerabilityCount = 0; @@ -16,19 +17,20 @@ public class AstScaSummaryResults implements Serializable { public AstScaSummaryResults() { } - public AstScaSummaryResults(int totalPackages, int directPackages, String createdOn, double riskScore, int totalOutdatedPackages, int highVulnerabilityCount, int mediumVulnerabilityCount, int lowVulnerabilityCount) { + public AstScaSummaryResults(int totalPackages, int directPackages, String createdOn, double riskScore, int totalOutdatedPackages, int criticalVulnerabilityCount, int highVulnerabilityCount, int mediumVulnerabilityCount, int lowVulnerabilityCount) { this.totalPackages = totalPackages; this.directPackages = directPackages; this.createdOn = createdOn; this.riskScore = riskScore; this.totalOutdatedPackages = totalOutdatedPackages; + this.criticalVulnerabilityCount = criticalVulnerabilityCount; this.highVulnerabilityCount = highVulnerabilityCount; this.mediumVulnerabilityCount = mediumVulnerabilityCount; this.lowVulnerabilityCount = lowVulnerabilityCount; } public int getTotalOkLibraries() { - int totalOk = (totalPackages - (highVulnerabilityCount + mediumVulnerabilityCount + lowVulnerabilityCount)); + int totalOk = (totalPackages - (criticalVulnerabilityCount +highVulnerabilityCount + mediumVulnerabilityCount + lowVulnerabilityCount)); totalOk = Math.max(totalOk, 0); return totalOk; } @@ -72,6 +74,14 @@ public int getTotalOutdatedPackages() { public void setTotalOutdatedPackages(int totalOutdatedPackages) { this.totalOutdatedPackages = totalOutdatedPackages; } + + public int getCriticalVulnerabilityCount() { + return criticalVulnerabilityCount; + } + + public void setCriticalVulnerabilityCount(int criticalVulnerabilityCount) { + this.criticalVulnerabilityCount = criticalVulnerabilityCount; + } public int getHighVulnerabilityCount() { return highVulnerabilityCount; diff --git a/src/main/java/com/cx/restclient/ast/dto/sca/report/Package.java b/src/main/java/com/cx/restclient/ast/dto/sca/report/Package.java index beafe48a..8066126f 100644 --- a/src/main/java/com/cx/restclient/ast/dto/sca/report/Package.java +++ b/src/main/java/com/cx/restclient/ast/dto/sca/report/Package.java @@ -23,6 +23,7 @@ public class Package implements Serializable { */ private String matchType; + private int criticalVulnerabilityCount; private int highVulnerabilityCount; private int mediumVulnerabilityCount; private int lowVulnerabilityCount; diff --git a/src/main/java/com/cx/restclient/ast/dto/sca/report/PackageSeverity.java b/src/main/java/com/cx/restclient/ast/dto/sca/report/PackageSeverity.java index cc6410f8..44ef22b0 100644 --- a/src/main/java/com/cx/restclient/ast/dto/sca/report/PackageSeverity.java +++ b/src/main/java/com/cx/restclient/ast/dto/sca/report/PackageSeverity.java @@ -8,5 +8,6 @@ public enum PackageSeverity { LOW, MEDIUM, - HIGH + HIGH, + CRITICAL } diff --git a/src/main/java/com/cx/restclient/common/summary/DependencyScanResult.java b/src/main/java/com/cx/restclient/common/summary/DependencyScanResult.java index bbafb917..8b75c788 100644 --- a/src/main/java/com/cx/restclient/common/summary/DependencyScanResult.java +++ b/src/main/java/com/cx/restclient/common/summary/DependencyScanResult.java @@ -17,6 +17,7 @@ public class DependencyScanResult extends Results implements Serializable { private ScannerType scannerType; private boolean resultReady; + private int criticalVulnerability; private int highVulnerability; private int mediumVulnerability; private int lowVulnerability; @@ -25,6 +26,7 @@ public class DependencyScanResult extends Results implements Serializable { private int nonVulnerableLibraries; private String scanStartTime; private String scanEndTime; + private List dependencyCriticalCVEReportTable = new ArrayList<>(); private List dependencyHighCVEReportTable = new ArrayList<>(); private List dependencyMediumCVEReportTable = new ArrayList<>(); private List dependencyLowCVEReportTable = new ArrayList<>(); @@ -35,6 +37,7 @@ public class DependencyScanResult extends Results implements Serializable { DependencyScanResult(AstScaResults scaResults){ scaResults.calculateVulnerableAndOutdatedPackages(); this.scannerType = ScannerType.AST_SCA; + this.criticalVulnerability = scaResults.getSummary().getCriticalVulnerabilityCount(); this.highVulnerability = scaResults.getSummary().getHighVulnerabilityCount(); this.mediumVulnerability = scaResults.getSummary().getMediumVulnerabilityCount(); this.lowVulnerability = scaResults.getSummary().getLowVulnerabilityCount(); @@ -51,6 +54,7 @@ public class DependencyScanResult extends Results implements Serializable { DependencyScanResult(OSAResults osaResults){ this.scannerType = ScannerType.OSA; + this.criticalVulnerability = osaResults.getResults().getTotalCriticalVulnerabilities(); this.highVulnerability = osaResults.getResults().getTotalHighVulnerabilities(); this.mediumVulnerability = osaResults.getResults().getTotalMediumVulnerabilities(); this.lowVulnerability = osaResults.getResults().getTotalLowVulnerabilities(); @@ -60,11 +64,11 @@ public class DependencyScanResult extends Results implements Serializable { this.nonVulnerableLibraries = osaResults.getResults().getNonVulnerableLibraries(); this.scanStartTime =osaResults.getScanStartTime(); this.scanEndTime = osaResults.getScanEndTime(); - this.setDependencyCVEReportTableOsa(osaResults.getOsaLowCVEReportTable(),osaResults.getOsaMediumCVEReportTable(),osaResults.getOsaHighCVEReportTable()); + this.setDependencyCVEReportTableOsa(osaResults.getOsaLowCVEReportTable(),osaResults.getOsaMediumCVEReportTable(),osaResults.getOsaHighCVEReportTable(),osaResults.getOsaCriticalCVEReportTable()); this.setTotalLibraries(osaResults.getResults().getTotalLibraries()); } - public void setDependencyCVEReportTableOsa(List osaCVEResultsLow,List osaCVEResultsMedium,List osaCVEResultsHigh){ + public void setDependencyCVEReportTableOsa(List osaCVEResultsLow,List osaCVEResultsMedium,List osaCVEResultsHigh, List osaCVEResultsCritical){ CVEReportTableRow row; for(CVEReportTableRow lowCVE :osaCVEResultsLow ){ row = lowCVE; @@ -78,6 +82,10 @@ public void setDependencyCVEReportTableOsa(List osaCVEResults row = highCVE; this.dependencyHighCVEReportTable.add(row); } + for(CVEReportTableRow criticalCVE :osaCVEResultsCritical ){ + row = criticalCVE; + this.dependencyCriticalCVEReportTable.add(row); + } } public void setDependencyCVEReportTableSCA(List scaFindings){ @@ -90,6 +98,8 @@ public void setDependencyCVEReportTableSCA(List scaFindings){ this.dependencyMediumCVEReportTable.add(row); }else if(scaFinding.getSeverity() == Severity.HIGH){ this.dependencyHighCVEReportTable.add(row); + }else if(scaFinding.getSeverity() == Severity.CRITICAL){ + this.dependencyCriticalCVEReportTable.add(row); } } } @@ -109,6 +119,14 @@ public boolean isResultReady() { public void setResultReady(boolean resultReady) { this.resultReady = resultReady; } + + public int getCriticalVulnerability() { + return criticalVulnerability; + } + + public void setCriticalVulnerability(int criticalVulnerability) { + this.criticalVulnerability = criticalVulnerability; + } public int getHighVulnerability() { return highVulnerability; @@ -173,6 +191,14 @@ public String getScanEndTime() { public void setScanEndTime(String scanEndTime) { this.scanEndTime = scanEndTime; } + + public List getDependencyCriticalCVEReportTable() { + return dependencyCriticalCVEReportTable; + } + + public void setDependencyCriticalCVEReportTable(List dependencyCriticalCVEReportTable) { + this.dependencyCriticalCVEReportTable = dependencyCriticalCVEReportTable; + } public List getDependencyHighCVEReportTable() { return dependencyHighCVEReportTable; diff --git a/src/main/java/com/cx/restclient/common/summary/SummaryUtils.java b/src/main/java/com/cx/restclient/common/summary/SummaryUtils.java index 9bb90871..dfa84844 100644 --- a/src/main/java/com/cx/restclient/common/summary/SummaryUtils.java +++ b/src/main/java/com/cx/restclient/common/summary/SummaryUtils.java @@ -169,6 +169,7 @@ else if(config.isOsaEnabled()) } //calculate dependency results bars: + int dependencyCritical = dependencyScanResult.getCriticalVulnerability(); int dependencyHigh = dependencyScanResult.getHighVulnerability(); int dependencyMedium = dependencyScanResult.getMediumVulnerability(); int dependencyLow = dependencyScanResult.getLowVulnerability(); @@ -176,10 +177,12 @@ else if(config.isOsaEnabled()) float dependencyBarNorm = dependencyMaxCount * 10f / 9f; + float dependencyCriticalTotalHeight = (float) dependencyCritical / dependencyBarNorm * 238f; float dependencyHighTotalHeight = (float) dependencyHigh / dependencyBarNorm * 238f; float dependencyMediumTotalHeight = (float) dependencyMedium / dependencyBarNorm * 238f; float dependencyLowTotalHeight = (float) dependencyLow / dependencyBarNorm * 238f; + templateData.put("dependencyCriticalTotalHeight", dependencyCriticalTotalHeight); templateData.put("dependencyHighTotalHeight", dependencyHighTotalHeight); templateData.put("dependencyMediumTotalHeight", dependencyMediumTotalHeight); templateData.put("dependencyLowTotalHeight", dependencyLowTotalHeight); diff --git a/src/main/java/com/cx/restclient/configuration/CxScanConfig.java b/src/main/java/com/cx/restclient/configuration/CxScanConfig.java index 07c58646..b20850d7 100644 --- a/src/main/java/com/cx/restclient/configuration/CxScanConfig.java +++ b/src/main/java/com/cx/restclient/configuration/CxScanConfig.java @@ -65,7 +65,8 @@ public void setShowCriticalLabel(boolean showCriticalLabel) { private Boolean isIncremental = false; private Boolean isSynchronous = false; private Boolean sastThresholdsEnabled = false; - private Integer sastCriticalThreshold; + private Boolean sastEnableCriticalSeverity = false; + private Integer sastCriticalThreshold; private Integer sastHighThreshold; private Integer sastMediumThreshold; private Integer sastLowThreshold; @@ -102,6 +103,7 @@ public void setprojectCustomFields(String projectCustomFields) { private Boolean osaRunInstall = false; private Boolean osaThresholdsEnabled = false; private Boolean osaFailOnError = false; + private Integer osaCriticalThreshold; private Integer osaHighThreshold; private Integer osaMediumThreshold; private Integer osaLowThreshold; @@ -498,6 +500,15 @@ public Boolean getSynchronous() { public void setSynchronous(Boolean synchronous) { this.isSynchronous = synchronous; } + + public Boolean getSastEnableCriticalSeverity() { + return sastEnableCriticalSeverity; + } + + public void setSastEnableCriticalSeverity(Boolean sastEnableCriticalSeverity) { + this.sastEnableCriticalSeverity = sastEnableCriticalSeverity; + } + public Boolean getSastThresholdsEnabled() { return sastThresholdsEnabled; @@ -626,6 +637,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; @@ -672,7 +691,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 8fdb121d..219781c3 100644 --- a/src/main/java/com/cx/restclient/dto/scansummary/ScanSummary.java +++ b/src/main/java/com/cx/restclient/dto/scansummary/ScanSummary.java @@ -101,6 +101,7 @@ private void addDependencyScanThresholdErrors(CxScanConfig config, OSAResults os if (config.isOSAThresholdEffectivelyEnabled() && (scaResults != null || osaResults != null)) { ErrorSource errorSource = osaResults != null ? ErrorSource.OSA : ErrorSource.SCA; + int totalCritical = 0; int totalHigh = 0; int totalMedium = 0; int totalLow = 0; @@ -110,6 +111,7 @@ private void addDependencyScanThresholdErrors(CxScanConfig config, OSAResults os AstScaSummaryResults summary = scaResults.getSummary(); if (summary != null) { hasSummary = true; + totalCritical = summary.getCriticalVulnerabilityCount(); totalHigh = summary.getHighVulnerabilityCount(); totalMedium = summary.getMediumVulnerabilityCount(); totalLow = summary.getLowVulnerabilityCount(); @@ -118,6 +120,7 @@ private void addDependencyScanThresholdErrors(CxScanConfig config, OSAResults os OSASummaryResults summary = osaResults.getResults(); if (summary != null) { hasSummary = true; + totalCritical = summary.getTotalCriticalVulnerabilities(); totalHigh = summary.getTotalHighVulnerabilities(); totalMedium = summary.getTotalMediumVulnerabilities(); totalLow = summary.getTotalLowVulnerabilities(); @@ -125,6 +128,7 @@ private void addDependencyScanThresholdErrors(CxScanConfig config, OSAResults os } if (hasSummary) { + 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); diff --git a/src/main/java/com/cx/restclient/osa/dto/Library.java b/src/main/java/com/cx/restclient/osa/dto/Library.java index e12195dd..cd3a6f83 100644 --- a/src/main/java/com/cx/restclient/osa/dto/Library.java +++ b/src/main/java/com/cx/restclient/osa/dto/Library.java @@ -11,6 +11,8 @@ public class Library implements Serializable { private String id;//:"36b32b00-9ee6-4e2f-85c9-3f03f26519a9", private String name;//:"lib-name", private String version;//:"lib-version", + @JsonProperty("criticalUniqueVulnerabilityCount") + private int criticalVulnerabilityCount;//:1, @JsonProperty("highUniqueVulnerabilityCount") private int highVulnerabilityCount;//:1, @JsonProperty("mediumUniqueVulnerabilityCount") @@ -46,6 +48,14 @@ public String getVersion() { public void setVersion(String version) { this.version = version; } + + public int getCriticalVulnerabilityCount() { + return this.criticalVulnerabilityCount; + } + + public void setCriticalVulnerabilityCount(int criticalVulnerabilityCount) { + this.criticalVulnerabilityCount = criticalVulnerabilityCount; + } public int getHighVulnerabilityCount() { return this.highVulnerabilityCount; diff --git a/src/main/java/com/cx/restclient/osa/dto/OSAResults.java b/src/main/java/com/cx/restclient/osa/dto/OSAResults.java index 039eeea6..14cd92f4 100644 --- a/src/main/java/com/cx/restclient/osa/dto/OSAResults.java +++ b/src/main/java/com/cx/restclient/osa/dto/OSAResults.java @@ -25,6 +25,7 @@ public class OSAResults extends Results implements Serializable { private OSAScanStatus osaScanStatus; private String osaProjectSummaryLink; private boolean osaResultsReady = false; + private List osaCriticalCVEReportTable = new ArrayList(); private List osaHighCVEReportTable = new ArrayList(); private List osaMediumCVEReportTable = new ArrayList(); private List osaLowCVEReportTable = new ArrayList(); @@ -111,6 +112,10 @@ public String getOsaScanId() { public void setOsaScanId(String osaScanId) { this.osaScanId = osaScanId; } + + public List getOsaCriticalCVEReportTable() { + return osaCriticalCVEReportTable; + } public List getOsaHighCVEReportTable() { return osaHighCVEReportTable; @@ -148,7 +153,10 @@ private void setOsaCVEReportTable(List osaVulnerabilities, List os } for (CVEReportTableRow row : cveMap.values()) { - if ("High".equals(row.getSeverity())) { + if ("Critical".equals(row.getSeverity())) { + osaCriticalCVEReportTable.add(row); + } + else if ("High".equals(row.getSeverity())) { osaHighCVEReportTable.add(row); } else if ("Medium".equals(row.getSeverity())) { osaMediumCVEReportTable.add(row); @@ -163,6 +171,10 @@ public void setDates(OSAScanStatus status) { this.scanStartTime = formatDate(status.getStartAnalyzeTime(), "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS", "dd/MM/yy HH:mm"); this.scanEndTime = formatDate(status.getEndAnalyzeTime(), "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS", "dd/MM/yy HH:mm"); } + + public void setOsaCriticalCVEReportTable(List osaCriticalCVEReportTable) { + this.osaCriticalCVEReportTable = osaCriticalCVEReportTable; + } public void setOsaHighCVEReportTable(List osaHighCVEReportTable) { this.osaHighCVEReportTable = osaHighCVEReportTable; diff --git a/src/main/java/com/cx/restclient/osa/dto/OSASummaryResults.java b/src/main/java/com/cx/restclient/osa/dto/OSASummaryResults.java index 3f68d0bf..0ad3da65 100644 --- a/src/main/java/com/cx/restclient/osa/dto/OSASummaryResults.java +++ b/src/main/java/com/cx/restclient/osa/dto/OSASummaryResults.java @@ -12,6 +12,7 @@ public class OSASummaryResults implements Serializable { private int totalLibraries; + private int criticalVulnerabilityLibraries; private int highVulnerabilityLibraries; private int mediumVulnerabilityLibraries; private int lowVulnerabilityLibraries; @@ -19,6 +20,7 @@ public class OSASummaryResults implements Serializable { private int vulnerableAndUpdated; private int vulnerableAndOutdated; private String vulnerabilityScore; + private int totalCriticalVulnerabilities; private int totalHighVulnerabilities; private int totalMediumVulnerabilities; private int totalLowVulnerabilities; @@ -30,6 +32,14 @@ public int getTotalLibraries() { public void setTotalLibraries(int totalLibraries) { this.totalLibraries = totalLibraries; } + + public int getCriticalVulnerabilityLibraries() { + return criticalVulnerabilityLibraries; + } + + public void setCriticalVulnerabilityLibraries(int criticalVulnerabilityLibraries) { + this.criticalVulnerabilityLibraries = criticalVulnerabilityLibraries; + } public int getHighVulnerabilityLibraries() { return highVulnerabilityLibraries; @@ -86,6 +96,14 @@ public String getVulnerabilityScore() { public void setVulnerabilityScore(String vulnerabilityScore) { this.vulnerabilityScore = vulnerabilityScore; } + + public int getTotalCriticalVulnerabilities() { + return totalCriticalVulnerabilities; + } + + public void setTotalCriticalVulnerabilities(int totalCriticalVulnerabilities) { + this.totalCriticalVulnerabilities = totalCriticalVulnerabilities; + } public int getTotalHighVulnerabilities() { return totalHighVulnerabilities; diff --git a/src/main/java/com/cx/restclient/osa/dto/ScanConfiguration.java b/src/main/java/com/cx/restclient/osa/dto/ScanConfiguration.java index 92b605b7..73e57b5b 100644 --- a/src/main/java/com/cx/restclient/osa/dto/ScanConfiguration.java +++ b/src/main/java/com/cx/restclient/osa/dto/ScanConfiguration.java @@ -32,6 +32,7 @@ public class ScanConfiguration { private boolean isIncremental = false; private boolean isSynchronous = false; private boolean thresholdsEnabled = false; + private Integer criticalThreshold; private Integer highThreshold; private Integer mediumThreshold; private Integer lowThreshold; @@ -41,6 +42,7 @@ public class ScanConfiguration { private String osaArchiveIncludePatterns; private boolean osaInstallBeforeScan; private boolean osaThresholdsEnabled = false; + private Integer osaCriticalThreshold; private Integer osaHighThreshold; private Integer osaMediumThreshold; private Integer osaLowThreshold; @@ -191,6 +193,18 @@ public boolean isThresholdsEnabled() { public void setThresholdsEnabled(boolean thresholdsEnabled) { this.thresholdsEnabled = thresholdsEnabled; } + + public Integer getCriticalThreshold() { + return criticalThreshold; + } + + public void setCriticalThreshold(Integer criticalThreshold) { + this.criticalThreshold = criticalThreshold; + } + + private void setCriticalThreshold(String criticalSeveritiesThreshold) { + this.criticalThreshold = getAsInteger(criticalSeveritiesThreshold); + } public Integer getHighThreshold() { return highThreshold; @@ -291,6 +305,18 @@ public boolean isOsaThresholdsEnabled() { public void setOsaThresholdsEnabled(boolean osaThresholdsEnabled) { this.osaThresholdsEnabled = osaThresholdsEnabled; } + + public Integer getOsaCriticalThreshold() { + return osaCriticalThreshold; + } + + public void setOsaCriticalThreshold(Integer osaCriticalThreshold) { + this.osaCriticalThreshold = osaCriticalThreshold; + } + + private void setOsaCriticalSeveritiesThreshold(String osaCriticalSeveritiesThreshold) { + this.osaCriticalThreshold = getAsInteger(osaCriticalSeveritiesThreshold); + } public Integer getOsaHighThreshold() { return osaHighThreshold; @@ -341,11 +367,11 @@ private Integer getAsInteger(String number) { } public boolean isSASTThresholdEffectivelyEnabled() { - return isThresholdsEnabled() && (getLowThreshold() != null || getMediumThreshold() != null || getHighThreshold() != null); + return isThresholdsEnabled() && (getLowThreshold() != null || getMediumThreshold() != null || getHighThreshold() != null || getCriticalThreshold() != null); } public boolean isOSAThresholdEffectivelyEnabled() { - return isOsaEnabled() && isOsaThresholdsEnabled() && (getOsaHighThreshold() != null || getOsaMediumThreshold() != null || getOsaLowThreshold() != null); + return isOsaEnabled() && isOsaThresholdsEnabled() && (getOsaCriticalThreshold() != null || getOsaHighThreshold() != null || getOsaMediumThreshold() != null || getOsaLowThreshold() != null); } public String getReportsDir() { diff --git a/src/main/java/com/cx/restclient/osa/utils/OSAUtils.java b/src/main/java/com/cx/restclient/osa/utils/OSAUtils.java index e340baf0..93f546f1 100644 --- a/src/main/java/com/cx/restclient/osa/utils/OSAUtils.java +++ b/src/main/java/com/cx/restclient/osa/utils/OSAUtils.java @@ -135,6 +135,7 @@ public static void printOSAResultsToConsole(OSAResults osaResults, boolean enabl log.info("------------------------"); log.info("Vulnerabilities Summary:"); log.info("------------------------"); + log.info("OSA critical severity results: " + osaSummaryResults.getTotalCriticalVulnerabilities()); log.info("OSA high severity results: " + osaSummaryResults.getTotalHighVulnerabilities()); log.info("OSA medium severity results: " + osaSummaryResults.getTotalMediumVulnerabilities()); log.info("OSA low severity results: " + osaSummaryResults.getTotalLowVulnerabilities()); diff --git a/src/main/resources/com/cx/report/report.ftl b/src/main/resources/com/cx/report/report.ftl index bd66b596..4924a1be 100644 --- a/src/main/resources/com/cx/report/report.ftl +++ b/src/main/resources/com/cx/report/report.ftl @@ -1516,6 +1516,76 @@
    + + +
  • + +
    + <#if config.osaThresholdsEnabled && config.osaCriticalThreshold??> + <@thresholdTooltip threshold=config.osaCriticalThreshold count=dependencyResult.criticakVulnerability/> + +
    +
    +
    +
    +
    + + + Med + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    Critical -
    +
    ${dependencyResult.criticalVulnerability}
    +
    +
    +
  • + +
    • + +