# Path: ptp/libptp/constants.py
# UNKNOWN = 0
# INFO = 1
# LOW = 2
# MEDIUM = 3
# HIGH = 4
# RANKING_SCALE = {HIGH: HIGH, MEDIUM: MEDIUM, LOW: LOW, INFO: INFO, UNKNOWN: UNKNOWN}
# 
# Path: ptp/libptp/exceptions.py
# class NotSupportedVersionError(PTPError):
#     """:mod:`ptp` error when the version of the tool is not supported."""
#     pass
# 
# Path: ptp/libptp/parser.py
# class XMLParser(AbstractParser):
# 
#     """Specialized parser for XML files.
# 
#     Define the special :func:`handle_file` function in order to process the XML report file.
# 
#     """
# 
#     #: str -- XMLParser only supports XML files.
#     __format__ = 'xml'
# 
#     def __init__(self, pathname='./', filename='*.xml', **kwargs):
#         """Initialize :class:`XMLParser`."""
#         AbstractParser.__init__(self, pathname, filename, **kwargs)
# 
#     @classmethod
#     def handle_file(cls, pathname='./', filename='*.xml', first=True):
#         """Return the root node of the XML file.
# 
#         :param str pathname: Path to the report directory.
#         :param str filename: Regex matching the report file.
#         :param bool first: Stop the search as soon as a file has been matched.
# 
#         :raises IOError: when the report file cannot be found.
#         :raises TypeError: when the report file has not the right extension.
#         :raises lxml.etree.XMLSyntaxError: when Lxml cannot parse the XML file.
# 
#         :return: handle on the root node element from the XML file.
#         :rtype: :class:`lxml.etree._Element`
# 
#         """
#         fullpath = cls._recursive_find(pathname, filename, first=first)
#         if not len(fullpath):
#             raise IOError("Report matching '%s' cannot be found." % os.path.join(pathname, filename))
#         fullpath = fullpath[0]
#         if not fullpath.endswith(cls.__format__):
#             raise TypeError("This parser only supports '%s' files" % cls.__format__)
#         return etree.parse(fullpath).getroot()
# 
# class FileParser(AbstractParser):
# 
#     """Specialized parser for generic report file(s).
# 
#     Define the special :func:`handle_file` function in order to process the generic report file.
# 
#     """
# 
#     @classmethod
#     def handle_file(cls, pathname='./', filename='*', first=True):
#         """Return a string of the content of the file.
# 
#         :param str pathname: Path to the report directory.
#         :param str filename: Regex matching the report file.
#         :param bool first: Stop the search as soon as a file has been matched.
# 
#         :raises IOError: when the report file cannot be found or an error occurs when opening/reading.
#         :raises OSError: when an error occurs when opening/reading the report file.
# 
#         :return: data from the file.
#         :rtype: str
# 
#         """
#         fullpath = cls._recursive_find(pathname, filename, first=first)
#         if not len(fullpath):
#             raise IOError("Report matching '%s' cannot be found." % filename)
#         fullpath = fullpath[0]
#         data = ''
#         with open(fullpath, 'r') as f:
#             data = f.read()
#         return data


import re
from lxml.etree import XMLSyntaxError
from ptp.libptp import constants
from ptp.libptp.exceptions import NotSupportedVersionError
from ptp.libptp.parser import XMLParser, FileParser

"""





class W3AFXMLParser(XMLParser):
    """W3AF XML specialized parser."""

    __tool__ = 'w3af'
    __format__ = 'xml'
    __version__ = r'1\.[0-9]+(\.[0-9]+)?'
    __httpfile_format__ = "*.http.txt"

    _re_version = re.compile(r'Version: (\S*)\s')
    _re_transaction = re.compile(r"(?<=={30}Request )[0-9]+ .*?={9}\n(.*?)(?=\n={70})", re.S)
    _re_request = re.compile(r"(^.*?)\n==.*?(?=={20}Response )", re.S)
    _re_response = re.compile(r"(?<=={40}Response )[0-9]+ .*?={9}\n(\w.*)", re.S)
    _re_reponse_header = re.compile(r".*?content-type: .*?\n", re.S)
    _re_response_body = re.compile(r"(?<=content-type: )(.*?\n)(.*)", re.S)
    _re_response_status_code = re.compile(r"(?<=HTTP/\w.\w )(.*)")

    HIGH = 'High'
    MEDIUM = 'Medium'
    LOW = 'Low'
    INFO = 'Information'

    RANKING_SCALE = {
        HIGH: constants.HIGH,

# Path: ptp/libptp/constants.py
# UNKNOWN = 0
# INFO = 1
# LOW = 2
# MEDIUM = 3
# HIGH = 4
# RANKING_SCALE = {HIGH: HIGH, MEDIUM: MEDIUM, LOW: LOW, INFO: INFO, UNKNOWN: UNKNOWN}
# 
# Path: ptp/libptp/exceptions.py
# class NotSupportedVersionError(PTPError):
#     """:mod:`ptp` error when the version of the tool is not supported."""
#     pass
# 
# Path: ptp/libptp/parser.py
# class XMLParser(AbstractParser):
# 
#     """Specialized parser for XML files.
# 
#     Define the special :func:`handle_file` function in order to process the XML report file.
# 
#     """
# 
#     #: str -- XMLParser only supports XML files.
#     __format__ = 'xml'
# 
#     def __init__(self, pathname='./', filename='*.xml', **kwargs):
#         """Initialize :class:`XMLParser`."""
#         AbstractParser.__init__(self, pathname, filename, **kwargs)
# 
#     @classmethod
#     def handle_file(cls, pathname='./', filename='*.xml', first=True):
#         """Return the root node of the XML file.
# 
#         :param str pathname: Path to the report directory.
#         :param str filename: Regex matching the report file.
#         :param bool first: Stop the search as soon as a file has been matched.
# 
#         :raises IOError: when the report file cannot be found.
#         :raises TypeError: when the report file has not the right extension.
#         :raises lxml.etree.XMLSyntaxError: when Lxml cannot parse the XML file.
# 
#         :return: handle on the root node element from the XML file.
#         :rtype: :class:`lxml.etree._Element`
# 
#         """
#         fullpath = cls._recursive_find(pathname, filename, first=first)
#         if not len(fullpath):
#             raise IOError("Report matching '%s' cannot be found." % os.path.join(pathname, filename))
#         fullpath = fullpath[0]
#         if not fullpath.endswith(cls.__format__):
#             raise TypeError("This parser only supports '%s' files" % cls.__format__)
#         return etree.parse(fullpath).getroot()
# 
# class FileParser(AbstractParser):
# 
#     """Specialized parser for generic report file(s).
# 
#     Define the special :func:`handle_file` function in order to process the generic report file.
# 
#     """
# 
#     @classmethod
#     def handle_file(cls, pathname='./', filename='*', first=True):
#         """Return a string of the content of the file.
# 
#         :param str pathname: Path to the report directory.
#         :param str filename: Regex matching the report file.
#         :param bool first: Stop the search as soon as a file has been matched.
# 
#         :raises IOError: when the report file cannot be found or an error occurs when opening/reading.
#         :raises OSError: when an error occurs when opening/reading the report file.
# 
#         :return: data from the file.
#         :rtype: str
# 
#         """
#         fullpath = cls._recursive_find(pathname, filename, first=first)
#         if not len(fullpath):
#             raise IOError("Report matching '%s' cannot be found." % filename)
#         fullpath = fullpath[0]
#         data = ''
#         with open(fullpath, 'r') as f:
#             data = f.read()
#         return data


# Path: ptp/tools/w3af/parser.py
import re
from lxml.etree import XMLSyntaxError
from ptp.libptp import constants
from ptp.libptp.exceptions import NotSupportedVersionError
from ptp.libptp.parser import XMLParser, FileParser


"""





class W3AFXMLParser(XMLParser):
    """W3AF XML specialized parser."""

    __tool__ = 'w3af'
    __format__ = 'xml'
    __version__ = r'1\.[0-9]+(\.[0-9]+)?'
    __httpfile_format__ = "*.http.txt"

    _re_version = re.compile(r'Version: (\S*)\s')
    _re_transaction = re.compile(r"(?<=={30}Request )[0-9]+ .*?={9}\n(.*?)(?=\n={70})", re.S)
    _re_request = re.compile(r"(^.*?)\n==.*?(?=={20}Response )", re.S)
    _re_response = re.compile(r"(?<=={40}Response )[0-9]+ .*?={9}\n(\w.*)", re.S)
    _re_reponse_header = re.compile(r".*?content-type: .*?\n", re.S)
    _re_response_body = re.compile(r"(?<=content-type: )(.*?\n)(.*)", re.S)
    _re_response_status_code = re.compile(r"(?<=HTTP/\w.\w )(.*)")

    HIGH = 'High'
    MEDIUM = 'Medium'
    LOW = 'Low'
    INFO = 'Information'

    RANKING_SCALE = {
        HIGH: constants.HIGH,

        MEDIUM: constants.MEDIUM,