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

Conversation

zigfridus
Copy link
Contributor

This PR will close #345

Copy link
Member

@Jeeppler Jeeppler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall you are on the right track, but you need to build up the data structure for the summary in the HTMLScanResultReportModelBuilder. See comments.

<tr>
<td>Red</td>
<td>
<span th:if="!${redList.isEmpty()}"><a href="#redFindingsBlock" th:text="${#lists.size(redList)}"></a></span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id should be: #scanTypeRedFindingsBlock

<div th:if="!${redList.isEmpty()}">
<h2 class='redFindingHeadline'>Red findings</h2>
<h2 class='redFindingHeadline' id="redFindingsBlock">Red findings</h2>
<table class='findingsTable redFindingsTable'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a new table for every scanType + redList.

<div th:if="!${redList.isEmpty()}">
<h2 class='redFindingHeadline'>Red findings</h2>
<h2 class='redFindingHeadline' id="redFindingsBlock">Red findings</h2>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each finding table needs a separate heading.
For example:

<h3 class='redFindingHeadline' id="codeScanRedFindingsBlock">Code Scan</a>

@zigfridus
Copy link
Contributor Author

@Jeeppler
Some quick questions.

  1. What does Secret Scan do? I haven't met this type of scan in SecHub before.
  2. It seems to me it's neccessary to significantly change the structure of model in HTMLScanResultReportModelBuilder. Do you approve this?

@Jeeppler
Copy link
Member

Jeeppler commented Apr 17, 2023

@zigfridus

  1. Secret Scan is looking through code or repositories and tries to find hard coded secrets and credentials. This is a common problem. For example, with AWS credentials: https://github.com/ramimac/aws-customer-security-incidents. The secret scan module is fairly new. It was introduced a few weeks ago.

  2. It seems to me it's necessary to significantly change the structure of model in HTMLScanResultReportModelBuilder. Do you approve this? - Yes, go ahead and do the necessary changes.

@zigfridus
Copy link
Contributor Author

@Jeeppler
I would like to ask, may I reorganize the summary table in the way like on this image.
image
This will greatly simplify for me the summary table creation?

@Jeeppler
Copy link
Member

@zigfridus yes, that is a good idea

@Jeeppler
Copy link
Member

@zigfridus please add the image of the table from the Google drive into this issue here. I would like to have the documentation of this issue in one place.

@zigfridus
Copy link
Contributor Author

@Jeeppler
Proposition of transposition of the Summary table:
summary table

@zigfridus
Copy link
Contributor Author

@Jeeppler
Please have a look at my last commit with a draft summary table.
Thanks

Copy link
Member

@Jeeppler Jeeppler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding work. I love how readable the code is.

I found some smaller issues. Please change those.

Still there are three major things I am missing:

  1. Tests (there should be a test for the ScanTypeCount class and extend HTMLScanResultReportModelBuilderTest)
  2. A list of CWEs found (see: Summary in Reports #345 (comment))
  3. The JSON report should contain the same summary (see: Summary in Reports #345 (comment))

You are clearly on the right track. I know the issue is challenging.

zigfridus added 5 commits May 16, 2023 14:35
- changed model's scanTypeCount List to Set in the HTMLScanResultReportModelBuilder;
- added tests in the HTMLScanResultReportModelBuilderTest;
- cleaned and added improvements in the ScanTypeCount;
- created tests for the ScanTypeCount;
- modified scanresult.html because of new set from the HTMLScanResultReportModelBuilder.
@zigfridus
Copy link
Contributor Author

@Jeeppler
Hello
Please have a look at my last commit. I added the neccessary sections into the JSON report.
I didn't create tests yet. I will create them if you are ok with my improvements.

@zigfridus zigfridus requested a review from Jeeppler May 26, 2023 07:39
Copy link
Member

@Jeeppler Jeeppler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. However, I did found some issues. For details have a look at the comments.

Please include a screenshot with your next pull-request review request (only as comment in the pull-request conversation).

@zigfridus
Copy link
Contributor Author

@Jeeppler
Could you please explain for me this your sentence:
"Please include a screenshot with your next pull-request review request (only as comment in the pull-request conversation)."
I don't clearly understand it.

@Jeeppler
Copy link
Member

Jeeppler commented Jun 1, 2023

@zigfridus It would be nice to have a screenshot of the report with the summary once you request a review. The simply reason is, that you are working on the HTML report and it is always a good idea to show case the visual changes.

Simply include the screenshot as part of this conversation.

@zigfridus
Copy link
Contributor Author

zigfridus commented Jul 5, 2023

Hello @Jeeppler
According to the test data in the example3_coverity.sarif.json the finding with the same CWE ID (for example CWE-352) could have both HIGH and MEDIUM severity at the same time. Is it possible or is it a mistake in the test data?
medium
high

@Jeeppler
Copy link
Member

Jeeppler commented Jul 5, 2023

@zigfridus yes, they could both have different severity levels even for the same CWE, depending on how the tool calculates the severity level (e, g. based on a Control Flow Graph). It is certainly an edge case.

In addition, some tools produce findings with a CWE-0. The problem, a CWE-0 does not exist.

In the real world there are a lot of oddities, quirks and bugs. Tests might help to check for those. However, I do expect that over time we will uncover some situations/combinations you/we did not account for. That is fine.

@zigfridus
Copy link
Contributor Author

@Jeeppler Thank you for the explanation.

@zigfridus
Copy link
Contributor Author

@Jeeppler Finally I have some result that I can show you. These are 2 reports, generated by the modified code.

example 1:
1
example 3:
3

Please have a look at the html files in the ZIP:
examples.zip

I didn't find at your example a details block: Should it exist in my report too?
details block

@Jeeppler
Copy link
Member

Jeeppler commented Jul 7, 2023

@zigfridus Thanks, I know it takes time. Overall, it look very nice. Good job. 🥇

The details block should exist in your report as well. I am surprised, that it does not exist in your code.

Regarding the tables. I think if they look this they would be easier to read:

CodeScan

High

CWE         | Name                                                      | Count
-------------------------------------------------------------------------
CWE-543  | Bad choice of lock object                                    | 1
CWE-352  | Cross-site request forgery                                   | 1
CWE-79    | Cross-site scripting                                        | 131
CWE-22    | Filesystem path, filename, or URI manipulation              | 5
…

In addition, it would be nice to use the <details> - HTML tag for the table with CWE numbers.

Closed:

> SecretScan
> CodeScan
…

CodeScan open:

> SecretScan
v CodeScan

High

CWE         | Name                                                      | Count
-------------------------------------------------------------------------
CWE-543  | Bad choice of lock object                                    | 1
CWE-352  | Cross-site request forgery                                   | 1
CWE-79    | Cross-site scripting                                        | 131
CWE-22    | Filesystem path, filename, or URI manipulation              | 5
…

@zigfridus
Copy link
Contributor Author

@Jeeppler
Please have a look at my improvements:
examples.zip

  1. Added the block of details in description.
  2. Designed summary blocks as tables.
  3. Add possibility to collapse summary blocks.

example_1
example_3

zigfridus and others added 8 commits November 2, 2023 19:55
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
…mons/model/SecHubReportMetaDataSummaryTest.java

Co-authored-by: Jeeppler <Jeeppler@users.noreply.github.com>
@zigfridus
Copy link
Contributor Author

@Jeeppler
I amended my code according to your recommendations. After that it was built successfully. Please have a look.

Copy link
Member

@Jeeppler Jeeppler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good too me 👍

@CLA-Mercedes-Benz
Copy link

CLA-Mercedes-Benz commented Nov 14, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@de-jcup de-jcup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.
I found some parts I want to have been changed. Especially the report for web scans is not correct rendering (JSON and HTML). Please look at the comments for more details.

@@ -241,7 +238,8 @@ public void before() throws Exception {
map.put("yellowList", new ArrayList<>());
map.put("greenList", new ArrayList<>());
map.put("isWebDesignMode", false);
map.put("metaData", Optional.ofNullable(null));
map.put("metaData", null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you do a
map.get("metadata") and you have not defined it, it will always be null

Please remove the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@de-jcup It seems to me I have already removed it in this commit or am I wrong?

hasMetaDataLabel("test-label2", "").
hasMetaDataLabel("test-label3_with_html", "<html>HTML is allowed, but must always be escaped in reports!</html>").
hasMetaDataLabel("test-label4_with_special_chars", "Line1\nLine2\tLine3").
hasMetaDataSummaryCodeScanTotal(32).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added your new tests - okay (of course)
But you dropped the existing meta data label tests. Why?

We need these tests to ensure that the labels are inside the report - it is an important version.

Please add the former meta data label checks/tests again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I didn't find any of these labels in the report that should be tested:
{"metaData":{"labels":{},"summary":
Should they exist here?

hasMetaDataLabel("test-label2", "").
hasMetaDataLabel("test-label3_with_html", "&lt;html&gt;HTML is allowed, but must always be escaped in reports!&lt;/html&gt;").
hasMetaDataLabel("test-label4_with_special_chars", "Line1\nLine2\tLine3");
hasHTMLString("<td><a href=\"#redCodeScanTable\">28</a></td>").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added your new tests - okay (of course)
But you dropped the existing meta data label tests. Why?

We need these tests to ensure that the labels are inside the report - it is an important version.

Please add the former meta data label checks/tests again.

Copy link
Contributor Author

@zigfridus zigfridus Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I didn't find any of these labels in the report that should be tested:
{"metaData":{"labels":{},"summary":
Should they exist here?

@de-jcup
Copy link
Member

de-jcup commented Nov 27, 2023

@zigfridus : I am happy to see that you have done some new commits/pushes. When your changes are complete, please re-request a review from me by GitHub UI. Thank you.

@zigfridus
Copy link
Contributor Author

zigfridus commented Nov 28, 2023

@de-jcup
I fixed some issues you found. Please have a look at my comments for unresolved conversations. I would like to have some clarifications. Thank you.

@zigfridus zigfridus requested a review from de-jcup November 28, 2023 20:45
@de-jcup
Copy link
Member

de-jcup commented Dec 19, 2023

@zigfridus : Sorry (again) for the late response

With

we introduced a "community" branch.

Please do me a favor and change your PR target from develop to community.
After this, I will merge the PR to community branch, do some additions and after this
merge it finally to develop

We try to install this as the default mechanism - to speed up merges, reduce frustration at contributor side, see build failures before merging to develop (main) branch etc. (see #2759 for details).

So... this is like a test balloon, but I hope this works well in future for other contributions/contributors as well.

Thank you for your patience, your contribution and your perseverance regarding this long ongoing PR...

Remark: With #2599 I fixed the sorting of the reduced open api file. Please merge the develop branch into your branch and get rid of the merge conflict (community branch is at same level as develop branch)

@zigfridus zigfridus changed the base branch from develop to community December 19, 2023 12:39
@zigfridus
Copy link
Contributor Author

@de-jcup
I changed this branch to community.

@Jeeppler
Copy link
Member

@zigfridus awesome, thank you.

@zigfridus
Copy link
Contributor Author

@Jeeppler
I changed the branch here. Could you please advice how to change destination branch in my fork?
Screenshot 2023-12-19 150410

@Jeeppler
Copy link
Member

Jeeppler commented Dec 21, 2023

@zigfridus I think the best way to solve the problem is to close this pull-request (2156) and create a new pull-request fork/branch with the target branch mercedes-benz:community.

To not loos all the discussions from this conversation, you can simply link/mention this pull-request in your new pull-request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Summary in Reports
5 participants