예제 #1
0
    def __init__(self, init_val=(), encoding=UTF8):
        DataContainer.__init__(self, encoding=encoding)
        OrderedDict.__init__(self)

        if isinstance(init_val, KeyValueContainer):
            self.update(init_val)
        elif isinstance(init_val, dict):
            # we lose compatibility with other ordered dict types this way
            raise TypeError('Undefined order, cannot get items from dict')
        else:
            for item in init_val:
                try:
                    key, val = item
                except TypeError:
                    raise TypeError(ERR_MSG % init_val)

                if key in self:
                    raise TypeError(ERR_MSG % init_val)

                if not isinstance(val, (list, tuple)):
                    raise TypeError(ERR_MSG % init_val)

                for sub_val in val:
                    if not isinstance(sub_val, (basestring, DataToken)):
                        raise TypeError(ERR_MSG % init_val)

                self[key] = val
예제 #2
0
    def __init__(self, init_val=(), encoding=UTF8):
        DataContainer.__init__(self, encoding=encoding)
        OrderedDict.__init__(self)

        if isinstance(init_val, KeyValueContainer):
            self.update(init_val)
        elif isinstance(init_val, dict):
            # we lose compatibility with other ordered dict types this way
            raise TypeError('Undefined order, cannot get items from dict')
        else:
            for item in init_val:
                try:
                    key, val = item
                except TypeError:
                    raise TypeError(ERR_MSG % init_val)

                if key in self:
                    raise TypeError(ERR_MSG % init_val)

                if not isinstance(val, (list, tuple)):
                    raise TypeError(ERR_MSG % init_val)

                for sub_val in val:
                    if not isinstance(sub_val, (basestring, DataToken)):
                        raise TypeError(ERR_MSG % init_val)

                self[key] = val
예제 #3
0
    def __init__(self, json_post_data, encoding=UTF8):
        """
        :param json_post_data: The JSON data as string
        """
        DataContainer.__init__(self, encoding=encoding)

        if not isinstance(json_post_data, basestring):
            raise TypeError(ERR_MSG % json_post_data)

        if not JSONContainer.is_json(json_post_data):
            raise ValueError(ERR_MSG % json_post_data[:50])

        self._json = None
        self._raw_json = None

        self.parse_json(json_post_data)
예제 #4
0
파일: php_sca.py 프로젝트: hougomartim/w3af
        def write_vuln_to_kb(vulnty, url, funcs):
            vulndata = php_sca.KB_DATA[vulnty]
            for f in funcs:
                vuln_sev = vulndata['severity']
                desc = name = vulndata['name']

                v = Vuln(name, desc, vuln_sev, 1, 'PHP Static Code Analyzer')
                v.set_uri(url)
                v.set_token((f.vulnsources[0], 0))

                args = list(vulndata['kb_key']) + [v]

                # TODO: Extract the method from the PHP code
                #     $_GET == GET
                #     $_POST == POST
                #     $_REQUEST == GET
                v.set_method('GET')

                # TODO: Extract all the other variables that are
                # present in the PHP file using the SCA
                v.set_dc(DataContainer())

                #
                # TODO: This needs to be checked! OS Commanding specific
                #       attributes.
                v['os'] = 'unix'
                v['separator'] = ''

                kb.kb.append(*args)
예제 #5
0
    def __init__(self, json_post_data, encoding=UTF8):
        """
        :param json_post_data: The JSON data as string
        """
        DataContainer.__init__(self, encoding=encoding)

        if not isinstance(json_post_data, basestring):
            raise TypeError(ERR_MSG % json_post_data)

        if not JSONContainer.is_json(json_post_data):
            raise ValueError(ERR_MSG % json_post_data[:50])

        self._json = None
        self._raw_json = None

        self.parse_json(json_post_data)
예제 #6
0
    def __init__(self, xml_post_data, encoding=UTF8):
        """
        :param xml_post_data: The XML data as string
        """
        DataContainer.__init__(self, encoding=encoding)

        if not isinstance(xml_post_data, basestring):
            raise TypeError(ERR_MSG % xml_post_data)

        if not XMLContainer.is_xml(xml_post_data):
            raise ValueError(ERR_MSG % xml_post_data[:50])

        self._xml = None
        self._raw_xml = None
        self.doctype = ''

        self.parse_xml(xml_post_data)
예제 #7
0
    def __init__(self, init_val=(), encoding=UTF8, relaxed_order=False):
        DataContainer.__init__(self, encoding=encoding)
        OrderedDict.__init__(self, relax=relaxed_order)

        if isinstance(init_val, NonRepeatKeyValueContainer):
            self.update(init_val)
        elif isinstance(init_val, dict):
            # we lose compatibility with other ordered dict types this way
            raise TypeError('Undefined order, cannot get items from dict')
        else:
            for item in init_val:
                try:
                    key, val = item
                except TypeError:
                    raise TypeError(ERR_MSG_NO_REP % init_val)

                if key in self:
                    raise TypeError(ERR_MSG_NO_REP % init_val)

                if not isinstance(val, (basestring, DataToken)):
                    raise TypeError(ERR_MSG_NO_REP % init_val)

                self[key] = val
예제 #8
0
    def __init__(self, init_val=(), encoding=UTF8, relaxed_order=False):
        DataContainer.__init__(self, encoding=encoding)
        OrderedDict.__init__(self, relax=relaxed_order)

        if isinstance(init_val, NonRepeatKeyValueContainer):
            self.update(init_val)
        elif isinstance(init_val, dict):
            # we lose compatibility with other ordered dict types this way
            raise TypeError('Undefined order, cannot get items from dict')
        else:
            for item in init_val:
                try:
                    key, val = item
                except TypeError:
                    raise TypeError(ERR_MSG_NO_REP % init_val)

                if key in self:
                    raise TypeError(ERR_MSG_NO_REP % init_val)

                if not isinstance(val, (basestring, DataToken)):
                    raise TypeError(ERR_MSG_NO_REP % init_val)

                self[key] = val
예제 #9
0
    def __init__(self, json_post_data, headers=None, encoding=UTF8):
        """
        :param json_post_data: The JSON data as string
        :param headers: The headers as dict
        """
        DataContainer.__init__(self, encoding=encoding)

        if not isinstance(json_post_data, basestring):
            raise TypeError(ERR_MSG % json_post_data)

        if not JSONContainer.is_json(json_post_data):
            raise ValueError(ERR_MSG % json_post_data[:50])

        if headers is not None and not isinstance(headers, dict):
            raise TypeError(ERR_MSG % headers)

        self._json = None
        self._raw_json = None

        self._headers = headers
        if self._headers is None:
            self._headers = JSONContainer.DEFAULT_HEADERS.copy()

        self.parse_json(json_post_data)
예제 #10
0
    def test_empty(self):
        dc = DataContainer()

        self.assertRaises(NotImplementedError, dc.get_param_names)
        self.assertIsNone(dc.get_token())
예제 #11
0
    def test_empty(self):
        dc = DataContainer()

        self.assertRaises(NotImplementedError, dc.get_param_names)
        self.assertIsNone(dc.get_token())