Skip to content

Commit

Permalink
✨ advance unittest for parser docs (#9372)
Browse files Browse the repository at this point in the history
* ✨ advance unittest for parser docs

* 🐛 fix

* 🐛 fix

* 🐛 fix

* 🐛 fix

* fix according to review

* fix

---------

Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
  • Loading branch information
manuel-sommer and Maffooch committed Jan 31, 2024
1 parent 1031edd commit 9ef45a7
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 8 deletions.
Expand Up @@ -37,4 +37,4 @@ All properties are strings and are required by the parser.
~~~

### Sample Scan Data
Sample Anchore-Engine scans can be found at https://github.com/DefectDojo/sample-scan-files/tree/master/anchore_engine .
Sample Anchore-Engine scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/anchore_engine).
2 changes: 1 addition & 1 deletion docs/content/en/integrations/parsers/file/anchore_grype.md
Expand Up @@ -189,4 +189,4 @@ All properties are expected as strings and are required by the parser.
~~~

### Sample Scan Data
Sample Grype scans can be found at https://github.com/DefectDojo/sample-scan-files/tree/master/anchore_grype .
Sample Grype scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/anchore_grype).
Expand Up @@ -85,4 +85,4 @@ Parser expects a .json file, with an array of Findings contained within a single
~~~

### Sample Scan Data
Sample scan data for testing purposes can be found at https://github.com/DefectDojo/sample-scan-files/tree/master/awssecurityhub.
Sample scan data for testing purposes can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/awssecurityhub).
2 changes: 1 addition & 1 deletion docs/content/en/integrations/parsers/file/bandit.md
Expand Up @@ -64,4 +64,4 @@ All properties are expected as strings, except "metrics" properties, which are e
~~~

### Sample Scan Data
Sample Bandit scans can be found at https://github.com/DefectDojo/sample-scan-files/tree/master/bandit.
Sample Bandit scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/bandit).
2 changes: 1 addition & 1 deletion docs/content/en/integrations/parsers/file/burp.md
Expand Up @@ -41,4 +41,4 @@ All XML elements are required and will be parsed as strings.
~~~

### Sample Scan Data
Sample Burp scans can be found at https://github.com/DefectDojo/sample-scan-files/tree/master/burp.
Sample Burp scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/burp).
Expand Up @@ -7,7 +7,7 @@ toc_hide: true
Accepts a JSON File, generated from the JFrog Artifact Summary API Call.

### Sample Scan Data / Unit Tests
See unit test example: https://github.com/DefectDojo/django-DefectDojo/blob/master/unittests/scans/jfrog_xray_api_summary_artifact/one_vuln.json
Sample JFrog Xray API Summary Artifact Scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/jfrog_xray_api_summary_artifact).

### Link To Tool
See JFrog Documentation: https://jfrog.com/help/r/jfrog-rest-apis/summary
5 changes: 4 additions & 1 deletion docs/content/en/integrations/parsers/file/openvas.md
Expand Up @@ -2,4 +2,7 @@
title: "OpenVAS Parser"
toc_hide: true
---
You can either upload the exported results of an OpenVAS Scan in a .csv or .xml format.
You can either upload the exported results of an OpenVAS Scan in a .csv or .xml format.

### Sample Scan Data
Sample OpenVAS scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/openvas).
2 changes: 1 addition & 1 deletion docs/content/en/integrations/parsers/file/threagile.md
Expand Up @@ -85,4 +85,4 @@ Parser expects an array of finding. All properties are strings. Required fields
~~~

### Sample Scan Data
You can run a sample model and download some sample risk data from [here](https://run.threagile.io/)
Sample Threagile scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/threagile).
2 changes: 2 additions & 0 deletions docs/content/en/integrations/parsers/file/vcg.md
Expand Up @@ -4,3 +4,5 @@ toc_hide: true
---
VCG output can be imported in CSV or Xml formats.

### Sample Scan Data
Sample Visual Code Grepper (VCG) scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/vcg).
16 changes: 16 additions & 0 deletions unittests/scans/vcg/one_finding.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--XML Export of VCG Results for directory: C:\\Projects\\WebGoat.Net. Scanned for C# security issues.-->
<CodeIssueCollection>
<CodeIssue>
<Priority>6</Priority>
<Severity>Suspicious Comment</Severity>
<Title>Comment Indicates Potentially Unfinished Code</Title>
<Description>The comment includes some wording which indicates that the developer regards
it as unfinished or does not trust it to work correctly.</Description>
<FileName>Findings.xml</FileName>
<Line>21</Line>
<CodeLine>TODO: Check the Code</CodeLine>
<Checked>False</Checked>
<CheckColour>LawnGreen</CheckColour>
</CodeIssue>
</CodeIssueCollection>
7 changes: 7 additions & 0 deletions unittests/test_parsers.py
Expand Up @@ -36,6 +36,13 @@ def test_file_existence(self):
self.assertTrue(re.search("toc_hide: true", content),
f"Documentation file '{doc_file}' does not contain toc_hide: true"
)
if category == "file":
self.assertTrue(re.search("### Sample Scan Data", content),
f"Documentation file '{doc_file}' does not contain ### Sample Scan Data"
)
self.assertTrue(re.search("https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans", content),
f"Documentation file '{doc_file}' does not contain https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans"
)

if parser_dir.name not in [
# there is not exception for now
Expand Down

0 comments on commit 9ef45a7

Please sign in to comment.