Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing openvas parser and including script_id for openvas and nmap #11454

Open
wants to merge 2 commits into
base: bugfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions dojo/tools/nmap/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def get_findings(self, file, test):
"**Extra Info:** {}\n".format(port_element.find("service").attrib["extrainfo"])
)
description += service_info
script_id = None
if script := port_element.find("script"):
if script_id := script.attrib.get("id"):
description += f"**Script ID:** {script_id}\n"
Expand Down Expand Up @@ -126,6 +127,7 @@ def get_findings(self, file, test):
severity=severity,
mitigation="N/A",
impact="No impact provided",
vuln_id_from_tool=script_id,
)
find.unsaved_endpoints = []
dupes[dupe_key] = find
Expand Down
6 changes: 5 additions & 1 deletion dojo/tools/openvas/xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def get_findings(self, filename, test):
report = root.find("report")
results = report.find("results")
for result in results:
script_id = None
for finding in result:
if finding.tag == "name":
title = finding.text
Expand All @@ -27,7 +28,9 @@ def get_findings(self, filename, test):
title = title + "_" + finding.text
description.append(f"**Port**: {finding.text}")
if finding.tag == "nvt":
description.append(f"**NVT**: {finding.text}")
script_id = finding.get("oid") or finding.text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have some implication for hash code generation since the description is used by default. Please remove this section, and keep the script_id to the vuln_id_from_tool field

text = f"{script_id}\n{finding.text}" if finding.get("oid") and finding.text else script_id
description.append(f"**NVT**: {text}")
if finding.tag == "severity":
severity = self.convert_cvss_score(finding.text)
description.append(f"**Severity**: {finding.text}")
Expand All @@ -42,6 +45,7 @@ def get_findings(self, filename, test):
severity=severity,
dynamic_finding=True,
static_finding=False,
vuln_id_from_tool=script_id,
)
findings.append(finding)
return findings
Expand Down
Loading