Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
720f078
Update files in folder dojo/tools/mozilla_observatory with PEP8 stand…
ajtortolero Jun 26, 2023
e6a2a93
Update files in folder dojo/tools/netsparker with PEP8 standars.
ajtortolero Jun 26, 2023
cb55e76
Update files in folder dojo/tools/neuvector with PEP8 standars.
ajtortolero Jun 26, 2023
ae88323
Update files in folder dojo/tools/neuvector_compliance with PEP8 stan…
ajtortolero Jun 26, 2023
6d343fd
Update files in folder dojo/tools/nexpose with PEP8 standars.
ajtortolero Jun 26, 2023
e6e7f09
Update files in folder dojo/tools/nikto with PEP8 standars.
ajtortolero Jun 26, 2023
5724957
Update files in folder dojo/tools/nmap with PEP8 standars.
ajtortolero Jun 26, 2023
06e0606
Update files in folder dojo/tools/npm_audit with PEP8 standars.
ajtortolero Jun 26, 2023
056ee69
Update files in folder dojo/tools/nsp with PEP8 standars.
ajtortolero Jun 26, 2023
ffb6aa7
Update files in folder dojo/tools/nuclei with PEP8 standars.
ajtortolero Jun 26, 2023
b761f80
Update files in folder dojo/tools/openscap with PEP8 standars.
ajtortolero Jun 26, 2023
80ffeae
Update files in folder dojo/tools/openvas_csv with PEP8 standars.
ajtortolero Jun 26, 2023
f864edc
Update files in folder dojo/tools/ort with PEP8 standars.
ajtortolero Jun 26, 2023
9029ab6
Update files in folder dojo/tools/ossindex_devaudit with PEP8 standars.
ajtortolero Jun 26, 2023
a1a7d2f
Update files in folder dojo/tools/outpost24 with PEP8 standars.
ajtortolero Jun 26, 2023
12bdaf1
Update files in folder dojo/tools/php_security_audit_v2 with PEP8 sta…
ajtortolero Jun 26, 2023
81f36ef
Update files in folder dojo/tools/php_symfony_security_check with PEP…
ajtortolero Jun 26, 2023
187bec2
Update files in folder dojo/tools/pip_audit with PEP8 standars.
ajtortolero Jun 26, 2023
a9c122b
Update files in folder dojo/tools/pmd with PEP8 standars.
ajtortolero Jun 26, 2023
8ed3147
Update files in folder dojo/tools/popeye with PEP8 standars.
ajtortolero Jun 26, 2023
473b775
Update files in folder dojo/tools/pwn_sast with PEP8 standars.
ajtortolero Jun 26, 2023
6b8b6db
Update files in folder dojo/tools/qualys with PEP8 standars.
ajtortolero Jun 26, 2023
faa68f7
Update files in folder dojo/tools/qualys_infrascan_webgui with PEP8 s…
ajtortolero Jun 26, 2023
1a382cc
Update files in folder dojo/tools/qualys_webapp with PEP8 standars.
ajtortolero Jun 26, 2023
1a5af8f
Update files in folder dojo/tools/retirejs with PEP8 standars.
ajtortolero Jun 26, 2023
d1d4f5f
Update files in folder dojo/tools/risk_recon with PEP8 standars.
ajtortolero Jun 26, 2023
0264ba4
Update files in folder dojo/tools/rubocop with PEP8 standars.
ajtortolero Jun 26, 2023
ca9d0a7
Update files in folder dojo/tools/rusty_hog with PEP8 standars.
ajtortolero Jun 26, 2023
5cc690e
Change BaseException to Exception
ajtortolero Jun 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions dojo/tools/mozilla_observatory/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,25 @@ def get_findings(self, file, test):
for key in nodes:
node = nodes[key]

description = "\n".join([
"**Score Description** : `" + node['score_description'] + "`",
"**Result** : `" + node['result'] + "`"
"**expectation** : " + str(node.get('expectation')) + "`",
])
description = "\n".join(
[
"**Score Description** : `"
+ node["score_description"]
+ "`",
"**Result** : `" + node["result"] + "`"
"**expectation** : " + str(node.get("expectation")) + "`",
]
)

finding = Finding(
title=node['score_description'],
title=node["score_description"],
test=test,
active=not node['pass'],
active=not node["pass"],
description=description,
severity=self.get_severity(int(node['score_modifier'])),
severity=self.get_severity(int(node["score_modifier"])),
static_finding=False,
dynamic_finding=True,
vuln_id_from_tool=node.get('name', key)
vuln_id_from_tool=node.get("name", key),
)

findings.append(finding)
Expand Down
50 changes: 29 additions & 21 deletions dojo/tools/netsparker/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class NetsparkerParser(object):

def get_scan_types(self):
return ["Netsparker Scan"]

Expand All @@ -20,26 +19,27 @@ def get_description_for_scan_types(self, scan_type):
def get_findings(self, filename, test):
tree = filename.read()
try:
data = json.loads(str(tree, 'utf-8-sig'))
except:
data = json.loads(str(tree, "utf-8-sig"))
except Exception:
data = json.loads(tree)
dupes = dict()
scan_date = datetime.datetime.strptime(data["Generated"], "%d/%m/%Y %H:%M %p").date()
scan_date = datetime.datetime.strptime(
data["Generated"], "%d/%m/%Y %H:%M %p"
).date()

for item in data["Vulnerabilities"]:

title = item["Name"]
findingdetail = html2text.html2text(item.get("Description", ""))
if "Cwe" in item["Classification"]:
try:
cwe = int(item["Classification"]["Cwe"].split(',')[0])
except:
cwe = int(item["Classification"]["Cwe"].split(",")[0])
except Exception:
cwe = None
else:
cwe = None
sev = item["Severity"]
if sev not in ['Info', 'Low', 'Medium', 'High', 'Critical']:
sev = 'Info'
if sev not in ["Info", "Low", "Medium", "High", "Critical"]:
sev = "Info"
mitigation = html2text.html2text(item.get("RemedialProcedure", ""))
references = html2text.html2text(item.get("RemedyReferences", ""))
url = item["Url"]
Expand All @@ -48,16 +48,18 @@ def get_findings(self, filename, test):
request = item["HttpRequest"]["Content"]
response = item["HttpResponse"]["Content"]

finding = Finding(title=title,
test=test,
description=findingdetail,
severity=sev.title(),
mitigation=mitigation,
impact=impact,
date=scan_date,
references=references,
cwe=cwe,
static_finding=True)
finding = Finding(
title=title,
test=test,
description=findingdetail,
severity=sev.title(),
mitigation=mitigation,
impact=impact,
date=scan_date,
references=references,
cwe=cwe,
static_finding=True,
)

if item["State"].find("FalsePositive") != -1:
finding.active = False
Expand All @@ -69,8 +71,14 @@ def get_findings(self, filename, test):
if item["State"].find("AcceptedRisk") != -1:
finding.risk_accepted = True

if (item["Classification"] is not None) and (item["Classification"]["Cvss"] is not None) and (item["Classification"]["Cvss"]["Vector"] is not None):
cvss_objects = cvss_parser.parse_cvss_from_text(item["Classification"]["Cvss"]["Vector"])
if (
(item["Classification"] is not None)
and (item["Classification"]["Cvss"] is not None)
and (item["Classification"]["Cvss"]["Vector"] is not None)
):
cvss_objects = cvss_parser.parse_cvss_from_text(
item["Classification"]["Cvss"]["Vector"]
)
if len(cvss_objects) > 0:
finding.cvssv3 = cvss_objects[0].clean_vector()

Expand Down
100 changes: 66 additions & 34 deletions dojo/tools/neuvector/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

logger = logging.getLogger(__name__)

NEUVECTOR_SCAN_NAME = 'NeuVector (REST)'
NEUVECTOR_IMAGE_SCAN_ENGAGEMENT_NAME = 'NV image scan'
NEUVECTOR_CONTAINER_SCAN_ENGAGEMENT_NAME = 'NV container scan'
NEUVECTOR_SCAN_NAME = "NeuVector (REST)"
NEUVECTOR_IMAGE_SCAN_ENGAGEMENT_NAME = "NV image scan"
NEUVECTOR_CONTAINER_SCAN_ENGAGEMENT_NAME = "NV container scan"


class NeuVectorJsonParser(object):
Expand All @@ -22,82 +22,114 @@ def parse_json(self, json_output):
try:
data = json_output.read()
try:
tree = json.loads(str(data, 'utf-8'))
except:
tree = json.loads(str(data, "utf-8"))
except Exception:
tree = json.loads(data)
except:
except Exception:
raise ValueError("Invalid format")

return tree

def get_items(self, tree, test):
items = {}
if 'report' in tree:
vulnerabilityTree = tree.get('report').get('vulnerabilities', [])
if "report" in tree:
vulnerabilityTree = tree.get("report").get("vulnerabilities", [])
for node in vulnerabilityTree:
item = get_item(node, test)
package_name = node.get('package_name')
package_name = node.get("package_name")
if len(package_name) > 64:
package_name = package_name[-64:]
unique_key = node.get('name') + str(package_name + str(
node.get('package_version')) + str(node.get('severity')))
unique_key = node.get("name") + str(
package_name
+ str(node.get("package_version"))
+ str(node.get("severity"))
)
items[unique_key] = item
return list(items.values())


def get_item(vulnerability, test):
severity = convert_severity(vulnerability.get('severity')) if 'severity' in vulnerability else "Info"
vector = vulnerability.get('vectors_v3') if 'vectors_v3' in vulnerability else "CVSSv3 vector not provided. "
fixed_version = vulnerability.get('fixed_version') if 'fixed_version' in vulnerability else "There seems to be no fix yet. Please check description field."
score_v3 = vulnerability.get('score_v3') if 'score_v3' in vulnerability else "No CVSSv3 score yet."
package_name = vulnerability.get('package_name')
severity = (
convert_severity(vulnerability.get("severity"))
if "severity" in vulnerability
else "Info"
)
vector = (
vulnerability.get("vectors_v3")
if "vectors_v3" in vulnerability
else "CVSSv3 vector not provided. "
)
fixed_version = (
vulnerability.get("fixed_version")
if "fixed_version" in vulnerability
else "There seems to be no fix yet. Please check description field."
)
score_v3 = (
vulnerability.get("score_v3")
if "score_v3" in vulnerability
else "No CVSSv3 score yet."
)
package_name = vulnerability.get("package_name")
if len(package_name) > 64:
package_name = package_name[-64:]
description = vulnerability.get('description') if 'description' in vulnerability else ""
link = vulnerability.get('link') if 'link' in vulnerability else ""
description = (
vulnerability.get("description")
if "description" in vulnerability
else ""
)
link = vulnerability.get("link") if "link" in vulnerability else ""

# create the finding object
finding = Finding(
title=vulnerability.get('name') + ": " + package_name + " - " + vulnerability.get('package_version'),
title=vulnerability.get("name")
+ ": "
+ package_name
+ " - "
+ vulnerability.get("package_version"),
test=test,
severity=severity,
description=description + "<p> Vulnerable Package: " +
package_name + "</p><p> Current Version: " + str(
vulnerability['package_version']) + "</p>",
description=description
+ "<p> Vulnerable Package: "
+ package_name
+ "</p><p> Current Version: "
+ str(vulnerability["package_version"])
+ "</p>",
mitigation=fixed_version.title(),
references=link,
component_name=package_name,
component_version=vulnerability.get('package_version'),
component_version=vulnerability.get("package_version"),
false_p=False,
duplicate=False,
out_of_scope=False,
mitigated=None,
severity_justification="{} (CVSS v3 base score: {})\n".format(vector, score_v3),
impact=severity)
finding.unsaved_vulnerability_ids = [vulnerability.get('name')]
severity_justification="{} (CVSS v3 base score: {})\n".format(
vector, score_v3
),
impact=severity,
)
finding.unsaved_vulnerability_ids = [vulnerability.get("name")]
finding.description = finding.description.strip()

return finding


# see neuvector/share/types.go
def convert_severity(severity):
if severity.lower() == 'critical':
if severity.lower() == "critical":
return "Critical"
elif severity.lower() == 'high':
elif severity.lower() == "high":
return "High"
elif severity.lower() == 'medium':
elif severity.lower() == "medium":
return "Medium"
elif severity.lower() == 'low':
elif severity.lower() == "low":
return "Low"
elif severity == '':
elif severity == "":
return "Info"
else:
return severity.title()


class NeuVectorParser(object):

def get_scan_types(self):
return [NEUVECTOR_SCAN_NAME]

Expand All @@ -111,7 +143,7 @@ def get_findings(self, filename, test):
if filename is None:
return list()

if filename.name.lower().endswith('.json'):
if filename.name.lower().endswith(".json"):
return NeuVectorJsonParser().parse(filename, test)
else:
raise ValueError('Unknown File Format')
raise ValueError("Unknown File Format")
Loading