mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
parent
8361c81cdf
commit
8c2428c9d3
351 changed files with 4686 additions and 2808 deletions
|
|
@ -4,7 +4,9 @@ protobuf messages based on a user defined rule set.
|
|||
|
||||
"""
|
||||
from mitmproxy import contentviews
|
||||
from mitmproxy.contentviews.grpc import ViewGrpcProtobuf, ViewConfig, ProtoParser
|
||||
from mitmproxy.contentviews.grpc import ProtoParser
|
||||
from mitmproxy.contentviews.grpc import ViewConfig
|
||||
from mitmproxy.contentviews.grpc import ViewGrpcProtobuf
|
||||
|
||||
config: ViewConfig = ViewConfig()
|
||||
config.parser_rules = [
|
||||
|
|
@ -68,13 +70,13 @@ config.parser_rules = [
|
|||
tag_prefixes=["1.5.1", "1.5.3", "1.5.4", "1.5.5", "1.5.6"],
|
||||
name="latitude",
|
||||
intended_decoding=ProtoParser.DecodedTypes.double,
|
||||
), # noqa: E501
|
||||
),
|
||||
ProtoParser.ParserFieldDefinition(
|
||||
tag=".2",
|
||||
tag_prefixes=["1.5.1", "1.5.3", "1.5.4", "1.5.5", "1.5.6"],
|
||||
name="longitude",
|
||||
intended_decoding=ProtoParser.DecodedTypes.double,
|
||||
), # noqa: E501
|
||||
),
|
||||
ProtoParser.ParserFieldDefinition(tag="7", name="app"),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ The content view API is explained in the mitmproxy.contentviews module.
|
|||
"""
|
||||
from typing import Optional
|
||||
|
||||
from mitmproxy import contentviews, flow
|
||||
from mitmproxy import contentviews
|
||||
from mitmproxy import flow
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
Use mitmproxy's filter pattern in scripts.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from mitmproxy import http
|
||||
from mitmproxy import flowfilter
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
class Filter:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ Modifying streamed responses is tricky and brittle:
|
|||
- If you want to replace all occurrences of "foobar", make sure to catch the cases
|
||||
where one chunk ends with [...]foo" and the next starts with "bar[...].
|
||||
"""
|
||||
from typing import Iterable, Union
|
||||
from collections.abc import Iterable
|
||||
from typing import Union
|
||||
|
||||
|
||||
def modify(data: bytes) -> Union[bytes, Iterable[bytes]]:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ the body is fully transmitted. Such trailers need to be announced in the initial
|
|||
headers by name, so the receiving endpoint can wait and read them after the
|
||||
body.
|
||||
"""
|
||||
|
||||
from mitmproxy import http
|
||||
from mitmproxy.http import Headers
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
"""
|
||||
Read a mitmproxy dump file.
|
||||
"""
|
||||
from mitmproxy import io, http
|
||||
from mitmproxy.exceptions import FlowReadException
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
from mitmproxy import http
|
||||
from mitmproxy import io
|
||||
from mitmproxy.exceptions import FlowReadException
|
||||
|
||||
with open(sys.argv[1], "rb") as logfile:
|
||||
freader = io.FlowReader(logfile)
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import random
|
|||
import sys
|
||||
from typing import BinaryIO
|
||||
|
||||
from mitmproxy import io, http
|
||||
from mitmproxy import http
|
||||
from mitmproxy import io
|
||||
|
||||
|
||||
class Writer:
|
||||
|
|
|
|||
|
|
@ -8,4 +8,7 @@ def load(l):
|
|||
logging.info("This is some informative text.")
|
||||
logging.warning("This is a warning.")
|
||||
logging.error("This is an error.")
|
||||
logging.log(ALERT, "This is an alert. It has the same urgency as info, but will also pop up in the status bar.")
|
||||
logging.log(
|
||||
ALERT,
|
||||
"This is an alert. It has the same urgency as info, but will also pop up in the status bar.",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ Make events hooks non-blocking using async or @concurrent
|
|||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import time
|
||||
|
||||
from mitmproxy.script import concurrent
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ Usage:
|
|||
"""
|
||||
import logging
|
||||
|
||||
from mitmproxy import ctx, http
|
||||
from mitmproxy import ctx
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
def request(flow: http.HTTPFlow) -> None:
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ Example Invocation:
|
|||
"""
|
||||
import logging
|
||||
|
||||
from mitmproxy.utils import strutils
|
||||
from mitmproxy import tcp
|
||||
from mitmproxy.utils import strutils
|
||||
|
||||
|
||||
def tcp_message(flow: tcp.TCPFlow):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ This example shows how to inject a WebSocket message into a running connection.
|
|||
"""
|
||||
import asyncio
|
||||
|
||||
from mitmproxy import ctx, http
|
||||
from mitmproxy import ctx
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
# Simple example: Inject a message as a response to an event
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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
|
||||
|
||||
app = Flask("proxapp")
|
||||
|
|
@ -24,5 +25,4 @@ addons = [
|
|||
# mitmproxy will connect to said domain and use its certificate but won't send any data.
|
||||
# By using `--set upstream_cert=false` and `--set connection_strategy_lazy` the local certificate is used instead.
|
||||
# asgiapp.WSGIApp(app, "example.com", 443),
|
||||
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue