forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.py
More file actions
55 lines (41 loc) · 2.07 KB
/
parser.py
File metadata and controls
55 lines (41 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
from dojo.models import Finding
class BearerCLIParser:
"""Bearer CLI tool is a SAST scanner for multiple languages"""
def get_scan_types(self):
return ["Bearer CLI"]
def get_label_for_scan_types(self, scan_type):
return "Bearer CLI"
def get_description_for_scan_types(self, scan_type):
return "Bearer CLI report file can be imported in JSON format (option -f json)."
def get_findings(self, file, test):
data = json.load(file)
items = []
dupes = set()
for content in data:
severity = content.capitalize()
for bearerfinding in data[content]:
if bearerfinding["fingerprint"] in dupes:
continue
dupes.add(bearerfinding["fingerprint"])
finding = Finding(
title=bearerfinding["title"] + " in " + bearerfinding["filename"] + ":" + str(bearerfinding["line_number"]),
test=test,
description=bearerfinding["description"] + "\n Detected code snippet: \n" + bearerfinding.get("snippet", bearerfinding.get("code_extract")),
severity=severity,
cwe=bearerfinding["cwe_ids"][0],
static_finding=True,
dynamic_finding=False,
references=bearerfinding["documentation_url"],
file_path=bearerfinding["filename"],
line=bearerfinding["line_number"],
sast_sink_object=bearerfinding["sink"],
sast_source_object=bearerfinding["source"],
sast_source_line=bearerfinding["source"]["start"],
sast_source_file_path=bearerfinding["filename"],
vuln_id_from_tool=bearerfinding["id"],
# the fingerprint is not constant over time, but because it's not used for dedupe it's safe and useful to set it
unique_id_from_tool=bearerfinding["fingerprint"],
)
items.append(finding)
return items