• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python filt.parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_binaryops

    def test_binaryops(self):
        a = filt.parse("~u foobar | ~h voing")
        isinstance(a, filt.FOr)
        self._dump(a)

        a = filt.parse("~u foobar & ~h voing")
        isinstance(a, filt.FAnd)
        self._dump(a)
开发者ID:AlTune,项目名称:mitmproxy,代码行数:8,代码来源:test_filt.py


示例2: test_quoting

    def test_quoting(self):
        a = filt.parse("~u 'foo ~u bar' ~u voing")
        assert a.lst[0].expr == "foo ~u bar"
        assert a.lst[1].expr == "voing"
        self._dump(a)

        a = filt.parse("~u foobar")
        assert a.expr == "foobar"

        a = filt.parse(r"~u 'foobar\"\''")
        assert a.expr == "foobar\"'"

        a = filt.parse(r'~u "foo \'bar"')
        assert a.expr == "foo 'bar"
开发者ID:AlTune,项目名称:mitmproxy,代码行数:14,代码来源:test_filt.py


示例3: __init__

    def __init__(self, server, options):
        flow.FlowMaster.__init__(self, options, server, flow.State())
        self.addons.add(*builtins.default_addons())
        # This line is just for type hinting
        self.options = self.options  # type: Options
        self.o = options
        self.showhost = options.showhost
        self.replay_ignore_params = options.replay_ignore_params
        self.replay_ignore_content = options.replay_ignore_content
        self.replay_ignore_host = options.replay_ignore_host
        self.refresh_server_playback = options.refresh_server_playback
        self.replay_ignore_payload_params = options.replay_ignore_payload_params

        self.set_stream_large_bodies(options.stream_large_bodies)

        if self.server and self.server.config.http2 and not tcp.HAS_ALPN:  # pragma: no cover
            print("ALPN support missing (OpenSSL 1.0.2+ required)!\n"
                  "HTTP/2 is disabled. Use --no-http2 to silence this warning.",
                  file=sys.stderr)

        if options.filtstr:
            self.filt = filt.parse(options.filtstr)
        else:
            self.filt = None

        if options.replacements:
            for i in options.replacements:
                self.replacehooks.add(*i)

        if options.setheaders:
            for i in options.setheaders:
                self.setheaders.add(*i)

        if options.server_replay:
            self.start_server_playback(
                self._readflow(options.server_replay),
                options.kill, options.rheaders,
                not options.keepserving,
                options.nopop,
                options.replay_ignore_params,
                options.replay_ignore_content,
                options.replay_ignore_payload_params,
                options.replay_ignore_host
            )

        if options.client_replay:
            self.start_client_playback(
                self._readflow(options.client_replay),
                not options.keepserving
            )

        if options.rfile:
            try:
                self.load_flows_file(options.rfile)
            except exceptions.FlowReadException as v:
                self.add_event("Flow file corrupted.", "error")
                raise DumpError(v)

        if self.options.app:
            self.start_app(self.options.app_host, self.options.app_port)
开发者ID:HuangGuoZhou,项目名称:mitmproxy,代码行数:60,代码来源:dump.py


示例4: set_intercept

 def set_intercept(self, txt):
     if txt:
         f = filt.parse(txt)
         if not f:
             return "Invalid filter expression."
         self.intercept = f
     else:
         self.intercept = None
开发者ID:AlTune,项目名称:mitmproxy,代码行数:8,代码来源:state.py


示例5: configure

 def configure(self, options):
     if options.stickyauth:
         flt = filt.parse(options.stickyauth)
         if not flt:
             raise exceptions.OptionsError(
                 "stickyauth: invalid filter expression: %s" % options.stickyauth
             )
         self.flt = flt
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:8,代码来源:stickyauth.py


示例6: configure

 def configure(self, options, updated):
     if options.stickycookie:
         flt = filt.parse(options.stickycookie)
         if not flt:
             raise exceptions.OptionsError(
                 "stickycookie: invalid filter expression: %s" % options.stickycookie
             )
         self.flt = flt
开发者ID:Angelcold,项目名称:mitmproxy,代码行数:8,代码来源:stickycookie.py


示例7: test_handle_response

    def test_handle_response(self):
        s = flow.StickyAuthState(filt.parse(".*"))
        f = tutils.tflow(resp=True)
        f.request.headers["authorization"] = "foo"
        s.handle_request(f)
        assert "address" in s.hosts

        f = tutils.tflow(resp=True)
        s.handle_request(f)
        assert f.request.headers["authorization"] == "foo"
开发者ID:Amerge,项目名称:mitmproxy,代码行数:10,代码来源:test_flow.py


示例8: set_stickyauth

 def set_stickyauth(self, txt):
     if txt:
         flt = filt.parse(txt)
         if not flt:
             return "Invalid filter expression."
         self.stickyauth_state = modules.StickyAuthState(flt)
         self.stickyauth_txt = txt
     else:
         self.stickyauth_state = None
         self.stickyauth_txt = None
开发者ID:AlTune,项目名称:mitmproxy,代码行数:10,代码来源:master.py


示例9: is_error

 def is_error(self, col, val):
     if col == 0:
         if not filt.parse(val):
             return "Invalid filter specification."
     elif col == 1:
         try:
             re.compile(val)
         except re.error:
             return "Invalid regular expression."
     return False
开发者ID:Angelcold,项目名称:mitmproxy,代码行数:10,代码来源:editors.py


示例10: test_simple

 def test_simple(self):
     assert not filt.parse("~b")
     assert filt.parse("~q")
     assert filt.parse("~c 10")
     assert filt.parse("~m foobar")
     assert filt.parse("~u foobar")
     assert filt.parse("~q ~c 10")
     p = filt.parse("~q ~c 10")
     self._dump(p)
     assert len(p.lst) == 2
开发者ID:AlTune,项目名称:mitmproxy,代码行数:10,代码来源:test_filt.py


示例11: set_limit

 def set_limit(self, txt):
     if txt == self.limit_txt:
         return
     if txt:
         f = filt.parse(txt)
         if not f:
             return "Invalid filter expression."
         self.view._close()
         self.view = FlowView(self.flows, f)
     else:
         self.view._close()
         self.view = FlowView(self.flows, None)
开发者ID:AlTune,项目名称:mitmproxy,代码行数:12,代码来源:state.py


示例12: configure

 def configure(self, options, updated):
     if options.filtstr:
         self.filter = filt.parse(options.filtstr)
         if not self.filter:
             raise exceptions.OptionsError(
                 "Invalid filter expression: %s" % options.filtstr
             )
     else:
         self.filter = None
     self.flow_detail = options.flow_detail
     self.outfp = options.tfile
     self.showhost = options.showhost
开发者ID:guangshi1982,项目名称:mitmproxy,代码行数:12,代码来源:dumper.py


示例13: configure

    def configure(self, options, updated):
        """
            options.setheaders is a tuple of (fpatt, header, value)

            fpatt: String specifying a filter pattern.
            header: Header name.
            value: Header value string
        """
        for fpatt, header, value in options.setheaders:
            cpatt = filt.parse(fpatt)
            if not cpatt:
                raise exceptions.OptionsError(
                    "Invalid setheader filter pattern %s" % fpatt
                )
            self.lst.append((fpatt, header, value, cpatt))
开发者ID:Angelcold,项目名称:mitmproxy,代码行数:15,代码来源:setheaders.py


示例14: test_response

    def test_response(self):
        c = (
            "SSID=mooo; domain=.google.com, FOO=bar; Domain=.google.com; Path=/; "
            "Expires=Wed, 13-Jan-2021 22:23:01 GMT; Secure; "
        )

        s, f = self._response(c, "host")
        assert not s.jar.keys()

        s, f = self._response(c, "www.google.com")
        assert list(s.jar.keys())[0] == ('.google.com', 80, '/')

        s, f = self._response("SSID=mooo", "www.google.com")
        assert list(s.jar.keys())[0] == ('www.google.com', 80, '/')

        # Test setting of multiple cookies
        c1 = "somecookie=test; Path=/"
        c2 = "othercookie=helloworld; Path=/"
        s, f = self._response(c1, "www.google.com")
        f.response.headers["Set-Cookie"] = c2
        s.handle_response(f)
        googlekey = list(s.jar.keys())[0]
        assert len(s.jar[googlekey].keys()) == 2

        # Test setting of weird cookie keys
        s = flow.StickyCookieState(filt.parse(".*"))
        f = tutils.tflow(req=netlib.tutils.treq(host="www.google.com", port=80), resp=True)
        cs = [
            "foo/bar=hello",
            "foo:bar=world",
            "[email protected]=fizz",
            "foo,bar=buzz",
        ]
        for c in cs:
            f.response.headers["Set-Cookie"] = c
            s.handle_response(f)
        googlekey = list(s.jar.keys())[0]
        assert len(s.jar[googlekey]) == len(cs)

        # Test overwriting of a cookie value
        c1 = "somecookie=helloworld; Path=/"
        c2 = "somecookie=newvalue; Path=/"
        s, f = self._response(c1, "www.google.com")
        f.response.headers["Set-Cookie"] = c2
        s.handle_response(f)
        googlekey = list(s.jar.keys())[0]
        assert len(s.jar[googlekey]) == 1
        assert list(s.jar[googlekey]["somecookie"].values())[0] == "newvalue"
开发者ID:christofferqa,项目名称:mitmproxy,代码行数:48,代码来源:test_flow.py


示例15: test_filter

    def test_filter(self):
        sio = StringIO()
        fl = filt.parse("~c 200")
        w = flow.FilteredFlowWriter(sio, fl)

        f = tutils.tflow(resp=True)
        f.response.status_code = 200
        w.add(f)

        f = tutils.tflow(resp=True)
        f.response.status_code = 201
        w.add(f)

        sio.seek(0)
        r = flow.FlowReader(sio)
        assert len(list(r.stream()))
开发者ID:Amerge,项目名称:mitmproxy,代码行数:16,代码来源:test_flow.py


示例16: add

    def add(self, fpatt, header, value):
        """
            Add a set header hook.

            fpatt: String specifying a filter pattern.
            header: Header name.
            value: Header value string

            Returns True if hook was added, False if the pattern could not be
            parsed.
        """
        cpatt = filt.parse(fpatt)
        if not cpatt:
            return False
        self.lst.append((fpatt, header, value, cpatt))
        return True
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:16,代码来源:modules.py


示例17: _parse_hook

def _parse_hook(s):
    sep, rem = s[0], s[1:]
    parts = rem.split(sep, 2)
    if len(parts) == 2:
        patt = ".*"
        a, b = parts
    elif len(parts) == 3:
        patt, a, b = parts
    else:
        raise ParseException(
            "Malformed hook specifier - too few clauses: %s" % s
        )

    if not a:
        raise ParseException("Empty clause: %s" % str(patt))

    if not filt.parse(patt):
        raise ParseException("Malformed filter pattern: %s" % patt)

    return patt, a, b
开发者ID:exploitprotocol,项目名称:mitmproxy,代码行数:20,代码来源:cmdline.py


示例18: configure

    def configure(self, options):
        """
            .replacements is a list of tuples (fpat, rex, s):

            fpatt: a string specifying a filter pattern.
            rex: a regular expression.
            s: the replacement string
        """
        lst = []
        for fpatt, rex, s in options.replacements:
            cpatt = filt.parse(fpatt)
            if not cpatt:
                raise exceptions.OptionsError(
                    "Invalid filter pattern: %s" % fpatt
                )
            try:
                re.compile(rex)
            except re.error as e:
                raise exceptions.OptionsError(
                    "Invalid regular expression: %s - %s" % (rex, str(e))
                )
            lst.append((rex, s, cpatt))
        self.lst = lst
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:23,代码来源:replace.py


示例19: start

def start(context):
    if len(sys.argv) != 2:
        raise ValueError("Usage: -s 'filt.py FILTER'")
    context.filter = filt.parse(sys.argv[1])
开发者ID:AlTune,项目名称:mitmproxy,代码行数:4,代码来源:filt.py


示例20: start

def start():
    if len(sys.argv) != 2:
        raise ValueError("Usage: -s 'filt.py FILTER'")
    state["filter"] = filt.parse(sys.argv[1])
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:4,代码来源:filt.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python flowfilter.parse函数代码示例发布时间:2022-05-27
下一篇:
Python contentviews.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap