repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_htpasswd.py
test/mitmproxy/utils/test_htpasswd.py
from pathlib import Path import pytest from mitmproxy.utils import htpasswd def test_sha1(): ht = htpasswd.HtpasswdFile( "user1:{SHA}8FePHnF0saQcTqjG4X96ijuIySo=\n" "user2:{SHA}i+UhJqb95FCnFio2UdWJu1HpV50=\n" "user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=:extra\n" ) assert ht.check_pas...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_sliding_window.py
test/mitmproxy/utils/test_sliding_window.py
from mitmproxy.utils import sliding_window def test_simple(): y = list(sliding_window.window(range(1000, 1005), 1, 2)) assert y == [ # prev this next next2 (None, 1000, 1001, 1002), (1000, 1001, 1002, 1003), (1001, 1002, 1003, 1004), (1002, 1003, 1004, None), ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_typecheck.py
test/mitmproxy/utils/test_typecheck.py
import io import typing from collections.abc import Sequence from typing import Any from typing import Optional from typing import TextIO from typing import Union import pytest from mitmproxy.utils import typecheck class TBase: def __init__(self, bar: int): pass class T(TBase): def __init__(self, ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_vt_codes.py
test/mitmproxy/utils/test_vt_codes.py
import io from mitmproxy.utils.vt_codes import ensure_supported def test_simple(): assert not ensure_supported(io.StringIO())
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_asyncio_utils.py
test/mitmproxy/utils/test_asyncio_utils.py
import asyncio import gc import sys import pytest from mitmproxy.utils import asyncio_utils async def ttask(): await asyncio.sleep(0) asyncio_utils.set_current_task_debug_info(name="newname") await asyncio.sleep(999) async def test_simple(monkeypatch): monkeypatch.setenv("PYTEST_CURRENT_TEST", "te...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/__init__.py
test/mitmproxy/utils/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_arg_check.py
test/mitmproxy/utils/test_arg_check.py
import contextlib import io from unittest import mock import pytest from mitmproxy.utils import arg_check @pytest.mark.parametrize( "arg, output", [ (["-T"], "-T is deprecated, please use --mode transparent instead"), (["-U"], "-U is deprecated, please use --mode upstream:SPEC instead"), ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_debug.py
test/mitmproxy/utils/test_debug.py
import io import sys from unittest import mock import pytest from mitmproxy.utils import debug @pytest.mark.parametrize("precompiled", [True, False]) def test_dump_system_info_precompiled(precompiled): sys.frozen = None with mock.patch.object(sys, "frozen", precompiled): assert ("binary" in debug.du...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_spec.py
test/mitmproxy/utils/test_spec.py
import pytest from mitmproxy.utils.spec import parse_spec def test_parse_spec(): flow_filter, subject, replacement = parse_spec("/foo/bar/voing") assert flow_filter.pattern == "foo" assert subject == "bar" assert replacement == "voing" flow_filter, subject, replacement = parse_spec("/bar/voing")...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_signals.py
test/mitmproxy/utils/test_signals.py
from unittest import mock import pytest from mitmproxy.utils.signals import AsyncSignal from mitmproxy.utils.signals import SyncSignal def test_sync_signal() -> None: m = mock.Mock() s = SyncSignal(lambda event: None) s.connect(m) s.send("foo") assert m.call_args_list == [mock.call("foo")] ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_emoji.py
test/mitmproxy/utils/test_emoji.py
from mitmproxy.tools.console.common import SYMBOL_MARK from mitmproxy.utils import emoji def test_emoji(): assert emoji.emoji[":default:"] == SYMBOL_MARK
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_strutils.py
test/mitmproxy/utils/test_strutils.py
import pytest from mitmproxy.utils import strutils def test_always_bytes(): assert strutils.always_bytes(bytes(range(256))) == bytes(range(256)) assert strutils.always_bytes("foo") == b"foo" with pytest.raises(ValueError): strutils.always_bytes("\u2605", "ascii") with pytest.raises(TypeError)...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_human.py
test/mitmproxy/utils/test_human.py
import time import pytest from mitmproxy.utils import human def test_format_timestamp(): assert human.format_timestamp(time.time()) def test_format_timestamp_with_milli(): assert human.format_timestamp_with_milli(time.time()) def test_parse_size(): assert human.parse_size("0") == 0 assert human....
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_javascript.py
test/mitmproxy/contentviews/test__view_javascript.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_javascript import beautify from mitmproxy.contentviews._view_javascript import javascript def test_view_javascript(): assert javascript.prettify(b"[1, 2, 3]", Metadata()) assert javascript.prettify(b"[1, 2, 3", Metada...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_socketio.py
test/mitmproxy/contentviews/test__view_socketio.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_socketio import EngineIO from mitmproxy.contentviews._view_socketio import parse_packet from mitmproxy.contentviews._view_socketio import socket_io from mitmproxy.contentviews._view_socketio import SocketIO from mitmproxy.test ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_graphql.py
test/mitmproxy/contentviews/test__view_graphql.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_graphql import format_graphql from mitmproxy.contentviews._view_graphql import format_query_list from mitmproxy.contentviews._view_graphql import graphql def test_render_priority(): assert 2 == graphql.render_priority( ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__api.py
test/mitmproxy/contentviews/test__api.py
import typing from pathlib import Path from ruamel.yaml import YAML import mitmproxy_rs.syntax_highlight from mitmproxy.contentviews._api import Contentview from mitmproxy.contentviews._api import InteractiveContentview from mitmproxy.contentviews._api import Metadata from mitmproxy.contentviews._api import SyntaxHig...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__utils.py
test/mitmproxy/contentviews/test__utils.py
from mitmproxy import tcp from mitmproxy.contentviews._utils import byte_pairs_to_str_pairs from mitmproxy.contentviews._utils import get_data from mitmproxy.contentviews._utils import make_metadata from mitmproxy.contentviews._utils import merge_repeated_keys from mitmproxy.contentviews._utils import yaml_dumps from m...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_json.py
test/mitmproxy/contentviews/test__view_json.py
import pytest from mitmproxy.contentviews import json_view from mitmproxy.contentviews import Metadata def test_view_json(): meta = Metadata() assert json_view.prettify(b"null", meta) assert json_view.prettify(b"{}", meta) with pytest.raises(ValueError): assert not json_view.prettify(b"{", me...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test_base.py
test/mitmproxy/contentviews/test_base.py
import pytest from mitmproxy.contentviews import base def test_format_dict(): d = {"one": "two", "three": "four"} with pytest.deprecated_call(): f_d = base.format_dict(d) assert next(f_d) d = {"adsfa": ""} with pytest.deprecated_call(): f_d = base.format_dict(d) assert next(f...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test___init__.py
test/mitmproxy/contentviews/test___init__.py
from .test__api import FailingPrettifyContentview from mitmproxy.contentviews import ContentviewRegistry from mitmproxy.contentviews import Metadata from mitmproxy.contentviews import prettify_message from mitmproxy.contentviews import raw from mitmproxy.contentviews import registry from mitmproxy.test import taddons f...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_raw.py
test/mitmproxy/contentviews/test__view_raw.py
from mitmproxy.contentviews._api import Metadata from mitmproxy.contentviews._view_raw import raw def test_view_raw(): meta = Metadata() assert raw.prettify(b"foo", meta) # unicode assert raw.prettify("🫠".encode(), meta) == "🫠" # invalid utf8 assert raw.prettify(b"\xff", meta) == r"\xff" d...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__compat.py
test/mitmproxy/contentviews/test__compat.py
from unittest import mock import pytest from mitmproxy.contentviews import _compat from mitmproxy.contentviews.base import View with pytest.deprecated_call(): class MockView(View): def __init__(self, name: str = "mock"): self._name = name self.syntax_highlight = "python" ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_mqtt.py
test/mitmproxy/contentviews/test__view_mqtt.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_mqtt import mqtt @pytest.mark.parametrize( "data,expected_text", [ pytest.param(b"\xc0\x00", "[PINGREQ]", id="PINGREQ"), pytest.param(b"\xd0\x00", "[PINGRESP]", id="PINGRESP"), pytest.param( ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_wbxml.py
test/mitmproxy/contentviews/test__view_wbxml.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_wbxml import wbxml datadir = "mitmproxy/contentviews/test_wbxml_data/" def test_wbxml(tdata): assert wbxml.prettify(b"\x03\x01\x6a\x00", Metadata()) == '<?xml version="1.0" ?>\n' with pytest.raises(Exception): ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__registry.py
test/mitmproxy/contentviews/test__registry.py
from unittest import mock from mitmproxy.contentviews._api import Metadata from mitmproxy.contentviews._registry import ContentviewRegistry from test.mitmproxy.contentviews.test__api import ExampleContentview from test.mitmproxy.contentviews.test__api import FailingRenderPriorityContentview def test_register_trigger...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_css.py
test/mitmproxy/contentviews/test__view_css.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_css import css @pytest.mark.parametrize( "filename", [ "animation-keyframe.css", "blank-lines-and-spaces.css", "block-comment.css", "empty-rule.css", "import-directive.css", ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/__init__.py
test/mitmproxy/contentviews/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_urlencoded.py
test/mitmproxy/contentviews/test__view_urlencoded.py
from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_urlencoded import urlencoded from mitmproxy.net.http import url def test_view_urlencoded(): d = url.encode([("one", "two"), ("three", "four")]).encode() assert urlencoded.prettify(d, Metadata()) == "one: two\nthree: four\n" d =...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_http3.py
test/mitmproxy/contentviews/test__view_http3.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_http3 import http3 from mitmproxy.tcp import TCPMessage from mitmproxy.test import tflow @pytest.mark.parametrize( "data", [ # HEADERS b"\x01\x1d\x00\x00\xd1\xc1\xd7P\x8a\x08\x9d\\\x0b\x81p\xdcx\x0f\x0...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_multipart.py
test/mitmproxy/contentviews/test__view_multipart.py
import pytest from mitmproxy import http from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_multipart import multipart def meta(content_type: str) -> Metadata: return Metadata( content_type=content_type.split(";")[0], http_message=http.Request.make( "POST", ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_xml_html.py
test/mitmproxy/contentviews/test__view_xml_html.py
import pytest from mitmproxy import http from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_xml_html import tokenize from mitmproxy.contentviews._view_xml_html import xml_html datadir = "mitmproxy/contentviews/test_xml_html_data/" def test_simple(tdata): assert xml_html.prettify(b"foo...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_dns.py
test/mitmproxy/contentviews/test__view_dns.py
import struct import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_dns import dns from mitmproxy.tcp import TCPMessage DNS_HTTPS_RECORD_RESPONSE = bytes.fromhex( "00008180000100010000000107746c732d656368036465760000410001c00c004100010000003c00520001000005004b0049fe0d00" ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/test__view_query.py
test/mitmproxy/contentviews/test__view_query.py
import pytest from mitmproxy.contentviews import Metadata from mitmproxy.contentviews._view_query import query from mitmproxy.test import tutils def test_view_query(): d = "" req = tutils.treq() req.query = [("foo", "bar"), ("foo", "baz")] out = query.prettify(d, Metadata(http_message=req)) asser...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/_view_image/test_view.py
test/mitmproxy/contentviews/_view_image/test_view.py
from mitmproxy.contentviews import image from mitmproxy.contentviews import Metadata def test_view_image(tdata): for img in [ "mitmproxy/data/image.png", "mitmproxy/data/image.gif", "mitmproxy/data/all.jpeg", "mitmproxy/data/image.ico", ]: with open(tdata.path(img), "rb...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/_view_image/test_image_parser.py
test/mitmproxy/contentviews/_view_image/test_image_parser.py
import pytest from mitmproxy.contentviews._view_image import image_parser @pytest.mark.parametrize( "filename, metadata", { # no textual data "mitmproxy/data/image_parser/ct0n0g04.png": [ ("Format", "Portable network graphics"), ("Size", "32 x 32 px"), ("ga...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/contentviews/_view_image/__init__.py
test/mitmproxy/contentviews/_view_image/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/script/test_concurrent.py
test/mitmproxy/script/test_concurrent.py
import asyncio import os import time import pytest from mitmproxy.test import taddons from mitmproxy.test import tflow class TestConcurrent: @pytest.mark.parametrize( "addon", ["concurrent_decorator.py", "concurrent_decorator_class.py"] ) async def test_concurrent(self, addon, tdata): wi...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/script/__init__.py
test/mitmproxy/script/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/import_error.py
test/mitmproxy/data/addonscripts/import_error.py
import nonexistent nonexistent.foo()
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/stream_modify.py
test/mitmproxy/data/addonscripts/stream_modify.py
import logging def modify(chunks): for chunk in chunks: yield chunk.replace(b"foo", b"bar") def running(): logging.info("stream_modify running") def responseheaders(flow): flow.response.stream = modify
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/tcp_stream_modify.py
test/mitmproxy/data/addonscripts/tcp_stream_modify.py
def tcp_message(flow): message = flow.messages[-1] if not message.from_client: message.content = message.content.replace(b"foo", b"bar")
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/error.py
test/mitmproxy/data/addonscripts/error.py
import logging def load(loader): logging.info("error load") def request(flow): raise ValueError("Error!")
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/load_error.py
test/mitmproxy/data/addonscripts/load_error.py
def load(_): raise ValueError()
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/concurrent_decorator_class.py
test/mitmproxy/data/addonscripts/concurrent_decorator_class.py
import time from mitmproxy.script import concurrent class ConcurrentClass: @concurrent def request(self, flow): time.sleep(0.25) @concurrent async def requestheaders(self, flow): time.sleep(0.25) addons = [ConcurrentClass()]
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/concurrent_decorator.py
test/mitmproxy/data/addonscripts/concurrent_decorator.py
import time from mitmproxy.script import concurrent @concurrent def request(flow): time.sleep(0.25) @concurrent async def requestheaders(flow): time.sleep(0.25)
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/shutdown.py
test/mitmproxy/data/addonscripts/shutdown.py
from mitmproxy import ctx def running(): ctx.master.shutdown()
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/addon.py
test/mitmproxy/data/addonscripts/addon.py
import logging event_log = [] class Addon: @property def event_log(self): return event_log def load(self, opts): logging.info("addon running") event_log.append("addonload") def configure(self, updated): event_log.append("addonconfigure") def configure(updated): ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/configure.py
test/mitmproxy/data/addonscripts/configure.py
from typing import Optional from mitmproxy import exceptions class OptionAddon: def load(self, loader): loader.add_option( name="optionaddon", typespec=Optional[int], default=None, help="Option Addon", ) def configure(self, updates): ra...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/concurrent_decorator_err.py
test/mitmproxy/data/addonscripts/concurrent_decorator_err.py
from mitmproxy.script import concurrent @concurrent def load(v): pass
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/same_filename/addon.py
test/mitmproxy/data/addonscripts/same_filename/addon.py
foo = 42
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/recorder/e.py
test/mitmproxy/data/addonscripts/recorder/e.py
import recorder addons = [recorder.Recorder("e")]
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/recorder/b.py
test/mitmproxy/data/addonscripts/recorder/b.py
import recorder addons = [recorder.Recorder("b")]
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/recorder/a.py
test/mitmproxy/data/addonscripts/recorder/a.py
import recorder addons = [recorder.Recorder("a")]
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/recorder/recorder.py
test/mitmproxy/data/addonscripts/recorder/recorder.py
import logging from mitmproxy import hooks class Recorder: call_log = [] def __init__(self, name="recorder"): self.name = name def __getattr__(self, attr): if attr in hooks.all_hooks and attr != "add_log": def prox(*args, **kwargs): lg = (self.name, attr, ar...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/addonscripts/recorder/c.py
test/mitmproxy/data/addonscripts/recorder/c.py
import recorder addons = [recorder.Recorder("c")]
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/data/servercert/generate.py
test/mitmproxy/data/servercert/generate.py
import pathlib import shutil src = pathlib.Path("../../net/data/verificationcerts") here = pathlib.Path(".") shutil.copy(src / "9da13359.0", "9da13359.0") for x in ["self-signed", "trusted-leaf", "trusted-root"]: (here / f"{x}.pem").write_text( (src / f"{x}.crt").read_text() + (src / f"{x}.key").read_tex...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/io/test_io.py
test/mitmproxy/io/test_io.py
import io from pathlib import Path import pytest from hypothesis import example from hypothesis import given from hypothesis.strategies import binary from mitmproxy import exceptions from mitmproxy import version from mitmproxy.io import FlowReader from mitmproxy.io import tnetstring here = Path(__file__).parent.par...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/io/test_har.py
test/mitmproxy/io/test_har.py
import json from pathlib import Path import pytest from mitmproxy import exceptions from mitmproxy.io.har import fix_headers from mitmproxy.io.har import request_to_flow from mitmproxy.tools.web.app import flow_to_json data_dir = Path(__file__).parent.parent / "data" def hardcode_variable_fields_for_tests(flow: di...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/io/test_compat.py
test/mitmproxy/io/test_compat.py
import pytest from mitmproxy import exceptions from mitmproxy import io @pytest.mark.parametrize( "dumpfile, url, count", [ ["dumpfile-011.mitm", "https://example.com/", 1], ["dumpfile-018.mitm", "https://www.example.com/", 1], ["dumpfile-019.mitm", "https://webrv.rtb-seller.com/", 1]...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/io/test_tnetstring.py
test/mitmproxy/io/test_tnetstring.py
import io import math import random import struct import unittest from mitmproxy.io import tnetstring MAXINT = 2 ** (struct.Struct("i").size * 8 - 1) - 1 # fmt: off FORMAT_EXAMPLES = { b'0:}': {}, b'0:]': [], b'51:5:hello,39:11:12345678901#4:this,4:true!0:~4:\x00\x00\x00\x00,]}': {b'hello': [12345678...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/platform/test_pf.py
test/mitmproxy/platform/test_pf.py
import sys import pytest from mitmproxy.platform import pf class TestLookup: def test_simple(self, tdata): if sys.platform == "freebsd10": p = tdata.path("mitmproxy/data/pf02") else: p = tdata.path("mitmproxy/data/pf01") with open(p, "rb") as f: d = f....
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/linkify-changelog.py
test/helper_tools/linkify-changelog.py
#!/usr/bin/env python3 import re from pathlib import Path changelog = Path(__file__).parent / "../../CHANGELOG.md" text = changelog.read_text(encoding="utf8") text, n = re.subn( r"\s*\(([^)]+)#(\d+)\)", "\n (\\1[#\\2](https://github.com/mitmproxy/mitmproxy/issues/\\2))", text, ) changelog.write_text(text...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/loggrep.py
test/helper_tools/loggrep.py
#!/usr/bin/env python3 import fileinput import re import sys if __name__ == "__main__": if len(sys.argv) < 3: print(f"Usage: {sys.argv[0]} port filenames") sys.exit() port = sys.argv[1] matches = False for line in fileinput.input(sys.argv[2:]): if re.search(r"^\[|(\d+\.){3}", l...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/hunt_memory_leaks.py
test/helper_tools/hunt_memory_leaks.py
import collections import gc import os import signal from mitmproxy import flow def load(loader): signal.signal(signal.SIGUSR1, debug1) signal.signal(signal.SIGUSR2, debug2) print(f"Debug signal registered. Run the following commands for diagnostics:") print() print(f" kill -s USR1 {os.getpid()}...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/memoryleak2.py
test/helper_tools/memoryleak2.py
import secrets from pathlib import Path import objgraph from mitmproxy import certs if __name__ == "__main__": store = certs.CertStore.from_store( path=Path("~/.mitmproxy/").expanduser(), basename="mitmproxy", key_size=2048 ) store.STORE_CAP = 5 for _ in range(5): store.get_cert( ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/memoryleak.py
test/helper_tools/memoryleak.py
import gc import threading from OpenSSL import SSL from pympler import muppy from pympler import refbrowser # import os # os.environ["TK_LIBRARY"] = r"C:\Python27\tcl\tcl8.5" # os.environ["TCL_LIBRARY"] = r"C:\Python27\tcl\tcl8.5" # Also noteworthy: guppy, objgraph step = 0 __memory_locals__ = True def str_fun(ob...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/dumperview.py
test/helper_tools/dumperview.py
#!/usr/bin/env python3 import asyncio import click from mitmproxy.addons import dumper from mitmproxy.test import taddons from mitmproxy.test import tflow def run_async(coro): """ Run the given async function in a new event loop. This allows async functions to be called synchronously. """ loop =...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/passive_close.py
test/helper_tools/passive_close.py
import socketserver from time import sleep class service(socketserver.BaseRequestHandler): def handle(self): data = "dummy" print("Client connected with ", self.client_address) while True: self.request.send( "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Lengt...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/helper_tools/inspect_dumpfile.py
test/helper_tools/inspect_dumpfile.py
#!/usr/bin/env python3 from pprint import pprint import click from mitmproxy.io import tnetstring def read_tnetstring(input): # tnetstring throw a ValueError on EOF, which is hard to catch # because they raise ValueErrors for a couple of other reasons. # Check for EOF to avoid this. if not input.rea...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/build.py
docs/build.py
#!/usr/bin/env python3 import shutil import subprocess from pathlib import Path here = Path(__file__).parent for script in sorted((here / "scripts").glob("*.py")): print(f"Generating output for {script.name}...") out = subprocess.check_output(["python3", script.absolute()], cwd=here, text=True) if out: ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/api-events.py
docs/scripts/api-events.py
#!/usr/bin/env python3 import contextlib import inspect import textwrap import typing from pathlib import Path from mitmproxy import addonmanager from mitmproxy import hooks from mitmproxy import log from mitmproxy.proxy import layer from mitmproxy.proxy import server_hooks from mitmproxy.proxy.layers import dns from ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/filters.py
docs/scripts/filters.py
#!/usr/bin/env python3 from mitmproxy import flowfilter print('<table class="table filtertable"><tbody>') for i in flowfilter.help: print("<tr><th>%s</th><td>%s</td></tr>" % i) print("</tbody></table>")
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/api-render.py
docs/scripts/api-render.py
#!/usr/bin/env python3 import os import shutil import textwrap from pathlib import Path import pdoc.render_helpers here = Path(__file__).parent if os.environ.get("DOCS_ARCHIVE", False): edit_url_map = {} else: edit_url_map = { "mitmproxy": "https://github.com/mitmproxy/mitmproxy/blob/main/mitmproxy/"...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/examples.py
docs/scripts/examples.py
#!/usr/bin/env python3 import re from pathlib import Path here = Path(__file__).absolute().parent example_dir = here / ".." / "src" / "examples" / "addons" examples = example_dir.glob("*.py") overview = [] listings = [] for example in examples: code = example.read_text() slug = str(example.with_suffix("").re...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/options.py
docs/scripts/options.py
#!/usr/bin/env python3 import asyncio from mitmproxy import options from mitmproxy import optmanager from mitmproxy.tools import console from mitmproxy.tools import dump from mitmproxy.tools import web masters = { "mitmproxy": console.master.ConsoleMaster, "mitmdump": dump.DumpMaster, "mitmweb": web.maste...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/clirecording/clidirector.py
docs/scripts/clirecording/clidirector.py
import json import random import subprocess import threading import time from typing import NamedTuple import libtmux class InstructionSpec(NamedTuple): instruction: str time_from: float time_to: float class CliDirector: def __init__(self): self.record_start = None self.pause_betwee...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/clirecording/screenplays.py
docs/scripts/clirecording/screenplays.py
#!/usr/bin/env python3 from clidirector import CliDirector def record_user_interface(d: CliDirector): tmux = d.start_session(width=120, height=36) window = tmux.attached_window d.start_recording("recordings/mitmproxy_user_interface.cast") d.message( "Welcome to the mitmproxy tutorial. In this...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/docs/scripts/clirecording/record.py
docs/scripts/clirecording/record.py
#!/usr/bin/env python3 import screenplays from clidirector import CliDirector if __name__ == "__main__": director = CliDirector() screenplays.record_user_interface(director) screenplays.record_intercept_requests(director) screenplays.record_modify_requests(director) screenplays.record_replay_reques...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/test_xss_scanner.py
examples/contrib/test_xss_scanner.py
import pytest import requests from examples.complex import xss_scanner as xss from mitmproxy.test import tflow from mitmproxy.test import tutils class TestXSSScanner: def test_get_XSS_info(self): # First type of exploit: <script>PAYLOAD</script> # Exploitable: xss_info = xss.get_XSS_data(...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/ntlm_upstream_proxy.py
examples/contrib/ntlm_upstream_proxy.py
import base64 import binascii import logging import socket from typing import Any from typing import Optional from ntlm_auth import gss_channel_bindings from ntlm_auth import ntlm from mitmproxy import addonmanager from mitmproxy import ctx from mitmproxy import http from mitmproxy.net.http import http1 from mitmprox...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/search.py
examples/contrib/search.py
import logging import re from collections.abc import Sequence from json import dumps from mitmproxy import command from mitmproxy import flow MARKER = ":mag:" RESULTS_STR = "Search Results: " class Search: def __init__(self): self.exp = None @command.command("search") def _search(self, flows: S...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/remote-debug.py
examples/contrib/remote-debug.py
""" This script enables remote debugging of the mitmproxy console *UI* with PyCharm. For general debugging purposes, it is easier to just debug mitmdump within PyCharm. Usage: - pip install pydevd on the mitmproxy machine - Open the Run/Debug Configuration dialog box in PyCharm, and select the Python Rem...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/all_markers.py
examples/contrib/all_markers.py
from mitmproxy import command from mitmproxy import ctx from mitmproxy.utils import emoji @command.command("all.markers") def all_markers(): "Create a new flow showing all marker values" for marker in emoji.emoji: ctx.master.commands.call( "view.flows.create", "get", f"https://example.com/...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/block_dns_over_https.py
examples/contrib/block_dns_over_https.py
""" This module is for blocking DNS over HTTPS requests. It loads a blocklist of IPs and hostnames that are known to serve DNS over HTTPS requests. It also uses headers, query params, and paths to detect DoH (and block it) """ import logging # known DoH providers' hostnames and IP addresses to block default_blocklis...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/change_upstream_proxy.py
examples/contrib/change_upstream_proxy.py
from mitmproxy import http from mitmproxy.connection import Server from mitmproxy.net.server_spec import ServerSpec # This scripts demonstrates how mitmproxy can switch to a second/different upstream proxy # in upstream proxy mode. # # Usage: mitmdump # -s change_upstream_proxy.py # --mode upstream:http://default-...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/tls_passthrough.py
examples/contrib/tls_passthrough.py
""" This addon allows conditional TLS Interception based on a user-defined strategy. Example: > mitmdump -s tls_passthrough.py 1. curl --proxy http://localhost:8080 https://example.com --insecure // works - we'll also see the contents in mitmproxy 2. curl --proxy http://localhost:8080 https://exampl...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/modify_body_inject_iframe.py
examples/contrib/modify_body_inject_iframe.py
# (this script works best with --anticache) from bs4 import BeautifulSoup from mitmproxy import ctx from mitmproxy import http class Injector: def load(self, loader): loader.add_option("iframe", str, "", "IFrame to inject") def response(self, flow: http.HTTPFlow) -> None: if ctx.options.ifra...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/suppress_error_responses.py
examples/contrib/suppress_error_responses.py
""" This script suppresses the 502 Bad Gateway messages, mitmproxy sends if the server is not responsing correctly. For example, this functionality can be helpful if mitmproxy is used in between a web scanner and a web application. Without this script, if the web application under test crashes, mitmproxy will send 502 ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/check_ssl_pinning.py
examples/contrib/check_ssl_pinning.py
import ipaddress import time import OpenSSL import mitmproxy from mitmproxy import ctx from mitmproxy.certs import Cert # Certificate for client connection is generated in dummy_cert() in certs.py. Monkeypatching # the function to generate test cases for SSL Pinning. def monkey_dummy_cert(privkey, cacert, commonna...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/dns_spoofing.py
examples/contrib/dns_spoofing.py
""" This script makes it possible to use mitmproxy in scenarios where IP spoofing has been used to redirect connections to mitmproxy. The way this works is that we rely on either the TLS Server Name Indication (SNI) or the Host header of the HTTP request. Of course, this is not foolproof - if an HTTPS connection comes ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/link_expander.py
examples/contrib/link_expander.py
# This script determines if request is an HTML webpage and if so seeks out # relative links (<a href="./about.html">) and expands them to absolute links # In practice this can be used to front an indexing spider that may not have the capability to expand relative page links. # Usage: mitmdump -s link_expander.py or mit...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/har_dump.py
examples/contrib/har_dump.py
""" This addon is now part of mitmproxy! See mitmproxy/addons/savehar.py. """
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/jsondump.py
examples/contrib/jsondump.py
""" This script serializes the entire traffic dump, including websocket traffic, as JSON, and either sends it to a URL or writes to a file. The serialization format is optimized for Elasticsearch; the script can be used to send all captured traffic to Elasticsearch directly. Usage: mitmproxy --mode revers...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/httpdump.py
examples/contrib/httpdump.py
#!/usr/bin/env python # dump content to files based on a filter # usage: mitmdump -s httpdump.py "~ts application/json" # # options: # - dumper_folder: content dump destination folder (default: ./httpdump) # - open_browser: open integrated browser with proxy configured at start (default: true) # # remember to add y...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/test_jsondump.py
examples/contrib/test_jsondump.py
import base64 import json import requests_mock from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test import tutils example_dir = tutils.test_data.push("../examples") class TestJSONDump: def echo_response(self, request, context): self.request = {"json": request.json(), ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/xss_scanner.py
examples/contrib/xss_scanner.py
r""" __ __ _____ _____ _____ \ \ / // ____/ ____| / ____| \ V /| (___| (___ | (___ ___ __ _ _ __ _ __ ___ _ __ > < \___ \\___ \ \___ \ / __/ _` | '_ \| '_ \ / _ \ '__| / . \ ____) |___) | ____) | (_| (_| | | | | | | | __/ | /_/ \_\_____/_____/ |_____/ \___\__,_|_| |_|_| |_|\___|_| ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/portfile.py
examples/contrib/portfile.py
import json import pathlib from typing import Optional from mitmproxy import ctx class PortFile: def load(self, loader): loader.add_option( name="datadir", typespec=Optional[str], default=None, help="Creates `portfile` mapping proxies (by mode spec) to the ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/http_manipulate_cookies.py
examples/contrib/http_manipulate_cookies.py
""" This script is an example of how to manipulate cookies both outgoing (requests) and ingoing (responses). In particular, this script inserts a cookie (specified in a json file) into every request (overwriting any existing cookie of the same name), and removes cookies from every response that have a certain set of na...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/examples/contrib/custom_next_layer.py
examples/contrib/custom_next_layer.py
""" This addon demonstrates how to override next_layer to modify the protocol in use. In this example, we are forcing connections to example.com:443 to instead go as plaintext to example.com:80. Example usage: - mitmdump -s custom_next_layer.py - curl -x localhost:8080 -k https://example.com """ import loggi...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false