diff options
-rw-r--r-- | mitmproxy/proxy/protocol/tls.py | 4 | ||||
-rw-r--r-- | netlib/check.py (renamed from netlib/utils.py) | 0 | ||||
-rw-r--r-- | netlib/http/http1/read.py | 4 | ||||
-rw-r--r-- | netlib/http/url.py | 6 | ||||
-rw-r--r-- | netlib/socks.py | 5 | ||||
-rw-r--r-- | test/mitmproxy/test_flow.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/tutils.py | 1 | ||||
-rw-r--r-- | test/netlib/test_check.py | 10 | ||||
-rw-r--r-- | test/netlib/test_utils.py | 10 |
9 files changed, 21 insertions, 21 deletions
diff --git a/mitmproxy/proxy/protocol/tls.py b/mitmproxy/proxy/protocol/tls.py index 940ab9ea..7b6b506c 100644 --- a/mitmproxy/proxy/protocol/tls.py +++ b/mitmproxy/proxy/protocol/tls.py @@ -7,7 +7,7 @@ import netlib.exceptions from mitmproxy import exceptions from mitmproxy.contrib.tls import _constructs from mitmproxy.proxy.protocol import base -from netlib import utils +from netlib import check # taken from https://testssl.sh/openssl-rfc.mappping.html @@ -265,7 +265,7 @@ class TlsClientHello: extension.type == 0x00 and len(extension.server_names) == 1 and extension.server_names[0].type == 0 and - utils.is_valid_host(extension.server_names[0].name) + check.is_valid_host(extension.server_names[0].name) ) if is_valid_sni_extension: return extension.server_names[0].name.decode("idna") diff --git a/netlib/utils.py b/netlib/check.py index 7b007cb5..7b007cb5 100644 --- a/netlib/utils.py +++ b/netlib/check.py diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py index 4c00a96a..89b73c5a 100644 --- a/netlib/http/http1/read.py +++ b/netlib/http/http1/read.py @@ -6,7 +6,7 @@ from netlib.http import request from netlib.http import response from netlib.http import headers from netlib.http import url -from netlib import utils +from netlib import check from netlib import exceptions @@ -274,7 +274,7 @@ def _parse_authority_form(hostport): try: host, port = hostport.split(b":") port = int(port) - if not utils.is_valid_host(host) or not utils.is_valid_port(port): + if not check.is_valid_host(host) or not check.is_valid_port(port): raise ValueError() except ValueError: raise exceptions.HttpSyntaxException("Invalid host specification: {}".format(hostport)) diff --git a/netlib/http/url.py b/netlib/http/url.py index 67e22efa..3ca58120 100644 --- a/netlib/http/url.py +++ b/netlib/http/url.py @@ -2,7 +2,7 @@ import urllib from typing import Sequence from typing import Tuple -from netlib import utils +from netlib import check # PY2 workaround @@ -62,9 +62,9 @@ def parse(url): if not full_path.startswith(b"/"): full_path = b"/" + full_path - if not utils.is_valid_host(host): + if not check.is_valid_host(host): raise ValueError("Invalid Host") - if not utils.is_valid_port(port): + if not check.is_valid_port(port): raise ValueError("Invalid Port") return parsed.scheme, host, port, full_path diff --git a/netlib/socks.py b/netlib/socks.py index 30fe1c9d..377308a8 100644 --- a/netlib/socks.py +++ b/netlib/socks.py @@ -2,7 +2,8 @@ import struct import array import ipaddress -from netlib import tcp, utils +from netlib import tcp +from netlib import check from mitmproxy.types import bidi @@ -204,7 +205,7 @@ class Message: elif atyp == ATYP.DOMAINNAME: length, = struct.unpack("!B", f.safe_read(1)) host = f.safe_read(length) - if not utils.is_valid_host(host): + if not check.is_valid_host(host): raise SocksError(REP.GENERAL_SOCKS_SERVER_FAILURE, "Invalid hostname: %s" % host) host = host.decode("idna") use_ipv6 = False diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 9ebcca34..9b7e7395 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -1,7 +1,7 @@ import mock import io -import netlib.utils +import netlib.tutils from netlib.http import Headers import mitmproxy.io from mitmproxy import flowfilter, options diff --git a/test/mitmproxy/tutils.py b/test/mitmproxy/tutils.py index 71dd20a4..aa70c0e8 100644 --- a/test/mitmproxy/tutils.py +++ b/test/mitmproxy/tutils.py @@ -9,7 +9,6 @@ from unittest.case import SkipTest import io -import netlib.utils import netlib.tutils from mitmproxy import controller from mitmproxy import connections diff --git a/test/netlib/test_check.py b/test/netlib/test_check.py new file mode 100644 index 00000000..6a1388f4 --- /dev/null +++ b/test/netlib/test_check.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +from netlib import check + + +def test_is_valid_host(): + assert not check.is_valid_host(b"") + assert check.is_valid_host(b"one.two") + assert not check.is_valid_host(b"one" * 255) + assert check.is_valid_host(b"one.two.") diff --git a/test/netlib/test_utils.py b/test/netlib/test_utils.py deleted file mode 100644 index db33fa31..00000000 --- a/test/netlib/test_utils.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 - -from netlib import utils - - -def test_is_valid_host(): - assert not utils.is_valid_host(b"") - assert utils.is_valid_host(b"one.two") - assert not utils.is_valid_host(b"one" * 255) - assert utils.is_valid_host(b"one.two.") |