当前位置: 首页>>代码示例>>Python>>正文


Python kv_container.KeyValueContainer类代码示例

本文整理汇总了Python中w3af.core.data.dc.generic.kv_container.KeyValueContainer的典型用法代码示例。如果您正苦于以下问题:Python KeyValueContainer类的具体用法?Python KeyValueContainer怎么用?Python KeyValueContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KeyValueContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_short_printable_repr_token_obj

    def test_get_short_printable_repr_token_obj(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])
        token = DataToken('a', '1', ('a', 0))
        dc.set_token(token)

        self.assertIsNotNone(dc.get_token())
        self.assertEqual(dc.get_short_printable_repr(), 'a=1&b=2&b=3')
开发者ID:andresriancho,项目名称:w3af,代码行数:7,代码来源:test_kv_container.py

示例2: test_iter_tokens

    def test_iter_tokens(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])
        tokens = [t for t in dc.iter_tokens()]

        EXPECTED_TOKENS = [('a', '1'), ('b', '2'), ('b', '3')]
        token_data = [(t.get_name(), t.get_value()) for t in tokens]
        self.assertEqual(EXPECTED_TOKENS, token_data)
开发者ID:0x554simon,项目名称:w3af,代码行数:7,代码来源:test_kv_container.py

示例3: test_get_short_printable_repr_unicode_value_unicode

    def test_get_short_printable_repr_unicode_value_unicode(self):
        dc = KeyValueContainer([(u'aéb', [u'céd']), (u'b', ['2', '3'])])
        dc.MAX_PRINTABLE = 7
        token = DataToken(u'aéb', u'céd', (u'aéb', 0))
        dc.set_token(token)

        self.assertEqual(dc.get_short_printable_repr(), '...a.b=c.d...')
开发者ID:andresriancho,项目名称:w3af,代码行数:7,代码来源:test_kv_container.py

示例4: test_get_short_printable_repr_unicode_value

    def test_get_short_printable_repr_unicode_value(self):
        dc = KeyValueContainer([(u'a', ['x']), (u'b', ['2', '3'])])
        dc.MAX_PRINTABLE = 5
        token = DataToken('a', 'é', ('a', 0))
        dc.set_token(token)

        self.assertEqual(dc.get_short_printable_repr(), '...a=....')
开发者ID:andresriancho,项目名称:w3af,代码行数:7,代码来源:test_kv_container.py

示例5: test_iter_bound_tokens

    def test_iter_bound_tokens(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])
        dcc_tokens = [(dcc, t) for dcc, t in dc.iter_bound_tokens()]

        EXPECTED_TOKENS = [('a', '1'), ('b', '2'), ('b', '3')]
        token_data = [(t.get_name(), t.get_value()) for dcc, t in dcc_tokens]
        self.assertEqual(EXPECTED_TOKENS, token_data)

        for dcc, _ in dcc_tokens:
            self.assertIsInstance(dcc, KeyValueContainer)
            self.assertEquals(dcc, dc)

        self.assertEqual(str(dcc), 'a=1&b=2&b=3')

        only_dcc = [dcc for dcc, t in dcc_tokens]
        dcc = only_dcc[0]
        token = dcc.get_token()
        token.set_value('5')
        self.assertEqual(str(dcc), 'a=5&b=2&b=3')

        dcc = only_dcc[1]
        token = dcc.get_token()
        token.set_value('5')
        self.assertEqual(str(dcc), 'a=1&b=5&b=3')

        dcc = only_dcc[2]
        token = dcc.get_token()
        token.set_value('5')
        self.assertEqual(str(dcc), 'a=1&b=2&b=5')
开发者ID:0x554simon,项目名称:w3af,代码行数:29,代码来源:test_kv_container.py

示例6: test_double_data_token_wrap

    def test_double_data_token_wrap(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['c', '3'])])
        dc.set_token(('b', 1))

        for dcc, token in dc.iter_bound_tokens():
            self.assertIsInstance(token, DataToken)
            self.assertIsInstance(token.get_value(), basestring)
开发者ID:0x554simon,项目名称:w3af,代码行数:7,代码来源:test_kv_container.py

示例7: test_copy_with_token

    def test_copy_with_token(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])

        dc.set_token(('a', 0))
        dc_copy = copy.deepcopy(dc)

        self.assertEqual(dc.get_token(), dc_copy.get_token())
        self.assertIsNotNone(dc.get_token())
        self.assertIsNotNone(dc_copy.get_token())
开发者ID:0x554simon,项目名称:w3af,代码行数:9,代码来源:test_kv_container.py

示例8: __init__

    def __init__(self, xml_post_data, encoding=UTF8):
        """
        :param xml_post_data: The XMLRPC call as string
        """
        KeyValueContainer.__init__(self, init_val=[], encoding=encoding)

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

        self._xml_post_data = xml_post_data
        self.parse_xml_data(xml_post_data)
开发者ID:andresriancho,项目名称:w3af,代码行数:11,代码来源:xmlrpc.py

示例9: __init__

    def __init__(self, uri, method='GET', headers=None, cookie=None,
                 post_data=None):
        super(FuzzableRequest, self).__init__()

        # Note: Do not check for the URI/Headers type here, since I'm doing it
        # in set_uri() and set_headers() already.
        if cookie is not None and not isinstance(cookie, Cookie):
            raise TypeError(TYPE_ERROR % ('cookie', 'Cookie'))

        if post_data is not None and not isinstance(post_data, DataContainer):
            raise TypeError(TYPE_ERROR % ('post_data', 'DataContainer'))

        # Internal variables
        self._method = method
        self._cookie = Cookie() if cookie is None else cookie
        self._post_data = KeyValueContainer() if post_data is None else post_data

        # Set the headers
        self._headers = None
        pheaders = Headers() if headers is None else headers
        self.set_headers(pheaders)

        # Set the URL
        self._uri = None
        self._url = None
        self.set_uri(uri)

        # Set the internal variables
        self._sent_info_comp = None
开发者ID:andresriancho,项目名称:w3af-kali,代码行数:29,代码来源:fuzzable_request.py

示例10: test_iter_setters

    def test_iter_setters(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])
        kv_setter = [(k, v, p, s) for (k, v, p, s) in dc.iter_setters()]

        EXPECTED_KEY_VALUES = [('a', '1', ('a', 0)),
                               ('b', '2', ('b', 0)),
                               ('b', '3', ('b', 1))]
        kvp = [(key, value, path) for (key, value, path, _) in kv_setter]
        self.assertEqual(EXPECTED_KEY_VALUES, kvp)

        for idx, (key, value, path, setter) in enumerate(kv_setter):
            if idx == 2:
                setter('w')

        self.assertEqual(str(dc), 'a=1&b=2&b=w')

        SET_VALUES = ['x', 'y', 'z']
        for idx, (key, value, path, setter) in enumerate(kv_setter):
            setter(SET_VALUES[idx])

        self.assertEqual(str(dc), 'a=x&b=y&b=z')
开发者ID:0x554simon,项目名称:w3af,代码行数:21,代码来源:test_kv_container.py

示例11: test_get_short_printable_repr_token_obj_reduce_printable

    def test_get_short_printable_repr_token_obj_reduce_printable(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])
        dc.MAX_PRINTABLE = 5
        token = DataToken('a', '1', ('a', 0))
        dc.set_token(token)

        self.assertIsNotNone(dc.get_token())
        self.assertEqual(dc.get_short_printable_repr(), '...a=1...')
开发者ID:andresriancho,项目名称:w3af,代码行数:8,代码来源:test_kv_container.py

示例12: test_set_token_using_data_token

    def test_set_token_using_data_token(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])

        token = DataToken('a', '1', ('a', 0))
        set_token = dc.set_token(token)

        self.assertEqual(dc.get_token().get_name(), 'a')
        self.assertEqual(dc.get_token().get_value(), '1')
        self.assertEqual(dc.get_token().get_path(), ('a', 0))
        self.assertIs(dc.get_token(), token)
        self.assertIs(set_token, token)
开发者ID:0x554simon,项目名称:w3af,代码行数:11,代码来源:test_kv_container.py

示例13: FuzzableRequest

class FuzzableRequest(RequestMixIn, DiskItem):
    """
    This class represents a fuzzable request. Fuzzable requests were created
    to allow w3af plugins to be much simpler and don't really care if the
    vulnerability is in the postdata, querystring, header, cookie or any other
    injection point.

    FuzzableRequest classes are just an easy to use representation of an HTTP
    Request, which will (during the audit phase) be wrapped into a Mutant
    and have its values modified.

    :author: Andres Riancho ([email protected])
    """
    # In most cases we don't care about these headers, even if provided by the
    # user, since they will be calculated based on the attributes we are
    # going to store and these won't be updated.
    REMOVE_HEADERS = ('content-length',)

    __slots__ = ('_method',
                 '_cookie',
                 '_post_data',
                 '_headers',
                 '_uri',
                 '_url',
                 '_sent_info_comp')

    def __init__(self, uri, method='GET', headers=None, cookie=None,
                 post_data=None):
        super(FuzzableRequest, self).__init__()

        # Note: Do not check for the URI/Headers type here, since I'm doing it
        # in set_uri() and set_headers() already.
        if cookie is not None and not isinstance(cookie, Cookie):
            raise TypeError(TYPE_ERROR % ('cookie', 'Cookie'))

        if post_data is not None and not isinstance(post_data, DataContainer):
            raise TypeError(TYPE_ERROR % ('post_data', 'DataContainer'))

        # Internal variables
        self._method = method
        self._cookie = Cookie() if cookie is None else cookie
        self._post_data = KeyValueContainer() if post_data is None else post_data

        # Set the headers
        self._headers = None
        pheaders = Headers() if headers is None else headers
        self.set_headers(pheaders)

        # Set the URL
        self._uri = None
        self._url = None
        self.set_uri(uri)

        # Set the internal variables
        self._sent_info_comp = None

    def __getstate__(self):
        state = {k: getattr(self, k) for k in self.__slots__}
        return state

    def __setstate__(self, state):
        [setattr(self, k, v) for k, v in state.iteritems()]

    def get_default_headers(self):
        """
        :return: The headers we want to use framework-wide for fuzzing. By
                 default we set the fuzzable_headers to [], which makes this
                 method return an empty Headers instance.

                 When the user sets a fuzzable_headers it will create a Headers
                 instance with empty values.

                 We then append the specific headers supplied for this
                 FuzzableRequest instance to the default headers. Any specific
                 headers override the default (empty) ones.
        """
        fuzzable_headers = cf.cf.get('fuzzable_headers') or []
        req_headers = [(h, '') for h in fuzzable_headers]
        return Headers(init_val=req_headers)

    @classmethod
    def from_parts(cls, url, method='GET', post_data=None, headers=None):
        """
        :return: An instance of FuzzableRequest from the provided parameters.
        """
        if isinstance(url, basestring):
            url = URL(url)

        if post_data == '':
            post_data = None

        elif isinstance(post_data, basestring):
            post_data = dc_from_hdrs_post(headers, post_data)

        return cls(url, method=method, headers=headers, post_data=post_data)

    @classmethod
    def from_http_response(cls, http_response):
        """
        :return: An instance of FuzzableRequest using the URL and cookie from
#.........这里部分代码省略.........
开发者ID:andresriancho,项目名称:w3af-kali,代码行数:101,代码来源:fuzzable_request.py

示例14: FuzzableRequest

class FuzzableRequest(RequestMixIn, DiskItem):
    """
    This class represents a fuzzable request. Fuzzable requests were created
    to allow w3af plugins to be much simpler and don't really care if the
    vulnerability is in the postdata, querystring, header, cookie or any other
    injection point.

    FuzzableRequest classes are just an easy to use representation of an HTTP
    Request, which will (during the audit phase) be wrapped into a Mutant
    and have its values modified.

    :author: Andres Riancho ([email protected])
    """
    # In most cases we don't care about these headers, even if provided by the
    # user, since they will be calculated based on the attributes we are
    # going to store and these won't be updated.
    REMOVE_HEADERS = ('content-length',)

    __slots__ = ('_method',
                 '_cookie',
                 '_post_data',
                 '_headers',
                 '_uri',
                 '_url',
                 '_sent_info_comp')

    def __init__(self, uri, method='GET', headers=None, cookie=None,
                 post_data=None):
        super(FuzzableRequest, self).__init__()

        # Note: Do not check for the URI/Headers type here, since I'm doing it
        # in set_uri() and set_headers() already.
        if cookie is not None and not isinstance(cookie, Cookie):
            raise TypeError(TYPE_ERROR % ('cookie', 'Cookie'))

        if post_data is not None and not isinstance(post_data, DataContainer):
            raise TypeError(TYPE_ERROR % ('post_data', 'DataContainer'))

        # Internal variables
        self._method = method
        self._cookie = Cookie() if cookie is None else cookie
        self._post_data = KeyValueContainer() if post_data is None else post_data

        # Set the headers
        self._headers = None
        pheaders = Headers() if headers is None else headers
        self.set_headers(pheaders)

        # Set the URL
        self._uri = None
        self._url = None
        self.set_uri(uri)

        # Set the internal variables
        self._sent_info_comp = None

    def __getstate__(self):
        state = {k: getattr(self, k) for k in self.__slots__}
        return state

    def __setstate__(self, state):
        [setattr(self, k, v) for k, v in state.iteritems()]

    def get_default_headers(self):
        """
        :return: The headers we want to use framework-wide for fuzzing. By
                 default we set the fuzzable_headers to [], which makes this
                 method return an empty Headers instance.

                 When the user sets a fuzzable_headers it will create a Headers
                 instance with empty values.

                 We then append the specific headers supplied for this
                 FuzzableRequest instance to the default headers. Any specific
                 headers override the default (empty) ones.
        """
        fuzzable_headers = cf.cf.get('fuzzable_headers') or []
        req_headers = [(h, '') for h in fuzzable_headers]
        return Headers(init_val=req_headers)

    @classmethod
    def from_parts(cls, url, method='GET', post_data=None, headers=None):
        """
        :return: An instance of FuzzableRequest from the provided parameters.
        """
        if isinstance(url, basestring):
            url = URL(url)

        if post_data == '':
            post_data = None

        elif isinstance(post_data, basestring):
            post_data = dc_from_hdrs_post(headers, post_data)

        return cls(url, method=method, headers=headers, post_data=post_data)

    @classmethod
    def from_http_response(cls, http_response):
        """
        :return: An instance of FuzzableRequest using the URL and cookie from
#.........这里部分代码省略.........
开发者ID:foobarmonk,项目名称:w3af,代码行数:101,代码来源:fuzzable_request.py

示例15: test_get_short_printable_repr_no_token

    def test_get_short_printable_repr_no_token(self):
        dc = KeyValueContainer([(u'a', ['1']), (u'b', ['2', '3'])])

        self.assertEqual(dc.get_short_printable_repr(), 'a=1&b=2&b=3')
开发者ID:andresriancho,项目名称:w3af,代码行数:4,代码来源:test_kv_container.py


注:本文中的w3af.core.data.dc.generic.kv_container.KeyValueContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。