Commit Graph

551 Commits

Author SHA1 Message Date
Aldo Cortesi
532ae7dc4a Add addons after initialisation in mitmproxy console
The main effect of this is that we now properly capture errors on startup that
were ignored before.
2016-07-16 09:22:56 +12:00
Maximilian Hils
60d2e14cb9 fix #1358 2016-07-15 00:07:32 -07:00
Aldo Cortesi
c7d0850d8f Script cleanups
- Preserve script order on config change
- Prohibit script duplicates (i.e. identical script + args)
- Various cleanups and tweaks
2016-07-15 16:35:24 +12:00
Aldo Cortesi
4ba7ce50c6 Add .start for addons and scripts
Also improve error messages, fix various unit tests
2016-07-15 14:52:34 +12:00
Aldo Cortesi
8fee5db675 Always use PollingObserver 2016-07-14 21:33:53 +12:00
Aldo Cortesi
9f1c46e7d6 Merge branch 'master' into script 2016-07-14 20:26:34 +12:00
Aldo Cortesi
e051928f26 Add missing mitmweb option 2016-07-14 20:24:56 +12:00
Aldo Cortesi
a4127fb6d5 Add a tick event for addons and scripts, and use it for race-free reload 2016-07-14 19:54:15 +12:00
Aldo Cortesi
5b2d1c044a Tighten the tick loop
In the past, we consumed from the event queue until we were idle for a certain
amount of time (0.1s). This would cause hangs in interactive tools when there
was a stream of events, hurting responsiveness. We now wait for a maximum of
0.1s before triggering the tick loop, will be able to reduce this further down
the track.
2016-07-14 19:54:15 +12:00
Aldo Cortesi
deffed2196 Script cleanup: editing in console, Python3 compatibility fixes 2016-07-14 19:54:15 +12:00
Aldo Cortesi
b94f5fd361 Convert examples and example tests for new-style scripts
Remove the test that just loads all the example scripts for now - it's a very
low-value test, and we need to think of something better.
2016-07-14 19:54:15 +12:00
Aldo Cortesi
a6821aad8e Zap old scripts infrastructure, fix concurrency tests 2016-07-14 19:54:15 +12:00
Aldo Cortesi
a3a22fba33 First-order integration of scripts addon 2016-07-14 19:54:15 +12:00
Shadab Zafar
1266255842 Re-add deletion of stickycookies (#1355)
This was originally added in #1324 (fixing issue #1096)
but got lost during "the big refactor" (#1352)
2016-07-14 00:37:27 -07:00
Maximilian Hils
f84a23f11d minor fixes 2016-07-13 22:01:16 -07:00
Maximilian Hils
ec6fbe9eb6 make options explicit 2016-07-13 21:45:25 -07:00
Aldo Cortesi
b2c4f301cb Stream to file -> addon
This commit also clarifies a confusion about the "outfile" attribute and its
use in testing in the mitmdump master.
2016-07-14 13:52:09 +12:00
Aldo Cortesi
cf3b3d206a Zap unused imports 2016-07-14 12:45:00 +12:00
Aldo Cortesi
120465a142 Ditch StickyCookie module 2016-07-14 12:17:28 +12:00
Aldo Cortesi
00509d86a8 StickyCookies to addon 2016-07-14 12:13:14 +12:00
Aldo Cortesi
143bf0dfa9 AntiCache to addon 2016-07-14 11:24:06 +12:00
Aldo Cortesi
97b2e6d958 Add a .setter helper to Options
This returns a function that sets a named attribute, and is handy for
event-driven code like mitmproxy console.
2016-07-14 11:11:41 +12:00
Aldo Cortesi
c52d567b43 Handle OptionsError for command-line args. 2016-07-14 10:19:16 +12:00
Aldo Cortesi
a8a083a10d Move StickyAuth into addon
This is the first addon that handles an OptionsError, so this commit also demos
how this works in console. Handling of command-line erorrs is on its way.
2016-07-14 10:08:41 +12:00
Aldo Cortesi
696789b8ec func.__name__ works in both 2.7 and 3.5
Thanks to @resam and @dwfreed for pointing this out
2016-07-14 09:33:26 +12:00
Aldo Cortesi
9ab1db513f Satisfy our ruthless linting overlords 2016-07-13 23:50:25 +12:00
Aldo Cortesi
255e1eb00b Add the addons mechanism
Demonstrate how it works and interacts with Options by adding our first new
builtin: anticomp.
2016-07-13 23:45:49 +12:00
Aldo Cortesi
7f8fd3cdff Basic outline of addons
Add addons.py, integrate with our event mechanism, and change the Master API so
options is the first init argument.
2016-07-13 23:26:04 +12:00
Aldo Cortesi
c9a0fe6a0e Show how options integrates with console
This is not functional at the moment, because all mutable options are still on
master.
2016-07-13 19:15:38 +12:00
Aldo Cortesi
a20f8e9620 More powerful Options scheme
This prepares us for the addon configuration mechanism and gives us a more
flexible way to handle options changes. This changeset should spell the end of
the current anti-pattern in our codebase where we duplicate data out of options
onto the master when mutability is needed. From now on, Options can be the one
source of thruth.

- Change notifications
- Rollback on error
2016-07-13 18:45:50 +12:00
strohu
6a9407d7cc Make sudo pfctl error check Python 3 compatible
In Python 3, subprocess.check_output() returns a sequence of bytes. This change ensures that it will be converted to a string, so the substring test for the sudo error message does not raise a TypeError. This fixes the code in Python 3 while remaining compatible with Python 2.
2016-07-12 15:47:01 +01:00
strohu
6217614204 Fix is_ascii check when determining next layer 2016-07-12 13:18:58 +01:00
Thomas Kriechbaumer
7c09255298 http2: more coverage 2016-07-10 20:07:43 +02:00
Shadab Zafar
c92992f03b Move cookie expiry detection to separate function 2016-07-09 22:20:25 +05:30
Shadab Zafar
608435cabf Delete stickycookies when told by the server
Fixes #1096
2016-07-09 22:20:25 +05:30
Shadab Zafar
0a21d27004 strutils.hexdump returns native_strings 2016-07-09 12:43:21 +05:30
Shadab Zafar
147f61fa62 py3++ 2016-07-09 11:14:12 +05:30
Shadab Zafar
b4469d2579 py3++: test_dump 2016-07-09 11:14:12 +05:30
Maximilian Hils
15c10d49f6 Merge pull request #1327 from mitmproxy/remove-script-context
Remove script context
2016-07-08 20:11:12 -07:00
Maximilian Hils
5d2b7c52f9 move script context to mitmproxy.ctx 2016-07-08 19:57:57 -07:00
jpkrause
05ab9c1b37 Updated coding style and modified flow format compat test to use v0.11 and v0.10 dump files 2016-07-08 15:03:36 -07:00
jpkrause
c9482c6255 Added flow converters for versions 0.11 and 0.12 2016-07-08 12:46:28 -07:00
Jason
92026d26ea [web] update build 2016-07-08 22:01:09 +08:00
Thomas Kriechbaumer
6da166d762 http2: fix self-depended streams 2016-07-08 10:37:56 +02:00
Maximilian Hils
7c67faa8da remove script contexts 2016-07-07 23:50:55 -07:00
Maximilian Hils
76473d44e0 py3++ 2016-07-07 17:50:26 -07:00
Maximilian Hils
f62e976e1e py3++ 2016-07-07 17:29:22 -07:00
Thomas Kriechbaumer
d962bd4e83 py3++ 2016-07-07 20:25:48 +02:00
Maximilian Hils
a212ce1f63 py3++ 2016-07-07 02:30:25 -07:00
Thomas Kriechbaumer
64ac2c73fe Merge pull request #1318 from mhils/tnetstring3-unicode-type
[tests actually pass] Add unicode to tnetstring3
2016-07-07 09:48:22 +02:00
Linmiao Xu
275cf7a6c2 Detect JSON API media type as a json content view
IANA assignment here:
https://www.iana.org/assignments/media-types/application/vnd.api+json

More about JSON API:
https://github.com/json-api/json-api
2016-07-06 21:10:35 -07:00
Maximilian Hils
64a867973d sni is now str, not bytes 2016-07-06 21:03:17 -07:00
Maximilian Hils
2c37ebfc72 fix dump file cross compat between python versions 2016-07-06 19:55:48 -07:00
Maximilian Hils
d406bee988 tnetstring3: adapt to unicode support 2016-07-06 19:55:48 -07:00
Maximilian Hils
48ee3a553e add tnetstring unicode type 2016-07-06 19:55:48 -07:00
Maximilian Hils
684b4b5130 tnetstring: keys are str on py3. migrate flow.io_compat 2016-07-06 19:55:48 -07:00
Maximilian Hils
e6e839d56d add python3 tnetstring implementation 2016-07-06 19:55:25 -07:00
Maximilian Hils
9c873d63f4 py3++, multidict fixes
This commit improves Python 3 compatibility and fixes two multidict
issues:

 1. Headers.items(multi=True) now decodes fields
 2. MultiDict.clear(item) has been removed, as Python's
    MutableMapping already defines .clear() with different
    semantics. This is confusing for everyone who expects a
    dict-like object. `.pop("attr", None)` is not fantastic,
    but it's the Python way to do it.
2016-07-06 19:53:29 -07:00
Maximilian Hils
444f0a4c39 py3++ 2016-07-06 17:31:08 -07:00
Maximilian Hils
38fd1d3ad7 fix issue introduced in 72f3b2b 2016-07-06 12:14:48 -07:00
Maximilian Hils
72f3b2bb17 minor code improvement 2016-07-05 19:32:25 -07:00
Maximilian Hils
e84f5fcc72 Merge pull request #1315 from mitmproxy/better-unicode-handling
remove clean_bin, clarify unicode handling
2016-07-05 16:02:37 -07:00
Maximilian Hils
00a35aa895 Merge pull request #1297 from dufferzafar/py3-flow-export
Python 3 - test_flow_export
2016-07-05 15:17:18 -07:00
Maximilian Hils
d51cf543bb remove clean_bin, clarify unicode handling 2016-07-05 15:11:32 -07:00
Thomas Kriechbaumer
05de3b759f http2: remove forbidden headers
E.g.: send_error_reponse sets a connection header
2016-07-05 22:15:57 +02:00
Thomas Kriechbaumer
50fdb01553 prevent early priority changes 2016-07-05 21:02:19 +02:00
Thomas Kriechbaumer
64880e7ebd handle related events from h2 2016-07-05 20:14:28 +02:00
Thomas Kriechbaumer
47db346959 improve end_stream handling
To replicate requests as close as possible frame-by-frame.

This fixes an issue with broken HTTP/2 implemenation by Akamai and
Twitter, which raise an error if we send an empty DataFrame only to
indicate END_STREAM.
2016-07-05 20:14:28 +02:00
Thomas Kriechbaumer
aa1b203182 http2: implement direct handling of priority 2016-07-05 20:14:28 +02:00
Maximilian Hils
ca9de786fd minor fix 2016-07-04 15:07:01 -07:00
Maximilian Hils
a6b3551934 raise ValueError if content-encoding is invalid 2016-07-04 13:58:09 -07:00
Shadab Zafar
d361177753 h2: move header parsing to netlib 2016-07-03 18:03:34 +05:30
Shadab Zafar
f623b3d99b py3++: test_flow_export 2016-07-02 21:15:20 +05:30
Shadab Zafar
17b727321f Replace map + lambda with list comprehensions 2016-07-02 21:15:20 +05:30
Shadab Zafar
393c1d74af fix lint issues 2016-07-02 18:56:22 +05:30
Maximilian Hils
d9f797e7e6 make the linter happy 2016-07-02 02:11:00 -07:00
Maximilian Hils
6032c4f235 message.content -> .raw_content, implement .text
This PR improves our handling of HTTP message body encodings:

- The unaltered message body is now accessible as `.raw_content`
- The "content-encoding"-decoded content (i.e. gzip removed) content
  is not `.content`, as this is what we want in 99% of the cases.
- `.text` now provides the "content-encoding"-decoded and then
  "content-type charset"-decoded message body.
- The decoded values for `.content` and `.text` are cached,
  so that repeated access and `x.text = x.text` is cheap.
- The `decoded()` decorator is now deprecated, as we can now just use
  `.content`. Similarly `HTTPMessage.get_decoded_content()` is
  deprecated.
2016-07-02 01:51:47 -07:00
Maximilian Hils
fa72462798 fix tcp message handling 2016-07-01 17:17:16 -07:00
Maximilian Hils
536c7acd13 py3++ 2016-07-01 14:10:48 -07:00
Shadab Zafar
268e42e55e py3++: test/mitmproxy/test_server 2016-07-01 10:23:04 -07:00
Jason
8f73dc79c0 [web] ui ducks for content view 2016-07-01 23:44:48 +08:00
Maximilian Hils
8366c87c57 update to latest typing release 2016-06-29 03:03:23 -07:00
Maximilian Hils
025efc030a Merge pull request #1301 from mitmproxy/simplify-tox
Simplify tox
2016-06-29 02:04:38 -07:00
Maximilian Hils
f7d4319c5a minor fixes 2016-06-28 23:48:19 -07:00
Maximilian Hils
b7430c0775 Merge pull request #1296 from gzzhanghao/test
[web] add tests for ducks/utils
2016-06-28 23:16:18 -07:00
Maximilian Hils
a57ea27bd4 watchdog: always use PollingObserver 2016-06-28 22:09:12 -07:00
Maximilian Hils
3b53d3e393 fix mysterious tox issue 2016-06-28 19:26:08 -07:00
Jason
37c2b47c26 [web] add tests for utils 2016-06-27 18:42:20 +08:00
Maximilian Hils
3eb2d04aac minor fixes 2016-06-26 01:45:45 -07:00
Jason
db415a26bc [web] log only in dev 2016-06-25 10:50:15 +08:00
Jason
a782571244 [web] build with envify 2016-06-25 10:43:30 +08:00
Jason
59dc5e4687 [web] update build 2016-06-25 10:09:21 +08:00
Jason
e400e9f513 [web] ErrorView 2016-06-25 09:52:49 +08:00
Jason
2b7923b4f4 [web] fix actions 2016-06-25 02:18:52 +08:00
Jason
571c817f21 [web] add msgQueue 2016-06-25 00:36:39 +08:00
Jason
5a1677c387 Merge branch 'master' of github.com:mitmproxy/mitmproxy into list
Conflicts:
	mitmproxy/web/static/app.js
	web/src/js/app.jsx
	web/src/js/connection.js
	web/src/js/ducks/websocket.js
2016-06-24 21:04:39 +08:00
Maximilian Hils
21c3480429 Merge remote-tracking branch 'jason/websocket' 2016-06-23 23:38:19 -07:00
Jason
f392b8e34c [web] bug fix 2016-06-24 01:20:42 +08:00
Jason
c40ff0277b [web] fix bugs 2016-06-24 01:01:34 +08:00
Jason
397554b7c7 [web] update build 2016-06-23 01:30:34 +08:00