com.cx.restclient.common.summary.DependencyScanResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cx-client-common Show documentation
Show all versions of cx-client-common Show documentation
Web client for interaction with Checkmarx SAST, SCA and OSA products
The newest version!
package com.cx.restclient.common.summary;
import com.cx.restclient.dto.Results;
import com.cx.restclient.dto.ScannerType;
import com.cx.restclient.dto.scansummary.Severity;
import com.cx.restclient.osa.dto.CVEReportTableRow;
import com.cx.restclient.osa.dto.OSAResults;
import com.cx.restclient.ast.dto.sca.AstScaResults;
import com.cx.restclient.ast.dto.sca.report.Finding;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import static com.cx.restclient.common.ShragaUtils.formatDate;
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;
private String summaryLink;
private int vulnerableAndOutdated;
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<>();
private int totalLibraries;
DependencyScanResult(){}
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();
this.resultReady = scaResults.isScaResultReady();
this.summaryLink = scaResults.getWebReportLink();
this.vulnerableAndOutdated = scaResults.getVulnerableAndOutdated();
this.nonVulnerableLibraries = scaResults.getNonVulnerableLibraries();
this.scanStartTime = formatDate(scaResults.getSummary().getCreatedOn(), "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS", "dd/MM/yy HH:mm");
this.scanEndTime ="";
this.setDependencyCVEReportTableSCA(scaResults.getFindings());
this.setTotalLibraries(scaResults.getSummary().getTotalPackages());
}
DependencyScanResult(OSAResults osaResults){
this.scannerType = ScannerType.OSA;
this.highVulnerability = osaResults.getResults().getTotalHighVulnerabilities();
this.mediumVulnerability = osaResults.getResults().getTotalMediumVulnerabilities();
this.lowVulnerability = osaResults.getResults().getTotalLowVulnerabilities();
this.resultReady = osaResults.isOsaResultsReady();
this.summaryLink = osaResults.getOsaProjectSummaryLink();
this.vulnerableAndOutdated = osaResults.getResults().getVulnerableAndOutdated();
this.nonVulnerableLibraries = osaResults.getResults().getNonVulnerableLibraries();
this.scanStartTime =osaResults.getScanStartTime();
this.scanEndTime = osaResults.getScanEndTime();
this.setDependencyCVEReportTableOsa(osaResults.getOsaLowCVEReportTable(),osaResults.getOsaMediumCVEReportTable(),osaResults.getOsaHighCVEReportTable(),osaResults.getOsaCriticalCVEReportTable());
this.setTotalLibraries(osaResults.getResults().getTotalLibraries());
}
public void setDependencyCVEReportTableOsa(List osaCVEResultsLow,List osaCVEResultsMedium,List osaCVEResultsHigh, List osaCVEResultsCritical){
CVEReportTableRow row;
for(CVEReportTableRow lowCVE :osaCVEResultsLow ){
row = lowCVE;
this.dependencyLowCVEReportTable.add(row);
}
for(CVEReportTableRow mediumCVE :osaCVEResultsMedium ){
row = mediumCVE;
this.dependencyMediumCVEReportTable.add(row);
}
for(CVEReportTableRow highCVE :osaCVEResultsHigh ){
row = highCVE;
this.dependencyHighCVEReportTable.add(row);
}
for(CVEReportTableRow criticalCVE :osaCVEResultsCritical ){
row = criticalCVE;
this.dependencyCriticalCVEReportTable.add(row);
}
}
public void setDependencyCVEReportTableSCA(List scaFindings){
CVEReportTableRow row;
for(Finding scaFinding :scaFindings ){
row =new CVEReportTableRow(scaFinding);
if(scaFinding.getSeverity() == Severity.LOW){
this.dependencyLowCVEReportTable.add(row);
}else if(scaFinding.getSeverity() == Severity.MEDIUM){
this.dependencyMediumCVEReportTable.add(row);
}else if(scaFinding.getSeverity() == Severity.HIGH){
this.dependencyHighCVEReportTable.add(row);
}else if(scaFinding.getSeverity() == Severity.CRITICAL){
this.dependencyCriticalCVEReportTable.add(row);
}
}
}
public ScannerType getScannerType() {
return scannerType;
}
public void setScannerType(ScannerType scannerType) {
this.scannerType = scannerType;
}
public boolean isResultReady() {
return resultReady;
}
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;
}
public void setHighVulnerability(int highVulnerability) {
this.highVulnerability = highVulnerability;
}
public int getMediumVulnerability() {
return mediumVulnerability;
}
public void setMediumVulnerability(int mediumVulnerability) {
this.mediumVulnerability = mediumVulnerability;
}
public int getLowVulnerability() {
return lowVulnerability;
}
public void setLowVulnerability(int lowVulnerability) {
this.lowVulnerability = lowVulnerability;
}
public String getSummaryLink() {
return summaryLink;
}
public void setSummaryLink(String summaryLink) {
this.summaryLink = summaryLink;
}
public int getVulnerableAndOutdated() {
return vulnerableAndOutdated;
}
public void setVulnerableAndOutdated(int vulnerableAndOutdated) {
this.vulnerableAndOutdated = vulnerableAndOutdated;
}
public int getNonVulnerableLibraries() {
return nonVulnerableLibraries;
}
public void setNonVulnerableLibraries(int nonVulnerableLibraries) {
this.nonVulnerableLibraries = nonVulnerableLibraries;
}
public String getScanStartTime() {
return scanStartTime;
}
public void setScanStartTime(String scanStartTime) {
this.scanStartTime = scanStartTime;
}
public String getScanEndTime() {
return scanEndTime;
}
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;
}
public void setDependencyHighCVEReportTable(List dependencyHighCVEReportTable) {
this.dependencyHighCVEReportTable = dependencyHighCVEReportTable;
}
public List getDependencyMediumCVEReportTable() {
return dependencyMediumCVEReportTable;
}
public void setDependencyMediumCVEReportTable(List dependencyMediumCVEReportTable) {
this.dependencyMediumCVEReportTable = dependencyMediumCVEReportTable;
}
public List getDependencyLowCVEReportTable() {
return dependencyLowCVEReportTable;
}
public void setDependencyLowCVEReportTable(List dependencyLowCVEReportTable) {
this.dependencyLowCVEReportTable = dependencyLowCVEReportTable;
}
public int getTotalLibraries() {
return totalLibraries;
}
public void setTotalLibraries(int totalLibraries) {
this.totalLibraries = totalLibraries;
}
}