The following issues were found
mitmproxy/contrib/wbxml/ASWBXML.py
779 issues
Line: 33
Column: 1
import xml.dom.minidom
import logging
from .ASWBXMLCodePage import ASWBXMLCodePage
from .ASWBXMLByteQueue import ASWBXMLByteQueue
from .GlobalTokens import GlobalTokens
from .InvalidDataException import InvalidDataException
class ASWBXML:
Reported by Pylint.
Line: 34
Column: 1
import logging
from .ASWBXMLCodePage import ASWBXMLCodePage
from .ASWBXMLByteQueue import ASWBXMLByteQueue
from .GlobalTokens import GlobalTokens
from .InvalidDataException import InvalidDataException
class ASWBXML:
versionByte = 0x03
Reported by Pylint.
Line: 35
Column: 1
from .ASWBXMLCodePage import ASWBXMLCodePage
from .ASWBXMLByteQueue import ASWBXMLByteQueue
from .GlobalTokens import GlobalTokens
from .InvalidDataException import InvalidDataException
class ASWBXML:
versionByte = 0x03
publicIdentifierByte = 0x01
Reported by Pylint.
Line: 36
Column: 1
from .ASWBXMLCodePage import ASWBXMLCodePage
from .ASWBXMLByteQueue import ASWBXMLByteQueue
from .GlobalTokens import GlobalTokens
from .InvalidDataException import InvalidDataException
class ASWBXML:
versionByte = 0x03
publicIdentifierByte = 0x01
characterSetByte = 0x6A
Reported by Pylint.
Line: 819
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b313-b320-xml-bad-minidom
def loadXml(self, strXML):
# note xmlDoc has .childNodes and .parentNode
self.xmlDoc = xml.dom.minidom.parseString(strXML)
def getXml(self):
if (self.xmlDoc != None):
try:
return self.xmlDoc.toprettyxml(indent=" ", newl="\n")
Reported by Bandit.
Line: 825
Column: 4
if (self.xmlDoc != None):
try:
return self.xmlDoc.toprettyxml(indent=" ", newl="\n")
except:
return self.xmlDoc.toxml()
def loadBytes(self, byteWBXML):
currentNode = self.xmlDoc
Reported by Pylint.
Line: 839
Column: 3
# Public Identifier is ignored
publicId = wbXMLBytes.dequeueMultibyteInt()
logging.debug("Version: %d, Public Identifier: %d" % (version, publicId))
# Character set
# Currently only UTF-8 is supported, throw if something else
charset = wbXMLBytes.dequeueMultibyteInt()
if (charset != 0x6A):
Reported by Pylint.
Line: 870
Column: 6
currentNode = currentNode.parentNode
else:
raise InvalidDataException("END global token encountered out of sequence")
break
elif ( currentByte == GlobalTokens.OPAQUE ):
CDATALength = wbXMLBytes.dequeueMultibyteInt()
newOpaqueNode = self.xmlDoc.createCDATASection(wbXMLBytes.dequeueString(CDATALength))
currentNode.appendChild(newOpaqueNode)
Reported by Pylint.
Line: 892
Column: 15
strTag = self.codePages[self.currentCodePage].getTag(token)
if (strTag == None):
strTag = "UNKNOWN_TAG_{0,2:X}".format(token)
newNode = self.xmlDoc.createElement(strTag)
# not sure if this should be set on every node or not
#newNode.setAttribute("xmlns", self.codePages[self.currentCodePage].xmlns)
Reported by Pylint.
Line: 903
Column: 3
if (hasContent):
currentNode = newNode
logging.debug("Total bytes dequeued: %d" % wbXMLBytes.bytesDequeued)
Reported by Pylint.
test/mitmproxy/test_http.py
635 issues
Line: 6
Column: 1
import json
from unittest import mock
import pytest
from mitmproxy import flow
from mitmproxy import flowfilter
from mitmproxy.exceptions import ControlException
from mitmproxy.http import Headers, Request, Response, HTTPFlow
Reported by Pylint.
Line: 316
Column: 9
def test_set_query(self):
request = treq()
assert not request.query
request.query["foo"] = "bar"
assert request.query["foo"] == "bar"
assert request.path == "/path?foo=bar"
request.query = [('foo', 'bar')]
assert request.query["foo"] == "bar"
assert request.path == "/path?foo=bar"
Reported by Pylint.
Line: 317
Column: 16
request = treq()
assert not request.query
request.query["foo"] = "bar"
assert request.query["foo"] == "bar"
assert request.path == "/path?foo=bar"
request.query = [('foo', 'bar')]
assert request.query["foo"] == "bar"
assert request.path == "/path?foo=bar"
Reported by Pylint.
Line: 320
Column: 16
assert request.query["foo"] == "bar"
assert request.path == "/path?foo=bar"
request.query = [('foo', 'bar')]
assert request.query["foo"] == "bar"
assert request.path == "/path?foo=bar"
def test_get_cookies_none(self):
request = treq()
request.headers = Headers()
Reported by Pylint.
Line: 332
Column: 16
request = treq()
request.headers = Headers(cookie="cookiename=cookievalue")
assert len(request.cookies) == 1
assert request.cookies['cookiename'] == 'cookievalue'
def test_get_cookies_double(self):
request = treq()
request.headers = Headers(cookie="cookiename=cookievalue;othercookiename=othercookievalue")
result = request.cookies
Reported by Pylint.
Line: 339
Column: 16
request.headers = Headers(cookie="cookiename=cookievalue;othercookiename=othercookievalue")
result = request.cookies
assert len(result) == 2
assert result['cookiename'] == 'cookievalue'
assert result['othercookiename'] == 'othercookievalue'
def test_get_cookies_withequalsign(self):
request = treq()
request.headers = Headers(cookie="cookiename=coo=kievalue;othercookiename=othercookievalue")
Reported by Pylint.
Line: 340
Column: 16
result = request.cookies
assert len(result) == 2
assert result['cookiename'] == 'cookievalue'
assert result['othercookiename'] == 'othercookievalue'
def test_get_cookies_withequalsign(self):
request = treq()
request.headers = Headers(cookie="cookiename=coo=kievalue;othercookiename=othercookievalue")
result = request.cookies
Reported by Pylint.
Line: 347
Column: 16
request.headers = Headers(cookie="cookiename=coo=kievalue;othercookiename=othercookievalue")
result = request.cookies
assert len(result) == 2
assert result['cookiename'] == 'coo=kievalue'
assert result['othercookiename'] == 'othercookievalue'
def test_set_cookies(self):
request = treq()
request.headers = Headers(cookie="cookiename=cookievalue")
Reported by Pylint.
Line: 348
Column: 16
result = request.cookies
assert len(result) == 2
assert result['cookiename'] == 'coo=kievalue'
assert result['othercookiename'] == 'othercookievalue'
def test_set_cookies(self):
request = treq()
request.headers = Headers(cookie="cookiename=cookievalue")
result = request.cookies
Reported by Pylint.
Line: 354
Column: 9
request = treq()
request.headers = Headers(cookie="cookiename=cookievalue")
result = request.cookies
result["cookiename"] = "foo"
assert request.cookies["cookiename"] == "foo"
request.cookies = [["one", "uno"], ["two", "due"]]
assert request.cookies["one"] == "uno"
assert request.cookies["two"] == "due"
Reported by Pylint.
mitmproxy/contrib/kaitaistruct/exif_le.py
503 issues
Line: 4
Column: 1
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
Reported by Pylint.
Line: 40
Column: 24
@property
def next_ifd(self):
if hasattr(self, '_m_next_ifd'):
return self._m_next_ifd if hasattr(self, '_m_next_ifd') else None
if self.next_ifd_ofs != 0:
_pos = self._io.pos()
self._io.seek(self.next_ifd_ofs)
self._m_next_ifd = self._root.Ifd(self._io, self, self._root)
Reported by Pylint.
Line: 537
Column: 24
@property
def type_byte_length(self):
if hasattr(self, '_m_type_byte_length'):
return self._m_type_byte_length if hasattr(self, '_m_type_byte_length') else None
self._m_type_byte_length = (2 if self.field_type == self._root.IfdField.FieldTypeEnum.word else (4 if self.field_type == self._root.IfdField.FieldTypeEnum.dword else 1))
return self._m_type_byte_length if hasattr(self, '_m_type_byte_length') else None
@property
Reported by Pylint.
Line: 545
Column: 24
@property
def byte_length(self):
if hasattr(self, '_m_byte_length'):
return self._m_byte_length if hasattr(self, '_m_byte_length') else None
self._m_byte_length = (self.length * self.type_byte_length)
return self._m_byte_length if hasattr(self, '_m_byte_length') else None
@property
Reported by Pylint.
Line: 553
Column: 24
@property
def is_immediate_data(self):
if hasattr(self, '_m_is_immediate_data'):
return self._m_is_immediate_data if hasattr(self, '_m_is_immediate_data') else None
self._m_is_immediate_data = self.byte_length <= 4
return self._m_is_immediate_data if hasattr(self, '_m_is_immediate_data') else None
@property
Reported by Pylint.
Line: 561
Column: 24
@property
def data(self):
if hasattr(self, '_m_data'):
return self._m_data if hasattr(self, '_m_data') else None
if not (self.is_immediate_data):
io = self._root._io
_pos = io.pos()
io.seek(self.ofs_or_data)
Reported by Pylint.
Line: 576
Column: 20
@property
def ifd0(self):
if hasattr(self, '_m_ifd0'):
return self._m_ifd0 if hasattr(self, '_m_ifd0') else None
_pos = self._io.pos()
self._io.seek(self.ifd0_ofs)
self._m_ifd0 = self._root.Ifd(self._io, self, self._root)
self._io.seek(_pos)
Reported by Pylint.
Line: 4
Column: 1
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
Reported by Pylint.
Line: 4
Column: 1
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
Reported by Pylint.
Line: 45
Column: 17
if self.next_ifd_ofs != 0:
_pos = self._io.pos()
self._io.seek(self.next_ifd_ofs)
self._m_next_ifd = self._root.Ifd(self._io, self, self._root)
self._io.seek(_pos)
return self._m_next_ifd if hasattr(self, '_m_next_ifd') else None
Reported by Pylint.
mitmproxy/contrib/kaitaistruct/exif_be.py
503 issues
Line: 4
Column: 1
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
Reported by Pylint.
Line: 40
Column: 24
@property
def next_ifd(self):
if hasattr(self, '_m_next_ifd'):
return self._m_next_ifd if hasattr(self, '_m_next_ifd') else None
if self.next_ifd_ofs != 0:
_pos = self._io.pos()
self._io.seek(self.next_ifd_ofs)
self._m_next_ifd = self._root.Ifd(self._io, self, self._root)
Reported by Pylint.
Line: 537
Column: 24
@property
def type_byte_length(self):
if hasattr(self, '_m_type_byte_length'):
return self._m_type_byte_length if hasattr(self, '_m_type_byte_length') else None
self._m_type_byte_length = (2 if self.field_type == self._root.IfdField.FieldTypeEnum.word else (4 if self.field_type == self._root.IfdField.FieldTypeEnum.dword else 1))
return self._m_type_byte_length if hasattr(self, '_m_type_byte_length') else None
@property
Reported by Pylint.
Line: 545
Column: 24
@property
def byte_length(self):
if hasattr(self, '_m_byte_length'):
return self._m_byte_length if hasattr(self, '_m_byte_length') else None
self._m_byte_length = (self.length * self.type_byte_length)
return self._m_byte_length if hasattr(self, '_m_byte_length') else None
@property
Reported by Pylint.
Line: 553
Column: 24
@property
def is_immediate_data(self):
if hasattr(self, '_m_is_immediate_data'):
return self._m_is_immediate_data if hasattr(self, '_m_is_immediate_data') else None
self._m_is_immediate_data = self.byte_length <= 4
return self._m_is_immediate_data if hasattr(self, '_m_is_immediate_data') else None
@property
Reported by Pylint.
Line: 561
Column: 24
@property
def data(self):
if hasattr(self, '_m_data'):
return self._m_data if hasattr(self, '_m_data') else None
if not (self.is_immediate_data):
io = self._root._io
_pos = io.pos()
io.seek(self.ofs_or_data)
Reported by Pylint.
Line: 576
Column: 20
@property
def ifd0(self):
if hasattr(self, '_m_ifd0'):
return self._m_ifd0 if hasattr(self, '_m_ifd0') else None
_pos = self._io.pos()
self._io.seek(self.ifd0_ofs)
self._m_ifd0 = self._root.Ifd(self._io, self, self._root)
self._io.seek(_pos)
Reported by Pylint.
Line: 4
Column: 1
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
Reported by Pylint.
Line: 4
Column: 1
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
Reported by Pylint.
Line: 45
Column: 17
if self.next_ifd_ofs != 0:
_pos = self._io.pos()
self._io.seek(self.next_ifd_ofs)
self._m_next_ifd = self._root.Ifd(self._io, self, self._root)
self._io.seek(_pos)
return self._m_next_ifd if hasattr(self, '_m_next_ifd') else None
Reported by Pylint.
test/mitmproxy/test_flowfilter.py
442 issues
Line: 2
Column: 1
import io
import pytest
from unittest.mock import patch
from mitmproxy.test import tflow
from mitmproxy import flowfilter, http
class TestParsing:
Reported by Pylint.
Line: 1
Column: 1
import io
import pytest
from unittest.mock import patch
from mitmproxy.test import tflow
from mitmproxy import flowfilter, http
class TestParsing:
Reported by Pylint.
Line: 3
Column: 1
import io
import pytest
from unittest.mock import patch
from mitmproxy.test import tflow
from mitmproxy import flowfilter, http
class TestParsing:
Reported by Pylint.
Line: 8
Column: 1
from mitmproxy import flowfilter, http
class TestParsing:
def _dump(self, x):
c = io.StringIO()
x.dump(fp=c)
assert c.getvalue()
Reported by Pylint.
Line: 10
Column: 5
class TestParsing:
def _dump(self, x):
c = io.StringIO()
x.dump(fp=c)
assert c.getvalue()
def test_parse_err(self):
Reported by Pylint.
Line: 10
Column: 5
class TestParsing:
def _dump(self, x):
c = io.StringIO()
x.dump(fp=c)
assert c.getvalue()
def test_parse_err(self):
Reported by Pylint.
Line: 11
Column: 9
class TestParsing:
def _dump(self, x):
c = io.StringIO()
x.dump(fp=c)
assert c.getvalue()
def test_parse_err(self):
assert flowfilter.parse("~h [") is None
Reported by Pylint.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def _dump(self, x):
c = io.StringIO()
x.dump(fp=c)
assert c.getvalue()
def test_parse_err(self):
assert flowfilter.parse("~h [") is None
def test_simple(self):
Reported by Bandit.
Line: 15
Column: 5
x.dump(fp=c)
assert c.getvalue()
def test_parse_err(self):
assert flowfilter.parse("~h [") is None
def test_simple(self):
assert not flowfilter.parse("~b")
assert flowfilter.parse("~q")
Reported by Pylint.
Line: 15
Column: 5
x.dump(fp=c)
assert c.getvalue()
def test_parse_err(self):
assert flowfilter.parse("~h [") is None
def test_simple(self):
assert not flowfilter.parse("~b")
assert flowfilter.parse("~q")
Reported by Pylint.
test/mitmproxy/proxy/layers/http/test_http.py
268 issues
Line: 1
Column: 1
import pytest
from mitmproxy.connection import ConnectionState, Server
from mitmproxy.flow import Error
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
Reported by Pylint.
Line: 3
Column: 1
import pytest
from mitmproxy.connection import ConnectionState, Server
from mitmproxy.flow import Error
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
Reported by Pylint.
Line: 4
Column: 1
import pytest
from mitmproxy.connection import ConnectionState, Server
from mitmproxy.flow import Error
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
Reported by Pylint.
Line: 5
Column: 1
from mitmproxy.connection import ConnectionState, Server
from mitmproxy.flow import Error
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
Reported by Pylint.
Line: 6
Column: 1
from mitmproxy.connection import ConnectionState, Server
from mitmproxy.flow import Error
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
from mitmproxy.proxy.layers.http import HTTPMode
Reported by Pylint.
Line: 7
Column: 1
from mitmproxy.flow import Error
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
from mitmproxy.proxy.layers.http import HTTPMode
from mitmproxy.proxy.layers.tcp import TcpMessageInjected, TcpStartHook
Reported by Pylint.
Line: 8
Column: 1
from mitmproxy.http import HTTPFlow, Response
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
from mitmproxy.proxy.layers.http import HTTPMode
from mitmproxy.proxy.layers.tcp import TcpMessageInjected, TcpStartHook
from mitmproxy.proxy.layers.websocket import WebsocketStartHook
Reported by Pylint.
Line: 9
Column: 1
from mitmproxy.net.server_spec import ServerSpec
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
from mitmproxy.proxy.layers.http import HTTPMode
from mitmproxy.proxy.layers.tcp import TcpMessageInjected, TcpStartHook
from mitmproxy.proxy.layers.websocket import WebsocketStartHook
from mitmproxy.tcp import TCPFlow, TCPMessage
Reported by Pylint.
Line: 10
Column: 1
from mitmproxy.proxy import layer
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
from mitmproxy.proxy.layers.http import HTTPMode
from mitmproxy.proxy.layers.tcp import TcpMessageInjected, TcpStartHook
from mitmproxy.proxy.layers.websocket import WebsocketStartHook
from mitmproxy.tcp import TCPFlow, TCPMessage
from test.mitmproxy.proxy.tutils import Placeholder, Playbook, reply, reply_next_layer
Reported by Pylint.
Line: 11
Column: 1
from mitmproxy.proxy.commands import CloseConnection, Log, OpenConnection, SendData
from mitmproxy.proxy.events import ConnectionClosed, DataReceived
from mitmproxy.proxy.layers import TCPLayer, http, tls
from mitmproxy.proxy.layers.http import HTTPMode
from mitmproxy.proxy.layers.tcp import TcpMessageInjected, TcpStartHook
from mitmproxy.proxy.layers.websocket import WebsocketStartHook
from mitmproxy.tcp import TCPFlow, TCPMessage
from test.mitmproxy.proxy.tutils import Placeholder, Playbook, reply, reply_next_layer
Reported by Pylint.
test/mitmproxy/addons/test_view.py
259 issues
Line: 1
Column: 1
import pytest
from mitmproxy.test import tflow
from mitmproxy.addons import view
from mitmproxy import flowfilter
from mitmproxy import exceptions
from mitmproxy import io
from mitmproxy.test import taddons
Reported by Pylint.
Line: 93
Column: 16
v.request(f)
assert list(v) == [f]
assert len(v._store) == 1
assert v.store_count() == 1
f2 = tft(start=3)
v.request(f2)
assert list(v) == [f, f2]
Reported by Pylint.
Line: 101
Column: 16
assert list(v) == [f, f2]
v.request(f2)
assert list(v) == [f, f2]
assert len(v._store) == 2
assert v.inbounds(0)
assert not v.inbounds(-1)
assert not v.inbounds(100)
Reported by Pylint.
Line: 112
Column: 16
assert list(v) == [f, f3, f2]
v.request(f3)
assert list(v) == [f, f3, f2]
assert len(v._store) == 3
f.marked = not f.marked
f2.marked = not f2.marked
v.clear_not_marked()
assert list(v) == [f, f2]
Reported by Pylint.
Line: 119
Column: 16
v.clear_not_marked()
assert list(v) == [f, f2]
assert len(v) == 2
assert len(v._store) == 2
v.clear()
assert len(v) == 0
assert len(v._store) == 0
Reported by Pylint.
Line: 123
Column: 16
v.clear()
assert len(v) == 0
assert len(v._store) == 0
def test_simple_tcp():
v = view.View()
f = tflow.ttcpflow()
Reported by Pylint.
Line: 150
Column: 16
assert(len(v)) == 4
v.set_filter_cmd("~m get")
assert [i.request.method for i in v] == ["GET", "GET"]
assert len(v._store) == 4
v.set_filter(None)
assert len(v) == 4
v.toggle_marked()
assert len(v) == 0
Reported by Pylint.
Line: 374
Column: 9
assert v[-1].request.timestamp_start == 1
assert v[2].request.timestamp_start == 1
with pytest.raises(IndexError):
v[5]
with pytest.raises(IndexError):
v[-5]
assert v._bisect(v[0]) == 1
assert v._bisect(v[2]) == 3
Reported by Pylint.
Line: 376
Column: 9
with pytest.raises(IndexError):
v[5]
with pytest.raises(IndexError):
v[-5]
assert v._bisect(v[0]) == 1
assert v._bisect(v[2]) == 3
Reported by Pylint.
Line: 378
Column: 12
with pytest.raises(IndexError):
v[-5]
assert v._bisect(v[0]) == 1
assert v._bisect(v[2]) == 3
def test_update():
v = view.View()
Reported by Pylint.
test/mitmproxy/addons/test_serverplayback.py
203 issues
Line: 3
Column: 1
import urllib
import pytest
import mitmproxy.test.tutils
from mitmproxy import exceptions
from mitmproxy import io
from mitmproxy.addons import serverplayback
from mitmproxy.test import taddons
Reported by Pylint.
Line: 71
Column: 31
r.request.host = "address"
r2.request.host = "address"
assert sp._hash(r) == sp._hash(r2)
r2.request.host = "wrong_address"
assert sp._hash(r) == sp._hash(r2)
def test_ignore_content():
Reported by Pylint.
Line: 71
Column: 16
r.request.host = "address"
r2.request.host = "address"
assert sp._hash(r) == sp._hash(r2)
r2.request.host = "wrong_address"
assert sp._hash(r) == sp._hash(r2)
def test_ignore_content():
Reported by Pylint.
Line: 73
Column: 31
r2.request.host = "address"
assert sp._hash(r) == sp._hash(r2)
r2.request.host = "wrong_address"
assert sp._hash(r) == sp._hash(r2)
def test_ignore_content():
s = serverplayback.ServerPlayback()
with taddons.context(s) as tctx:
Reported by Pylint.
Line: 73
Column: 16
r2.request.host = "address"
assert sp._hash(r) == sp._hash(r2)
r2.request.host = "wrong_address"
assert sp._hash(r) == sp._hash(r2)
def test_ignore_content():
s = serverplayback.ServerPlayback()
with taddons.context(s) as tctx:
Reported by Pylint.
Line: 86
Column: 16
r.request.content = b"foo"
r2.request.content = b"foo"
assert s._hash(r) == s._hash(r2)
r2.request.content = b"bar"
assert not s._hash(r) == s._hash(r2)
tctx.configure(s, server_replay_ignore_content=True)
r = tflow.tflow(resp=True)
Reported by Pylint.
Line: 86
Column: 30
r.request.content = b"foo"
r2.request.content = b"foo"
assert s._hash(r) == s._hash(r2)
r2.request.content = b"bar"
assert not s._hash(r) == s._hash(r2)
tctx.configure(s, server_replay_ignore_content=True)
r = tflow.tflow(resp=True)
Reported by Pylint.
Line: 88
Column: 34
r2.request.content = b"foo"
assert s._hash(r) == s._hash(r2)
r2.request.content = b"bar"
assert not s._hash(r) == s._hash(r2)
tctx.configure(s, server_replay_ignore_content=True)
r = tflow.tflow(resp=True)
r2 = tflow.tflow(resp=True)
r.request.content = b"foo"
Reported by Pylint.
Line: 88
Column: 20
r2.request.content = b"foo"
assert s._hash(r) == s._hash(r2)
r2.request.content = b"bar"
assert not s._hash(r) == s._hash(r2)
tctx.configure(s, server_replay_ignore_content=True)
r = tflow.tflow(resp=True)
r2 = tflow.tflow(resp=True)
r.request.content = b"foo"
Reported by Pylint.
Line: 95
Column: 30
r2 = tflow.tflow(resp=True)
r.request.content = b"foo"
r2.request.content = b"foo"
assert s._hash(r) == s._hash(r2)
r2.request.content = b"bar"
assert s._hash(r) == s._hash(r2)
r2.request.content = b""
assert s._hash(r) == s._hash(r2)
r2.request.content = None
Reported by Pylint.
mitmproxy/flowfilter.py
184 issues
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
Line: 537
Column: 28
# ones.
parts = []
for cls in filter_unary:
f = pp.Literal(f"~{cls.code}") + pp.WordEnd()
f.setParseAction(cls.make)
parts.append(f)
# This is a bit of a hack to simulate Word(pyparsing_unicode.printables),
# which has a horrible performance with len(pyparsing.pyparsing_unicode.printables) == 1114060
Reported by Pylint.
mitmproxy/contrib/urwid/raw_display.py
182 issues
Line: 39
Column: 5
if os.name == "nt":
IS_WINDOWS = True
from . import win32
from ctypes import byref
else:
IS_WINDOWS = False
import fcntl
import termios
Reported by Pylint.
Line: 47
Column: 1
import termios
import tty
from urwid import util
from urwid import escape
from urwid.display_common import BaseScreen, RealTerminal, \
UPDATE_PALETTE_ENTRY, AttrSpec, UNPRINTABLE_TRANS_TABLE, \
INPUT_DESCRIPTORS_CHANGED
from urwid import signals
Reported by Pylint.
Line: 48
Column: 1
import tty
from urwid import util
from urwid import escape
from urwid.display_common import BaseScreen, RealTerminal, \
UPDATE_PALETTE_ENTRY, AttrSpec, UNPRINTABLE_TRANS_TABLE, \
INPUT_DESCRIPTORS_CHANGED
from urwid import signals
from urwid.compat import PYTHON3, bytes, B
Reported by Pylint.
Line: 49
Column: 1
from urwid import util
from urwid import escape
from urwid.display_common import BaseScreen, RealTerminal, \
UPDATE_PALETTE_ENTRY, AttrSpec, UNPRINTABLE_TRANS_TABLE, \
INPUT_DESCRIPTORS_CHANGED
from urwid import signals
from urwid.compat import PYTHON3, bytes, B
Reported by Pylint.
Line: 52
Column: 1
from urwid.display_common import BaseScreen, RealTerminal, \
UPDATE_PALETTE_ENTRY, AttrSpec, UNPRINTABLE_TRANS_TABLE, \
INPUT_DESCRIPTORS_CHANGED
from urwid import signals
from urwid.compat import PYTHON3, bytes, B
from subprocess import Popen, PIPE
STDIN = object()
Reported by Pylint.
Line: 53
Column: 1
UPDATE_PALETTE_ENTRY, AttrSpec, UNPRINTABLE_TRANS_TABLE, \
INPUT_DESCRIPTORS_CHANGED
from urwid import signals
from urwid.compat import PYTHON3, bytes, B
from subprocess import Popen, PIPE
STDIN = object()
Reported by Pylint.
Line: 662
Column: 17
def determine_button_release( flag ):
if b & 4 and last & 1:
append_button( 0 + flag )
next |= 1
if b & 2 and last & 2:
append_button( 1 + flag )
next |= 2
if b & 1 and last & 4:
append_button( 2 + flag )
Reported by Pylint.
Line: 24
Column: 1
from __future__ import division, print_function
"""
Direct terminal UI implementation
"""
import os
import select
Reported by Pylint.
Line: 53
Column: 1
UPDATE_PALETTE_ENTRY, AttrSpec, UNPRINTABLE_TRANS_TABLE, \
INPUT_DESCRIPTORS_CHANGED
from urwid import signals
from urwid.compat import PYTHON3, bytes, B
from subprocess import Popen, PIPE
STDIN = object()
Reported by Pylint.
Line: 61
Column: 24
class Screen(BaseScreen, RealTerminal):
def __init__(self, input=STDIN, output=sys.stdout):
"""Initialize a screen that directly prints escape codes to an output
terminal.
"""
super(Screen, self).__init__()
self._pal_escape = {}
Reported by Pylint.