import re

from lib.common.abc import Vulnerability


class XSS(Vulnerability):

    name = 'CROSS-SITE SCRIPTING (XSS)'
    keyname = 'xss'

    def __init__(self, file_path):
        super().__init__(file_path)

    def find(self):
        return self._find(r'<.+>.*(\'|").*(\$[a-zA-Z0-9_]+).*(\'|").*</.+>|<.*(\'|").*<\?php.*(\$[a-zA-Z0-9_]+).*(\'|").*>', False)

    def __is_user_input(self, field):
        for line in self.get_lines():

            if re.search(r'_(GET|POST|DELETE|PUT|PATCH|OPTIONS)\[(.*)%s.*\]' % field, line):
                return True

        return False

7e6d2bc512804556b507ee4620c17921181e1043
<mask token>


class XSS(Vulnerability):
    <mask token>
    <mask token>

    def __init__(self, file_path):
        super().__init__(file_path)

    def find(self):
        return self._find(
            '<.+>.*(\\\'|").*(\\$[a-zA-Z0-9_]+).*(\\\'|").*</.+>|<.*(\\\'|").*<\\?php.*(\\$[a-zA-Z0-9_]+).*(\\\'|").*>'
            , False)
    <mask token>

<mask token>


class XSS(Vulnerability):
    <mask token>
    <mask token>

    def __init__(self, file_path):
        super().__init__(file_path)

    def find(self):
        return self._find(
            '<.+>.*(\\\'|").*(\\$[a-zA-Z0-9_]+).*(\\\'|").*</.+>|<.*(\\\'|").*<\\?php.*(\\$[a-zA-Z0-9_]+).*(\\\'|").*>'
            , False)

    def __is_user_input(self, field):
        for line in self.get_lines():
            if re.search(
                '_(GET|POST|DELETE|PUT|PATCH|OPTIONS)\\[(.*)%s.*\\]' %
                field, line):
                return True
        return False

<mask token>


class XSS(Vulnerability):
    name = 'CROSS-SITE SCRIPTING (XSS)'
    keyname = 'xss'

    def __init__(self, file_path):
        super().__init__(file_path)

    def find(self):
        return self._find(
            '<.+>.*(\\\'|").*(\\$[a-zA-Z0-9_]+).*(\\\'|").*</.+>|<.*(\\\'|").*<\\?php.*(\\$[a-zA-Z0-9_]+).*(\\\'|").*>'
            , False)

    def __is_user_input(self, field):
        for line in self.get_lines():
            if re.search(
                '_(GET|POST|DELETE|PUT|PATCH|OPTIONS)\\[(.*)%s.*\\]' %
                field, line):
                return True
        return False

import re
from lib.common.abc import Vulnerability


class XSS(Vulnerability):
    name = 'CROSS-SITE SCRIPTING (XSS)'
    keyname = 'xss'

    def __init__(self, file_path):
        super().__init__(file_path)

    def find(self):
        return self._find(
            '<.+>.*(\\\'|").*(\\$[a-zA-Z0-9_]+).*(\\\'|").*</.+>|<.*(\\\'|").*<\\?php.*(\\$[a-zA-Z0-9_]+).*(\\\'|").*>'
            , False)

    def __is_user_input(self, field):
        for line in self.get_lines():
            if re.search(
                '_(GET|POST|DELETE|PUT|PATCH|OPTIONS)\\[(.*)%s.*\\]' %
                field, line):
                return True
        return False

import re

from lib.common.abc import Vulnerability


class XSS(Vulnerability):

    name = 'CROSS-SITE SCRIPTING (XSS)'
    keyname = 'xss'

    def __init__(self, file_path):
        super().__init__(file_path)

    def find(self):
        return self._find(r'<.+>.*(\'|").*(\$[a-zA-Z0-9_]+).*(\'|").*</.+>|<.*(\'|").*<\?php.*(\$[a-zA-Z0-9_]+).*(\'|").*>', False)

    def __is_user_input(self, field):
        for line in self.get_lines():

            if re.search(r'_(GET|POST|DELETE|PUT|PATCH|OPTIONS)\[(.*)%s.*\]' % field, line):
                return True

        return False
