diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/addons/events.py | 5 | ||||
-rw-r--r-- | examples/complex/dup_and_replay.py | 14 | ||||
-rw-r--r-- | examples/complex/har_dump.py | 8 | ||||
-rw-r--r-- | examples/complex/sslstrip.py | 2 | ||||
-rwxr-xr-x | examples/complex/xss_scanner.py | 4 | ||||
-rw-r--r-- | examples/simple/README.md | 2 | ||||
-rw-r--r-- | examples/simple/filter_flows.py | 2 | ||||
-rw-r--r-- | examples/simple/io_write_dumpfile.py | 2 |
8 files changed, 20 insertions, 19 deletions
diff --git a/examples/addons/events.py b/examples/addons/events.py index 674ab4c8..cd714ba0 100644 --- a/examples/addons/events.py +++ b/examples/addons/events.py @@ -167,11 +167,6 @@ class Events: loaded. """ - def tick(self): - """ - A regular ticker - called approximately once every 100ms. - """ - def update(self, flows: typing.Sequence[mitmproxy.flow.Flow]): """ Update is called when one or more flow objects have been modified, diff --git a/examples/complex/dup_and_replay.py b/examples/complex/dup_and_replay.py index 2baa1ea6..adcebff3 100644 --- a/examples/complex/dup_and_replay.py +++ b/examples/complex/dup_and_replay.py @@ -2,7 +2,13 @@ from mitmproxy import ctx def request(flow): - f = flow.copy() - ctx.master.view.add(f) - f.request.path = "/changed" - ctx.master.replay_request(f, block=True) + # Avoid an infinite loop by not replaying already replayed requests + if flow.request.is_replay: + return + flow = flow.copy() + # Only interactive tools have a view. If we have one, add a duplicate entry + # for our flow. + if "view" in ctx.master.addons: + ctx.master.commands.call("view.add", [flow]) + flow.request.path = "/changed" + ctx.master.commands.call("replay.client", [flow]) diff --git a/examples/complex/har_dump.py b/examples/complex/har_dump.py index 9e287a19..040c7d28 100644 --- a/examples/complex/har_dump.py +++ b/examples/complex/har_dump.py @@ -20,11 +20,11 @@ from mitmproxy import ctx from mitmproxy.utils import strutils from mitmproxy.net.http import cookies -HAR = {} # type: typing.Dict +HAR: typing.Dict = {} # A list of server seen till now is maintained so we can avoid # using 'connect' time for entries that use an existing connection. -SERVERS_SEEN = set() # type: typing.Set[connections.ServerConnection] +SERVERS_SEEN: typing.Set[connections.ServerConnection] = set() def load(l): @@ -155,12 +155,12 @@ def done(): Called once on script shutdown, after any other events. """ if ctx.options.hardump: - json_dump = json.dumps(HAR, indent=2) # type: str + json_dump: str = json.dumps(HAR, indent=2) if ctx.options.hardump == '-': mitmproxy.ctx.log(json_dump) else: - raw = json_dump.encode() # type: bytes + raw: bytes = json_dump.encode() if ctx.options.hardump.endswith('.zhar'): raw = zlib.compress(raw, 9) diff --git a/examples/complex/sslstrip.py b/examples/complex/sslstrip.py index c3f8c4f7..c862536f 100644 --- a/examples/complex/sslstrip.py +++ b/examples/complex/sslstrip.py @@ -9,7 +9,7 @@ import typing # noqa from mitmproxy import http # set of SSL/TLS capable hosts -secure_hosts = set() # type: typing.Set[str] +secure_hosts: typing.Set[str] = set() def request(flow: http.HTTPFlow) -> None: diff --git a/examples/complex/xss_scanner.py b/examples/complex/xss_scanner.py index 0c0dd0f3..55fc2fe7 100755 --- a/examples/complex/xss_scanner.py +++ b/examples/complex/xss_scanner.py @@ -95,7 +95,7 @@ def find_unclaimed_URLs(body: str, requestUrl: bytes) -> None: return None class ScriptURLExtractor(HTMLParser): - script_URLs = [] # type: List[str] + script_URLs: List[str] = [] def handle_starttag(self, tag, attrs): if (tag == "script" or tag == "iframe") and "src" in [name for name, value in attrs]: @@ -254,7 +254,7 @@ def paths_to_text(html: str, string: str) -> List[str]: class PathHTMLParser(HTMLParser): currentPath = "" - paths = [] # type: List[str] + paths: List[str] = [] def handle_starttag(self, tag, attrs): self.currentPath += ("/" + tag) diff --git a/examples/simple/README.md b/examples/simple/README.md index d140a84c..2fafdd5a 100644 --- a/examples/simple/README.md +++ b/examples/simple/README.md @@ -14,5 +14,5 @@ | modify_querystring.py | Modify HTTP query strings. | | redirect_requests.py | Redirect a request to a different server. | | send_reply_from_proxy.py | Send a HTTP response directly from the proxy. | -| upsidedownternet.py | Turn all images upside down. | +| internet_in_mirror.py | Turn all images upside down. | | wsgi_flask_app.py | Embed a WSGI app into mitmproxy. | diff --git a/examples/simple/filter_flows.py b/examples/simple/filter_flows.py index 70979591..d252089c 100644 --- a/examples/simple/filter_flows.py +++ b/examples/simple/filter_flows.py @@ -7,7 +7,7 @@ from mitmproxy import ctx, http class Filter: def __init__(self): - self.filter = None # type: flowfilter.TFilter + self.filter: flowfilter.TFilter = None def configure(self, updated): self.filter = flowfilter.parse(ctx.options.flowfilter) diff --git a/examples/simple/io_write_dumpfile.py b/examples/simple/io_write_dumpfile.py index be6e4121..c8c59c62 100644 --- a/examples/simple/io_write_dumpfile.py +++ b/examples/simple/io_write_dumpfile.py @@ -13,7 +13,7 @@ import typing # noqa class Writer: def __init__(self, path: str) -> None: - self.f = open(path, "wb") # type: typing.IO[bytes] + self.f: typing.IO[bytes] = open(path, "wb") self.w = io.FlowWriter(self.f) def response(self, flow: http.HTTPFlow) -> None: |