diff options
-rw-r--r-- | .appveyor.yml | 3 | ||||
-rw-r--r-- | .travis.yml | 10 | ||||
-rw-r--r-- | README.rst | 2 | ||||
-rwxr-xr-x | dev.sh | 2 | ||||
-rw-r--r-- | mitmproxy/utils/typecheck.py | 27 | ||||
-rw-r--r-- | mitmproxy/version.py | 2 | ||||
-rw-r--r-- | setup.py | 1 | ||||
-rw-r--r-- | test/mitmproxy/net/http/test_url.py | 13 | ||||
-rw-r--r-- | tox.ini | 7 |
9 files changed, 52 insertions, 15 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 3725ea3f..129a84c3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,6 +7,9 @@ environment: matrix: - PYTHON: "C:\\Python35" TOXENV: "py35" + # TODO: ENABLE WHEN AVAILABLE + # - PYTHON: "C:\\Python36" + # TOXENV: "py36" SNAPSHOT_HOST: secure: NeTo57s2rJhCd/mjKHetXVxCFd3uhr8txnjnAXD1tUI= diff --git a/.travis.yml b/.travis.yml index c078e30a..eb388687 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,16 @@ matrix: - debian-sid packages: - libssl-dev + - python: 3.6 + env: TOXENV=py36 OPENSSL_ALPN + addons: + apt: + sources: + # Debian sid currently holds OpenSSL 1.1.0 + # change this with future releases! + - debian-sid + packages: + - libssl-dev - python: 3.5 env: TOXENV=docs git: @@ -10,6 +10,8 @@ interface. ``mitmdump`` is the command-line version of mitmproxy. Think tcpdump for HTTP. +``mitmweb`` is a web-based interface for mitmproxy. + ``pathoc`` and ``pathod`` are perverse HTTP client and server applications designed to let you craft almost any conceivable HTTP request, including ones that creatively violate the standards. @@ -2,7 +2,7 @@ set -e set -x -PYVERSION=3.5 +PYVERSION=${1:-3.5} VENV="venv$PYVERSION" echo "Creating dev environment in $VENV using Python $PYVERSION" diff --git a/mitmproxy/utils/typecheck.py b/mitmproxy/utils/typecheck.py index ca2c7d5d..0b29f6a4 100644 --- a/mitmproxy/utils/typecheck.py +++ b/mitmproxy/utils/typecheck.py @@ -1,4 +1,5 @@ import typing +import sys def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None: @@ -21,8 +22,15 @@ def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None: type(value) )) - if typeinfo.__qualname__ == "Union": - for T in typeinfo.__union_params__: + typename = str(typeinfo) + + if typename.startswith("typing.Union"): + if sys.version_info < (3, 6): + types = typeinfo.__union_params__ + else: + types = typeinfo.__args__ + + for T in types: try: check_type(attr_name, value, T) except TypeError: @@ -30,21 +38,26 @@ def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None: else: return raise e - elif typeinfo.__qualname__ == "Tuple": + elif typename.startswith("typing.Tuple"): + if sys.version_info < (3, 6): + types = typeinfo.__tuple_params__ + else: + types = typeinfo.__args__ + if not isinstance(value, (tuple, list)): raise e - if len(typeinfo.__tuple_params__) != len(value): + if len(types) != len(value): raise e - for i, (x, T) in enumerate(zip(value, typeinfo.__tuple_params__)): + for i, (x, T) in enumerate(zip(value, types)): check_type("{}[{}]".format(attr_name, i), x, T) return - elif typeinfo.__qualname__ == "Sequence": + elif typename.startswith("typing.Sequence"): T = typeinfo.__args__[0] if not isinstance(value, (tuple, list)): raise e for v in value: check_type(attr_name, v, T) - elif typeinfo.__qualname__ == "IO": + elif typename.startswith("typing.IO"): if hasattr(value, "read"): return elif not isinstance(value, typeinfo): diff --git a/mitmproxy/version.py b/mitmproxy/version.py index b6cf0e17..3206044d 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -1,4 +1,4 @@ -IVERSION = (1, 0, 0) +IVERSION = (1, 0, 1) VERSION = ".".join(str(i) for i in IVERSION) PATHOD = "pathod " + VERSION MITMPROXY = "mitmproxy " + VERSION @@ -35,6 +35,7 @@ setup( "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Security", diff --git a/test/mitmproxy/net/http/test_url.py b/test/mitmproxy/net/http/test_url.py index 94b2eacc..5f85112b 100644 --- a/test/mitmproxy/net/http/test_url.py +++ b/test/mitmproxy/net/http/test_url.py @@ -1,3 +1,6 @@ +import pytest +import sys + from mitmproxy.test import tutils from mitmproxy.net.http import url @@ -42,14 +45,18 @@ def test_parse(): # Null byte in host with tutils.raises(ValueError): url.parse("http://foo\0") - # Port out of range - _, _, port, _ = url.parse("http://foo:999999") - assert port == 80 # Invalid IPv6 URL - see http://www.ietf.org/rfc/rfc2732.txt with tutils.raises(ValueError): url.parse('http://lo[calhost') +@pytest.mark.skipif(sys.version_info < (3, 6), reason='requires Python 3.6 or higher') +def test_parse_port_range(): + # Port out of range + with tutils.raises(ValueError): + url.parse("http://foo:999999") + + def test_unparse(): assert url.unparse("http", "foo.com", 99, "") == "http://foo.com:99" assert url.unparse("http", "foo.com", 80, "/bar") == "http://foo.com/bar" @@ -1,10 +1,9 @@ [tox] -envlist = py35, docs, lint +envlist = py35, py36, docs, lint skipsdist = True toxworkdir={env:TOX_WORK_DIR:.tox} [testenv] -basepython = python3.5 deps = {env:CI_DEPS:} -rrequirements.txt @@ -52,6 +51,8 @@ deps = # The 3.2 release is broken 🎉 # the next commit after this updates the bootloaders, which then segfault! 🎉 # https://github.com/pyinstaller/pyinstaller/issues/2232 - git+https://github.com/pyinstaller/pyinstaller.git@483c819d6a256b58db6740696a901bd41c313f0c + git+https://github.com/pyinstaller/pyinstaller.git@483c819d6a256b58db6740696a901bd41c313f0c; sys_platform == 'win32' + git+https://github.com/mhils/pyinstaller.git@d094401e4196b1a6a03818b80164a5f555861cef; sys_platform != 'win32' + commands = rtool {posargs} |