diff options
-rw-r--r-- | mitmproxy/addons/dumper.py | 12 | ||||
-rw-r--r-- | mitmproxy/addons/view.py | 4 | ||||
-rw-r--r-- | mitmproxy/options.py | 10 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_dumper.py | 6 | ||||
-rw-r--r-- | test/mitmproxy/tools/test_dump.py | 6 |
5 files changed, 18 insertions, 20 deletions
diff --git a/mitmproxy/addons/dumper.py b/mitmproxy/addons/dumper.py index 0df2d339..aaad8aa2 100644 --- a/mitmproxy/addons/dumper.py +++ b/mitmproxy/addons/dumper.py @@ -47,14 +47,18 @@ class Dumper: "The default content view mode.", choices = [i.name.lower() for i in contentviews.views] ) + loader.add_option( + "dumper_filter", typing.Optional[str], None, + "Limit which flows are dumped." + ) def configure(self, updated): - if "view_filter" in updated: - if ctx.options.view_filter: - self.filter = flowfilter.parse(ctx.options.view_filter) + if "dumper_filter" in updated: + if ctx.options.dumper_filter: + self.filter = flowfilter.parse(ctx.options.dumper_filter) if not self.filter: raise exceptions.OptionsError( - "Invalid filter expression: %s" % ctx.options.view_filter + "Invalid filter expression: %s" % ctx.options.dumper_filter ) else: self.filter = None diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index c0f7e7b4..598cb66d 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -147,6 +147,10 @@ class View(collections.Sequence): def load(self, loader): loader.add_option( + "view_filter", typing.Optional[str], None, + "Limit the view to matching flows." + ) + loader.add_option( "view_order", str, "time", "Flow sort order.", choices=list(map(lambda c: c[1], orders)), diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 0ada5306..b6f3398b 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -41,11 +41,6 @@ class Options(optmanager.OptManager): upstream_cert = None # type: bool websocket = None # type: bool - # FIXME: Options that must be migrated to addons, but are complicated - # because they're used by more than one addon, or because they're - # embedded in the core code somehow. - view_filter = None # type: Optional[str] - def __init__(self, **kwargs) -> None: super().__init__() self.add_option( @@ -212,9 +207,4 @@ class Options(optmanager.OptManager): """ ) - self.add_option( - "view_filter", Optional[str], None, - "Limit which flows are displayed." - ) - self.update(**kwargs) diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index 7c54ab88..228bacf8 100644 --- a/test/mitmproxy/addons/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -15,7 +15,7 @@ from mitmproxy import http def test_configure(): d = dumper.Dumper() with taddons.context(d) as ctx: - ctx.configure(d, view_filter="~b foo") + ctx.configure(d, dumper_filter="~b foo") assert d.filter f = tflow.tflow(resp=True) @@ -23,10 +23,10 @@ def test_configure(): f.response.content = b"foo" assert d.match(f) - ctx.configure(d, view_filter=None) + ctx.configure(d, dumper_filter=None) assert not d.filter with pytest.raises(exceptions.OptionsError): - ctx.configure(d, view_filter="~~") + ctx.configure(d, dumper_filter="~~") assert not d.filter diff --git a/test/mitmproxy/tools/test_dump.py b/test/mitmproxy/tools/test_dump.py index 9e67f420..f950d719 100644 --- a/test/mitmproxy/tools/test_dump.py +++ b/test/mitmproxy/tools/test_dump.py @@ -10,13 +10,13 @@ from .. import tservers class TestDumpMaster(tservers.MasterTest): - def mkmaster(self, flt, **opts): - o = options.Options(view_filter=flt, **opts) + def mkmaster(self, **opts): + o = options.Options(**opts) m = dump.DumpMaster(o, with_termlog=False, with_dumper=False) return m def test_has_error(self): - m = self.mkmaster(None) + m = self.mkmaster() ent = log.LogEntry("foo", "error") ent.reply = controller.DummyReply() m.addons.trigger("log", ent) |