Skip to content

Commit a2a52f1

Browse files
🐛 Fix tenable CWE #13245 (#13252)
* 🐛 Fix tenable CWE #13245 * update * update
1 parent 8940cc8 commit a2a52f1

File tree

3 files changed

+7759
-1
lines changed

3 files changed

+7759
-1
lines changed

dojo/tools/tenable/xml_format.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,11 @@ def get_findings(self, filename: str, test: Test) -> list:
239239
cwe_element_text = self.safely_get_element_text(
240240
item.find("cwe"),
241241
)
242+
242243
if cwe_element_text is not None:
243-
cwe = cwe_element_text
244+
match = re.search(r"\d+", cwe_element_text)
245+
if match:
246+
cwe = int(match.group())
244247

245248
# parsing and storing the CWE would affect dedupe/hash_codes, commentint out for now
246249
# if not cwe:

unittests/scans/tenable/nessus/nessus_with_cwe-.nessus

Lines changed: 7745 additions & 0 deletions
Large diffs are not rendered by default.

unittests/tools/test_tenable_parser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ def test_parse_some_findings_with_cvssv3_nessus_legacy(self):
195195
self.assertEqual("http", endpoint.protocol)
196196
self.assertEqual("CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N", finding.cvssv3)
197197

198+
def test_parse_some_findings_with_nessus_with_cwe(self):
199+
with (get_unit_tests_scans_path("tenable/nessus") / "nessus_with_cwe-.nessus").open(encoding="utf-8") as testfile:
200+
parser = TenableParser()
201+
findings = parser.get_findings(testfile, self.create_test())
202+
for finding in findings:
203+
for endpoint in finding.unsaved_endpoints:
204+
endpoint.clean()
205+
finding = findings[0]
206+
self.assertEqual(94, finding.cwe)
207+
198208
def test_parse_many_findings_xml_nessus_was_legacy(self):
199209
with (get_unit_tests_scans_path("tenable/nessus_was") / "nessus_was_many_vuln.xml").open(encoding="utf-8") as testfile:
200210
parser = TenableParser()

0 commit comments

Comments
 (0)