The following issues were found
test/mitmproxy/addons/test_stickyauth.py
11 issues
Line: 1
Column: 1
import pytest
from mitmproxy.test import tflow
from mitmproxy.test import taddons
from mitmproxy.addons import stickyauth
from mitmproxy import exceptions
Reported by Pylint.
Line: 1
Column: 1
import pytest
from mitmproxy.test import tflow
from mitmproxy.test import taddons
from mitmproxy.addons import stickyauth
from mitmproxy import exceptions
Reported by Pylint.
Line: 10
Column: 1
from mitmproxy import exceptions
def test_configure():
r = stickyauth.StickyAuth()
with taddons.context(r) as tctx:
tctx.configure(r, stickyauth="~s")
with pytest.raises(exceptions.OptionsError):
tctx.configure(r, stickyauth="~~")
Reported by Pylint.
Line: 11
Column: 5
def test_configure():
r = stickyauth.StickyAuth()
with taddons.context(r) as tctx:
tctx.configure(r, stickyauth="~s")
with pytest.raises(exceptions.OptionsError):
tctx.configure(r, stickyauth="~~")
Reported by Pylint.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
tctx.configure(r, stickyauth="~~")
tctx.configure(r, stickyauth=None)
assert not r.flt
def test_simple():
r = stickyauth.StickyAuth()
with taddons.context(r) as tctx:
Reported by Bandit.
Line: 21
Column: 1
assert not r.flt
def test_simple():
r = stickyauth.StickyAuth()
with taddons.context(r) as tctx:
tctx.configure(r, stickyauth=".*")
f = tflow.tflow(resp=True)
f.request.headers["authorization"] = "foo"
Reported by Pylint.
Line: 22
Column: 5
def test_simple():
r = stickyauth.StickyAuth()
with taddons.context(r) as tctx:
tctx.configure(r, stickyauth=".*")
f = tflow.tflow(resp=True)
f.request.headers["authorization"] = "foo"
r.request(f)
Reported by Pylint.
Line: 25
Column: 9
r = stickyauth.StickyAuth()
with taddons.context(r) as tctx:
tctx.configure(r, stickyauth=".*")
f = tflow.tflow(resp=True)
f.request.headers["authorization"] = "foo"
r.request(f)
assert "address" in r.hosts
Reported by Pylint.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
f.request.headers["authorization"] = "foo"
r.request(f)
assert "address" in r.hosts
f = tflow.tflow(resp=True)
r.request(f)
assert f.request.headers["authorization"] == "foo"
Reported by Bandit.
Line: 31
Column: 9
assert "address" in r.hosts
f = tflow.tflow(resp=True)
r.request(f)
assert f.request.headers["authorization"] == "foo"
Reported by Pylint.
test/mitmproxy/tools/test_cmdline.py
11 issues
Line: 1
Column: 1
import argparse
from mitmproxy import options
from mitmproxy.tools import cmdline, web, dump, console
from mitmproxy.tools import main
def test_common():
parser = argparse.ArgumentParser()
Reported by Pylint.
Line: 8
Column: 1
from mitmproxy.tools import main
def test_common():
parser = argparse.ArgumentParser()
opts = options.Options()
cmdline.common_options(parser, opts)
args = parser.parse_args(args=[])
main.process_options(parser, opts, args)
Reported by Pylint.
Line: 16
Column: 1
main.process_options(parser, opts, args)
def test_mitmproxy():
opts = options.Options()
console.master.ConsoleMaster(opts)
ap = cmdline.mitmproxy(opts)
assert ap
Reported by Pylint.
Line: 19
Column: 5
def test_mitmproxy():
opts = options.Options()
console.master.ConsoleMaster(opts)
ap = cmdline.mitmproxy(opts)
assert ap
def test_mitmdump():
opts = options.Options()
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
opts = options.Options()
console.master.ConsoleMaster(opts)
ap = cmdline.mitmproxy(opts)
assert ap
def test_mitmdump():
opts = options.Options()
dump.DumpMaster(opts)
Reported by Bandit.
Line: 23
Column: 1
assert ap
def test_mitmdump():
opts = options.Options()
dump.DumpMaster(opts)
ap = cmdline.mitmdump(opts)
assert ap
Reported by Pylint.
Line: 26
Column: 5
def test_mitmdump():
opts = options.Options()
dump.DumpMaster(opts)
ap = cmdline.mitmdump(opts)
assert ap
def test_mitmweb():
opts = options.Options()
Reported by Pylint.
Line: 27
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
opts = options.Options()
dump.DumpMaster(opts)
ap = cmdline.mitmdump(opts)
assert ap
def test_mitmweb():
opts = options.Options()
web.master.WebMaster(opts)
Reported by Bandit.
Line: 30
Column: 1
assert ap
def test_mitmweb():
opts = options.Options()
web.master.WebMaster(opts)
ap = cmdline.mitmweb(opts)
assert ap
Reported by Pylint.
Line: 33
Column: 5
def test_mitmweb():
opts = options.Options()
web.master.WebMaster(opts)
ap = cmdline.mitmweb(opts)
assert ap
Reported by Pylint.
test/mitmproxy/contentviews/test_hex.py
11 issues
Line: 2
Column: 1
from mitmproxy.contentviews import hex
from . import full_eval
def test_view_hex():
v = full_eval(hex.ViewHex())
assert v(b"foo")
Reported by Pylint.
Line: 1
Column: 1
from mitmproxy.contentviews import hex
from . import full_eval
def test_view_hex():
v = full_eval(hex.ViewHex())
assert v(b"foo")
Reported by Pylint.
Line: 1
Column: 1
from mitmproxy.contentviews import hex
from . import full_eval
def test_view_hex():
v = full_eval(hex.ViewHex())
assert v(b"foo")
Reported by Pylint.
Line: 5
Column: 1
from . import full_eval
def test_view_hex():
v = full_eval(hex.ViewHex())
assert v(b"foo")
def test_render_priority():
Reported by Pylint.
Line: 6
Column: 5
def test_view_hex():
v = full_eval(hex.ViewHex())
assert v(b"foo")
def test_render_priority():
v = hex.ViewHex()
Reported by Pylint.
Line: 7
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_view_hex():
v = full_eval(hex.ViewHex())
assert v(b"foo")
def test_render_priority():
v = hex.ViewHex()
assert not v.render_priority(b"ascii")
Reported by Bandit.
Line: 10
Column: 1
assert v(b"foo")
def test_render_priority():
v = hex.ViewHex()
assert not v.render_priority(b"ascii")
assert v.render_priority(b"\xFF")
assert not v.render_priority(b"")
Reported by Pylint.
Line: 11
Column: 5
def test_render_priority():
v = hex.ViewHex()
assert not v.render_priority(b"ascii")
assert v.render_priority(b"\xFF")
assert not v.render_priority(b"")
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_render_priority():
v = hex.ViewHex()
assert not v.render_priority(b"ascii")
assert v.render_priority(b"\xFF")
assert not v.render_priority(b"")
Reported by Bandit.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_render_priority():
v = hex.ViewHex()
assert not v.render_priority(b"ascii")
assert v.render_priority(b"\xFF")
assert not v.render_priority(b"")
Reported by Bandit.
mitmproxy/master.py
11 issues
Line: 15
Column: 1
from mitmproxy import log
from mitmproxy import options
from mitmproxy.net import server_spec
from . import ctx as mitmproxy_ctx
# Conclusively preventing cross-thread races on proxy shutdown turns out to be
# very hard. We could build a thread sync infrastructure for this, or we could
# wait until we ditch threads and move all the protocols into the async loop.
# Until then, silence non-critical errors.
Reported by Pylint.
Line: 55
Column: 16
exc = None
try:
loop()
except Exception: # pragma: no cover
exc = traceback.format_exc()
finally:
if not self.should_exit.is_set(): # pragma: no cover
self.shutdown()
loop = asyncio.get_event_loop()
Reported by Pylint.
Line: 1
Column: 1
import asyncio
import logging
import sys
import threading
import traceback
from mitmproxy import addonmanager, hooks
from mitmproxy import command
from mitmproxy import controller
Reported by Pylint.
Line: 42
Column: 5
mitmproxy_ctx.log = self.log
mitmproxy_ctx.options = self.options
def start(self):
self.should_exit.clear()
async def running(self):
self.addons.trigger(hooks.RunningHook())
Reported by Pylint.
Line: 45
Column: 5
def start(self):
self.should_exit.clear()
async def running(self):
self.addons.trigger(hooks.RunningHook())
def run_loop(self, loop):
self.start()
asyncio.ensure_future(self.running())
Reported by Pylint.
Line: 48
Column: 5
async def running(self):
self.addons.trigger(hooks.RunningHook())
def run_loop(self, loop):
self.start()
asyncio.ensure_future(self.running())
exc = None
try:
Reported by Pylint.
Line: 62
Column: 17
self.shutdown()
loop = asyncio.get_event_loop()
tasks = asyncio.all_tasks(loop)
for p in tasks:
p.cancel()
loop.close()
if exc: # pragma: no cover
print(exc, file=sys.stderr)
Reported by Pylint.
Line: 74
Column: 5
self.addons.trigger(hooks.DoneHook())
def run(self):
loop = asyncio.get_event_loop()
self.run_loop(loop.run_forever)
async def _shutdown(self):
self.should_exit.set()
Reported by Pylint.
Line: 99
Column: 5
except RuntimeError:
pass # Event loop stopped before Future completed.
def _change_reverse_host(self, f):
"""
When we load flows in reverse proxy mode, we adjust the target host to
the reverse proxy destination for all flows we load. This makes it very
easy to replay saved flows against a different host.
"""
Reported by Pylint.
Line: 110
Column: 5
f.request.host, f.request.port = upstream_spec.address
f.request.scheme = upstream_spec.scheme
async def load_flow(self, f):
"""
Loads a flow
"""
if isinstance(f, http.HTTPFlow):
Reported by Pylint.
mitmproxy/contentviews/graphql.py
11 issues
Line: 47
Column: 1
elif is_graphql_batch_query(data):
return "GraphQL", base.format_text(format_query_list(data))
def render_priority(self, data: bytes, *, content_type: typing.Optional[str] = None, **metadata) -> float:
if content_type != "application/json":
return 0
data = parse_json(data)
Reported by Pylint.
Line: 1
Column: 1
import json
import typing
from mitmproxy.contentviews import base
from mitmproxy.contentviews.json import parse_json, PARSE_ERROR
def format_graphql(data):
Reported by Pylint.
Line: 9
Column: 1
from mitmproxy.contentviews.json import parse_json, PARSE_ERROR
def format_graphql(data):
query = data["query"]
header_data = data.copy()
header_data["query"] = "..."
return """{header}
---
Reported by Pylint.
Line: 19
Column: 1
""".format(header=json.dumps(header_data, indent=2), query = query)
def format_query_list(data: typing.List[typing.Any]):
num_queries = len(data) - 1
result = ""
for i, op in enumerate(data):
result += "--- {i}/{num_queries}\n".format(i=i, num_queries=num_queries)
result += format_graphql(op)
Reported by Pylint.
Line: 22
Column: 12
def format_query_list(data: typing.List[typing.Any]):
num_queries = len(data) - 1
result = ""
for i, op in enumerate(data):
result += "--- {i}/{num_queries}\n".format(i=i, num_queries=num_queries)
result += format_graphql(op)
return result
Reported by Pylint.
Line: 28
Column: 1
return result
def is_graphql_query(data):
return isinstance(data, dict) and "query" in data and "\n" in data["query"]
def is_graphql_batch_query(data):
return isinstance(data, list) and isinstance(data[0], dict) and "query" in data[0]
Reported by Pylint.
Line: 32
Column: 1
return isinstance(data, dict) and "query" in data and "\n" in data["query"]
def is_graphql_batch_query(data):
return isinstance(data, list) and isinstance(data[0], dict) and "query" in data[0]
class ViewGraphQL(base.View):
name = "GraphQL"
Reported by Pylint.
Line: 36
Column: 1
return isinstance(data, list) and isinstance(data[0], dict) and "query" in data[0]
class ViewGraphQL(base.View):
name = "GraphQL"
def __call__(self, data, **metadata):
data = parse_json(data)
if data is not PARSE_ERROR:
Reported by Pylint.
Line: 39
Column: 5
class ViewGraphQL(base.View):
name = "GraphQL"
def __call__(self, data, **metadata):
data = parse_json(data)
if data is not PARSE_ERROR:
if is_graphql_query(data):
return "GraphQL", base.format_text(format_graphql(data))
elif is_graphql_batch_query(data):
Reported by Pylint.
Line: 42
Column: 13
def __call__(self, data, **metadata):
data = parse_json(data)
if data is not PARSE_ERROR:
if is_graphql_query(data):
return "GraphQL", base.format_text(format_graphql(data))
elif is_graphql_batch_query(data):
return "GraphQL", base.format_text(format_query_list(data))
def render_priority(self, data: bytes, *, content_type: typing.Optional[str] = None, **metadata) -> float:
Reported by Pylint.
mitmproxy/tools/console/flowdetailview.py
11 issues
Line: 2
Column: 1
import typing
import urwid
import mitmproxy.flow
from mitmproxy import http
from mitmproxy.tools.console import common, searchable
from mitmproxy.utils import human, strutils
Reported by Pylint.
Line: 22
Column: 17
return "–"
def flowdetails(state, flow: mitmproxy.flow.Flow):
text = []
sc = flow.server_conn
cc = flow.client_conn
req: typing.Optional[http.Request]
Reported by Pylint.
Line: 1
Column: 1
import typing
import urwid
import mitmproxy.flow
from mitmproxy import http
from mitmproxy.tools.console import common, searchable
from mitmproxy.utils import human, strutils
Reported by Pylint.
Line: 10
Column: 1
from mitmproxy.utils import human, strutils
def maybe_timestamp(base, attr):
if base is not None and getattr(base, attr):
return human.format_timestamp_with_milli(getattr(base, attr))
else:
# in mitmdump we serialize before a connection is closed.
# loading those flows at a later point shouldn't display "active".
Reported by Pylint.
Line: 11
Column: 5
def maybe_timestamp(base, attr):
if base is not None and getattr(base, attr):
return human.format_timestamp_with_milli(getattr(base, attr))
else:
# in mitmdump we serialize before a connection is closed.
# loading those flows at a later point shouldn't display "active".
# We also use a ndash (and not a regular dash) so that it is sorted
Reported by Pylint.
Line: 22
Column: 1
return "–"
def flowdetails(state, flow: mitmproxy.flow.Flow):
text = []
sc = flow.server_conn
cc = flow.client_conn
req: typing.Optional[http.Request]
Reported by Pylint.
Line: 22
Column: 1
return "–"
def flowdetails(state, flow: mitmproxy.flow.Flow):
text = []
sc = flow.server_conn
cc = flow.client_conn
req: typing.Optional[http.Request]
Reported by Pylint.
Line: 22
Column: 1
return "–"
def flowdetails(state, flow: mitmproxy.flow.Flow):
text = []
sc = flow.server_conn
cc = flow.client_conn
req: typing.Optional[http.Request]
Reported by Pylint.
Line: 25
Column: 5
def flowdetails(state, flow: mitmproxy.flow.Flow):
text = []
sc = flow.server_conn
cc = flow.client_conn
req: typing.Optional[http.Request]
resp: typing.Optional[http.Response]
if isinstance(flow, http.HTTPFlow):
req = flow.request
Reported by Pylint.
Line: 26
Column: 5
text = []
sc = flow.server_conn
cc = flow.client_conn
req: typing.Optional[http.Request]
resp: typing.Optional[http.Response]
if isinstance(flow, http.HTTPFlow):
req = flow.request
resp = flow.response
Reported by Pylint.
mitmproxy/version.py
10 issues
Line: 35
Column: 9
stderr=subprocess.STDOUT,
cwd=here,
)
last_tag, tag_dist_str, commit = git_describe.decode().strip().rsplit("-", 2)
commit = commit.lstrip("g")[:7]
tag_dist = int(tag_dist_str)
except Exception:
pass
else:
Reported by Pylint.
Line: 38
Column: 12
last_tag, tag_dist_str, commit = git_describe.decode().strip().rsplit("-", 2)
commit = commit.lstrip("g")[:7]
tag_dist = int(tag_dist_str)
except Exception:
pass
else:
# Add commit info for non-tagged releases
if tag_dist > 0:
mitmproxy_version += f" (+{tag_dist}, commit {commit})"
Reported by Pylint.
Line: 1
Column: 1
import os
import subprocess
import sys
VERSION = "8.0.0.dev"
MITMPROXY = "mitmproxy " + VERSION
# Serialization format version. This is displayed nowhere, it just needs to be incremented by one
# for each change in the file format.
Reported by Pylint.
Line: 2
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import os
import subprocess
import sys
VERSION = "8.0.0.dev"
MITMPROXY = "mitmproxy " + VERSION
# Serialization format version. This is displayed nowhere, it just needs to be incremented by one
# for each change in the file format.
Reported by Bandit.
Line: 22
Column: 1
here = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
try:
# Check that we're in the mitmproxy repository: https://github.com/mitmproxy/mitmproxy/issues/3987
# cb0e3287090786fad566feb67ac07b8ef361b2c3 is the first mitmproxy commit.
subprocess.run(
['git', 'cat-file', '-e', 'cb0e3287090786fad566feb67ac07b8ef361b2c3'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
try:
# Check that we're in the mitmproxy repository: https://github.com/mitmproxy/mitmproxy/issues/3987
# cb0e3287090786fad566feb67ac07b8ef361b2c3 is the first mitmproxy commit.
subprocess.run(
['git', 'cat-file', '-e', 'cb0e3287090786fad566feb67ac07b8ef361b2c3'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
cwd=here,
check=True)
Reported by Bandit.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html
try:
# Check that we're in the mitmproxy repository: https://github.com/mitmproxy/mitmproxy/issues/3987
# cb0e3287090786fad566feb67ac07b8ef361b2c3 is the first mitmproxy commit.
subprocess.run(
['git', 'cat-file', '-e', 'cb0e3287090786fad566feb67ac07b8ef361b2c3'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
cwd=here,
check=True)
Reported by Bandit.
Line: 30
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html
stderr=subprocess.DEVNULL,
cwd=here,
check=True)
git_describe = subprocess.check_output(
['git', 'describe', '--tags', '--long'],
stderr=subprocess.STDOUT,
cwd=here,
)
last_tag, tag_dist_str, commit = git_describe.decode().strip().rsplit("-", 2)
Reported by Bandit.
Line: 30
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
stderr=subprocess.DEVNULL,
cwd=here,
check=True)
git_describe = subprocess.check_output(
['git', 'describe', '--tags', '--long'],
stderr=subprocess.STDOUT,
cwd=here,
)
last_tag, tag_dist_str, commit = git_describe.decode().strip().rsplit("-", 2)
Reported by Bandit.
Line: 38
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html
last_tag, tag_dist_str, commit = git_describe.decode().strip().rsplit("-", 2)
commit = commit.lstrip("g")[:7]
tag_dist = int(tag_dist_str)
except Exception:
pass
else:
# Add commit info for non-tagged releases
if tag_dist > 0:
mitmproxy_version += f" (+{tag_dist}, commit {commit})"
Reported by Bandit.
mitmproxy/tools/console/grideditor/col_bytes.py
10 issues
Line: 1
Column: 1
import urwid
from mitmproxy.tools.console import signals
from mitmproxy.tools.console.grideditor import base
from mitmproxy.utils import strutils
class Column(base.Column):
def Display(self, data):
return Display(data)
Reported by Pylint.
Line: 1
Column: 1
import urwid
from mitmproxy.tools.console import signals
from mitmproxy.tools.console.grideditor import base
from mitmproxy.utils import strutils
class Column(base.Column):
def Display(self, data):
return Display(data)
Reported by Pylint.
Line: 7
Column: 1
from mitmproxy.utils import strutils
class Column(base.Column):
def Display(self, data):
return Display(data)
def Edit(self, data):
return Edit(data)
Reported by Pylint.
Line: 17
Column: 5
def blank(self):
return b""
def keypress(self, key, editor):
if key in ["m_select"]:
editor.walker.start_edit()
else:
return key
Reported by Pylint.
Line: 24
Column: 1
return key
class Display(base.Cell):
def __init__(self, data: bytes) -> None:
self.data = data
escaped = strutils.bytes_to_escaped_str(data)
w = urwid.Text(escaped, wrap="any")
super().__init__(w)
Reported by Pylint.
Line: 28
Column: 9
def __init__(self, data: bytes) -> None:
self.data = data
escaped = strutils.bytes_to_escaped_str(data)
w = urwid.Text(escaped, wrap="any")
super().__init__(w)
def get_data(self) -> bytes:
return self.data
Reported by Pylint.
Line: 35
Column: 1
return self.data
class Edit(base.Cell):
def __init__(self, data: bytes) -> None:
d = strutils.bytes_to_escaped_str(data)
w = urwid.Edit(edit_text=d, wrap="any", multiline=True)
w = urwid.AttrWrap(w, "editfield")
super().__init__(w)
Reported by Pylint.
Line: 37
Column: 9
class Edit(base.Cell):
def __init__(self, data: bytes) -> None:
d = strutils.bytes_to_escaped_str(data)
w = urwid.Edit(edit_text=d, wrap="any", multiline=True)
w = urwid.AttrWrap(w, "editfield")
super().__init__(w)
def get_data(self) -> bytes:
Reported by Pylint.
Line: 38
Column: 9
class Edit(base.Cell):
def __init__(self, data: bytes) -> None:
d = strutils.bytes_to_escaped_str(data)
w = urwid.Edit(edit_text=d, wrap="any", multiline=True)
w = urwid.AttrWrap(w, "editfield")
super().__init__(w)
def get_data(self) -> bytes:
txt = self._w.get_text()[0].strip()
Reported by Pylint.
Line: 39
Column: 9
def __init__(self, data: bytes) -> None:
d = strutils.bytes_to_escaped_str(data)
w = urwid.Edit(edit_text=d, wrap="any", multiline=True)
w = urwid.AttrWrap(w, "editfield")
super().__init__(w)
def get_data(self) -> bytes:
txt = self._w.get_text()[0].strip()
try:
Reported by Pylint.
mitmproxy/coretypes/multidict.py
10 issues
Line: 169
Column: 17
return super().items()
class MultiDict(_MultiDict[KT, VT], serializable.Serializable):
"""A concrete MultiDict, storing its own data."""
def __init__(self, fields=()):
super().__init__()
self.fields = tuple(
Reported by Pylint.
Line: 197
Column: 21
return cls(state)
class MultiDictView(_MultiDict[KT, VT]):
"""
The MultiDictView provides the MultiDict interface over calculated data.
The view itself contains no state - data is retrieved from the parent on
request, and stored back to the parent on change.
"""
Reported by Pylint.
Line: 132
Column: 5
item = (key, value)
self.fields = self.fields[:index] + (item,) + self.fields[index:]
def keys(self, multi: bool = False):
"""
Get all keys.
If `multi` is True, one key per value will be returned.
If `multi` is False, duplicate keys will only be returned once.
Reported by Pylint.
Line: 144
Column: 5
for k, _ in self.items(multi)
)
def values(self, multi: bool = False):
"""
Get all values.
If `multi` is True, all values will be returned.
If `multi` is False, only the first value per key will be returned.
Reported by Pylint.
Line: 156
Column: 5
for _, v in self.items(multi)
)
def items(self, multi: bool = False):
"""
Get all (key, value) tuples.
If `multi` is True, all `(key, value)` pairs will be returned.
If False, only one tuple per key is returned.
Reported by Pylint.
Line: 1
Column: 1
from abc import ABCMeta
from abc import abstractmethod
from typing import Iterator
from typing import List
from typing import MutableMapping
from typing import Sequence
from typing import Tuple
from typing import TypeVar
Reported by Pylint.
Line: 16
Column: 1
VT = TypeVar('VT')
class _MultiDict(MutableMapping[KT, VT], metaclass=ABCMeta):
"""
A MultiDict is a dictionary-like data structure that supports multiple values per key.
"""
fields: Tuple[Tuple[KT, VT], ...]
Reported by Pylint.
Line: 163
Column: 9
If `multi` is True, all `(key, value)` pairs will be returned.
If False, only one tuple per key is returned.
"""
if multi:
return self.fields
else:
return super().items()
Reported by Pylint.
Line: 221
Column: 5
return values[0]
@property # type: ignore
def fields(self):
return self._getter()
@fields.setter
def fields(self, value):
self._setter(value)
Reported by Pylint.
Line: 228
Column: 5
def fields(self, value):
self._setter(value)
def copy(self) -> "MultiDict[KT,VT]":
return MultiDict(self.fields)
Reported by Pylint.
mitmproxy/exceptions.py
10 issues
Line: 24
Column: 5
Base class for all exceptions thrown by mitmproxy.
"""
def __init__(self, message=None):
super().__init__(message)
class FlowReadException(MitmproxyException):
pass
Reported by Pylint.
Line: 52
Column: 5
"""
Raised by addons to signal that no further handlers should handle this event.
"""
pass
class TypeError(MitmproxyException):
pass
Reported by Pylint.
Line: 55
Column: 1
pass
class TypeError(MitmproxyException):
pass
Reported by Pylint.
Line: 4
Column: 1
"""
Edit 2020-12 @mhils:
The advice below hasn't paid off in any form. We now just use builtin exceptions and specialize where necessary.
---
We try to be very hygienic regarding the exceptions we throw:
Reported by Pylint.
Line: 28
Column: 1
super().__init__(message)
class FlowReadException(MitmproxyException):
pass
class ControlException(MitmproxyException):
pass
Reported by Pylint.
Line: 32
Column: 1
pass
class ControlException(MitmproxyException):
pass
class CommandError(Exception):
pass
Reported by Pylint.
Line: 36
Column: 1
pass
class CommandError(Exception):
pass
class OptionsError(MitmproxyException):
pass
Reported by Pylint.
Line: 40
Column: 1
pass
class OptionsError(MitmproxyException):
pass
class AddonManagerError(MitmproxyException):
pass
Reported by Pylint.
Line: 44
Column: 1
pass
class AddonManagerError(MitmproxyException):
pass
class AddonHalt(MitmproxyException):
"""
Reported by Pylint.
Line: 55
Column: 1
pass
class TypeError(MitmproxyException):
pass
Reported by Pylint.