diff options
-rw-r--r-- | docs/pathod/intro.rst | 6 | ||||
-rw-r--r-- | mitmproxy/addons/termlog.py | 2 | ||||
-rw-r--r-- | mitmproxy/options.py | 13 | ||||
-rw-r--r-- | mitmproxy/test/tflow.py | 2 | ||||
-rw-r--r-- | mitmproxy/tools/console/eventlog.py | 4 | ||||
-rw-r--r-- | mitmproxy/tools/console/master.py | 2 | ||||
-rw-r--r-- | mitmproxy/tools/main.py | 5 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_cut.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_dumper.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_termlog.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_connections.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_flowfilter.py | 14 | ||||
-rw-r--r-- | test/mitmproxy/tools/console/test_master.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/tools/test_dump.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/tservers.py | 8 | ||||
-rw-r--r-- | web/src/js/__tests__/components/FlowView/__snapshots__/DetailsSpec.js.snap | 4 | ||||
-rw-r--r-- | web/src/js/__tests__/ducks/_tflow.js | 2 |
17 files changed, 46 insertions, 28 deletions
diff --git a/docs/pathod/intro.rst b/docs/pathod/intro.rst index bf0c531f..1c1ad60e 100644 --- a/docs/pathod/intro.rst +++ b/docs/pathod/intro.rst @@ -3,6 +3,7 @@ Pathology 101 ============= +.. _pathod: pathod ------ @@ -83,15 +84,14 @@ distinguish them from crafted responses. For example, a request to: .. _pathoc: - pathoc ------ Pathoc is a perverse HTTP daemon designed to let you craft almost any conceivable HTTP request, including ones that creatively violate the standards. HTTP requests are specified using a :ref:`small, terse language <language>`, -which pathod shares with its server-side twin pathod. To view pathoc's complete -range of options, use the command-line help: +which pathoc shares with its server-side twin :ref:`pathod`. To view pathoc's +complete range of options, use the command-line help: >>> pathoc --help diff --git a/mitmproxy/addons/termlog.py b/mitmproxy/addons/termlog.py index 4c37b005..3a9f2c19 100644 --- a/mitmproxy/addons/termlog.py +++ b/mitmproxy/addons/termlog.py @@ -20,7 +20,7 @@ class TermLog: else: outfile = self.outfile or realstdout - if ctx.options.verbosity >= log.log_tier(e.level): + if log.log_tier(ctx.options.verbosity) >= log.log_tier(e.level): click.secho( e.msg, file=outfile, diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 5e6602fb..8a01cf40 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -27,6 +27,14 @@ console_layouts = [ "horizontal", ] +log_verbosity = [ + "error", + "warn", + "info", + "alert", + "debug", +] + APP_HOST = "mitm.it" APP_PORT = 80 CA_DIR = "~/.mitmproxy" @@ -162,8 +170,9 @@ class Options(optmanager.OptManager): """ ) self.add_option( - "verbosity", int, 2, - "Log verbosity." + "verbosity", str, 'info', + "Log verbosity.", + choices=log_verbosity ) self.add_option( "default_contentview", str, "auto", diff --git a/mitmproxy/test/tflow.py b/mitmproxy/test/tflow.py index 9004df2f..e754cb54 100644 --- a/mitmproxy/test/tflow.py +++ b/mitmproxy/test/tflow.py @@ -148,7 +148,7 @@ def tclient_conn(): """ c = connections.ClientConnection.from_state(dict( id=str(uuid.uuid4()), - address=("address", 22), + address=("127.0.0.1", 22), clientcert=None, mitmcert=None, ssl_established=False, diff --git a/mitmproxy/tools/console/eventlog.py b/mitmproxy/tools/console/eventlog.py index 5fdada9f..a76b910e 100644 --- a/mitmproxy/tools/console/eventlog.py +++ b/mitmproxy/tools/console/eventlog.py @@ -1,6 +1,8 @@ import urwid from mitmproxy.tools.console import signals from mitmproxy.tools.console import layoutwidget +from mitmproxy import ctx +from mitmproxy import log EVENTLOG_SIZE = 10000 @@ -32,6 +34,8 @@ class EventLog(urwid.ListBox, layoutwidget.LayoutWidget): return urwid.ListBox.keypress(self, size, key) def sig_add_log(self, sender, e, level): + if log.log_tier(ctx.options.verbosity) < log.log_tier(level): + return txt = "%s: %s" % (level, str(e)) if level in ("error", "warn"): e = urwid.Text((level, txt)) diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py index cd29dba9..8c8cfe61 100644 --- a/mitmproxy/tools/console/master.py +++ b/mitmproxy/tools/console/master.py @@ -87,7 +87,7 @@ class ConsoleMaster(master.Master): ) def sig_add_log(self, sender, e, level): - if self.options.verbosity < log.log_tier(level): + if log.log_tier(self.options.verbosity) < log.log_tier(level): return if level in ("error", "warn"): signals.status_message.send( diff --git a/mitmproxy/tools/main.py b/mitmproxy/tools/main.py index 58900d29..1575de98 100644 --- a/mitmproxy/tools/main.py +++ b/mitmproxy/tools/main.py @@ -16,6 +16,7 @@ from mitmproxy import exceptions # noqa from mitmproxy import options # noqa from mitmproxy import optmanager # noqa from mitmproxy import proxy # noqa +from mitmproxy import log # noqa from mitmproxy.utils import debug # noqa @@ -40,7 +41,7 @@ def process_options(parser, opts, args): print(debug.dump_system_info()) sys.exit(0) if args.quiet or args.options or args.commands: - args.verbosity = 0 + args.verbosity = 'error' args.flow_detail = 0 adict = {} @@ -79,7 +80,7 @@ def run(MasterKlass, args, extra=None): # pragma: no cover master.addons.trigger("configure", opts.keys()) master.addons.trigger("tick") remaining = opts.update_known(**unknown) - if remaining and opts.verbosity > 1: + if remaining and log.log_tier(opts.verbosity) > 1: print("Ignored options: %s" % remaining) if args.options: print(optmanager.dump_defaults(opts)) diff --git a/test/mitmproxy/addons/test_cut.py b/test/mitmproxy/addons/test_cut.py index e028331f..242c6c2f 100644 --- a/test/mitmproxy/addons/test_cut.py +++ b/test/mitmproxy/addons/test_cut.py @@ -32,7 +32,7 @@ def test_extract(): ["s.header[header-response]", "svalue"], ["cc.address.port", "22"], - ["cc.address.host", "address"], + ["cc.address.host", "127.0.0.1"], ["cc.tls_version", "TLSv1.2"], ["cc.sni", "address"], ["cc.ssl_established", "false"], diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index d8aa593b..fb80f3ce 100644 --- a/test/mitmproxy/addons/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -148,7 +148,7 @@ class TestContentView: sio = io.StringIO() d = dumper.Dumper(sio) with taddons.context(options=options.Options()) as ctx: - ctx.configure(d, flow_detail=4, verbosity=3) + ctx.configure(d, flow_detail=4, verbosity='debug') d.response(tflow.tflow()) assert ctx.master.has_log("content viewer failed") diff --git a/test/mitmproxy/addons/test_termlog.py b/test/mitmproxy/addons/test_termlog.py index 2133b74d..027bdfeb 100644 --- a/test/mitmproxy/addons/test_termlog.py +++ b/test/mitmproxy/addons/test_termlog.py @@ -16,7 +16,7 @@ class TestTermLog: ]) def test_output(self, outfile, expected_out, expected_err, capfd): t = termlog.TermLog(outfile=outfile) - with taddons.context(options=Options(verbosity=2)) as tctx: + with taddons.context(options=Options(verbosity='info')) as tctx: tctx.configure(t) t.log(log.LogEntry("one", "info")) t.log(log.LogEntry("two", "debug")) diff --git a/test/mitmproxy/test_connections.py b/test/mitmproxy/test_connections.py index 99367bb6..83f0bd34 100644 --- a/test/mitmproxy/test_connections.py +++ b/test/mitmproxy/test_connections.py @@ -29,7 +29,7 @@ class TestClientConnection: def test_repr(self): c = tflow.tclient_conn() - assert 'address:22' in repr(c) + assert '127.0.0.1:22' in repr(c) assert 'ALPN' in repr(c) assert 'TLS' not in repr(c) diff --git a/test/mitmproxy/test_flowfilter.py b/test/mitmproxy/test_flowfilter.py index fe9b2408..c411258a 100644 --- a/test/mitmproxy/test_flowfilter.py +++ b/test/mitmproxy/test_flowfilter.py @@ -225,11 +225,11 @@ class TestMatchingHTTPFlow: def test_src(self): q = self.req() - assert self.q("~src address", q) + assert self.q("~src 127.0.0.1", q) assert not self.q("~src foobar", q) assert self.q("~src :22", q) assert not self.q("~src :99", q) - assert self.q("~src address:22", q) + assert self.q("~src 127.0.0.1:22", q) q.client_conn.address = None assert not self.q('~src address:22', q) @@ -315,11 +315,11 @@ class TestMatchingTCPFlow: def test_src(self): f = self.flow() - assert self.q("~src address", f) + assert self.q("~src 127.0.0.1", f) assert not self.q("~src foobar", f) assert self.q("~src :22", f) assert not self.q("~src :99", f) - assert self.q("~src address:22", f) + assert self.q("~src 127.0.0.1:22", f) def test_dst(self): f = self.flow() @@ -440,11 +440,11 @@ class TestMatchingWebSocketFlow: def test_src(self): f = self.flow() - assert self.q("~src address", f) + assert self.q("~src 127.0.0.1", f) assert not self.q("~src foobar", f) assert self.q("~src :22", f) assert not self.q("~src :99", f) - assert self.q("~src address:22", f) + assert self.q("~src 127.0.0.1:22", f) def test_dst(self): f = self.flow() @@ -524,7 +524,7 @@ class TestMatchingDummyFlow: assert not self.q("~s", f) - assert self.q("~src address", f) + assert self.q("~src 127.0.0.1", f) assert not self.q("~src nonexistent", f) assert not self.q("~tcp", f) diff --git a/test/mitmproxy/tools/console/test_master.py b/test/mitmproxy/tools/console/test_master.py index a3478bdc..ef357c76 100644 --- a/test/mitmproxy/tools/console/test_master.py +++ b/test/mitmproxy/tools/console/test_master.py @@ -28,7 +28,7 @@ def test_options(): class TestMaster(tservers.MasterTest): def mkmaster(self, **opts): if "verbosity" not in opts: - opts["verbosity"] = 1 + opts["verbosity"] = 'warn' o = options.Options(**opts) m = console.master.ConsoleMaster(o, proxy.DummyServer()) m.addons.trigger("configure", o.keys()) diff --git a/test/mitmproxy/tools/test_dump.py b/test/mitmproxy/tools/test_dump.py index 69a76d2e..597333af 100644 --- a/test/mitmproxy/tools/test_dump.py +++ b/test/mitmproxy/tools/test_dump.py @@ -12,7 +12,7 @@ from .. import tservers class TestDumpMaster(tservers.MasterTest): def mkmaster(self, flt, **opts): - o = options.Options(view_filter=flt, verbosity=-1, flow_detail=0, **opts) + o = options.Options(view_filter=flt, verbosity='error', flow_detail=0, **opts) m = dump.DumpMaster(o, proxy.DummyServer(), with_termlog=False, with_dumper=False) return m diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index 3a2050e1..9faaf20e 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -2,6 +2,7 @@ import os.path import threading import tempfile import sys +from unittest import mock import mitmproxy.platform from mitmproxy.proxy.config import ProxyConfig @@ -23,10 +24,13 @@ class MasterTest: def cycle(self, master, content): f = tflow.tflow(req=tutils.treq(content=content)) - master.addons.handle_lifecycle("clientconnect", f.client_conn) + layer = mock.Mock("mitmproxy.proxy.protocol.base.Layer") + layer.client_conn = f.client_conn + layer.reply = controller.DummyReply() + master.addons.handle_lifecycle("clientconnect", layer) for i in eventsequence.iterate(f): master.addons.handle_lifecycle(*i) - master.addons.handle_lifecycle("clientdisconnect", f.client_conn) + master.addons.handle_lifecycle("clientdisconnect", layer) return f def dummy_cycle(self, master, n, content): diff --git a/web/src/js/__tests__/components/FlowView/__snapshots__/DetailsSpec.js.snap b/web/src/js/__tests__/components/FlowView/__snapshots__/DetailsSpec.js.snap index dcee1895..6e01ae85 100644 --- a/web/src/js/__tests__/components/FlowView/__snapshots__/DetailsSpec.js.snap +++ b/web/src/js/__tests__/components/FlowView/__snapshots__/DetailsSpec.js.snap @@ -12,7 +12,7 @@ exports[`ConnectionInfo Component should render correctly 1`] = ` Address: </td> <td> - address:22 + 127.0.0.1:22 </td> </tr> <tr> @@ -47,7 +47,7 @@ exports[`Details Component should render correctly 1`] = ` Address: </td> <td> - address:22 + 127.0.0.1:22 </td> </tr> <tr> diff --git a/web/src/js/__tests__/ducks/_tflow.js b/web/src/js/__tests__/ducks/_tflow.js index f6a382bd..44b32342 100644 --- a/web/src/js/__tests__/ducks/_tflow.js +++ b/web/src/js/__tests__/ducks/_tflow.js @@ -2,7 +2,7 @@ export default function(){ return { "client_conn": { "address": [ - "address", + "127.0.0.1", 22 ], "alpn_proto_negotiated": "http/1.1", |