Commit Graph

1332 Commits

Author SHA1 Message Date
Aldo Cortesi
8065b44eed addons.view: clarify modification events
This adds a set of store modification events, and uses them for flow settings.
This addresses a bug where settings could persist even after flows were deleted.
2016-11-15 09:53:17 +13:00
Aldo Cortesi
9b08279c7c addons.proxyauth: out with the old, in with the new
- Strip out old auth mechanisms, and enable addon
- Disable web app auth for now - this should just use the Tornado auth stuff
2016-11-13 19:59:59 +13:00
Aldo Cortesi
dc88b7d110 addons.proxyauth: complete and test 2016-11-13 18:14:23 +13:00
Aldo Cortesi
e644d2167c stub out proxyauth addon
Stub out basic workings, add and test configure event.
2016-11-13 16:22:33 +13:00
Aldo Cortesi
fe01b1435a upstream_proxy_auth -> upstream_auth
Also clarify what this does in commandline help.
2016-11-13 11:50:28 +13:00
Aldo Cortesi
3b00bc339d Complete upstream authentication module
- Handles upstream CONNECT and regular requests, plus HTTP Basic for reverse
proxy
- Add some tests to make sure we can rely on the .via attribute on server
connections.
2016-11-13 11:43:27 +13:00
Aldo Cortesi
a9b4560187 Refine handling of HTTP CONNECT
- CONNECT requests do not generate the usual http events. Instead, they
generate the http_connect event and handlers then have the option of setting an
error response to abort the connect.
- The connect handler is called for both upstream proxy and regular proxy CONNECTs.
2016-11-12 18:28:37 +13:00
Aldo Cortesi
38f8d9e541 Add the http_connect event for HTTP CONNECT requests 2016-11-12 12:44:43 +13:00
Aldo Cortesi
bc01a146b0 Upstream proxy auth to addon 2016-11-12 11:58:04 +13:00
Aldo Cortesi
3958940420 Test failure during 100-continue
Also:

- Remove duplicate and unused code
- Tighten scope of HttpReadDisconnect handler - we only want to ignore this for
the initial read, not for the entire block that includes things like the expect
handling.
2016-11-12 11:58:04 +13:00
Aldo Cortesi
82ac7d05a6 Bug: ask requestheaders before request body is read
Also add the beginnings of a test suite to exercise issues like this.
2016-11-12 11:58:04 +13:00
Thomas Kriechbaumer
184e29e119 http2: add push-promise metadata test 2016-11-05 05:13:36 +01:00
Aldo Cortesi
067198a5dd Remove deprecated interfaces 2016-11-04 11:47:47 +13:00
Aldo Cortesi
6c8c4465d9 script.concurrent: tests to taddons 2016-11-04 10:59:41 +13:00
Aldo Cortesi
4f4db223fe addons: convert last of the test suite to taddons 2016-11-04 09:17:56 +13:00
Aldo Cortesi
deb66d3cac addons.setheaders: fix configure bug, tests to taddons 2016-11-04 09:09:39 +13:00
Aldo Cortesi
b51a96081a addons.view: test suite to 100%
This takes coverage for all of /addons to 100%
2016-11-04 08:55:01 +13:00
Aldo Cortesi
17e828b243 addons.view: test improvements 2016-11-03 20:53:06 +13:00
Aldo Cortesi
5ade93f2ad addons.streambodies: 100% test coverage 2016-11-03 20:16:07 +13:00
Aldo Cortesi
d7d6edb3d1 addons.serverplayback: 100% test coverage 2016-11-03 20:05:21 +13:00
Aldo Cortesi
e1fc80937d addons.serverplayback: test suite to taddons 2016-11-03 19:43:33 +13:00
Aldo Cortesi
e9a96f4d7f addons.script: 100% test coverage 2016-11-03 19:36:34 +13:00
Aldo Cortesi
d9538637c3 addons.script: convert to test.taddons 2016-11-03 18:57:34 +13:00
Aldo Cortesi
d31f2698a5 addons.onboarding: remove duplicate code 2016-11-03 16:20:38 +13:00
Aldo Cortesi
9fc6674151 addons.intercept: 100% test coverage 2016-11-03 16:16:29 +13:00
Aldo Cortesi
77e6dfe35c streamfile: make options less crazy
Instead of a (file, mode) tuple, move to "streamfile" as the path, and
"streamfile_append" to specify if we should append or not.

Leave the command-line options intact for now.
2016-11-03 15:18:55 +13:00
Aldo Cortesi
9f77c79227 FileStreamer -> StreamFile
options.wfile -> options.streamfile
2016-11-03 15:00:18 +13:00
Aldo Cortesi
43a8221989 addons: filestreamer test cov to 100%
Also address a bug in taddons that caused options changes that raised errors to
be retained rather than rolled back.
2016-11-03 14:50:23 +13:00
Aldo Cortesi
fbdce4b629 addons filstreamer: tests and bugfixes
- Move tests to taddons
- Fix a bug where options updates caused streaming to halt
2016-11-03 12:44:19 +13:00
Aldo Cortesi
5109fd8ecb Change antiquated test cipher suites
This breaks Travis, possibly due to OpenSSL version.
2016-11-03 08:23:19 +13:00
Aldo Cortesi
b867fb35a3 addons: dumper spit and polish
- 100% test coverage
- Cleanups
- Add test/mitmproxy/addons/dumperview.py, a small utility for viewing dumper
output variations
2016-11-02 22:47:49 +13:00
Aldo Cortesi
a75b3474a4 tests: convert test_dumper to use taddons 2016-11-02 11:17:08 +13:00
Aldo Cortesi
59b269425f tests: client_playback coverage 2016-11-02 10:59:33 +13:00
Aldo Cortesi
7e6d014f8f tests: pathod/tutils.py -> pathod/tservers.py
And remove all aliases for mitmproxy.test.tutils
2016-11-02 10:06:25 +13:00
Aldo Cortesi
c55e8d8f62 tests: clean up test/mitmproxy/tutils.py
Remove aliases, use mitmproxy/test/tutils instead.
2016-11-02 09:44:18 +13:00
Aldo Cortesi
fc7606bd98 tests: minor cleanup for tests/mitmproxy/tutils.py 2016-11-02 08:51:26 +13:00
Aldo Cortesi
83fdd82a52 addons anticom, anticache: expand tests, new truss 2016-11-01 17:38:45 +13:00
Aldo Cortesi
50deaf56bf Remove addons.State
- Do a first-pass port of mitmweb. Some stuff still broken.
- Remove more all State tests from the test suite
2016-11-01 10:06:28 +13:00
Aldo Cortesi
9d9735dd07 Replace addons.state in test suite
Use a super-simple flow recorder instead.
2016-11-01 09:36:24 +13:00
Aldo Cortesi
daf355bb4c console: add caching sort keys
This is a tad complicated. The underlying sorted list implementation expects
the sort key to be stable for the lifetime of the object. However, if we sort
by size, for instance, the sort order changes as the flow progresses through
its lifecycle. We address this through two means:

- Let order keys cache the sort value by flow ID.
- Add a facility to refresh items in the list by removing and re-adding them
when they are updated.
2016-10-30 21:11:30 +13:00
Aldo Cortesi
9abfb1aac2 console: re-add follow focus 2016-10-30 19:47:32 +13:00
Aldo Cortesi
f08b57fb9b console: "v" to reverse flow order 2016-10-30 17:57:43 +13:00
Aldo Cortesi
a67a591893 console: o for flow order
"o" shortcut and --order cmdline option to change flow order.

Options is now bound to "O".
2016-10-30 17:42:34 +13:00
Aldo Cortesi
6b6c44551a addons.view: Add first-class support for marking
Marking now works differently - it's no longer just another filter, it's
applied in addition to the filter. This means you can apply a filter, mark some
flows, and then toggle between marked and unmarked flows matching the filter.

I'm leaving the filter for marked flows intact - it will come in handy in other
situations.
2016-10-30 15:45:36 +13:00
Aldo Cortesi
2b76db1272 console: Port from state to view
First phase of the port - basic flow list and flow view functionality working.
More to come.
2016-10-30 14:56:36 +13:00
Aldo Cortesi
b9eb1a3479 Add options.default_contentview
This is the first step in a longer process of revamping content views. For the
moment, the option is not exposed on the command line.
2016-10-30 12:05:37 +13:00
Aldo Cortesi
944dcbaaa0 Cleanups: remove intercept from addons.state, unused imports 2016-10-30 11:13:05 +13:00
Aldo Cortesi
81a00f6f76 Replace interception in mitmproxy and mitmweb with addon
Fixes #1674
2016-10-30 11:07:09 +13:00
Aldo Cortesi
d1f14961ed test.taddon: Add cycle() method, use it to test addons.intercept 2016-10-30 10:52:57 +13:00
Aldo Cortesi
b4904d33ba Move test flow creators to mitmproxy.test.tflow 2016-10-30 10:12:39 +13:00
Aldo Cortesi
2dc3284fbb Add addons.intercept
- Add an addon to handle intercept based on a filter pattern
- Start sketching out a nicer testing truss for addons in mitmproxy.test.taddon
2016-10-29 15:44:48 +13:00
Aldo Cortesi
71d2636594 Sync 2016-10-29 12:35:10 +13:00
Aldo Cortesi
005c22445b addons.view: focus.focusflow -> focus.flow 2016-10-29 11:55:44 +13:00
Aldo Cortesi
7ecaeb0214 addons.view.focus: next and prev methods 2016-10-29 11:50:10 +13:00
Aldo Cortesi
32a0a7b860 addons.view: flow settings
Add a flow settings mechanism, enable focus and settings unilaterally.
2016-10-29 11:37:32 +13:00
Aldo Cortesi
14df969434 addons.view.focus: Better handling of view refresh
When we refresh and our current focus goes out of scope, we set the focus to
the element nearest the old focus.
2016-10-29 11:08:35 +13:00
Aldo Cortesi
90e7142b5c addons.View: better order reversal
Deal with some subtleties in order reversal, add a toggle method that emits
refresh.
2016-10-29 10:55:57 +13:00
Aldo Cortesi
12a70d03ad addons.view: Add a focus tracker 2016-10-29 10:17:29 +13:00
Aldo Cortesi
9dcc3a3e20 addons.View: hook up signals 2016-10-29 08:25:19 +13:00
Aldo Cortesi
69bacee1d8 Sketch out addons.View
The first iteration of a replacement for addons.State
2016-10-29 08:25:19 +13:00
Thomas Kriechbaumer
44ac370f08 upgrade h2 to >=2.5.0 2016-10-27 15:10:53 -07:00
Maximilian Hils
97f1236c99 Merge pull request #1670 from chhsiao90/display-cipher-#582
Resolved #582: display ClientConnection select cipher of TLS
2016-10-27 11:38:22 -07:00
chhsiao90
d52f35428c Show tls version on console 2016-10-26 14:36:14 +08:00
Maximilian Hils
b1bdae3d1c typecheck options, fix current inconsistencies 2016-10-25 20:45:48 -07:00
chhsiao90
960f2e8bf0 Resolved #582: display ClientConnection select cipher of TLS 2016-10-26 11:32:42 +08:00
Maximilian Hils
145c2892f7 Merge pull request #1664 from chhsiao90/sni-display-#1639
Resolved #1639: display sni on ClientConnection
2016-10-24 19:56:05 -07:00
chhsiao90
39ac29e37c Resolved #1639: display sni on ClientConnection 2016-10-25 10:46:53 +08:00
Maximilian Hils
ef4e9b2b85 Merge pull request #1656 from mhils/improve-export-2
Improve Flow Export
2016-10-24 19:19:58 -07:00
Sahil Chelaramani
7b3505336a replace mitmproxy.utils.lrucache with functools.lru_cache 2016-10-24 16:03:16 -07:00
Maximilian Hils
e87daa70f3 improve flow export 2016-10-22 20:32:39 -07:00
Maximilian Hils
ea2d6474bf Merge pull request #1649 from cortesi/kill
Don't call error for flow kill
2016-10-22 19:22:50 -07:00
Maximilian Hils
a1a792aeac various encoding fixes, fix #1650 2016-10-22 18:47:12 -07:00
Aldo Cortesi
6170493615 Don't call error for flow kill
This is now the error handler on master, so whatever the intetion was it's now
definitely wrong.
2016-10-22 15:56:42 +13:00
Aldo Cortesi
cc8b422d9d multidict: remove to_dict
We never use it, and it is dangerously ambiguous when a key is associated with
a list.
2016-10-21 11:42:21 +13:00
Aldo Cortesi
18ee6255c0 multidict: ditch ImmutableMultiDict
A contorted class we only use for cookie attributes. We don't need it.
2016-10-21 11:40:05 +13:00
Aldo Cortesi
8430f857b5 The final piece: netlib -> mitproxy.net 2016-10-20 11:56:38 +13:00
Aldo Cortesi
853e03a5e7 netlib.tutils -> mitmproxy.test.tutils
There's a LOT more to be done refactoring our different conflicting test utils.
2016-10-20 11:42:55 +13:00
Aldo Cortesi
01a449b5cb netlib.exceptions.* -> mitmproxy.exceptions 2016-10-20 11:27:05 +13:00
Aldo Cortesi
301d52d9d0 netlib.encoding -> netlib.http.encoding
Encoding is highly specific to http, and only used within this module.
2016-10-20 11:06:57 +13:00
Aldo Cortesi
f964d49853 netlib.certutils -> mitmproxy.certs 2016-10-20 11:02:52 +13:00
Aldo Cortesi
9870844b38 netlib.utils -> netlib.check
Now only contains is_valid_[host,port]

Intermediate step - this will be in mitproxy.net soon.
2016-10-20 10:46:47 +13:00
Aldo Cortesi
e0f3cce14c netlib.utils.[get,set]bit -> mitmproxy.utils.bits 2016-10-20 10:38:57 +13:00
Aldo Cortesi
9555126585 netlib.utils.BiDi -> mitmproxy.types.bidi.BiDi 2016-10-20 10:32:09 +13:00
Aldo Cortesi
a684585e7c netlib.debug -> mitmproxy.utils.debug 2016-10-20 10:25:36 +13:00
Aldo Cortesi
1ecb25cdc1 mitmproxy.types.[basethread,multidict,serializable] 2016-10-20 10:22:23 +13:00
Aldo Cortesi
f45f4e677e netlib.strutils -> mitmproxy.utils.strutils 2016-10-20 10:11:58 +13:00
Aldo Cortesi
1407830280 netlib.human -> mitmproxy.utils.human 2016-10-20 09:45:18 +13:00
Aldo Cortesi
069119364d Create mitmproxy.utils hierarchy
- Add mitproxy.utils.lrucache, mitproxy.utils.data
2016-10-20 09:35:55 +13:00
Aldo Cortesi
e73c7fe77e mitmproxy.protocol -> mitmproxy.proxy.protocol
The protocols here are compltely proxy-specific, are only used from within the
proxy module, and are not exposed to users.
2016-10-19 23:11:56 +13:00
Aldo Cortesi
24cf8da27e Move all tools into mitmproxy.tools, move models/* to top level
The primary motivation here (and for all the other moving around) is to present
a clean "front of house" to library users, and to migrate primary objects to
the top of the module hierarchy.
2016-10-19 20:26:05 +13:00
Aldo Cortesi
5a68d21e8c Remove flow module entirely, move contents to top level
mitmproxy.flow.io -> mitmproxy.io
mitmproxy.flow.export -> mitmproxy.export
2016-10-19 15:08:35 +13:00
Aldo Cortesi
7c32d4ea2a flow.state -> addons.state 2016-10-19 14:48:42 +13:00
Aldo Cortesi
22eebfd574 addons.Addons -> addonmanager, builtins -> addons 2016-10-19 14:39:39 +13:00
Aldo Cortesi
966418725b controller.Log -> log.Log 2016-10-19 14:14:59 +13:00
Aldo Cortesi
bce387a5a0 Kill flow.master - create master.Master
Also extract events into .events
2016-10-19 13:22:50 +13:00
Aldo Cortesi
264a09e778 Let's dispense with this fiction that we support multiple servers
It's simple enough to re-add if needed, and until then is just cruft.
2016-10-19 12:37:32 +13:00
Aldo Cortesi
87629586ae web app cleanups: tests and examples 2016-10-19 11:48:51 +13:00
Aldo Cortesi
ceb8caee98 Web apps to addons
This commit removes the app registry, adds a wsgiapp addon base, and ports the
onboarding app to it.
2016-10-19 11:40:51 +13:00
Aldo Cortesi
03cb5bb325 No need for all builtins to be loaded for server tests 2016-10-18 22:30:21 +13:00
Aldo Cortesi
466f5e56a1 Convert flow.state to an addon
A first step, and already many things are much nicer.
2016-10-18 21:51:36 +13:00
Aldo Cortesi
d5056c5627 accept_addon -> resume, intercept/resume events 2016-10-18 12:02:35 +13:00
Aldo Cortesi
825b02d495 master.duplicate_flow -> state.duplicate_flow
This is a pure operation on state, and doesn't belong on master.

Part of prep to move state to an addon.
2016-10-18 11:29:51 +13:00
Aldo Cortesi
b25d94a6ac Response body streaming to addon 2016-10-18 10:42:05 +13:00
Maximilian Hils
beed406058 fix tests 2016-10-17 03:37:42 -07:00
Thomas Kriechbaumer
94c9dd66e6 remove empty lines at beginning of file 2016-10-17 10:32:12 +02:00
Maximilian Hils
758860531a fix socks5 mode with tls 2016-10-16 23:05:51 -07:00
Aldo Cortesi
c774a9fec9 python3: clean up super and __future__ 2016-10-17 18:03:07 +13:00
Aldo Cortesi
a647b30365 python3: clean up class brackets 2016-10-17 17:37:08 +13:00
Aldo Cortesi
fb22f2ff4f Zap object base class 2016-10-17 17:37:08 +13:00
Aldo Cortesi
ce98a9219e test & examples: zap six 2016-10-17 16:45:45 +13:00
Aldo Cortesi
9a0195bf64 scripts: keep scripts just after the ScriptLoader in addon chain
We need scripts to run _before_ filestreamer, so we can't just add them to the
end of the chain. This patch also fixes an issue that could cause scripts to be
initialised un-necessarily if only the order of scripts in options changed.
2016-10-16 20:26:06 +13:00
Aldo Cortesi
fb69c9c345 docs: overview, classes, arguments 2016-10-16 20:26:06 +13:00
Maximilian Hils
e9284ab7ee add regression test for #1605 2016-10-14 01:22:30 -07:00
Aldo Cortesi
89d36713e3 certutils: cap the cert store size at 100 by default
This should be enough to give us reuse without growing infinitely. This is part
of fixing the memory situation in mitmdump.

TODO: There's an opportunity here for a better algorithm, that expires certs
based on least-recently-accessed time, rather than oldest generated time.
2016-10-05 10:44:31 +11:00
Thomas Kriechbaumer
90898f9084 use flt instead of filt for flowfilter expressions 2016-10-04 14:51:04 +02:00
Aldo Cortesi
882c363ec5 debug: Hard exit after debug signal 2016-10-04 16:48:13 +11:00
Aldo Cortesi
7fe09f4d26 Consolidate logging
- Make log event handler work
- Move terminal event log into an addon
- Clean various log related errors and duplications
2016-10-04 13:00:15 +11:00
Aldo Cortesi
2e48b60ff1 Clarify channel interaction pattern
Before this patch, it wasn't clear when the arguments to an event could be
modified, and when a new object should be returned. After this patch, the right
thing to do is to modify the arguments in 99% of cases. The only exception to
this is root_layer, for which we can find a better structure down the track.
2016-10-04 08:13:56 +11:00
Aldo Cortesi
1ae73b9157 Add requestheaders event
HTTP1 only for now, HTTP2 coming next.
2016-10-04 08:13:56 +11:00
Thomas Kriechbaumer
36c04f1631 fix flowfilter.match args 2016-10-03 12:04:17 +02:00
Thomas Kriechbaumer
bb60b76af4 use flowfilter.match 2016-10-03 11:45:54 +02:00
Thomas Kriechbaumer
ba84248910 rename mitmproxy.filt -> mitmproxy.flowfilter 2016-10-03 11:45:54 +02:00
Maximilian Hils
611dad12a7 Revert "Add API to programmatically create new requests (#1534)"
This reverts commit ccbdcd684b,
which yielded a test timeout.
2016-10-02 23:08:51 -07:00
Tyler St. Onge
ccbdcd684b Add API to programmatically create new requests (#1534) 2016-10-01 13:06:59 +02:00
Aldo Cortesi
070aa27cf5 parse_set_cookie header returns an empty list if no cookies are found
This matches parse_cookie, and is more idiomatic.
2016-09-28 15:10:31 +10:00
Aldo Cortesi
b21f076cc8 Merge branch 'multi-cookie' of https://github.com/dufferzafar/mitmproxy 2016-09-28 12:44:40 +10:00
Shadab Zafar
5383c15ff2 Add tests for comma separated Set-Cookies 2016-09-27 21:28:54 +05:30
Ryan Laughlin
ad6d675b20 In reverse proxy mode, always send SNI 2016-09-27 10:49:04 -04:00
Shadab Zafar
e8ffc5167b Can't have , in the sticky cookie test
Since we support comma separated cookies now
2016-09-27 16:44:09 +05:30
Shadab Zafar
9ec0790271 Make needed changes in tests 2016-09-27 16:44:09 +05:30
Shadab Zafar
85bf5e18f6 Update cookie tests
This is needed since _read_pairs now returns a list of cookies each of which
is a list of [name, value] tuples.
2016-09-27 16:44:08 +05:30
Maximilian Hils
eeec17902f update dependencies, minor fixes (#1577) 2016-09-24 21:01:48 -07:00
Maximilian Hils
0a643ad20f remove option argument for addons.add (#1576) 2016-09-24 18:21:12 -07:00
Maximilian Hils
9142da1a7d Merge pull request #1566 from mhils/issue-1546
add websocket on/off switch, improve logging (fix #1546, fix #1547)
2016-09-22 03:06:39 -07:00
Maximilian Hils
77868434e7 fix tests 2016-09-22 02:10:02 -07:00
Maximilian Hils
a3329c5a80 scripts: cut traceback properly, fix #1467 2016-09-22 02:03:12 -07:00
Maximilian Hils
9e0b935fa2 Merge pull request #1564 from mhils/issue-1554
Fix Response.make content-length header
2016-09-21 21:49:14 -07:00
Maximilian Hils
0b532789a0 fix Response.make content-length header 2016-09-21 20:34:01 -07:00
Maximilian Hils
770936f1f9 raise TypeError on invalid header assignment, fix #1562 2016-09-21 19:21:32 -07:00
Aldo Cortesi
cfb943bfdd Redesign client replay
- Move to an addon
- Use a much simpler synchronisation mechanism
2016-09-11 20:00:34 +12:00
Aldo Cortesi
6b9221ffeb Add "run_once" support to the script addon, use it in mitmproxy
Fixes #1418
2016-09-11 13:22:01 +12:00
Aldo Cortesi
9b814ca067 options.replay_ignore* -> options.server_replay_ignore* 2016-09-10 10:21:52 +12:00
Aldo Cortesi
8677e91074 options.nopop -> options.server_replay_nopop 2016-09-10 10:09:07 +12:00
Aldo Cortesi
5ebe8c1bc8 options.rheaders -> options.server_replay_use_headers 2016-09-10 10:09:07 +12:00
Aldo Cortesi
b0213a2c0e options.kill -> options.replay_kill_extra 2016-09-10 10:09:07 +12:00
Aldo Cortesi
4ff8a72521 Roll out synchronisation for mitmproxy tests
This extends some of the work I did for pathod and netlib to the mitmproxy test
suite. It also fixes what may be a leak in replays.

Failing on connection leak is disabled on Windows for the moment.

Fixes #1535
2016-09-10 09:18:11 +12:00
Aldo Cortesi
ea49b8a2e2 Merge pull request #1532 from cortesi/playback
Playback and fix construct breakage
2016-09-07 12:59:11 +12:00
Schamper
5728a1c900 Make 'none' synonymous to 'identity' 2016-09-06 17:00:08 +02:00
Aldo Cortesi
9abdd3a8d9 Move server playback in to an addon
- Move server playback into an addon
- Implement a better sync strategy to decide when to exit if keepserving is
off. We now wait for the final flow played back to no longer be live.
- Leave interactive server playback in mitmproxy console broken for now - there
are broader addon-related changes that need to be made for that, and this patch
is already big.

Fixes #1229
2016-09-06 23:48:02 +12:00
Schamper
85e1539d0a Add test 2016-09-06 11:07:50 +02:00