本文整理汇总了Python中mitmproxy.flowfilter.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_binaryops
def test_binaryops(self):
a = flowfilter.parse("~u foobar | ~h voing")
isinstance(a, flowfilter.FOr)
self._dump(a)
a = flowfilter.parse("~u foobar & ~h voing")
isinstance(a, flowfilter.FAnd)
self._dump(a)
开发者ID:s4chin,项目名称:mitmproxy,代码行数:8,代码来源:test_flowfilter.py
示例2: test_signals
def test_signals():
v = view.View()
rec_add = Record()
rec_update = Record()
rec_remove = Record()
rec_refresh = Record()
def clearrec():
rec_add.calls = []
rec_update.calls = []
rec_remove.calls = []
rec_refresh.calls = []
v.sig_view_add.connect(rec_add)
v.sig_view_update.connect(rec_update)
v.sig_view_remove.connect(rec_remove)
v.sig_view_refresh.connect(rec_refresh)
assert not any([rec_add, rec_update, rec_remove, rec_refresh])
# Simple add
v.add([tft()])
assert rec_add
assert not any([rec_update, rec_remove, rec_refresh])
# Filter change triggers refresh
clearrec()
v.set_filter(flowfilter.parse("~m put"))
assert rec_refresh
assert not any([rec_update, rec_add, rec_remove])
v.set_filter(flowfilter.parse("~m get"))
# An update that results in a flow being added to the view
clearrec()
v[0].request.method = "PUT"
v.update([v[0]])
assert rec_remove
assert not any([rec_update, rec_refresh, rec_add])
# An update that does not affect the view just sends update
v.set_filter(flowfilter.parse("~m put"))
clearrec()
v.update([v[0]])
assert rec_update
assert not any([rec_remove, rec_refresh, rec_add])
# An update for a flow in state but not view does not do anything
f = v[0]
v.set_filter(flowfilter.parse("~m get"))
assert not len(v)
clearrec()
v.update([f])
assert not any([rec_add, rec_update, rec_remove, rec_refresh])
开发者ID:mhils,项目名称:mitmproxy,代码行数:54,代码来源:test_view.py
示例3: test_focus
def test_focus():
# Special case - initialising with a view that already contains data
v = view.View()
v.add(tft())
f = view.Focus(v)
assert f.index is 0
assert f.flow is v[0]
# Start empty
v = view.View()
f = view.Focus(v)
assert f.index is None
assert f.flow is None
v.add(tft(start=1))
assert f.index == 0
assert f.flow is v[0]
v.add(tft(start=0))
assert f.index == 1
assert f.flow is v[1]
v.add(tft(start=2))
assert f.index == 1
assert f.flow is v[1]
v.remove(v[1])
assert f.index == 1
assert f.flow is v[1]
v.remove(v[1])
assert f.index == 0
assert f.flow is v[0]
v.remove(v[0])
assert f.index is None
assert f.flow is None
v.add(tft(method="get", start=0))
v.add(tft(method="get", start=1))
v.add(tft(method="put", start=2))
v.add(tft(method="get", start=3))
f.flow = v[2]
assert f.flow.request.method == "PUT"
filt = flowfilter.parse("~m get")
v.set_filter(filt)
assert f.index == 2
filt = flowfilter.parse("~m oink")
v.set_filter(filt)
assert f.index is None
开发者ID:MatthewShao,项目名称:mitmproxy,代码行数:53,代码来源:test_view.py
示例4: test_quoting
def test_quoting(self):
a = flowfilter.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 = flowfilter.parse("~u foobar")
assert a.expr == "foobar"
a = flowfilter.parse(r"~u 'foobar\"\''")
assert a.expr == "foobar\"'"
a = flowfilter.parse(r'~u "foo \'bar"')
assert a.expr == "foo 'bar"
开发者ID:s4chin,项目名称:mitmproxy,代码行数:14,代码来源:test_flowfilter.py
示例5: configure
def configure(self, options, updated):
"""
.replacements is a list of tuples (fpat, rex, s):
fpatt: a string specifying a filter pattern.
rex: a regular expression, as bytes.
s: the replacement string, as bytes
"""
if self.optionName in updated:
lst = []
for rep in getattr(options, self.optionName):
if isinstance(rep, str):
fpatt, rex, s = parse_hook(rep)
else:
fpatt, rex, s = rep
flt = flowfilter.parse(fpatt)
if not flt:
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, flt))
self.lst = lst
开发者ID:dwfreed,项目名称:mitmproxy,代码行数:29,代码来源:replace.py
示例6: configure
def configure(self, updated):
"""
.replacements is a list of tuples (fpat, rex, s):
fpatt: a string specifying a filter pattern.
rex: a regular expression, as string.
s: the replacement string
"""
if "replacements" in updated:
lst = []
for rep in ctx.options.replacements:
fpatt, rex, s = parse_hook(rep)
flt = flowfilter.parse(fpatt)
if not flt:
raise exceptions.OptionsError(
"Invalid filter pattern: %s" % fpatt
)
try:
# We should ideally escape here before trying to compile
re.compile(rex)
except re.error as e:
raise exceptions.OptionsError(
"Invalid regular expression: %s - %s" % (rex, str(e))
)
if s.startswith("@") and not os.path.isfile(s[1:]):
raise exceptions.OptionsError(
"Invalid file path: {}".format(s[1:])
)
lst.append((rex, s, flt))
self.lst = lst
开发者ID:cortesi,项目名称:mitmproxy,代码行数:31,代码来源:replace.py
示例7: test_filter
def test_filter():
v = view.View()
f = flowfilter.parse("~m get")
v.request(tft(method="get"))
v.request(tft(method="put"))
v.request(tft(method="get"))
v.request(tft(method="put"))
assert(len(v)) == 4
v.set_filter(f)
assert [i.request.method for i in v] == ["GET", "GET"]
assert len(v._store) == 4
v.set_filter(None)
assert len(v) == 4
v.toggle_marked()
assert len(v) == 0
v.toggle_marked()
assert len(v) == 4
v[1].marked = True
v.toggle_marked()
assert len(v) == 1
assert v[0].marked
v.toggle_marked()
assert len(v) == 4
开发者ID:mhils,项目名称:mitmproxy,代码行数:25,代码来源:test_view.py
示例8: set_intercept
def set_intercept(self, txt):
if txt:
flt = flowfilter.parse(txt)
if not flt:
return "Invalid filter expression."
self.intercept = flt
else:
self.intercept = None
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:8,代码来源:state.py
示例9: set_filter
def set_filter(self, input_filter: typing.Optional[str]) -> None:
filt = matchall if not input_filter else flowfilter.parse(input_filter)
if not filt:
raise CommandError(
"Invalid interception filter: %s" % filt
)
self.filter = filt
self._refilter()
开发者ID:mitmproxy,项目名称:mitmproxy,代码行数:8,代码来源:session.py
示例10: configure
def configure(self, options, updated):
if options.stickyauth:
flt = flowfilter.parse(options.stickyauth)
if not flt:
raise exceptions.OptionsError(
"stickyauth: invalid filter expression: %s" % options.stickyauth
)
self.flt = flt
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:8,代码来源:stickyauth.py
示例11: configure
def configure(self, updated):
if "readfile_filter" in updated:
filt = None
if ctx.options.readfile_filter:
filt = flowfilter.parse(ctx.options.readfile_filter)
if not filt:
raise exceptions.OptionsError(
"Invalid readfile filter: %s" % ctx.options.readfile_filter
)
self.filter = filt
开发者ID:cortesi,项目名称:mitmproxy,代码行数:10,代码来源:readfile.py
示例12: is_error
def is_error(self, col, val):
if col == 0:
if not flowfilter.parse(val):
return "Invalid filter specification."
elif col == 1:
try:
re.compile(val)
except re.error:
return "Invalid regular expression."
return False
开发者ID:MatthewShao,项目名称:mitmproxy,代码行数:10,代码来源:editors.py
示例13: configure
def configure(self, updated):
if "intercept" in updated:
if not ctx.options.intercept:
self.filt = None
return
self.filt = flowfilter.parse(ctx.options.intercept)
if not self.filt:
raise exceptions.OptionsError(
"Invalid interception filter: %s" % ctx.options.intercept
)
开发者ID:davidpshaw,项目名称:mitmproxy,代码行数:10,代码来源:intercept.py
示例14: configure
def configure(self, updated):
if "view_filter" in updated:
if ctx.options.view_filter:
self.filter = flowfilter.parse(ctx.options.view_filter)
if not self.filter:
raise exceptions.OptionsError(
"Invalid filter expression: %s" % ctx.options.view_filter
)
else:
self.filter = None
开发者ID:davidpshaw,项目名称:mitmproxy,代码行数:10,代码来源:dumper.py
示例15: configure
def configure(self, updated):
if "stickycookie" in updated:
if ctx.options.stickycookie:
flt = flowfilter.parse(ctx.options.stickycookie)
if not flt:
raise exceptions.OptionsError(
"stickycookie: invalid filter expression: %s" % ctx.options.stickycookie
)
self.flt = flt
else:
self.flt = None
开发者ID:StevenVanAcker,项目名称:mitmproxy,代码行数:11,代码来源:stickycookie.py
示例16: set_filter_cmd
def set_filter_cmd(self, f: str) -> None:
"""
Sets the current view filter.
"""
filt = None
if f:
filt = flowfilter.parse(f)
if not filt:
raise exceptions.CommandError(
"Invalid interception filter: %s" % f
)
self.set_filter(filt)
开发者ID:mitmproxy,项目名称:mitmproxy,代码行数:12,代码来源:view.py
示例17: configure
def configure(self, options, updated):
if options.filtstr:
self.filter = flowfilter.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:mkagenius,项目名称:mitmproxy,代码行数:12,代码来源:dumper.py
示例18: configure
def configure(self, updated):
if "setheaders" in updated:
self.lst = []
for shead in ctx.options.setheaders:
fpatt, header, value = parse_setheader(shead)
flt = flowfilter.parse(fpatt)
if not flt:
raise exceptions.OptionsError(
"Invalid setheader filter pattern %s" % fpatt
)
self.lst.append((fpatt, header, value, flt))
开发者ID:cortesi,项目名称:mitmproxy,代码行数:12,代码来源:setheaders.py
示例19: test_simple
def test_simple(self):
assert not flowfilter.parse("~b")
assert flowfilter.parse("~q")
assert flowfilter.parse("~c 10")
assert flowfilter.parse("~m foobar")
assert flowfilter.parse("~u foobar")
assert flowfilter.parse("~q ~c 10")
p = flowfilter.parse("~q ~c 10")
self._dump(p)
assert len(p.lst) == 2
开发者ID:s4chin,项目名称:mitmproxy,代码行数:10,代码来源:test_flowfilter.py
示例20: set_view_filter
def set_view_filter(self, txt):
if txt == self.filter_txt:
return
if txt:
flt = flowfilter.parse(txt)
if not flt:
return "Invalid filter expression."
self.view._close()
self.view = FlowView(self.flows, flt)
else:
self.view._close()
self.view = FlowView(self.flows, None)
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:12,代码来源:state.py
注:本文中的mitmproxy.flowfilter.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论