1
- from dojo .models import Test
2
1
from dojo .tools .rusty_hog .parser import RustyhogParser
3
2
from unittests .dojo_test_case import DojoTestCase , get_unit_tests_scans_path
4
3
@@ -7,25 +6,25 @@ class TestRustyhogParser(DojoTestCase):
7
6
def test_parse_file_with_no_vuln_has_no_finding_choctawhog (self ):
8
7
with open (get_unit_tests_scans_path ("rusty_hog" ) / "choctawhog_no_vuln.json" , encoding = "utf-8" ) as testfile :
9
8
parser = RustyhogParser ()
10
- findings = parser .get_items (testfile , "Rusty Hog" , Test () ) # The outputfile is empty. A subscanner can't be classified
9
+ findings = parser .get_findings (testfile , "Rusty Hog" ) # The outputfile is empty. A subscanner can't be classified
11
10
self .assertEqual (0 , len (findings ))
12
11
13
12
def test_parse_file_with_one_vuln_has_one_finding_choctawhog (self ):
14
13
with open (get_unit_tests_scans_path ("rusty_hog" ) / "choctawhog_one_vuln.json" , encoding = "utf-8" ) as testfile :
15
14
parser = RustyhogParser ()
16
- findings = parser .get_items (testfile , "Choctaw Hog" , Test () )
15
+ findings = parser .get_findings (testfile , "Choctaw Hog" )
17
16
self .assertEqual (1 , len (findings ))
18
17
19
18
def test_parse_file_with_multiple_vuln_has_multiple_finding_choctawhog (self ):
20
19
with open (get_unit_tests_scans_path ("rusty_hog" ) / "choctawhog_many_vulns.json" , encoding = "utf-8" ) as testfile :
21
20
parser = RustyhogParser ()
22
- findings = parser .get_items (testfile , "Choctaw Hog" , Test () )
21
+ findings = parser .get_findings (testfile , "Choctaw Hog" )
23
22
self .assertEqual (13 , len (findings ))
24
23
25
24
def test_parse_file_with_multiple_vuln_has_multiple_finding_choctawhog_content (self ):
26
25
with open (get_unit_tests_scans_path ("rusty_hog" ) / "choctawhog_many_vulns.json" , encoding = "utf-8" ) as testfile :
27
26
parser = RustyhogParser ()
28
- findings = parser .get_items (testfile , "Choctaw Hog" , Test () )
27
+ findings = parser .get_findings (testfile , "Choctaw Hog" )
29
28
self .assertEqual (findings [0 ].title , "Email address found in Git path .github/workflows/main.yml (a7bce96377c4ff2ac16cd51fb0da7fe7ea678829)" )
30
29
self .assertIn ("**This string was found:** ['dojo-helpers@this-repo.com']" , findings [0 ].description )
31
30
self .assertIn ("**Commit message:** removing action" , findings [0 ].description )
@@ -38,25 +37,25 @@ def test_parse_file_with_multiple_vuln_has_multiple_finding_choctawhog_content(s
38
37
def test_parse_file_with_no_vuln_has_no_finding_duorchog (self ):
39
38
with open (get_unit_tests_scans_path ("rusty_hog" ) / "durochog_no_vuln.json" , encoding = "utf-8" ) as testfile :
40
39
parser = RustyhogParser ()
41
- findings = parser .get_items (testfile , "Rusty Hog" , Test () ) # The outputfile is empty. A subscanner can't be classified
40
+ findings = parser .get_findings (testfile , "Rusty Hog" ) # The outputfile is empty. A subscanner can't be classified
42
41
self .assertEqual (0 , len (findings ))
43
42
44
43
def test_parse_file_with_one_vuln_has_one_finding_durochog (self ):
45
44
with open (get_unit_tests_scans_path ("rusty_hog" ) / "durochog_one_vuln.json" , encoding = "utf-8" ) as testfile :
46
45
parser = RustyhogParser ()
47
- findings = parser .get_items (testfile , "Duroc Hog" , Test () )
46
+ findings = parser .get_findings (testfile , "Duroc Hog" )
48
47
self .assertEqual (1 , len (findings ))
49
48
50
49
def test_parse_file_with_multiple_vuln_has_multiple_finding_durochog (self ):
51
50
with open (get_unit_tests_scans_path ("rusty_hog" ) / "durochog_many_vulns.json" , encoding = "utf-8" ) as testfile :
52
51
parser = RustyhogParser ()
53
- findings = parser .get_items (testfile , "Duroc Hog" , Test () )
52
+ findings = parser .get_findings (testfile , "Duroc Hog" )
54
53
self .assertEqual (4 , len (findings ))
55
54
56
55
def test_parse_file_with_multiple_vuln_has_multiple_finding_durochog_content (self ):
57
56
with open (get_unit_tests_scans_path ("rusty_hog" ) / "durochog_many_vulns.json" , encoding = "utf-8" ) as testfile :
58
57
parser = RustyhogParser ()
59
- findings = parser .get_items (testfile , "Duroc Hog" , Test () )
58
+ findings = parser .get_findings (testfile , "Duroc Hog" )
60
59
self .assertEqual (findings [0 ].title , "password (Password) found in path /scan_folder/unittests/scans/sonarqube/sonar-no-finding.html" )
61
60
self .assertIn ("**This string was found:** ['password = getEncryptedPass()']" , findings [0 ].description )
62
61
self .assertIn ("**Path of Issue:** /scan_folder/unittests/scans/sonarqube/sonar-no-finding.html" , findings [0 ].description )
@@ -67,25 +66,25 @@ def test_parse_file_with_multiple_vuln_has_multiple_finding_durochog_content(sel
67
66
def test_parse_file_with_no_vuln_has_no_finding_gottingenhog (self ):
68
67
with open (get_unit_tests_scans_path ("rusty_hog" ) / "gottingenhog_no_vuln.json" , encoding = "utf-8" ) as testfile :
69
68
parser = RustyhogParser ()
70
- findings = parser .get_items (testfile , "Rusty Hog" , Test () ) # The outputfile is empty. A subscanner can't be classified
69
+ findings = parser .get_findings (testfile , "Rusty Hog" ) # The outputfile is empty. A subscanner can't be classified
71
70
self .assertEqual (0 , len (findings ))
72
71
73
72
def test_parse_file_with_one_vuln_has_one_finding_gottingenhog (self ):
74
73
with open (get_unit_tests_scans_path ("rusty_hog" ) / "gottingenhog_one_vuln.json" , encoding = "utf-8" ) as testfile :
75
74
parser = RustyhogParser ()
76
- findings = parser .get_items (testfile , "Gottingen Hog" , Test () )
75
+ findings = parser .get_findings (testfile , "Gottingen Hog" )
77
76
self .assertEqual (1 , len (findings ))
78
77
79
78
def test_parse_file_with_multiple_vuln_has_multiple_finding_gottingenhog (self ):
80
79
with open (get_unit_tests_scans_path ("rusty_hog" ) / "gottingenhog_many_vulns.json" , encoding = "utf-8" ) as testfile :
81
80
parser = RustyhogParser ()
82
- findings = parser .get_items (testfile , "Gottingen Hog" , Test () )
81
+ findings = parser .get_findings (testfile , "Gottingen Hog" )
83
82
self .assertEqual (10 , len (findings ))
84
83
85
84
def test_parse_file_with_multiple_vuln_has_multiple_finding_gottingenhog_content (self ):
86
85
with open (get_unit_tests_scans_path ("rusty_hog" ) / "gottingenhog_many_vulns.json" , encoding = "utf-8" ) as testfile :
87
86
parser = RustyhogParser ()
88
- findings = parser .get_items (testfile , "Gottingen Hog" , Test () )
87
+ findings = parser .get_findings (testfile , "Gottingen Hog" )
89
88
self .assertEqual (findings [0 ].title , "password found in Jira ID TEST-123 (Issue Description)" )
90
89
self .assertIn ("**This string was found:** ['password: jeans']" , findings [0 ].description )
91
90
self .assertIn ("**JIRA Issue ID:** TEST-123" , findings [0 ].description )
@@ -96,19 +95,19 @@ def test_parse_file_with_multiple_vuln_has_multiple_finding_gottingenhog_content
96
95
def test_parse_file_with_no_vuln_has_no_finding_essexhog (self ):
97
96
with open (get_unit_tests_scans_path ("rusty_hog" ) / "essexhog_no_vuln.json" , encoding = "utf-8" ) as testfile :
98
97
parser = RustyhogParser ()
99
- findings = parser .get_items (testfile , "Rusty Hog" , Test () ) # The outputfile is empty. A subscanner can't be classified
98
+ findings = parser .get_findings (testfile , "Rusty Hog" ) # The outputfile is empty. A subscanner can't be classified
100
99
self .assertEqual (0 , len (findings ))
101
100
102
101
def test_parse_file_with_one_vuln_has_one_finding_essexhog (self ):
103
102
with open (get_unit_tests_scans_path ("rusty_hog" ) / "essexhog_one_vuln.json" , encoding = "utf-8" ) as testfile :
104
103
parser = RustyhogParser ()
105
- findings = parser .get_items (testfile , "Essex Hog" , Test () )
104
+ findings = parser .get_findings (testfile , "Essex Hog" )
106
105
self .assertEqual (1 , len (findings ))
107
106
108
107
def test_parse_file_with_multiple_vuln_has_multiple_finding_essexhog (self ):
109
108
with open (get_unit_tests_scans_path ("rusty_hog" ) / "essexhog_many_vulns.json" , encoding = "utf-8" ) as testfile :
110
109
parser = RustyhogParser ()
111
- findings = parser .get_items (testfile , "Essex Hog" , Test () )
110
+ findings = parser .get_findings (testfile , "Essex Hog" )
112
111
self .assertEqual (3 , len (findings ))
113
112
self .assertEqual ("https://confluence.com/pages/viewpage.action?pageId=12345" , findings [0 ].file_path )
114
113
self .assertEqual ("['-----BEGIN EC PRIVATE KEY-----']" , findings [0 ].payload )
@@ -117,7 +116,7 @@ def test_parse_file_with_multiple_vuln_has_multiple_finding_essexhog(self):
117
116
def test_parse_file_with_multiple_vuln_has_multiple_finding_essexhog_content (self ):
118
117
with open (get_unit_tests_scans_path ("rusty_hog" ) / "essexhog_many_vulns.json" , encoding = "utf-8" ) as testfile :
119
118
parser = RustyhogParser ()
120
- findings = parser .get_items (testfile , "Essex Hog" , Test () )
119
+ findings = parser .get_findings (testfile , "Essex Hog" )
121
120
self .assertEqual (findings [0 ].title , "SSH (EC) private key found in Confluence Page ID 12345" )
122
121
self .assertIn ("-----BEGIN EC PRIVATE KEY-----" , findings [0 ].description )
123
122
self .assertIn ("**Confluence URL:** [https://confluence.com/pages/viewpage.action?pageId=12345](https://confluence.com/pages/viewpage.action?pageId=12345)" , findings [0 ].description )
0 commit comments