Skip to content

Commit

Permalink
Merge branch 'tkt_129_nmap_no_results' into 'dev'
Browse files Browse the repository at this point in the history
Resolve "Plugin Nmap"

Closes #129

See merge request faradaysec/faraday-plugins!78
  • Loading branch information
llazzaro committed Jul 2, 2020
2 parents 69cc684 + b9db8ca commit 54ab323
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/current/fix_xml_nmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix broken xml on nmap plugin
11 changes: 7 additions & 4 deletions faraday_plugins/plugins/repo/nmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"""

from faraday_plugins.plugins.plugin import PluginXMLFormat
import re
import os

from io import BytesIO

try:
import xml.etree.cElementTree as ET
Expand All @@ -17,12 +16,15 @@
except ImportError:
import xml.etree.ElementTree as ET
ETREE_VERSION = ET.VERSION
from lxml import etree
from lxml.etree import XMLParser
from faraday_plugins.plugins.plugin import PluginXMLFormat

ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")]

current_path = os.path.abspath(os.getcwd())



class NmapXmlParser:
"""
The objective of this class is to parse an xml file generated by
Expand Down Expand Up @@ -55,7 +57,8 @@ def parse_xml(self, xml_output):
"""

try:
return ET.fromstring(xml_output)
magical_parser = XMLParser(recover=True)
return etree.parse(BytesIO(xml_output), magical_parser)
except SyntaxError as err:
#logger.error("SyntaxError: %s." % (err))
return None
Expand Down

0 comments on commit 54ab323

Please sign in to comment.