The following issues were found

mitmproxy/proxy/events.py
16 issues
Class 'CommandCompleted' has no '__annotations__' member
Error

Line: 75 Column: 23

                      return super().__new__(cls)

    def __init_subclass__(cls, **kwargs):
        command_cls = cls.__annotations__.get("command", None)
        valid_command_subclass = (
                isinstance(command_cls, type)
                and issubclass(command_cls, commands.Command)
                and command_cls is not commands.Command
        )

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 30 Column: 5

                  Every layer initially receives a start event.
    This is useful to emit events on startup.
    """
    pass


@dataclass
class ConnectionEvent(Event):
    """

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 57 Column: 5

                  """
    Remote has closed a connection.
    """
    pass


class CommandCompleted(Event):
    """
    Emitted when a command has been finished, e.g.

            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 68 Column: 1

                  command: commands.Command
    reply: typing.Any

    def __new__(cls, *args, **kwargs):
        if cls is CommandCompleted:
            raise TypeError("CommandCompleted may not be instantiated directly.")
        assert is_dataclass(cls)
        return super().__new__(cls)


            

Reported by Pylint.

Unused argument 'args'
Error

Line: 68 Column: 1

                  command: commands.Command
    reply: typing.Any

    def __new__(cls, *args, **kwargs):
        if cls is CommandCompleted:
            raise TypeError("CommandCompleted may not be instantiated directly.")
        assert is_dataclass(cls)
        return super().__new__(cls)


            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 74 Column: 1

                      assert is_dataclass(cls)
        return super().__new__(cls)

    def __init_subclass__(cls, **kwargs):
        command_cls = cls.__annotations__.get("command", None)
        valid_command_subclass = (
                isinstance(command_cls, type)
                and issubclass(command_cls, commands.Command)
                and command_cls is not commands.Command

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 16 Column: 1

              from mitmproxy.connection import Connection


class Event:
    """
    Base class for all events.
    """

    def __repr__(self):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 25 Column: 1

                      return f"{type(self).__name__}({repr(self.__dict__)})"


class Start(Event):
    """
    Every layer initially receives a start event.
    This is useful to emit events on startup.
    """
    pass

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 53 Column: 1

                      return f"DataReceived({target}, {self.data})"


class ConnectionClosed(ConnectionEvent):
    """
    Remote has closed a connection.
    """
    pass


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 71
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  def __new__(cls, *args, **kwargs):
        if cls is CommandCompleted:
            raise TypeError("CommandCompleted may not be instantiated directly.")
        assert is_dataclass(cls)
        return super().__new__(cls)

    def __init_subclass__(cls, **kwargs):
        command_cls = cls.__annotations__.get("command", None)
        valid_command_subclass = (

            

Reported by Bandit.

test/mitmproxy/addons/test_mapremote.py
16 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from mitmproxy.addons import mapremote
from mitmproxy.test import taddons
from mitmproxy.test import tflow


class TestMapRemote:


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from mitmproxy.addons import mapremote
from mitmproxy.test import taddons
from mitmproxy.test import tflow


class TestMapRemote:


            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              from mitmproxy.test import tflow


class TestMapRemote:

    def test_configure(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(mr, map_remote=["one/two/three"])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              
class TestMapRemote:

    def test_configure(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(mr, map_remote=["one/two/three"])
            with pytest.raises(Exception, match="Invalid regular expression"):
                tctx.configure(mr, map_remote=["/foo/+/three"])

            

Reported by Pylint.

Method could be a function
Error

Line: 10 Column: 5

              
class TestMapRemote:

    def test_configure(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(mr, map_remote=["one/two/three"])
            with pytest.raises(Exception, match="Invalid regular expression"):
                tctx.configure(mr, map_remote=["/foo/+/three"])

            

Reported by Pylint.

Variable name "mr" doesn't conform to snake_case naming style
Error

Line: 11 Column: 9

              class TestMapRemote:

    def test_configure(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(mr, map_remote=["one/two/three"])
            with pytest.raises(Exception, match="Invalid regular expression"):
                tctx.configure(mr, map_remote=["/foo/+/three"])


            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

                          with pytest.raises(Exception, match="Invalid regular expression"):
                tctx.configure(mr, map_remote=["/foo/+/three"])

    def test_simple(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(
                mr,
                map_remote=[

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

                          with pytest.raises(Exception, match="Invalid regular expression"):
                tctx.configure(mr, map_remote=["/foo/+/three"])

    def test_simple(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(
                mr,
                map_remote=[

            

Reported by Pylint.

Variable name "mr" doesn't conform to snake_case naming style
Error

Line: 18 Column: 9

                              tctx.configure(mr, map_remote=["/foo/+/three"])

    def test_simple(self):
        mr = mapremote.MapRemote()
        with taddons.context(mr) as tctx:
            tctx.configure(
                mr,
                map_remote=[
                    ":example.org/images/:mitmproxy.org/img/",

            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 26 Column: 13

                                  ":example.org/images/:mitmproxy.org/img/",
                ]
            )
            f = tflow.tflow()
            f.request.url = b"https://example.org/images/test.jpg"
            mr.request(f)
            assert f.request.url == "https://mitmproxy.org/img/test.jpg"

    def test_has_reply(self):

            

Reported by Pylint.

test/mitmproxy/tools/console/test_integration.py
16 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import sys
from typing import List

import pytest

import mitmproxy.options
from mitmproxy import master
from mitmproxy.tools.console import window
from mitmproxy.tools.console.master import ConsoleMaster

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 13 Column: 14

              from mitmproxy.tools.console.master import ConsoleMaster


def tokenize(input: str) -> List[str]:
    keys = []
    for i, k in enumerate(re.split("[<>]", input)):
        if i % 2:
            keys.append(k)
        else:

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 24 Column: 20

              

class ConsoleTestMaster(ConsoleMaster):
    def type(self, input: str) -> None:
        for key in tokenize(input):
            self.window.keypress(self.ui.get_cols_rows(), key)


@pytest.fixture

            

Reported by Pylint.

Redefining name 'console' from outer scope (line 30)
Error

Line: 42 Column: 29

                  return m


def test_integration(tdata, console):
    console.type(f":view.flows.load {tdata.path('mitmproxy/data/dumpfile-7.mitm')}<enter>")
    console.type("<enter><tab><tab>")
    console.type("<space><tab><tab>")  # view second flow



            

Reported by Pylint.

Redefining name 'console' from outer scope (line 30)
Error

Line: 48 Column: 27

                  console.type("<space><tab><tab>")  # view second flow


def test_options_home_end(console):
    console.type("O<home><end>")


def test_keybindings_home_end(console):
    console.type("K<home><end>")
            

Reported by Pylint.

Redefining name 'console' from outer scope (line 30)
Error

Line: 52 Column: 31

                  console.type("O<home><end>")


def test_keybindings_home_end(console):
    console.type("K<home><end>")
            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re
import sys
from typing import List

import pytest

import mitmproxy.options
from mitmproxy import master
from mitmproxy.tools.console import window

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              from mitmproxy.tools.console.master import ConsoleMaster


def tokenize(input: str) -> List[str]:
    keys = []
    for i, k in enumerate(re.split("[<>]", input)):
        if i % 2:
            keys.append(k)
        else:

            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

                  return keys


class ConsoleTestMaster(ConsoleMaster):
    def type(self, input: str) -> None:
        for key in tokenize(input):
            self.window.keypress(self.ui.get_cols_rows(), key)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

              

class ConsoleTestMaster(ConsoleMaster):
    def type(self, input: str) -> None:
        for key in tokenize(input):
            self.window.keypress(self.ui.get_cols_rows(), key)


@pytest.fixture

            

Reported by Pylint.

examples/contrib/har_dump.py
16 issues
Unable to import 'mitmproxy'
Error

Line: 21 Column: 1

              from datetime import datetime
from datetime import timezone

import mitmproxy

from mitmproxy import connection
from mitmproxy import version
from mitmproxy import ctx
from mitmproxy.utils import strutils

            

Reported by Pylint.

Unable to import 'mitmproxy'
Error

Line: 23 Column: 1

              
import mitmproxy

from mitmproxy import connection
from mitmproxy import version
from mitmproxy import ctx
from mitmproxy.utils import strutils
from mitmproxy.net.http import cookies


            

Reported by Pylint.

Unable to import 'mitmproxy'
Error

Line: 24 Column: 1

              import mitmproxy

from mitmproxy import connection
from mitmproxy import version
from mitmproxy import ctx
from mitmproxy.utils import strutils
from mitmproxy.net.http import cookies

HAR: typing.Dict = {}

            

Reported by Pylint.

Unable to import 'mitmproxy'
Error

Line: 25 Column: 1

              
from mitmproxy import connection
from mitmproxy import version
from mitmproxy import ctx
from mitmproxy.utils import strutils
from mitmproxy.net.http import cookies

HAR: typing.Dict = {}


            

Reported by Pylint.

Unable to import 'mitmproxy.utils'
Error

Line: 26 Column: 1

              from mitmproxy import connection
from mitmproxy import version
from mitmproxy import ctx
from mitmproxy.utils import strutils
from mitmproxy.net.http import cookies

HAR: typing.Dict = {}

# A list of server seen till now is maintained so we can avoid

            

Reported by Pylint.

Unable to import 'mitmproxy.net.http'
Error

Line: 27 Column: 1

              from mitmproxy import version
from mitmproxy import ctx
from mitmproxy.utils import strutils
from mitmproxy.net.http import cookies

HAR: typing.Dict = {}

# A list of server seen till now is maintained so we can avoid
# using 'connect' time for entries that use an existing connection.

            

Reported by Pylint.

Unused argument 'updated'
Error

Line: 42 Column: 15

                  )


def configure(updated):
    HAR.update({
        "log": {
            "version": "1.2",
            "creator": {
                "name": "mitmproxy har_dump",

            

Reported by Pylint.

Argument name "l" doesn't conform to snake_case naming style
Error

Line: 36 Column: 1

              SERVERS_SEEN: typing.Set[connection.Server] = set()


def load(l):
    l.add_option(
        "hardump", str, "", "HAR dump path.",
    )



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 1

              SERVERS_SEEN: typing.Set[connection.Server] = set()


def load(l):
    l.add_option(
        "hardump", str, "", "HAR dump path.",
    )



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 1

                  )


def configure(updated):
    HAR.update({
        "log": {
            "version": "1.2",
            "creator": {
                "name": "mitmproxy har_dump",

            

Reported by Pylint.

mitmproxy/net/http/url.py
16 issues
FIXME: We shouldn't rely on urllib here.
Error

Line: 33 Column: 3

                      Raises:
            ValueError, if the URL is not properly formatted.
    """
    # FIXME: We shouldn't rely on urllib here.

    # Size of Ascii character after encoding is 1 byte which is same as its size
    # But non-Ascii character's size after encoding will be more than its size
    def ascii_check(l):
        if len(l) == len(str(l).encode()):

            

Reported by Pylint.

Redefining name 'check' from outer scope (line 7)
Error

Line: 155 Column: 40

                  }.get(scheme, None)


def parse_authority(authority: AnyStr, check: bool) -> Tuple[str, Optional[int]]:
    """Extract the host and port from host header/authority information

    Raises:
        ValueError, if check is True and the authority information is malformed.
    """

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re
import urllib.parse
from typing import AnyStr, Optional
from typing import Sequence
from typing import Tuple

from mitmproxy.net import check
# This regex extracts & splits the host header into host and port.
# Handles the edge case of IPv6 addresses containing colons.

            

Reported by Pylint.

Argument name "l" doesn't conform to snake_case naming style
Error

Line: 37 Column: 5

              
    # Size of Ascii character after encoding is 1 byte which is same as its size
    # But non-Ascii character's size after encoding will be more than its size
    def ascii_check(l):
        if len(l) == len(str(l).encode()):
            return True
        return False

    if isinstance(url, bytes):

            

Reported by Pylint.

Unnecessary "else" after "raise"
Error

Line: 51 Column: 5

                          url = urllib.parse.urlunsplit(url)

    parsed = urllib.parse.urlparse(url)
    if not parsed.hostname:
        raise ValueError("No hostname given")

    else:
        host = parsed.hostname.encode("idna")
        if isinstance(parsed, urllib.parse.ParseResult):

            

Reported by Pylint.

Argument name "s" doesn't conform to snake_case naming style
Error

Line: 88 Column: 1

                  return f"{scheme}://{authority}{path}"


def encode(s: Sequence[Tuple[str, str]], similar_to: str = None) -> str:
    """
        Takes a list of (key, value) tuples and returns a urlencoded string.
        If similar_to is passed, the output is formatted similar to the provided urlencoded string.
    """


            

Reported by Pylint.

Argument name "s" doesn't conform to snake_case naming style
Error

Line: 108 Column: 1

                  return encoded


def decode(s):
    """
        Takes a urlencoded string and returns a list of surrogate-escaped (key, value) tuples.
    """
    return urllib.parse.parse_qsl(s, keep_blank_values=True, errors='surrogateescape')


            

Reported by Pylint.

Argument name "b" doesn't conform to snake_case naming style
Error

Line: 115 Column: 1

                  return urllib.parse.parse_qsl(s, keep_blank_values=True, errors='surrogateescape')


def quote(b: str, safe: str = "/") -> str:
    """
    Returns:
        An ascii-encodable str.
    """
    return urllib.parse.quote(b, safe=safe, errors="surrogateescape")

            

Reported by Pylint.

Argument name "s" doesn't conform to snake_case naming style
Error

Line: 123 Column: 1

                  return urllib.parse.quote(b, safe=safe, errors="surrogateescape")


def unquote(s: str) -> str:
    """
    Args:
        s: A surrogate-escaped str
    Returns:
        A surrogate-escaped str

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 137 Column: 5

                  """
        Returns the host component, with a port specification if needed.
    """
    if default_port(scheme) == port:
        return host
    else:
        if isinstance(host, bytes):
            return b"%s:%d" % (host, port)
        else:

            

Reported by Pylint.

test/mitmproxy/addons/test_upstream_auth.py
16 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import base64
import pytest

from mitmproxy import exceptions
from mitmproxy.test import taddons
from mitmproxy.test import tflow
from mitmproxy.addons import upstream_auth



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import base64
import pytest

from mitmproxy import exceptions
from mitmproxy.test import taddons
from mitmproxy.test import tflow
from mitmproxy.addons import upstream_auth



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              from mitmproxy.addons import upstream_auth


def test_configure():
    up = upstream_auth.UpstreamAuth()
    with taddons.context(up) as tctx:
        tctx.configure(up, upstream_auth="test:test")
        assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:test")


            

Reported by Pylint.

Variable name "up" doesn't conform to snake_case naming style
Error

Line: 11 Column: 5

              

def test_configure():
    up = upstream_auth.UpstreamAuth()
    with taddons.context(up) as tctx:
        tctx.configure(up, upstream_auth="test:test")
        assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:test")

        tctx.configure(up, upstream_auth="test:")

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 14
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  up = upstream_auth.UpstreamAuth()
    with taddons.context(up) as tctx:
        tctx.configure(up, upstream_auth="test:test")
        assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:test")

        tctx.configure(up, upstream_auth="test:")
        assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:")

        tctx.configure(up, upstream_auth=None)

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 17
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:test")

        tctx.configure(up, upstream_auth="test:")
        assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:")

        tctx.configure(up, upstream_auth=None)
        assert not up.auth

        with pytest.raises(exceptions.OptionsError):

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:")

        tctx.configure(up, upstream_auth=None)
        assert not up.auth

        with pytest.raises(exceptions.OptionsError):
            tctx.configure(up, upstream_auth="")
        with pytest.raises(exceptions.OptionsError):
            tctx.configure(up, upstream_auth=":")

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 30 Column: 1

                          tctx.configure(up, upstream_auth=":test")


def test_simple():
    up = upstream_auth.UpstreamAuth()
    with taddons.context(up) as tctx:
        tctx.configure(up, upstream_auth="foo:bar")

        f = tflow.tflow()

            

Reported by Pylint.

Variable name "up" doesn't conform to snake_case naming style
Error

Line: 31 Column: 5

              

def test_simple():
    up = upstream_auth.UpstreamAuth()
    with taddons.context(up) as tctx:
        tctx.configure(up, upstream_auth="foo:bar")

        f = tflow.tflow()
        up.http_connect_upstream(f)

            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 35 Column: 9

                  with taddons.context(up) as tctx:
        tctx.configure(up, upstream_auth="foo:bar")

        f = tflow.tflow()
        up.http_connect_upstream(f)
        assert "proxy-authorization" in f.request.headers

        f = tflow.tflow()
        up.requestheaders(f)

            

Reported by Pylint.

examples/contrib/block_dns_over_https.py
16 issues
Unable to import 'mitmproxy'
Error

Line: 9 Column: 1

              """
from typing import List

from mitmproxy import ctx

# known DoH providers' hostnames and IP addresses to block
default_blocklist: dict = {
    "hostnames": [
        "dns.adguard.com", "dns-family.adguard.com", "dns.google", "cloudflare-dns.com",

            

Reported by Pylint.

Implicit string concatenation found in list
Error

Line: 59 Column: 1

                      "2606:4700:3033::6812:2dcc", "2606:4700:3033::6818:7b35", "2606:4700:3034::681c:16a",
        "2606:4700:3035::6818:7a35", "2606:4700:3035::681f:5a8a", "2606:4700:3036::681c:6a",
        "2606:4700:3036::681f:5b8a", "2606:4700:60:0:a71e:6467:cef8:2a56", "2620:10a:80bb::10",
        "2620:10a:80bb::20", "2620:10a:80bb::30" "2620:10a:80bc::10", "2620:10a:80bc::20",
        "2620:10a:80bc::30", "2620:119:fc::2", "2620:119:fc::3", "2620:fe::10", "2620:fe::11",
        "2620:fe::9", "2620:fe::fe:10", "2620:fe::fe:11", "2620:fe::fe:9", "2620:fe::fe",
        "2a00:5a60::ad1:ff", "2a00:5a60::ad2:ff", "2a00:5a60::bad1:ff", "2a00:5a60::bad2:ff",
        "2a00:d880:5:bf0::7c93", "2a01:4f8:1c0c:8233::1", "2a01:4f8:1c1c:6b4b::1", "2a01:4f8:c2c:52bf::1",
        "2a01:4f9:c010:43ce::1", "2a01:4f9:c01f:4::abcd", "2a01:7c8:d002:1ef:5054:ff:fe40:3703",

            

Reported by Pylint.

Line too long (104/100)
Error

Line: 17 Column: 1

                      "dns.adguard.com", "dns-family.adguard.com", "dns.google", "cloudflare-dns.com",
        "mozilla.cloudflare-dns.com", "security.cloudflare-dns.com", "family.cloudflare-dns.com",
        "dns.quad9.net", "dns9.quad9.net", "dns10.quad9.net", "dns11.quad9.net", "doh.opendns.com",
        "doh.familyshield.opendns.com", "doh.cleanbrowsing.org", "doh.xfinity.com", "dohdot.coxlab.net",
        "odvr.nic.cz", "doh.dnslify.com", "dns.nextdns.io", "dns.dnsoverhttps.net", "doh.crypto.sx",
        "doh.powerdns.org", "doh-fi.blahdns.com", "doh-jp.blahdns.com", "doh-de.blahdns.com",
        "doh.ffmuc.net", "dns.dns-over-https.com", "doh.securedns.eu", "dns.rubyfish.cn",
        "dns.containerpi.com", "dns.containerpi.com", "dns.containerpi.com", "doh-2.seby.io",
        "doh.seby.io", "commons.host", "doh.dnswarden.com", "doh.dnswarden.com", "doh.dnswarden.com",

            

Reported by Pylint.

Line too long (101/100)
Error

Line: 22 Column: 1

                      "doh.powerdns.org", "doh-fi.blahdns.com", "doh-jp.blahdns.com", "doh-de.blahdns.com",
        "doh.ffmuc.net", "dns.dns-over-https.com", "doh.securedns.eu", "dns.rubyfish.cn",
        "dns.containerpi.com", "dns.containerpi.com", "dns.containerpi.com", "doh-2.seby.io",
        "doh.seby.io", "commons.host", "doh.dnswarden.com", "doh.dnswarden.com", "doh.dnswarden.com",
        "dns-nyc.aaflalo.me", "dns.aaflalo.me", "doh.applied-privacy.net", "doh.captnemo.in",
        "doh.tiar.app", "doh.tiarap.org", "doh.dns.sb", "rdns.faelix.net", "doh.li", "doh.armadillodns.net",
        "jp.tiar.app", "jp.tiarap.org", "doh.42l.fr", "dns.hostux.net", "dns.hostux.net", "dns.aa.net.uk",
        "adblock.mydns.network", "ibksturm.synology.me", "jcdns.fun", "ibuki.cgnat.net", "dns.twnic.tw",
        "example.doh.blockerdns.com", "dns.digitale-gesellschaft.ch", "doh.libredns.gr",

            

Reported by Pylint.

Line too long (108/100)
Error

Line: 24 Column: 1

                      "dns.containerpi.com", "dns.containerpi.com", "dns.containerpi.com", "doh-2.seby.io",
        "doh.seby.io", "commons.host", "doh.dnswarden.com", "doh.dnswarden.com", "doh.dnswarden.com",
        "dns-nyc.aaflalo.me", "dns.aaflalo.me", "doh.applied-privacy.net", "doh.captnemo.in",
        "doh.tiar.app", "doh.tiarap.org", "doh.dns.sb", "rdns.faelix.net", "doh.li", "doh.armadillodns.net",
        "jp.tiar.app", "jp.tiarap.org", "doh.42l.fr", "dns.hostux.net", "dns.hostux.net", "dns.aa.net.uk",
        "adblock.mydns.network", "ibksturm.synology.me", "jcdns.fun", "ibuki.cgnat.net", "dns.twnic.tw",
        "example.doh.blockerdns.com", "dns.digitale-gesellschaft.ch", "doh.libredns.gr",
        "doh.centraleu.pi-dns.com", "doh.northeu.pi-dns.com", "doh.westus.pi-dns.com",
        "doh.eastus.pi-dns.com", "dns.flatuslifir.is", "private.canadianshield.cira.ca",

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 25 Column: 1

                      "doh.seby.io", "commons.host", "doh.dnswarden.com", "doh.dnswarden.com", "doh.dnswarden.com",
        "dns-nyc.aaflalo.me", "dns.aaflalo.me", "doh.applied-privacy.net", "doh.captnemo.in",
        "doh.tiar.app", "doh.tiarap.org", "doh.dns.sb", "rdns.faelix.net", "doh.li", "doh.armadillodns.net",
        "jp.tiar.app", "jp.tiarap.org", "doh.42l.fr", "dns.hostux.net", "dns.hostux.net", "dns.aa.net.uk",
        "adblock.mydns.network", "ibksturm.synology.me", "jcdns.fun", "ibuki.cgnat.net", "dns.twnic.tw",
        "example.doh.blockerdns.com", "dns.digitale-gesellschaft.ch", "doh.libredns.gr",
        "doh.centraleu.pi-dns.com", "doh.northeu.pi-dns.com", "doh.westus.pi-dns.com",
        "doh.eastus.pi-dns.com", "dns.flatuslifir.is", "private.canadianshield.cira.ca",
        "protected.canadianshield.cira.ca", "family.canadianshield.cira.ca", "dns.google.com",

            

Reported by Pylint.

Line too long (104/100)
Error

Line: 26 Column: 1

                      "dns-nyc.aaflalo.me", "dns.aaflalo.me", "doh.applied-privacy.net", "doh.captnemo.in",
        "doh.tiar.app", "doh.tiarap.org", "doh.dns.sb", "rdns.faelix.net", "doh.li", "doh.armadillodns.net",
        "jp.tiar.app", "jp.tiarap.org", "doh.42l.fr", "dns.hostux.net", "dns.hostux.net", "dns.aa.net.uk",
        "adblock.mydns.network", "ibksturm.synology.me", "jcdns.fun", "ibuki.cgnat.net", "dns.twnic.tw",
        "example.doh.blockerdns.com", "dns.digitale-gesellschaft.ch", "doh.libredns.gr",
        "doh.centraleu.pi-dns.com", "doh.northeu.pi-dns.com", "doh.westus.pi-dns.com",
        "doh.eastus.pi-dns.com", "dns.flatuslifir.is", "private.canadianshield.cira.ca",
        "protected.canadianshield.cira.ca", "family.canadianshield.cira.ca", "dns.google.com",
        "dns.google.com"

            

Reported by Pylint.

Line too long (101/100)
Error

Line: 43 Column: 1

                      "149.112.112.11", "149.112.112.112", "149.112.112.9", "149.112.121.10", "149.112.121.20",
        "149.112.121.30", "149.112.122.10", "149.112.122.20", "149.112.122.30", "159.69.198.101",
        "168.235.81.167", "172.104.93.80", "172.65.3.223", "174.138.29.175", "174.68.248.77",
        "176.103.130.130", "176.103.130.131", "176.103.130.132", "176.103.130.134", "176.56.236.175",
        "178.62.214.105", "185.134.196.54", "185.134.197.54", "185.213.26.187", "185.216.27.142",
        "185.228.168.10", "185.228.168.168", "185.235.81.1", "185.26.126.37", "185.26.126.37",
        "185.43.135.1", "185.95.218.42", "185.95.218.43", "195.30.94.28", "2001:148f:fffe::1",
        "2001:19f0:7001:3259:5400:2ff:fe71:bc9", "2001:19f0:7001:5554:5400:2ff:fe57:3077",
        "2001:19f0:7001:5554:5400:2ff:fe57:3077", "2001:19f0:7001:5554:5400:2ff:fe57:3077",

            

Reported by Pylint.

Line too long (101/100)
Error

Line: 51 Column: 1

                      "2001:19f0:7001:5554:5400:2ff:fe57:3077", "2001:19f0:7001:5554:5400:2ff:fe57:3077",
        "2001:4860:4860::8844", "2001:4860:4860::8888",
        "2001:4b98:dc2:43:216:3eff:fe86:1d28", "2001:558:fe21:6b:96:113:151:149",
        "2001:608:a01::3", "2001:678:888:69:c45d:2738:c3f2:1878", "2001:8b0::2022", "2001:8b0::2023",
        "2001:c50:ffff:1:101:101:101:101", "210.17.9.228", "217.169.20.22", "217.169.20.23",
        "2400:6180:0:d0::5f73:4001", "2400:8902::f03c:91ff:feda:c514", "2604:180:f3::42",
        "2604:a880:1:20::51:f001", "2606:4700::6810:f8f9", "2606:4700::6810:f9f9", "2606:4700::6812:1a80",
        "2606:4700::6812:1b80", "2606:4700::6812:237", "2606:4700::6812:337", "2606:4700:3033::6812:2ccc",
        "2606:4700:3033::6812:2dcc", "2606:4700:3033::6818:7b35", "2606:4700:3034::681c:16a",

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 54 Column: 1

                      "2001:608:a01::3", "2001:678:888:69:c45d:2738:c3f2:1878", "2001:8b0::2022", "2001:8b0::2023",
        "2001:c50:ffff:1:101:101:101:101", "210.17.9.228", "217.169.20.22", "217.169.20.23",
        "2400:6180:0:d0::5f73:4001", "2400:8902::f03c:91ff:feda:c514", "2604:180:f3::42",
        "2604:a880:1:20::51:f001", "2606:4700::6810:f8f9", "2606:4700::6810:f9f9", "2606:4700::6812:1a80",
        "2606:4700::6812:1b80", "2606:4700::6812:237", "2606:4700::6812:337", "2606:4700:3033::6812:2ccc",
        "2606:4700:3033::6812:2dcc", "2606:4700:3033::6818:7b35", "2606:4700:3034::681c:16a",
        "2606:4700:3035::6818:7a35", "2606:4700:3035::681f:5a8a", "2606:4700:3036::681c:6a",
        "2606:4700:3036::681f:5b8a", "2606:4700:60:0:a71e:6467:cef8:2a56", "2620:10a:80bb::10",
        "2620:10a:80bb::20", "2620:10a:80bb::30" "2620:10a:80bc::10", "2620:10a:80bc::20",

            

Reported by Pylint.

mitmproxy/flow.py
16 issues
No value for argument 'server_conn' in constructor call
Error

Line: 157 Column: 13

              
    @classmethod
    def from_state(cls, state):
        f = cls(None, None)
        f.set_state(state)
        return f

    def copy(self):
        """Make a copy of this flow."""

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 109 Column: 9

              
    def __init__(
        self,
        type: str,
        client_conn: connection.Client,
        server_conn: connection.Server,
        live: bool = None
    ) -> None:
        self.type = type

            

Reported by Pylint.

Unused argument 'force'
Error

Line: 178 Column: 22

                      else:
            return False

    def backup(self, force=False):
        """
        Save a backup of this flow, which can be restored by calling `Flow.revert()`.
        """
        if not self._backup:
            self._backup = self.get_state()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import time
import typing  # noqa
import uuid

from mitmproxy import controller, connection
from mitmproxy import exceptions
from mitmproxy import stateobject
from mitmproxy import version


            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 49 Column: 9

                  def from_state(cls, state):
        # the default implementation assumes an empty constructor. Override
        # accordingly.
        f = cls(None)
        f.set_state(state)
        return f


class Flow(stateobject.StateObject):

            

Reported by Pylint.

Too many instance attributes (13/7)
Error

Line: 54 Column: 1

                      return f


class Flow(stateobject.StateObject):
    """
    Base class for network flows. A flow is a collection of objects,
    for example HTTP request/response pairs or a list of TCP messages.

    See also:

            

Reported by Pylint.

Line too long (115/100)
Error

Line: 89 Column: 1

                  """
    If this attribute is a non-empty string the flow has been marked by the user.

    A string value will be used as the marker annotation. May either be a single character or a Unicode emoji name.

    For example `:grapes:` becomes `🍇` in views that support emoji rendering.
    Consult the [Github API Emoji List](https://api.github.com/emojis) for a list of emoji that may be used.
    Not all emoji, especially [emoji modifiers](https://en.wikipedia.org/wiki/Miscellaneous_Symbols_and_Pictographs#Emoji_modifiers)
    will render consistently.

            

Reported by Pylint.

Line too long (108/100)
Error

Line: 92 Column: 1

                  A string value will be used as the marker annotation. May either be a single character or a Unicode emoji name.

    For example `:grapes:` becomes `🍇` in views that support emoji rendering.
    Consult the [Github API Emoji List](https://api.github.com/emojis) for a list of emoji that may be used.
    Not all emoji, especially [emoji modifiers](https://en.wikipedia.org/wiki/Miscellaneous_Symbols_and_Pictographs#Emoji_modifiers)
    will render consistently.

    The default marker for the view will be used if the Unicode emoji name can not be interpreted.
    """

            

Reported by Pylint.

Line too long (132/100)
Error

Line: 93 Column: 1

              
    For example `:grapes:` becomes `🍇` in views that support emoji rendering.
    Consult the [Github API Emoji List](https://api.github.com/emojis) for a list of emoji that may be used.
    Not all emoji, especially [emoji modifiers](https://en.wikipedia.org/wiki/Miscellaneous_Symbols_and_Pictographs#Emoji_modifiers)
    will render consistently.

    The default marker for the view will be used if the Unicode emoji name can not be interpreted.
    """


            

Reported by Pylint.

Line too long (112/100)
Error

Line: 103 Column: 1

                  """
    This attribute indicates if this flow has been replayed in either direction.

     - a value of `request` indicates that the request has been artifically replayed by mitmproxy to the server.
     - a value of `response` indicates that the response to the client's request has been set by server replay.
    """

    def __init__(
        self,

            

Reported by Pylint.

test/mitmproxy/script/test_concurrent.py
16 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import time

import pytest

from mitmproxy import controller

from mitmproxy.test import tflow
from mitmproxy.test import taddons


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import time

import pytest

from mitmproxy import controller

from mitmproxy.test import tflow
from mitmproxy.test import taddons


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from mitmproxy.test import taddons


class Thing:
    def __init__(self):
        self.reply = controller.DummyReply()
        self.live = True



            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 11 Column: 1

              from mitmproxy.test import taddons


class Thing:
    def __init__(self):
        self.reply = controller.DummyReply()
        self.live = True



            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

                      self.live = True


class TestConcurrent:
    def test_concurrent(self, tdata):
        with taddons.context() as tctx:
            sc = tctx.script(
                tdata.path(
                    "mitmproxy/data/addonscripts/concurrent_decorator.py"

            

Reported by Pylint.

Method could be a function
Error

Line: 18 Column: 5

              

class TestConcurrent:
    def test_concurrent(self, tdata):
        with taddons.context() as tctx:
            sc = tctx.script(
                tdata.path(
                    "mitmproxy/data/addonscripts/concurrent_decorator.py"
                )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

              

class TestConcurrent:
    def test_concurrent(self, tdata):
        with taddons.context() as tctx:
            sc = tctx.script(
                tdata.path(
                    "mitmproxy/data/addonscripts/concurrent_decorator.py"
                )

            

Reported by Pylint.

Variable name "sc" doesn't conform to snake_case naming style
Error

Line: 20 Column: 13

              class TestConcurrent:
    def test_concurrent(self, tdata):
        with taddons.context() as tctx:
            sc = tctx.script(
                tdata.path(
                    "mitmproxy/data/addonscripts/concurrent_decorator.py"
                )
            )
            f1, f2 = tflow.tflow(), tflow.tflow()

            

Reported by Pylint.

Variable name "f2" doesn't conform to snake_case naming style
Error

Line: 25 Column: 17

                                  "mitmproxy/data/addonscripts/concurrent_decorator.py"
                )
            )
            f1, f2 = tflow.tflow(), tflow.tflow()
            tctx.cycle(sc, f1)
            tctx.cycle(sc, f2)
            start = time.time()
            while time.time() - start < 5:
                if f1.reply.state == f2.reply.state == "committed":

            

Reported by Pylint.

Variable name "f1" doesn't conform to snake_case naming style
Error

Line: 25 Column: 13

                                  "mitmproxy/data/addonscripts/concurrent_decorator.py"
                )
            )
            f1, f2 = tflow.tflow(), tflow.tflow()
            tctx.cycle(sc, f1)
            tctx.cycle(sc, f2)
            start = time.time()
            while time.time() - start < 5:
                if f1.reply.state == f2.reply.state == "committed":

            

Reported by Pylint.

mitmproxy/contentviews/protobuf.py
15 issues
Unable to import 'kaitaistruct'
Error

Line: 4 Column: 1

              import io
from typing import Optional

from kaitaistruct import KaitaiStream
from . import base
from mitmproxy.contrib.kaitaistruct import google_protobuf


def write_buf(out, field_tag, body, indent_level):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              from typing import Optional

from kaitaistruct import KaitaiStream
from . import base
from mitmproxy.contrib.kaitaistruct import google_protobuf


def write_buf(out, field_tag, body, indent_level):
    if body is not None:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 25 Column: 5

              
    try:
        buf = google_protobuf.GoogleProtobuf(KaitaiStream(io.BytesIO(raw)))
    except:
        return False
    stack.extend([(pair, 0) for pair in buf.pairs[::-1]])

    while len(stack):
        pair, indent_level = stack.pop()

            

Reported by Pylint.

Access to a protected member _m_field_tag of a client class
Error

Line: 36 Column: 13

                          body = None
        elif pair.wire_type == pair.WireTypes.group_end:
            body = None
            pair._m_field_tag = None
        elif pair.wire_type == pair.WireTypes.len_delimited:
            body = pair.value.body
        elif pair.wire_type == pair.WireTypes.varint:
            body = pair.value.value
        else:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 48 Column: 9

                          next_buf = google_protobuf.GoogleProtobuf(KaitaiStream(io.BytesIO(body)))
            stack.extend([(pair, indent_level + 2) for pair in next_buf.pairs[::-1]])
            write_buf(out, pair.field_tag, None, indent_level)
        except:
            write_buf(out, pair.field_tag, body, indent_level)

        if stack:
            prev_level = stack[-1][1]
        else:

            

Reported by Pylint.

Unused argument 'data'
Error

Line: 82 Column: 31

              
        return "Protobuf", base.format_text(decoded)

    def render_priority(self, data: bytes, *, content_type: Optional[str] = None, **metadata) -> float:
        return float(content_type in self.__content_types)

            

Reported by Pylint.

Unused argument 'metadata'
Error

Line: 82 Column: 1

              
        return "Protobuf", base.format_text(decoded)

    def render_priority(self, data: bytes, *, content_type: Optional[str] = None, **metadata) -> float:
        return float(content_type in self.__content_types)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import io
from typing import Optional

from kaitaistruct import KaitaiStream
from . import base
from mitmproxy.contrib.kaitaistruct import google_protobuf


def write_buf(out, field_tag, body, indent_level):

            

Reported by Pylint.

third party import "from mitmproxy.contrib.kaitaistruct import google_protobuf" should be placed before "from . import base"
Error

Line: 6 Column: 1

              
from kaitaistruct import KaitaiStream
from . import base
from mitmproxy.contrib.kaitaistruct import google_protobuf


def write_buf(out, field_tag, body, indent_level):
    if body is not None:
        out.write("{: <{level}}{}: {}\n".format('', field_tag, body if isinstance(body, int) else str(body, 'utf-8'),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              from mitmproxy.contrib.kaitaistruct import google_protobuf


def write_buf(out, field_tag, body, indent_level):
    if body is not None:
        out.write("{: <{level}}{}: {}\n".format('', field_tag, body if isinstance(body, int) else str(body, 'utf-8'),
                                                level=indent_level))
    elif field_tag is not None:
        out.write(' ' * indent_level + str(field_tag) + " {\n")

            

Reported by Pylint.