Skip to content

Commit 10dfa22

Browse files
🐛 fix nmap parser, add script output #10456 (#10739)
* 🐛 fix nmap parser, add script output * review comment * added unittest
1 parent c71facf commit 10dfa22

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

dojo/tools/nmap/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ def get_findings(self, file, test):
9696
service_info += (
9797
"**Extra Info:** {}\n".format(port_element.find("service").attrib["extrainfo"])
9898
)
99-
10099
description += service_info
101-
100+
if script := port_element.find("script"):
101+
if script_id := script.attrib.get("id"):
102+
description += f"**Script ID:** {script_id}\n"
103+
if script_output := script.attrib.get("output"):
104+
description += f"**Script Output:** {script_output}\n"
102105
description += "\n\n"
103106

104107
# manage some script like

unittests/tools/test_nmap_parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,6 @@ def test_parse_issue4406(self):
131131
self.assertEqual("ip-10-250-195-71.eu-west-1.compute.internal", endpoint.host)
132132
self.assertEqual(31641, endpoint.port)
133133
self.assertEqual("tcp", endpoint.protocol)
134+
with self.subTest(i=55):
135+
finding = findings[55]
136+
self.assertEqual("### Host\n\n**IP Address:** 10.250.195.71\n**FQDN:** ip-10-250-195-71.eu-west-1.compute.internal\n\n\n**Port/Protocol:** 30150/tcp\n\n\n**Script ID:** fingerprint-strings\n**Script Output:** \n GenericLines: \n E_BAD_PROTOCOL\n\n\n", finding.description)

0 commit comments

Comments
 (0)