Skip to content

Commit 68f4596

Browse files
authored
[Generic parser] Add more unit tests (DefectDojo#4354)
1 parent 999832d commit 68f4596

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Date,Title,CweId,Url,Severity,Description,Mitigation,Impact,References,Active,Verified,FalsePositive,Duplicate
2+
28/02/2021,ASDF,1,https://vulnerable.endpoint.com/resource1/asdf,Low,Some description,Some mitigation advice,Some Impact,,TRUE,TRUE,FALSE,FALSE
3+
28/02/2021,ASDF,2,https://vulnerable.endpoint.com/resource2/qwerty,Low,Some description,Some mitigation advice,Some Impact,,TRUE,TRUE,FALSE,FALSE
4+
28/02/2021,ASDF,3,https://vulnerable.endpoint.com/resource3/asdf,Low,Some description,Some mitigation advice,Some Impact,,TRUE,TRUE,FALSE,FALSE
5+
28/02/2021,ASDF,4,https://vulnerable.endpoint.com/resource4/asdf,Low,Some description,Some mitigation advice,Some Impact,,TRUE,TRUE,FALSE,FALSE
6+
28/02/2021,ASDF,5,https://vulnerable.endpoint.com/resource5/asdf,Low,Some description,Some mitigation advice,Some Impact,,TRUE,TRUE,FALSE,FALSE

dojo/unittests/tools/test_generic_parser.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ def setUp(self):
2323
product=self.product)
2424
self.test = Test(engagement=self.engagement)
2525

26+
def test_parse_report1(self):
27+
file = open("dojo/unittests/scans/generic/generic_report1.csv")
28+
parser = GenericParser()
29+
findings = parser.get_findings(file, self.test, True, True)
30+
self.assertEqual(1, len(findings))
31+
finding = findings[0]
32+
self.assertEqual(5, len(finding.unsaved_endpoints))
33+
endpoint = finding.unsaved_endpoints[0]
34+
self.assertEqual("vulnerable.endpoint.com:443", endpoint.host)
35+
self.assertEqual("resource1/asdf", endpoint.path)
36+
endpoint = finding.unsaved_endpoints[1]
37+
self.assertEqual("vulnerable.endpoint.com:443", endpoint.host)
38+
self.assertEqual("resource2/qwerty", endpoint.path)
39+
self.assertEqual("https", endpoint.protocol)
40+
2641
def test_parse_no_csv_content_no_findings(self):
2742
findings = ""
2843
file = TestFile("findings.csv", findings)

0 commit comments

Comments
 (0)