Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 345 summary in reports #2156

Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5100a67
Add summary table #345
zigfridus Apr 10, 2023
1899d25
Add possibility to click on results in the summary table #345
zigfridus Apr 10, 2023
d4d1a83
The draft summary table in a HTML report #345
zigfridus Apr 27, 2023
e120a14
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Apr 27, 2023
6b4f0a3
Merge branch 'feature-345-summary-in-reports' of https://github.com/z…
zigfridus Apr 27, 2023
8d6f949
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus May 16, 2023
8c8badd
Some improvements and fixes #345:
zigfridus May 16, 2023
3b7d863
Added summary section into report #345
zigfridus May 24, 2023
8e73dc2
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus May 26, 2023
70ea329
Added a details section the child of summary section into report #345
zigfridus May 26, 2023
be03972
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Jul 19, 2023
6446141
Improvement of html and json reports #345
zigfridus Jul 19, 2023
15e3bbf
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Aug 4, 2023
0fe8d85
Minor fixes and improvements #345
zigfridus Aug 4, 2023
d57c6ee
Enabled github's workflow test #345
zigfridus Aug 5, 2023
07bf0ee
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Aug 16, 2023
a039d35
Fixed some tests and html templates #345
zigfridus Aug 16, 2023
a445501
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Aug 24, 2023
e22c483
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Sep 8, 2023
690dbad
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Oct 6, 2023
4595649
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Oct 10, 2023
3efa782
Modified tests for the new report from #345
zigfridus Oct 27, 2023
ee84a7c
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Oct 27, 2023
9a933f9
Merge branch 'feature-345-temp' into feature-345-summary-in-reports
zigfridus Oct 28, 2023
3b618b3
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Oct 30, 2023
228dc45
Merge remote-tracking branch 'refs/remotes/origin/feature-345-summary…
zigfridus Oct 30, 2023
983f58d
Fixed some tests and html templates #345
zigfridus Nov 2, 2023
f5406f8
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Nov 2, 2023
8883070
Merge remote-tracking branch 'refs/remotes/origin/feature-345-summary…
zigfridus Nov 2, 2023
560b6d4
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
2119dd0
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
de9a510
Update sechub-scan/src/test/java/com/mercedesbenz/sechub/domain/scan/…
zigfridus Nov 2, 2023
145b073
Update sechub-scan/src/test/java/com/mercedesbenz/sechub/domain/scan/…
zigfridus Nov 2, 2023
a9af1db
Update sechub-scan/src/test/java/com/mercedesbenz/sechub/domain/scan/…
zigfridus Nov 2, 2023
fa7fed8
Update sechub-scan/src/main/resources/templates/report/html/scanresul…
zigfridus Nov 2, 2023
1b33a68
Update sechub-scan/src/main/resources/templates/report/html/scanresul…
zigfridus Nov 2, 2023
8c5a8b0
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
7f791c9
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
30c719c
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
01d06c5
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
c6fcc75
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
5b22630
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
f4cbf11
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
fc221ff
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
8c6fad0
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
2e32976
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
72b4d82
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
106ed2f
Update sechub-scan/src/main/resources/templates/report/html/scanresul…
zigfridus Nov 2, 2023
9b83ae7
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
48b0359
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
6472fce
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
8d49cc8
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
a9bdd22
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
d1295a9
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
a9e8bdb
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
708ee95
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
98e6464
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
2888d06
Update sechub-commons-model/src/test/java/com/mercedesbenz/sechub/com…
zigfridus Nov 2, 2023
02fdfa5
Minor modifications in some tests #345
zigfridus Nov 2, 2023
aaeeedd
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Nov 22, 2023
98bef78
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
zigfridus Nov 26, 2023
6999d6a
Fixed bug when critical, info and unclassified findings shown incorre…
zigfridus Nov 26, 2023
59f4918
Fixed some inaccuracies. #345
zigfridus Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ public class SecHubReportMetaData {

private Map<String, String> labels = new LinkedHashMap<>();

private SecHubReportSummary summary = new SecHubReportSummary();

public Map<String, String> getLabels() {
return labels;
}

public SecHubReportSummary getSummary() {
return summary;
}

public void setSummary(SecHubReportSummary summary) {
this.summary = summary;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class SecHubReportScan {
zigfridus marked this conversation as resolved.
Show resolved Hide resolved

private long total = 0;
private long red = 0;
private long yellow = 0;
private long green = 0;
private SecHubReportScanDetails details = new SecHubReportScanDetails();

public void reportScanHelper(SecHubFinding finding) {
incrementColors(finding);
details.detailsHelper(finding);
}

public void incrementColors(SecHubFinding finding) {
Severity severity = finding.getSeverity();
switch (severity) {
case HIGH -> incrementRedCount();
case MEDIUM -> incrementYellowCount();
case LOW, INFO -> incrementGreenCount();
}
incrementTotalCount();
}

protected void incrementRedCount() {
this.red++;
}

protected void incrementYellowCount() {
this.yellow++;
}

protected void incrementGreenCount() {
this.green++;
}

protected void incrementTotalCount() {
this.total++;
}

public long getTotal() {
return total;
}

public long getRed() {
return red;
}

public long getYellow() {
return yellow;
}

public long getGreen() {
return green;
}

public SecHubReportScanDetails getDetails() {
return details;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class SecHubReportScanDetails {
zigfridus marked this conversation as resolved.
Show resolved Hide resolved
private List<SeverityDetails> high = new ArrayList<>();
private List<SeverityDetails> medium = new ArrayList<>();
private List<SeverityDetails> low = new ArrayList<>();

public void detailsHelper(SecHubFinding finding) {
switch (finding.getSeverity()) {
case HIGH -> detailsFiller(high, finding);
case MEDIUM -> detailsFiller(medium, finding);
case LOW, INFO -> detailsFiller(low, finding);
}
}

private void detailsFiller(List<SeverityDetails> severityDetailsList, SecHubFinding finding) {
boolean fl = false;
zigfridus marked this conversation as resolved.
Show resolved Hide resolved
int i = 0;
while (fl == false && i < severityDetailsList.size()) {
zigfridus marked this conversation as resolved.
Show resolved Hide resolved
SeverityDetails details = severityDetailsList.get(i);
if (details.getCweId().equals(finding.getCweId())) {
details.incrementCount();
fl = true;
}
i++;
}
if (fl == false) {
severityDetailsList.add(new SeverityDetails(finding.getCweId(), finding.getName()));
}
}

public List<SeverityDetails> getHigh() {
return high;
}

public List<SeverityDetails> getMedium() {
return medium;
}

public List<SeverityDetails> getLow() {
return low;
}

@JsonIgnoreProperties(ignoreUnknown = true)
private class SeverityDetails {
private Integer cweId;
private String name;
private long count;

SeverityDetails(Integer cweId, String name) {
this.cweId = cweId;
this.name = name;
this.count = 1;
}

public void incrementCount() {
this.count++;
}

public Integer getCweId() {
return cweId;
}

public String getName() {
return name;
}

public long getCount() {
return count;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.commons.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class SecHubReportSummary {
zigfridus marked this conversation as resolved.
Show resolved Hide resolved

SecHubReportScan codeScan = new SecHubReportScan();
SecHubReportScan infraScan = new SecHubReportScan();
SecHubReportScan webScan = new SecHubReportScan();

public SecHubReportScan getCodeScan() {
return codeScan;
}

public void setCodeScan(SecHubReportScan codeScan) {
this.codeScan = codeScan;
}

public SecHubReportScan getInfraScan() {
return infraScan;
}

public void setInfraScan(SecHubReportScan infraScan) {
this.infraScan = infraScan;
}

public SecHubReportScan getWebScan() {
return webScan;
}

public void setWebScan(SecHubReportScan webScan) {
this.webScan = webScan;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
package com.mercedesbenz.sechub.domain.scan;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -14,10 +11,7 @@
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import com.mercedesbenz.sechub.commons.model.SecHubFinding;
import com.mercedesbenz.sechub.commons.model.SecHubResult;
import com.mercedesbenz.sechub.commons.model.SecHubResultTrafficLightFilter;
import com.mercedesbenz.sechub.commons.model.TrafficLight;
import com.mercedesbenz.sechub.commons.model.*;
import com.mercedesbenz.sechub.domain.scan.report.ScanSecHubReport;
import com.mercedesbenz.sechub.sharedkernel.MustBeDocumented;

Expand Down Expand Up @@ -53,16 +47,16 @@ public Map<String, Object> build(ScanSecHubReport report) {
}

switch (trafficLight) {
case RED:
styleRed = SHOW_LIGHT;
break;
case YELLOW:
styleYellow = SHOW_LIGHT;
break;
case GREEN:
styleGreen = SHOW_LIGHT;
break;
default:
case RED:
styleRed = SHOW_LIGHT;
break;
case YELLOW:
styleYellow = SHOW_LIGHT;
break;
case GREEN:
styleGreen = SHOW_LIGHT;
break;
default:
}
HtmlCodeScanDescriptionSupport codeScanSupport = new HtmlCodeScanDescriptionSupport();
SecHubResult result = report.getResult();
Expand Down Expand Up @@ -111,6 +105,36 @@ public Map<String, Object> build(ScanSecHubReport report) {
} else {
model.put("jobuuid", "none");
}

Map<ScanType, ScanTypeCount> scanSummaryMap = new HashMap<>();
zigfridus marked this conversation as resolved.
Show resolved Hide resolved
for (SecHubFinding finding : result.getFindings()) {
ScanType scanType = finding.getType();
ScanTypeCount scanTypeCount;
if (scanSummaryMap.containsKey(scanType)) {
scanTypeCount = scanSummaryMap.get(scanType);
} else {
scanTypeCount = ScanTypeCount.of(scanType);
scanSummaryMap.put(scanType, scanTypeCount);
}
incrementScanCount(finding.getSeverity(), scanTypeCount);
}
Set<ScanTypeCount> scanTypeCountSet = new TreeSet<>();
scanTypeCountSet.addAll(scanSummaryMap.values());
model.put("scanTypeCountSet", scanTypeCountSet);
zigfridus marked this conversation as resolved.
Show resolved Hide resolved

return model;
}

protected void incrementScanCount(Severity severity, ScanTypeCount scanTypeCount) {
if (Severity.HIGH.equals(severity)) {
zigfridus marked this conversation as resolved.
Show resolved Hide resolved
scanTypeCount.incrementHighSeverityCount();
}
if (Severity.MEDIUM.equals(severity)) {
scanTypeCount.incrementMediumSeverityCount();
}
if (Severity.LOW.equals(severity)) {
scanTypeCount.incrementLowSeverityCount();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.domain.scan;

import com.mercedesbenz.sechub.commons.model.ScanType;

public class ScanTypeCount implements Comparable<ScanTypeCount> {

private ScanType scanType;
private int highSeverityCount;
private int mediumSeverityCount;
private int lowSeverityCount;

private ScanTypeCount(ScanType scanType){
this.scanType = scanType;
highSeverityCount = 0;
mediumSeverityCount = 0;
lowSeverityCount = 0;
}

public static ScanTypeCount of(ScanType scanType) {
if (scanType == null) {
throw new IllegalArgumentException("ScanType argument must exist");
}
return new ScanTypeCount(scanType);
}

public ScanType getScanType() {
return scanType;
}

public int getHighSeverityCount() {
return highSeverityCount;
}

public int getMediumSeverityCount() {
return mediumSeverityCount;
}

public int getLowSeverityCount() {
return lowSeverityCount;
}

public void incrementHighSeverityCount(){
zigfridus marked this conversation as resolved.
Show resolved Hide resolved
this.highSeverityCount++;
}

public void incrementMediumSeverityCount(){
this.mediumSeverityCount++;
}

public void incrementLowSeverityCount(){
this.lowSeverityCount++;
}

@Override
public int compareTo(ScanTypeCount o) {
if (o == null) {
return 1;
}
String descriptionA = this.scanType.getDescription();
String descriptionB = o.scanType.getDescription();
return descriptionA.compareTo(descriptionB);
}
}
Loading