Skip to content

Commit fcfb39c

Browse files
Jino-TJino Tesauro
andauthored
Parser docstrings (#12253)
* Created docstrings for acunetix but haven't tested * Added OSV get_fields and get_dedupe_fields * Added checkov get_fields and get_dedupe_fields * Added whispers get_fields and get_dedupe_fields * Added snyk code get_fields and get_dedupe_fields * Added get_fields and get_dedupe_fields for sarif and updated checkov * Updated previosly made get_fields and get_dedupe_fields * Added Docstrings for qualys and acunetix * Added docstrings for qualys hacker guardian * Updated qualys hacker guardian docstring * Added docstrings for qualys webapp * Added docstrings for tenable parser --------- Co-authored-by: Jino Tesauro <jinotesauro@pop-os.localdomain>
1 parent f55c623 commit fcfb39c

File tree

25 files changed

+812
-8
lines changed

25 files changed

+812
-8
lines changed

dojo/tools/acunetix/parse_acunetix360_json.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,50 @@ class AcunetixJSONParser:
1111

1212
"""This parser is written for Acunetix JSON Findings."""
1313

14+
def get_fields(self) -> list[str]:
15+
"""
16+
Return the list of fields used in the Acunetix 360 Parser.
17+
18+
Fields:
19+
- title: Set to the name outputted by the Acunetix 360 Scanner.
20+
- description: Set to Description variable outputted from Acunetix 360 Scanner.
21+
- severity: Set to severity from Acunetix 360 Scanner converted into Defect Dojo format.
22+
- mitigation: Set to RemedialProcedure variable outputted from Acunetix 360 Scanner if it is present.
23+
- impact: Set to Impact variable outputted from Acunetix 360 Scanner if it is present.
24+
- date: Set to FirstSeenDate variable outputted from Acunetix 360 Scanner if present. If not, it is set to Generated variable from output.
25+
- cwe: Set to converted cwe in Classification variable outputted from Acunetix 360 Scanner if it is present.
26+
- static_finding: Set to True.
27+
- cvssv3: Set to converted cvssv3 in Classification variable outputted from Acunetix 360 Scanner if it is present.
28+
- risk_accepted: Set to True if AcceptedRisk is present in State variable outputted from Acunetix 360 Scanner. No value if variable is not present.
29+
- active: Set to false.
30+
"""
31+
return [
32+
"title",
33+
"description",
34+
"severity",
35+
"mitigation",
36+
"impact",
37+
"date",
38+
"cwe",
39+
"static_finding",
40+
"cvssv3",
41+
"risk_accepted",
42+
"active",
43+
]
44+
45+
def get_dedupe_fields(self) -> list[str]:
46+
"""
47+
Return the list of fields used for deduplication in the Acunetix 360 Parser.
48+
49+
Fields:
50+
- title: Set to the name outputted by the Acunetix 360 Scanner.
51+
- description: Set to Description variable outputted from Acunetix 360 Scanner.
52+
"""
53+
return [
54+
"title",
55+
"description",
56+
]
57+
1458
def get_findings(self, filename, test):
1559
dupes = {}
1660
data = json.load(filename)

dojo/tools/acunetix/parse_acunetix_xml.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,52 @@ class AcunetixXMLParser:
1616

1717
"""This parser is written for Acunetix XML reports"""
1818

19+
def get_fields(self) -> list[str]:
20+
"""
21+
Return the list of fields used in the Acunetix XML Parser.
22+
23+
Fields:
24+
- title: Set to the name outputted by the Acunetix XML Scanner.
25+
- severity: Set to severity from Acunetix XML Scanner converted into Defect Dojo format.
26+
- description: Set to description, Details, and TechnivalDetails variables outputted from Acunetix XML Scanner.
27+
- false_p: Set to True/False based on Defect Dojo standards.
28+
- static_finding: Set to True by default and updated to False if requests are present.
29+
- dynamic_finding: Set to False by default and updated to True if requests are present.
30+
- nb_occurences: Set to 1 and increased based on presence of occurences.
31+
- impact: Set to impact outputted from Acunetix XML Scanner if it is present.
32+
- mitigation: Set to Recommendation outputted from Acunetix XML Scanner if it is present.
33+
- date: Set to StartTime outputted from Acunetix XML Scanner if it is present.
34+
- cwe: Set to converted cwe outputted from Acunetix XML Scanner if it is present.
35+
- cvssv3: Set to converted cvssv3 values outputted from Acunetix XML Scanner if it is present.
36+
"""
37+
return [
38+
"title",
39+
"severity",
40+
"description",
41+
"false_p",
42+
"static_finding",
43+
"dynamic_finding",
44+
"nb_occurences",
45+
"impact",
46+
"mitigation",
47+
"date",
48+
"cwe",
49+
"cvssv3",
50+
]
51+
52+
def get_dedupe_fields(self) -> list[str]:
53+
"""
54+
Return the list of fields used for deduplication in the Acunetix XML Parser.
55+
56+
Fields:
57+
- title: Set to the name outputted by the Acunetix XML Scanner.
58+
- description: Set to description, Details, and TechnivalDetails variables outputted from Acunetix XML Scanner.
59+
"""
60+
return [
61+
"title",
62+
"description",
63+
]
64+
1965
def get_findings(self, filename, test):
2066
dupes = {}
2167
root = parse(filename).getroot()

dojo/tools/acunetix/parser.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,75 @@ class AcunetixParser:
66

77
"""Parser for Acunetix XML files and Acunetix 360 JSON files."""
88

9+
def get_fields(self) -> list[str]:
10+
"""
11+
Return the list of fields used in the Acunetix XML Parser.
12+
13+
Fields:
14+
- title: Set to the name outputted by the Acunetix XML Scanner.
15+
- severity: Set to severity from Acunetix XML Scanner converted into Defect Dojo format.
16+
- description: Set to description, Details, and TechnivalDetails variables outputted from Acunetix XML Scanner.
17+
- false_p: Set to True/False based on Defect Dojo standards.
18+
- static_finding: Set to True by default and updated to False if requests are present.
19+
- dynamic_finding: Set to False by default and updated to True if requests are present.
20+
- nb_occurences: Set to 1 and increased based on presence of occurences.
21+
- impact: Set to impact outputted from Acunetix XML Scanner if it is present.
22+
- mitigation: Set to Recommendation outputted from Acunetix XML Scanner if it is present.
23+
- date: Set to StartTime outputted from Acunetix XML Scanner if it is present.
24+
- cwe: Set to converted cwe outputted from Acunetix XML Scanner if it is present.
25+
- cvssv3: Set to converted cvssv3 values outputted from Acunetix XML Scanner if it is present.
26+
27+
Return the list of fields used in the Acunetix 360 Parser.
28+
29+
Fields:
30+
- title: Set to the name outputted by the Acunetix 360 Scanner.
31+
- description: Set to Description variable outputted from Acunetix 360 Scanner.
32+
- severity: Set to severity from Acunetix 360 Scanner converted into Defect Dojo format.
33+
- mitigation: Set to RemedialProcedure variable outputted from Acunetix 360 Scanner if it is present.
34+
- impact: Set to Impact variable outputted from Acunetix 360 Scanner if it is present.
35+
- date: Set to FirstSeenDate variable outputted from Acunetix 360 Scanner if present. If not, it is set to Generated variable from output.
36+
- cwe: Set to converted cwe in Classification variable outputted from Acunetix 360 Scanner if it is present.
37+
- static_finding: Set to True.
38+
- cvssv3: Set to converted cvssv3 in Classification variable outputted from Acunetix 360 Scanner if it is present.
39+
- risk_accepted: Set to True if AcceptedRisk is present in State variable outputted from Acunetix 360 Scanner. No value if variable is not present.
40+
- active: Set to false.
41+
"""
42+
return [
43+
"title",
44+
"severity",
45+
"description",
46+
"false_p",
47+
"static_finding",
48+
"dynamic_finding",
49+
"nb_occurences",
50+
"impact",
51+
"mitigation",
52+
"date",
53+
"cwe",
54+
"cvssv3",
55+
"risk_accepted",
56+
"active",
57+
]
58+
59+
def get_dedupe_fields(self) -> list[str]:
60+
"""
61+
Return the list of fields used for deduplication in the Acunetix XML Parser.
62+
63+
Fields:
64+
- title: Set to the name outputted by the Acunetix XML Scanner.
65+
- description: Set to description, Details, and TechnivalDetails variables outputted from Acunetix XML Scanner.
66+
67+
Return the list of fields used for deduplication in the Acunetix 360 Parser.
68+
69+
Fields:
70+
- title: Set to the name outputted by the Acunetix 360 Scanner.
71+
- description: Set to Description variable outputted from Acunetix 360 Scanner.
72+
"""
73+
return [
74+
"title",
75+
"description",
76+
]
77+
978
def get_scan_types(self):
1079
return ["Acunetix Scan"]
1180

dojo/tools/bandit/parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ def get_fields(self) -> list[str]:
1818
- file_path: Set to filename from Bandit Scanner.
1919
- line: Set to line from Bandit Scanner.
2020
- date: Set to date from Bandit Scanner.
21+
- static_finding: Set to true.
22+
- dynamic_finding: Set to false.
2123
- vuln_id_from_tool: Made from joining test_name and test_id.
2224
- nb_occurences: Initially set to 1 then updated.
23-
- scanner_condifence: Set to confidence value if one is returned from the Bandit Scanner.
25+
- scanner_confidence: Set to confidence value if one is returned from the Bandit Scanner.
2426
"""
2527
return [
2628
"title",
@@ -29,6 +31,8 @@ def get_fields(self) -> list[str]:
2931
"file_path",
3032
"line",
3133
"date",
34+
"static_finding",
35+
"dynamic_finding",
3236
"vuln_id_from_tool",
3337
"nb_occurences",
3438
"scanner_confidence",

dojo/tools/brakeman/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def get_fields(self) -> list[str]:
1919
- file_path: Set to file from Brakeman Scanner.
2020
- line: Set to line from Brakeman Scanner.
2121
- date: Set to end_date from Brakeman Scanner.
22+
- static_finding: Set to true.
2223
"""
2324
return [
2425
"title",
@@ -27,6 +28,7 @@ def get_fields(self) -> list[str]:
2728
"file_path",
2829
"line",
2930
"date",
31+
"static_finding",
3032
]
3133

3234
def get_dedupe_fields(self) -> list[str]:
@@ -40,6 +42,7 @@ def get_dedupe_fields(self) -> list[str]:
4042
- description: Made by joining filename, line number, issue confidence, code, user input, and render path provided by Brakeman Scanner.
4143
4244
NOTE: uses legacy dedupe: ['title', 'cwe', 'line', 'file_path', 'description']
45+
NOTE: cwe is not provided by parser.
4346
"""
4447
return [
4548
"title",

dojo/tools/burp/parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def get_fields(self) -> list[str]:
3131
- scanner_confidence: Converted from Burp format (Certain, Firm, or Tentative) into Defect Dojo integer format.
3232
- description: Made by combining URL, url_host, path, and detail.
3333
- mitigation: Made using Remediation that was ouputted by Burp scanner
34+
- false_p: Set to false.
35+
- duplicate: Set to false.
36+
- out_of_scope: Set to false.
37+
- dynamic_finding: Set to true.
3438
- impact: Set to background returned by Burp Scanner.
3539
- unique_id_from_tool: Set to serial_number returned by Burp Scanner.
3640
- vuln_id_from_tool: Taken from output of Burp Scanner.
@@ -44,6 +48,10 @@ def get_fields(self) -> list[str]:
4448
"scanner_confidence",
4549
"description",
4650
"mitigation",
51+
"false_p",
52+
"duplicate",
53+
"out_of_scope",
54+
"dynamic_finding",
4755
"impact",
4856
"unique_id_from_tool",
4957
"vuln_id_from_tool",
@@ -60,6 +68,7 @@ def get_dedupe_fields(self) -> list[str]:
6068
- description: Made by combining URL, url_host, path, and detail.
6169
6270
NOTE: uses legacy dedupe: ['title', 'cwe', 'line', 'file_path', 'description']
71+
NOTE: line and file_path is not provided by parser
6372
"""
6473
return [
6574
"title",

dojo/tools/cargo_audit/parser.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ def get_dedupe_fields(self) -> list[str]:
4444
Return the list of fields used for deduplication in the Cargo Audit Parser.
4545
4646
Fields:
47-
- vulnerability_ids:
4847
- severity: Set to "High" regardless of context.
4948
- component_name: Set to name of package provided by the Cargo Audit Scanner.
5049
- component_version: Set to version of package provided by the Cargo Audit Scanner.
5150
- vuln_id_from_tool: Set to id provided by the Cargo Audit Scanner.
5251
53-
NOTE: Dedupe fields in settings.dist.py list vulnerability_ids and vuln_id_from_tool
52+
NOTE: vulnerability_ids is not provided by parser.
53+
NOTE: vulnerability_ids appears to be stored in unsaved_vulnerability_ids.
5454
"""
5555
return [
56-
"vulnerability_ids",
5756
"severity",
5857
"component_name",
5958
"component_version",

dojo/tools/checkmarx/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def get_fields(self) -> list[str]:
2727
- severity: Set to severity outputted by Checkmarx Scanner.
2828
- file_path: Set to filename outputted by Checkmarx Scanner.
2929
- date: Set to date outputted by Checkmarx Scanner.
30+
- static_finding: Set to true.
3031
- nb_occurences: Inittially set to 1 and then updated accordingly.
3132
- line: Set to line outputted by Checkmarx Scanner.
3233
- unique_id_from_tool: [If mode set to detailed] Set to the unique pathId outputted by Checkmarx Parser.
@@ -48,6 +49,7 @@ def get_fields(self) -> list[str]:
4849
"severity",
4950
"file_path",
5051
"date",
52+
"static_finding",
5153
"nb_occurences",
5254
"line",
5355
"unique_id_from_tool",

dojo/tools/checkov/parser.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,53 @@
44

55

66
class CheckovParser:
7+
8+
def get_fields(self) -> list[str]:
9+
"""
10+
Return the list of fields used in the Checkov Parser.
11+
Fields:
12+
- title: Set to check_name outputted from Checkov Scanner.
13+
- description: Custom description made from: check type, check id, and check name.
14+
- severity: Set to severity from Checkov Scanner that has been translated into Defect Dojo format.
15+
- mitigation: Set to severity from Checkov Scanner that has been translated into Defect Dojo format.
16+
- file_path: Set to file path from Checkov Scanner.
17+
- line: Set to first line of the file line range from Checkov Scanner.
18+
- component_name: Set to resource from Checkov Scanner.
19+
- static_finding: Set to true.
20+
- dynamic_finding: Set to false.
21+
"""
22+
return [
23+
"title",
24+
"description",
25+
"severity",
26+
"mitigation",
27+
"file_path",
28+
"line",
29+
"component_name",
30+
"static_finding",
31+
"dynamic_finding",
32+
]
33+
34+
def get_dedupe_fields(self) -> list[str]:
35+
"""
36+
Return the list of dedupe fields used in the Checkov Parser
37+
38+
Fields:
39+
- title: Set to check_name outputted from Checkov Scanner.
40+
- line: Set to first line of the file line range from Checkov Scanner.
41+
- file_path: Set to file path from Checkov Scanner.
42+
- description: Custom description made from: check type, check id, and check name.
43+
44+
NOTE: uses legacy dedupe: ['title', 'cwe', 'line', 'file_path', 'description']
45+
NOTE: cwe is not provided by parser
46+
"""
47+
return [
48+
"title",
49+
"line",
50+
"file_path",
51+
"description",
52+
]
53+
754
def get_scan_types(self):
855
return ["Checkov Scan"]
956

dojo/tools/gitleaks/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def get_fields(self) -> list[str]:
1818
- severity: Set to high and inccreased to critical if "Github", "AWS", or "Heroku" are in the isssue rule.
1919
- file_path: Set to issuel file from Gitleaks Scanner.
2020
- line: Set to line number from Gitleaks Scanner.
21+
- dynamic_finding: Set to false.
22+
- static_finding: Set to true.
2123
- nb_occurences: Inittially set to 1 and incremented based on number of occurences.
2224
"""
2325
return [
@@ -26,6 +28,8 @@ def get_fields(self) -> list[str]:
2628
"severity",
2729
"file_path",
2830
"line",
31+
"dynamic_finding",
32+
"static_finding",
2933
"nb_occurences",
3034
]
3135

@@ -40,6 +44,7 @@ def get_dedupe_fields(self) -> list[str]:
4044
- description: Custom description made from commit details.
4145
4246
NOTE: uses legacy dedupe: ['title', 'cwe', 'line', 'file_path', 'description']
47+
NOTE: cwe is not provided by parser.
4348
"""
4449
return [
4550
"title",

0 commit comments

Comments
 (0)