The following issues were found

test/mitmproxy/proxy/test_utils.py
15 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from mitmproxy.proxy.utils import expect


def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from mitmproxy.proxy.utils import expect


def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              from mitmproxy.proxy.utils import expect


def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):
            return "".join(reversed(x))


            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 5

              

def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):
            return "".join(reversed(x))

        @expect(str)

            

Reported by Pylint.

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

Line: 9 Column: 9

              def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):
            return "".join(reversed(x))

        @expect(str)
        def bar(self, x):
            yield "".join(reversed(x))

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 9 Column: 9

              def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):
            return "".join(reversed(x))

        @expect(str)
        def bar(self, x):
            yield "".join(reversed(x))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 9

              def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):
            return "".join(reversed(x))

        @expect(str)
        def bar(self, x):
            yield "".join(reversed(x))

            

Reported by Pylint.

Method could be a function
Error

Line: 9 Column: 9

              def test_expect():
    class Foo:
        @expect(str, int)
        def foo(self, x):
            return "".join(reversed(x))

        @expect(str)
        def bar(self, x):
            yield "".join(reversed(x))

            

Reported by Pylint.

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

Line: 13 Column: 9

                          return "".join(reversed(x))

        @expect(str)
        def bar(self, x):
            yield "".join(reversed(x))

    f = Foo()

    assert f.foo("foo") == "oof"

            

Reported by Pylint.

Black listed name "bar"
Error

Line: 13 Column: 9

                          return "".join(reversed(x))

        @expect(str)
        def bar(self, x):
            yield "".join(reversed(x))

    f = Foo()

    assert f.foo("foo") == "oof"

            

Reported by Pylint.

examples/addons/contentview.py
15 issues
Unable to import 'mitmproxy'
Error

Line: 10 Column: 1

              """
from typing import Optional

from mitmproxy import contentviews, flow
from mitmproxy import http


class ViewSwapCase(contentviews.View):
    name = "swapcase"

            

Reported by Pylint.

Unable to import 'mitmproxy'
Error

Line: 11 Column: 1

              from typing import Optional

from mitmproxy import contentviews, flow
from mitmproxy import http


class ViewSwapCase(contentviews.View):
    name = "swapcase"


            

Reported by Pylint.

Unused argument 'unknown_metadata'
Error

Line: 21 Column: 1

                      return "case-swapped text", contentviews.format_text(data.swapcase())

    def render_priority(
        self,
        data: bytes,
        *,
        content_type: Optional[str] = None,
        flow: Optional[flow.Flow] = None,
        http_message: Optional[http.Message] = None,

            

Reported by Pylint.

Unused argument 'data'
Error

Line: 22 Column: 9

              
    def render_priority(
        self,
        data: bytes,
        *,
        content_type: Optional[str] = None,
        flow: Optional[flow.Flow] = None,
        http_message: Optional[http.Message] = None,
        **unknown_metadata,

            

Reported by Pylint.

Unused argument 'flow'
Error

Line: 25 Column: 9

                      data: bytes,
        *,
        content_type: Optional[str] = None,
        flow: Optional[flow.Flow] = None,
        http_message: Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        if content_type == "text/plain":
            return 1

            

Reported by Pylint.

Redefining name 'flow' from outer scope (line 10)
Error

Line: 25 Column: 9

                      data: bytes,
        *,
        content_type: Optional[str] = None,
        flow: Optional[flow.Flow] = None,
        http_message: Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        if content_type == "text/plain":
            return 1

            

Reported by Pylint.

Unused argument 'http_message'
Error

Line: 26 Column: 9

                      *,
        content_type: Optional[str] = None,
        flow: Optional[flow.Flow] = None,
        http_message: Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        if content_type == "text/plain":
            return 1
        else:

            

Reported by Pylint.

Unused argument 'l'
Error

Line: 38 Column: 10

              view = ViewSwapCase()


def load(l):
    contentviews.add(view)


def done():
    contentviews.remove(view)

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              from mitmproxy import http


class ViewSwapCase(contentviews.View):
    name = "swapcase"

    def __call__(self, data, **metadata) -> contentviews.TViewResult:
        return "case-swapped text", contentviews.format_text(data.swapcase())


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

                  def __call__(self, data, **metadata) -> contentviews.TViewResult:
        return "case-swapped text", contentviews.format_text(data.swapcase())

    def render_priority(
        self,
        data: bytes,
        *,
        content_type: Optional[str] = None,
        flow: Optional[flow.Flow] = None,

            

Reported by Pylint.

test/mitmproxy/net/http/test_multipart.py
15 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from mitmproxy.http import Headers
from mitmproxy.net.http import multipart


def test_decode():
    boundary = 'somefancyboundary'
    content = (

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from mitmproxy.http import Headers
from mitmproxy.net.http import multipart


def test_decode():
    boundary = 'somefancyboundary'
    content = (

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              from mitmproxy.net.http import multipart


def test_decode():
    boundary = 'somefancyboundary'
    content = (
        "--{0}\n"
        "Content-Disposition: form-data; name=\"field1\"\n\n"
        "value1\n"

            

Reported by Pylint.

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

                  )
    form = multipart.decode(f'multipart/form-data; boundary={boundary}', content)

    assert len(form) == 2
    assert form[0] == (b"field1", b"value1")
    assert form[1] == (b"field2", b"value2")

    boundary = 'boundary茅莽'
    result = multipart.decode(f'multipart/form-data; boundary={boundary}', content)

            

Reported by Bandit.

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

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

                  form = multipart.decode(f'multipart/form-data; boundary={boundary}', content)

    assert len(form) == 2
    assert form[0] == (b"field1", b"value1")
    assert form[1] == (b"field2", b"value2")

    boundary = 'boundary茅莽'
    result = multipart.decode(f'multipart/form-data; boundary={boundary}', content)
    assert result == []

            

Reported by Bandit.

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

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

              
    assert len(form) == 2
    assert form[0] == (b"field1", b"value1")
    assert form[1] == (b"field2", b"value2")

    boundary = 'boundary茅莽'
    result = multipart.decode(f'multipart/form-data; boundary={boundary}', content)
    assert result == []


            

Reported by Bandit.

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

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

              
    boundary = 'boundary茅莽'
    result = multipart.decode(f'multipart/form-data; boundary={boundary}', content)
    assert result == []

    assert multipart.decode("", content) == []


def test_encode():

            

Reported by Bandit.

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

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

                  result = multipart.decode(f'multipart/form-data; boundary={boundary}', content)
    assert result == []

    assert multipart.decode("", content) == []


def test_encode():
    data = [(b"file", b"shell.jpg"),
            (b"file_size", b"1000")]

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 31 Column: 1

                  assert multipart.decode("", content) == []


def test_encode():
    data = [(b"file", b"shell.jpg"),
            (b"file_size", b"1000")]
    headers = Headers(
        content_type='multipart/form-data; boundary=127824672498'
    )

            

Reported by Pylint.

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

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

                  )
    content = multipart.encode(headers, data)

    assert b'Content-Disposition: form-data; name="file"' in content
    assert b'Content-Type: text/plain; charset=utf-8\r\n\r\nshell.jpg\r\n\r\n--127824672498\r\n' in content
    assert b'1000\r\n\r\n--127824672498--\r\n'
    assert len(content) == 252

    with pytest.raises(ValueError, match=r"boundary found in encoded string"):

            

Reported by Bandit.

mitmproxy/contentviews/base.py
15 issues
FIXME: This should be either bytes or str ultimately.
Error

Line: 10 Column: 3

              
KEY_MAX = 30

TTextType = typing.Union[str, bytes]  # FIXME: This should be either bytes or str ultimately.
TViewLine = typing.List[typing.Tuple[str, TTextType]]
TViewResult = typing.Tuple[str, typing.Iterator[TViewLine]]


class View(ABC):

            

Reported by Pylint.

Redefining name 'flow' from outer scope (line 5)
Error

Line: 24 Column: 9

                      data: bytes,
        *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,
        **unknown_metadata,
    ) -> TViewResult:
        """
        Transform raw data into human-readable output.

            

Reported by Pylint.

Unused argument 'unknown_metadata'
Error

Line: 46 Column: 1

                      raise NotImplementedError()  # pragma: no cover

    def render_priority(
        self,
        data: bytes,
        *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,

            

Reported by Pylint.

Unused argument 'data'
Error

Line: 47 Column: 9

              
    def render_priority(
        self,
        data: bytes,
        *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,
        **unknown_metadata,

            

Reported by Pylint.

Unused argument 'content_type'
Error

Line: 49 Column: 9

                      self,
        data: bytes,
        *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        """

            

Reported by Pylint.

Redefining name 'flow' from outer scope (line 5)
Error

Line: 50 Column: 9

                      data: bytes,
        *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        """
        Return the priority of this view for rendering `data`.

            

Reported by Pylint.

Unused argument 'flow'
Error

Line: 50 Column: 9

                      data: bytes,
        *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        """
        Return the priority of this view for rendering `data`.

            

Reported by Pylint.

Unused argument 'http_message'
Error

Line: 51 Column: 9

                      *,
        content_type: typing.Optional[str] = None,
        flow: typing.Optional[flow.Flow] = None,
        http_message: typing.Optional[http.Message] = None,
        **unknown_metadata,
    ) -> float:
        """
        Return the priority of this view for rendering `data`.
        If no particular view is chosen by the user, the view with the highest priority is selected.

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Default view cutoff *in lines*
import typing
from abc import ABC, abstractmethod

from mitmproxy import flow
from mitmproxy import http

KEY_MAX = 30


            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              TViewResult = typing.Tuple[str, typing.Iterator[TViewLine]]


class View(ABC):
    name: typing.ClassVar[str]

    @abstractmethod
    def __call__(
        self,

            

Reported by Pylint.

test/mitmproxy/addons/test_keepserving.py
15 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import asyncio
import pytest

from mitmproxy.addons import keepserving
from mitmproxy.test import taddons
from mitmproxy import command


class Dummy:

            

Reported by Pylint.

Attribute 'is_shutdown' defined outside __init__
Error

Line: 35 Column: 9

                  _is_shutdown = False

    def shutdown(self):
        self.is_shutdown = True


@pytest.mark.asyncio
async def test_keepserving():
    ks = TKS()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import asyncio
import pytest

from mitmproxy.addons import keepserving
from mitmproxy.test import taddons
from mitmproxy import command


class Dummy:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from mitmproxy import command


class Dummy:
    def __init__(self, val: bool):
        self.val = val

    def load(self, loader):
        loader.add_option("client_replay", bool, self.val, "test")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

                  def __init__(self, val: bool):
        self.val = val

    def load(self, loader):
        loader.add_option("client_replay", bool, self.val, "test")
        loader.add_option("server_replay", bool, self.val, "test")
        loader.add_option("rfile", bool, self.val, "test")

    @command.command("readfile.reading")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                      loader.add_option("rfile", bool, self.val, "test")

    @command.command("readfile.reading")
    def readfile(self) -> bool:
        return self.val

    @command.command("replay.client.count")
    def creplay(self) -> int:
        return 1 if self.val else 0

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                      return self.val

    @command.command("replay.client.count")
    def creplay(self) -> int:
        return 1 if self.val else 0

    @command.command("replay.server.count")
    def sreplay(self) -> int:
        return 1 if self.val else 0

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                      return 1 if self.val else 0

    @command.command("replay.server.count")
    def sreplay(self) -> int:
        return 1 if self.val else 0


class TKS(keepserving.KeepServing):
    _is_shutdown = False

            

Reported by Pylint.

Missing class docstring
Error

Line: 31 Column: 1

                      return 1 if self.val else 0


class TKS(keepserving.KeepServing):
    _is_shutdown = False

    def shutdown(self):
        self.is_shutdown = True


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 1

              

@pytest.mark.asyncio
async def test_keepserving():
    ks = TKS()
    d = Dummy(True)
    with taddons.context(ks) as tctx:
        tctx.master.addons.add(d)
        ks.running()

            

Reported by Pylint.

test/mitmproxy/test_proxy.py
15 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import argparse

import pytest

from mitmproxy import options
from mitmproxy.tools import cmdline
from mitmproxy.tools import main



            

Reported by Pylint.

Assigning result of a function call, where the function has no return
Error

Line: 27 Column: 9

                      opts = options.Options()
        cmdline.common_options(parser, opts)
        args = parser.parse_args(args=args)
        pconf = main.process_options(parser, opts, args)
        return parser, pconf

    def assert_noerr(self, *args):
        m, p = self.p(*args)
        assert p

            

Reported by Pylint.

Unused variable 'm'
Error

Line: 31 Column: 9

                      return parser, pconf

    def assert_noerr(self, *args):
        m, p = self.p(*args)
        assert p
        return p

    def test_simple(self):
        assert self.p()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import argparse

import pytest

from mitmproxy import options
from mitmproxy.tools import cmdline
from mitmproxy.tools import main



            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 1

                      raise Exception(message)


class TestProcessProxyOptions:

    def p(self, *args):
        parser = MockParser()
        opts = options.Options()
        cmdline.common_options(parser, opts)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

              
class TestProcessProxyOptions:

    def p(self, *args):
        parser = MockParser()
        opts = options.Options()
        cmdline.common_options(parser, opts)
        args = parser.parse_args(args=args)
        pconf = main.process_options(parser, opts, args)

            

Reported by Pylint.

Method could be a function
Error

Line: 22 Column: 5

              
class TestProcessProxyOptions:

    def p(self, *args):
        parser = MockParser()
        opts = options.Options()
        cmdline.common_options(parser, opts)
        args = parser.parse_args(args=args)
        pconf = main.process_options(parser, opts, args)

            

Reported by Pylint.

Method name "p" doesn't conform to snake_case naming style
Error

Line: 22 Column: 5

              
class TestProcessProxyOptions:

    def p(self, *args):
        parser = MockParser()
        opts = options.Options()
        cmdline.common_options(parser, opts)
        args = parser.parse_args(args=args)
        pconf = main.process_options(parser, opts, args)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                      pconf = main.process_options(parser, opts, args)
        return parser, pconf

    def assert_noerr(self, *args):
        m, p = self.p(*args)
        assert p
        return p

    def test_simple(self):

            

Reported by Pylint.

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

Line: 31 Column: 9

                      return parser, pconf

    def assert_noerr(self, *args):
        m, p = self.p(*args)
        assert p
        return p

    def test_simple(self):
        assert self.p()

            

Reported by Pylint.

test/mitmproxy/test_hooks.py
15 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from dataclasses import dataclass

import pytest

from mitmproxy import hooks


def test_hook():
    with pytest.raises(TypeError, match="may not be instantiated directly"):

            

Reported by Pylint.

Unused variable 'FooHook2'
Error

Line: 29 Column: 9

              
    with pytest.warns(RuntimeWarning, match="Two conflicting event classes"):
        @dataclass
        class FooHook2(hooks.Hook):
            name = "foo"

    @dataclass
    class AnotherABC(hooks.Hook):
        name = ""

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from dataclasses import dataclass

import pytest

from mitmproxy import hooks


def test_hook():
    with pytest.raises(TypeError, match="may not be instantiated directly"):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              from mitmproxy import hooks


def test_hook():
    with pytest.raises(TypeError, match="may not be instantiated directly"):
        hooks.Hook()

    class NoDataClass(hooks.Hook):
        pass

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 12 Column: 5

                  with pytest.raises(TypeError, match="may not be instantiated directly"):
        hooks.Hook()

    class NoDataClass(hooks.Hook):
        pass

    with pytest.raises(TypeError, match="not a dataclass"):
        NoDataClass()


            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 5

                  with pytest.raises(TypeError, match="may not be instantiated directly"):
        hooks.Hook()

    class NoDataClass(hooks.Hook):
        pass

    with pytest.raises(TypeError, match="not a dataclass"):
        NoDataClass()


            

Reported by Pylint.

Missing class docstring
Error

Line: 19 Column: 5

                      NoDataClass()

    @dataclass
    class FooHook(hooks.Hook):
        data: bytes

    e = FooHook(b"foo")
    assert repr(e)
    assert e.args() == [b"foo"]

            

Reported by Pylint.

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

Line: 22 Column: 5

                  class FooHook(hooks.Hook):
        data: bytes

    e = FooHook(b"foo")
    assert repr(e)
    assert e.args() == [b"foo"]
    assert FooHook in hooks.all_hooks.values()

    with pytest.warns(RuntimeWarning, match="Two conflicting event classes"):

            

Reported by Pylint.

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

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

                      data: bytes

    e = FooHook(b"foo")
    assert repr(e)
    assert e.args() == [b"foo"]
    assert FooHook in hooks.all_hooks.values()

    with pytest.warns(RuntimeWarning, match="Two conflicting event classes"):
        @dataclass

            

Reported by Bandit.

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

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

              
    e = FooHook(b"foo")
    assert repr(e)
    assert e.args() == [b"foo"]
    assert FooHook in hooks.all_hooks.values()

    with pytest.warns(RuntimeWarning, match="Two conflicting event classes"):
        @dataclass
        class FooHook2(hooks.Hook):

            

Reported by Bandit.

test/mitmproxy/data/addonscripts/addon.py
15 issues
Unable to import 'mitmproxy'
Error

Line: 1 Column: 1

              from mitmproxy import ctx
event_log = []


class Addon:
    @property
    def event_log(self):
        return event_log


            

Reported by Pylint.

Unused argument 'opts'
Error

Line: 10 Column: 20

                  def event_log(self):
        return event_log

    def load(self, opts):
        ctx.log.info("addon running")
        event_log.append("addonload")

    def configure(self, updated):
        event_log.append("addonconfigure")

            

Reported by Pylint.

Unused argument 'updated'
Error

Line: 14 Column: 25

                      ctx.log.info("addon running")
        event_log.append("addonload")

    def configure(self, updated):
        event_log.append("addonconfigure")


def configure(updated):
    event_log.append("scriptconfigure")

            

Reported by Pylint.

Unused argument 'updated'
Error

Line: 18 Column: 15

                      event_log.append("addonconfigure")


def configure(updated):
    event_log.append("scriptconfigure")


def load(l):
    event_log.append("scriptload")

            

Reported by Pylint.

Unused argument 'l'
Error

Line: 22 Column: 10

                  event_log.append("scriptconfigure")


def load(l):
    event_log.append("scriptload")


addons = [Addon()]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from mitmproxy import ctx
event_log = []


class Addon:
    @property
    def event_log(self):
        return event_log


            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              event_log = []


class Addon:
    @property
    def event_log(self):
        return event_log

    def load(self, opts):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

              
class Addon:
    @property
    def event_log(self):
        return event_log

    def load(self, opts):
        ctx.log.info("addon running")
        event_log.append("addonload")

            

Reported by Pylint.

Method could be a function
Error

Line: 10 Column: 5

                  def event_log(self):
        return event_log

    def load(self, opts):
        ctx.log.info("addon running")
        event_log.append("addonload")

    def configure(self, updated):
        event_log.append("addonconfigure")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

                  def event_log(self):
        return event_log

    def load(self, opts):
        ctx.log.info("addon running")
        event_log.append("addonload")

    def configure(self, updated):
        event_log.append("addonconfigure")

            

Reported by Pylint.

test/mitmproxy/proxy/test_commands.py
15 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from dataclasses import dataclass

import pytest

from mitmproxy import connection
from mitmproxy.hooks import all_hooks
from mitmproxy.proxy import commands



            

Reported by Pylint.

Redefining name 'tconn' from outer scope (line 11)
Error

Line: 15 Column: 22

                  return connection.Server(None)


def test_dataclasses(tconn):
    assert repr(commands.SendData(tconn, b"foo"))
    assert repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from dataclasses import dataclass

import pytest

from mitmproxy import connection
from mitmproxy.hooks import all_hooks
from mitmproxy.proxy import commands



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              

@pytest.fixture
def tconn() -> connection.Server:
    return connection.Server(None)


def test_dataclasses(tconn):
    assert repr(commands.SendData(tconn, b"foo"))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

                  return connection.Server(None)


def test_dataclasses(tconn):
    assert repr(commands.SendData(tconn, b"foo"))
    assert repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))

            

Reported by Pylint.

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

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

              

def test_dataclasses(tconn):
    assert repr(commands.SendData(tconn, b"foo"))
    assert repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))


            

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

              
def test_dataclasses(tconn):
    assert repr(commands.SendData(tconn, b"foo"))
    assert repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))



            

Reported by Bandit.

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

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

              def test_dataclasses(tconn):
    assert repr(commands.SendData(tconn, b"foo"))
    assert repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))


def test_start_hook():

            

Reported by Bandit.

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

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

                  assert repr(commands.SendData(tconn, b"foo"))
    assert repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))


def test_start_hook():
    with pytest.raises(TypeError):

            

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 repr(commands.OpenConnection(tconn))
    assert repr(commands.CloseConnection(tconn))
    assert repr(commands.GetSocket(tconn))
    assert repr(commands.Log("hello", "info"))


def test_start_hook():
    with pytest.raises(TypeError):
        commands.StartHook()

            

Reported by Bandit.

test/helper_tools/dumperview.py
15 issues
Unable to import 'mitmproxy.addons'
Error

Line: 4 Column: 1

              #!/usr/bin/env python3
import click

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


def show(flow_detail, flows):

            

Reported by Pylint.

Unable to import 'mitmproxy.test'
Error

Line: 5 Column: 1

              import click

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


def show(flow_detail, flows):
    d = dumper.Dumper()

            

Reported by Pylint.

Unable to import 'mitmproxy.test'
Error

Line: 6 Column: 1

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


def show(flow_detail, flows):
    d = dumper.Dumper()
    with taddons.context() as ctx:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
import click

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


def show(flow_detail, flows):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              from mitmproxy.test import taddons


def show(flow_detail, flows):
    d = dumper.Dumper()
    with taddons.context() as ctx:
        ctx.configure(d, flow_detail=flow_detail)
        for f in flows:
            ctx.cycle(d, f)

            

Reported by Pylint.

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

Line: 10 Column: 5

              

def show(flow_detail, flows):
    d = dumper.Dumper()
    with taddons.context() as ctx:
        ctx.configure(d, flow_detail=flow_detail)
        for f in flows:
            ctx.cycle(d, f)


            

Reported by Pylint.

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

Line: 13 Column: 13

                  d = dumper.Dumper()
    with taddons.context() as ctx:
        ctx.configure(d, flow_detail=flow_detail)
        for f in flows:
            ctx.cycle(d, f)


@click.group()
def cli():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@click.group()
def cli():
    pass


@cli.command()
@click.option('--level', default=1, help='Detail level')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

              
@cli.command()
@click.option('--level', default=1, help='Detail level')
def tcp(level):
    f1 = tflow.ttcpflow(client_conn=True, server_conn=True)
    show(level, [f1])


@cli.command()

            

Reported by Pylint.

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

Line: 25 Column: 5

              @cli.command()
@click.option('--level', default=1, help='Detail level')
def tcp(level):
    f1 = tflow.ttcpflow(client_conn=True, server_conn=True)
    show(level, [f1])


@cli.command()
@click.option('--level', default=1, help='Detail level')

            

Reported by Pylint.