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

🐛 fix nessus severity #9549

Merged
merged 3 commits into from
Feb 20, 2024
Merged
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
19 changes: 19 additions & 0 deletions dojo/tools/tenable/xml_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ def get_text_severity(self, severity_id):
severity = "Info"
return severity

def get_cvss_severity(self, cvss_score):
"""Convert data of the report into severity"""
severity = "Info"
if float(cvss_score) >= 9.0:
severity = "Critical"
elif float(cvss_score) >= 7.0:
severity = "High"
elif float(cvss_score) >= 5.0:
severity = "Medium"
elif float(cvss_score) > 0.0:
severity = "Low"
else:
severity = "Info"
return severity

def safely_get_element_text(self, element):
if element is None:
return None
Expand Down Expand Up @@ -203,6 +218,10 @@ def get_findings(self, filename: str, test: Test) -> list:
if cvssv3_score_element_text is not None:
cvssv3_score = cvssv3_score_element_text

cvss = self.safely_get_element_text(item.find("cvss3_base_score"))
if cvss is not None:
severity = self.get_cvss_severity(cvss)

# Determine the current entry has already been parsed in
# this report
dupe_key = severity + title
Expand Down
7,711 changes: 7,711 additions & 0 deletions unittests/scans/tenable/nessus/issue_6992.nessus

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion unittests/tools/test_tenable_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test_parse_some_findings_csv_nessus_legacy(self):
self.assertEqual("CVE-2004-2761", finding.unsaved_vulnerability_ids[0])
# this vuln have 'CVE-2013-2566,CVE-2015-2808' as CVE
finding = findings[3]
print(f"finding.unsaved_vulnerability_ids: {finding.unsaved_vulnerability_ids} - {type(finding.unsaved_vulnerability_ids)} - {type(finding.unsaved_vulnerability_ids[0])}")
self.assertEqual(2, len(finding.unsaved_vulnerability_ids))
self.assertEqual("CVE-2013-2566", finding.unsaved_vulnerability_ids[0])
self.assertEqual("CVE-2015-2808", finding.unsaved_vulnerability_ids[1])
Expand Down Expand Up @@ -268,3 +267,13 @@ def test_parse_many_tenable_vulns(self):
self.assertEqual(1, len(finding.unsaved_vulnerability_ids))
for vulnerability_id in finding.unsaved_vulnerability_ids:
self.assertEqual('CVE-2023-32233', vulnerability_id)

def test_parse_issue_6992(self):
testfile = open("unittests/scans/tenable/nessus/issue_6992.nessus")
parser = TenableParser()
findings = parser.get_findings(testfile, self.create_test())
for finding in findings:
for endpoint in finding.unsaved_endpoints:
endpoint.clean()
self.assertEqual(1, len(findings))
self.assertEqual("High", findings[0].severity)
Loading