The following issues were found
mitmproxy/contentviews/javascript.py
5 issues
Line: 61
Column: 1
res = beautify(data)
return "JavaScript", base.format_text(res)
def render_priority(self, data: bytes, *, content_type: Optional[str] = None, **metadata) -> float:
return float(content_type in self.__content_types)
Reported by Pylint.
Line: 1
Column: 1
import io
import re
from typing import Optional
from mitmproxy.utils import strutils
from mitmproxy.contentviews import base
DELIMITERS = '{};\n'
SPECIAL_AREAS = (
Reported by Pylint.
Line: 20
Column: 1
)
def beautify(data):
data = strutils.escape_special_areas(
data,
SPECIAL_AREAS,
DELIMITERS
)
Reported by Pylint.
Line: 48
Column: 1
return data
class ViewJavaScript(base.View):
name = "JavaScript"
__content_types = (
"application/x-javascript",
"application/javascript",
"text/javascript"
Reported by Pylint.
Line: 61
Column: 1
res = beautify(data)
return "JavaScript", base.format_text(res)
def render_priority(self, data: bytes, *, content_type: Optional[str] = None, **metadata) -> float:
return float(content_type in self.__content_types)
Reported by Pylint.
test/mitmproxy/data/addonscripts/stream_modify.py
5 issues
Line: 1
Column: 1
from mitmproxy import ctx
def modify(chunks):
for chunk in chunks:
yield chunk.replace(b"foo", b"bar")
def running():
ctx.log.info("stream_modify running")
Reported by Pylint.
Line: 1
Column: 1
from mitmproxy import ctx
def modify(chunks):
for chunk in chunks:
yield chunk.replace(b"foo", b"bar")
def running():
ctx.log.info("stream_modify running")
Reported by Pylint.
Line: 3
Column: 1
from mitmproxy import ctx
def modify(chunks):
for chunk in chunks:
yield chunk.replace(b"foo", b"bar")
def running():
ctx.log.info("stream_modify running")
Reported by Pylint.
Line: 8
Column: 1
yield chunk.replace(b"foo", b"bar")
def running():
ctx.log.info("stream_modify running")
def responseheaders(flow):
flow.response.stream = modify
Reported by Pylint.
Line: 12
Column: 1
ctx.log.info("stream_modify running")
def responseheaders(flow):
flow.response.stream = modify
Reported by Pylint.
examples/addons/wsgi-flask-app.py
5 issues
Line: 9
Column: 1
a single simplest-possible page.
"""
from flask import Flask
from mitmproxy.addons import asgiapp
app = Flask("proxapp")
@app.route('/')
Reported by Pylint.
Line: 1
Column: 1
"""
Host a WSGI app in mitmproxy.
This example shows how to graft a WSGI app onto mitmproxy. In this
instance, we're using the Flask framework (http://flask.pocoo.org/) to expose
a single simplest-possible page.
"""
from flask import Flask
from mitmproxy.addons import asgiapp
Reported by Pylint.
Line: 15
Column: 1
@app.route('/')
def hello_world() -> str:
return 'Hello World!'
addons = [
# Host app at the magic domain "example.com" on port 80. Requests to this
Reported by Pylint.
Line: 23
Column: 1
# Host app at the magic domain "example.com" on port 80. Requests to this
# domain and port combination will now be routed to the WSGI app instance.
asgiapp.WSGIApp(app, "example.com", 80)
# SSL works too, but the magic domain needs to be resolvable from the mitmproxy machine due to mitmproxy's design.
# mitmproxy will connect to said domain and use serve its certificate (unless --no-upstream-cert is set)
# but won't send any data.
# mitmproxy.ctx.master.apps.add(app, "example.com", 443)
]
Reported by Pylint.
Line: 24
Column: 1
# domain and port combination will now be routed to the WSGI app instance.
asgiapp.WSGIApp(app, "example.com", 80)
# SSL works too, but the magic domain needs to be resolvable from the mitmproxy machine due to mitmproxy's design.
# mitmproxy will connect to said domain and use serve its certificate (unless --no-upstream-cert is set)
# but won't send any data.
# mitmproxy.ctx.master.apps.add(app, "example.com", 443)
]
Reported by Pylint.
examples/addons/anatomy.py
5 issues
Line: 6
Column: 1
Run as follows: mitmproxy -s anatomy.py
"""
from mitmproxy import ctx
class Counter:
def __init__(self):
self.num = 0
Reported by Pylint.
Line: 13
Column: 23
def __init__(self):
self.num = 0
def request(self, flow):
self.num = self.num + 1
ctx.log.info("We've seen %d flows" % self.num)
addons = [
Reported by Pylint.
Line: 9
Column: 1
from mitmproxy import ctx
class Counter:
def __init__(self):
self.num = 0
def request(self, flow):
self.num = self.num + 1
Reported by Pylint.
Line: 9
Column: 1
from mitmproxy import ctx
class Counter:
def __init__(self):
self.num = 0
def request(self, flow):
self.num = self.num + 1
Reported by Pylint.
Line: 13
Column: 5
def __init__(self):
self.num = 0
def request(self, flow):
self.num = self.num + 1
ctx.log.info("We've seen %d flows" % self.num)
addons = [
Reported by Pylint.
test/mitmproxy/data/addonscripts/concurrent_decorator.py
5 issues
Line: 3
Column: 1
import time
import sys
from mitmproxy.script import concurrent
@concurrent
def request(flow):
time.sleep(0.1)
Reported by Pylint.
Line: 2
Column: 1
import time
import sys
from mitmproxy.script import concurrent
@concurrent
def request(flow):
time.sleep(0.1)
Reported by Pylint.
Line: 7
Column: 13
@concurrent
def request(flow):
time.sleep(0.1)
Reported by Pylint.
Line: 1
Column: 1
import time
import sys
from mitmproxy.script import concurrent
@concurrent
def request(flow):
time.sleep(0.1)
Reported by Pylint.
Line: 7
Column: 1
@concurrent
def request(flow):
time.sleep(0.1)
Reported by Pylint.
test/helper_tools/passive_close.py
5 issues
Line: 1
Column: 1
import socketserver
from time import sleep
class service(socketserver.BaseRequestHandler):
def handle(self):
data = 'dummy'
print("Client connected with ", self.client_address)
Reported by Pylint.
Line: 5
Column: 1
from time import sleep
class service(socketserver.BaseRequestHandler):
def handle(self):
data = 'dummy'
print("Client connected with ", self.client_address)
while True:
Reported by Pylint.
Line: 5
Column: 1
from time import sleep
class service(socketserver.BaseRequestHandler):
def handle(self):
data = 'dummy'
print("Client connected with ", self.client_address)
while True:
Reported by Pylint.
Line: 14
Column: 16
self.request.send(
"HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 7\r\n\r\ncontent")
data = self.request.recv(1024)
if not len(data):
print("Connection closed by remote: ", self.client_address)
sleep(3600)
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
Reported by Pylint.
Line: 19
Column: 1
sleep(3600)
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
pass
server = ThreadedTCPServer(('', 1520), service)
server.serve_forever()
Reported by Pylint.
test/mitmproxy/coretypes/test_basethread.py
5 issues
Line: 7
Column: 44
def test_basethread():
t = basethread.BaseThread('foobar')
assert re.match(r'foobar - age: \d+s', t._threadinfo())
Reported by Pylint.
Line: 1
Column: 1
import re
from mitmproxy.coretypes import basethread
def test_basethread():
t = basethread.BaseThread('foobar')
assert re.match(r'foobar - age: \d+s', t._threadinfo())
Reported by Pylint.
Line: 5
Column: 1
from mitmproxy.coretypes import basethread
def test_basethread():
t = basethread.BaseThread('foobar')
assert re.match(r'foobar - age: \d+s', t._threadinfo())
Reported by Pylint.
Line: 6
Column: 5
def test_basethread():
t = basethread.BaseThread('foobar')
assert re.match(r'foobar - age: \d+s', t._threadinfo())
Reported by Pylint.
Line: 7
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_basethread():
t = basethread.BaseThread('foobar')
assert re.match(r'foobar - age: \d+s', t._threadinfo())
Reported by Bandit.
examples/addons/log-events.py
5 issues
Line: 2
Column: 1
"""Post messages to mitmproxy's event log."""
from mitmproxy import ctx
def load(l):
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
Reported by Pylint.
Line: 5
Column: 10
from mitmproxy import ctx
def load(l):
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
Reported by Pylint.
Line: 1
Column: 1
"""Post messages to mitmproxy's event log."""
from mitmproxy import ctx
def load(l):
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
Reported by Pylint.
Line: 5
Column: 1
from mitmproxy import ctx
def load(l):
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
Reported by Pylint.
Line: 5
Column: 1
from mitmproxy import ctx
def load(l):
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
Reported by Pylint.
test/mitmproxy/proxy/conftest.py
4 issues
Line: 3
Column: 1
import os
import pytest
from hypothesis import settings
from mitmproxy import connection, options
from mitmproxy.addons.proxyserver import Proxyserver
from mitmproxy.addons.termlog import TermLog
from mitmproxy.proxy import context
Reported by Pylint.
Line: 4
Column: 1
import os
import pytest
from hypothesis import settings
from mitmproxy import connection, options
from mitmproxy.addons.proxyserver import Proxyserver
from mitmproxy.addons.termlog import TermLog
from mitmproxy.proxy import context
Reported by Pylint.
Line: 1
Column: 1
import os
import pytest
from hypothesis import settings
from mitmproxy import connection, options
from mitmproxy.addons.proxyserver import Proxyserver
from mitmproxy.addons.termlog import TermLog
from mitmproxy.proxy import context
Reported by Pylint.
Line: 13
Column: 1
@pytest.fixture
def tctx() -> context.Context:
opts = options.Options()
Proxyserver().load(opts)
TermLog().load(opts)
return context.Context(
connection.Client(
Reported by Pylint.
mitmproxy/platform/linux.py
4 issues
Line: 1
Column: 1
import socket
import struct
import typing
# Python's socket module does not have these constants
SO_ORIGINAL_DST = 80
SOL_IPV6 = 41
Reported by Pylint.
Line: 10
Column: 1
SOL_IPV6 = 41
def original_addr(csock: socket.socket) -> typing.Tuple[str, int]:
# Get the original destination on Linux.
# In theory, this can be done using the following syscalls:
# sock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16)
# sock.getsockopt(SOL_IPV6, SO_ORIGINAL_DST, 28)
#
Reported by Pylint.
Line: 29
Column: 9
# with buflen=8 doesn't work.
dst = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16)
port, raw_ip = struct.unpack_from("!2xH4s", dst)
ip = socket.inet_ntop(socket.AF_INET, raw_ip)
else:
dst = csock.getsockopt(SOL_IPV6, SO_ORIGINAL_DST, 28)
port, raw_ip = struct.unpack_from("!2xH4x16s", dst)
ip = socket.inet_ntop(socket.AF_INET6, raw_ip)
return ip, port
Reported by Pylint.
Line: 33
Column: 9
else:
dst = csock.getsockopt(SOL_IPV6, SO_ORIGINAL_DST, 28)
port, raw_ip = struct.unpack_from("!2xH4x16s", dst)
ip = socket.inet_ntop(socket.AF_INET6, raw_ip)
return ip, port
Reported by Pylint.