diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9fd024617..22262fc50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,10 +40,12 @@ jobs: matrix: include: - os: ubuntu-latest - py: "3.13" + py: "3.14" - os: windows-latest - py: "3.13" + py: "3.14" - os: macos-latest + py: "3.14" + - os: ubuntu-latest py: "3.13" - os: ubuntu-latest py: "3.12" @@ -85,7 +87,7 @@ jobs: - if: matrix.container run: | apt-get update - apt-get install --no-install-recommends -y git ca-certificates binutils + apt-get install --no-install-recommends -y git ca-certificates binutils build-essential - uses: mhils/workflows/checkout@8a2bdd081227cbdd6f5d3bbb54a759607feac0b6 - uses: mhils/workflows/setup-uv@8a2bdd081227cbdd6f5d3bbb54a759607feac0b6 - uses: mhils/workflows/uv-sync@8a2bdd081227cbdd6f5d3bbb54a759607feac0b6 diff --git a/.python-version b/.python-version index 24ee5b1be..6324d401a 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.13 +3.14 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2e90653..4fd0db0e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Unreleased: mitmproxy next +- mitmproxy now supports Python 3.14. Binary releases ship with 3.14 by default. + ([#7918](https://github.com/mitmproxy/mitmproxy/pull/7918), @mhils) - Replace `htpasswd` file parser with a custom implementation to migrate off unmaintained `passlib` dependency. The new parser only supports bcrypt and SHA-1 hashing. Contributions for additional formats are welcome as long as they don't introduce new diff --git a/mitmproxy/io/har.py b/mitmproxy/io/har.py index 80f4e933e..287aeb86b 100644 --- a/mitmproxy/io/har.py +++ b/mitmproxy/io/har.py @@ -152,4 +152,8 @@ def request_to_flow(request_json: dict) -> http.HTTPFlow: case _: new_flow.response.http_version = "HTTP/1.1" + # Remove compression because that may generate different sizes between versions + new_flow.request.decode() + new_flow.response.decode() + return new_flow diff --git a/pyproject.toml b/pyproject.toml index 97abbd7c1..fa35adbc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ classifiers = [ "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Security", "Topic :: Internet :: WWW/HTTP", @@ -56,13 +57,13 @@ dependencies = [ "urwid>=2.6.14,<=3.0.3", "wsproto>=1.0,<=1.2.0", "publicsuffix2>=2.20190812,<=2.20191221", - "zstandard>=0.15,<=0.25.0", + "zstandard>=0.25,<=0.25.0", ] [dependency-groups] dev = [ "click==8.3.0", - "hypothesis==6.141.0", + "hypothesis==6.130.6", "maturin==1.9.6", "pdoc==15.0.4", "pyinstaller==6.16.0", @@ -74,7 +75,6 @@ dev = [ "pytest==8.4.2", "requests==2.32.5", "wheel==0.45.1", - "windows-curses==2.4.1; sys_platform == 'win32'", "build==1.3.0", "mypy==1.18.2", "types-requests==2.32.4.20250913", diff --git a/release/docker/Dockerfile b/release/docker/Dockerfile index 93761d36c..a39ddef09 100644 --- a/release/docker/Dockerfile +++ b/release/docker/Dockerfile @@ -1,9 +1,9 @@ -FROM python:3.13-trixie AS wheelbuilder +FROM python:3.14-trixie AS wheelbuilder COPY mitmproxy-*-py3-none-any.whl /wheels/ RUN pip install wheel && pip wheel --wheel-dir /wheels /wheels/*.whl -FROM python:3.13-slim-trixie +FROM python:3.14-slim-trixie RUN useradd -mU mitmproxy RUN apt-get update \ diff --git a/test/mitmproxy/data/har_files/chrome.json b/test/mitmproxy/data/har_files/chrome.json index 240c99c3e..b9ba48bf8 100644 --- a/test/mitmproxy/data/har_files/chrome.json +++ b/test/mitmproxy/data/har_files/chrome.json @@ -194,6 +194,10 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "23866" ] ], "contentLength": 23866, diff --git a/test/mitmproxy/data/har_files/firefox.json b/test/mitmproxy/data/har_files/firefox.json index e3b701447..5e7f7cef5 100644 --- a/test/mitmproxy/data/har_files/firefox.json +++ b/test/mitmproxy/data/har_files/firefox.json @@ -174,6 +174,10 @@ [ "x-amz-cf-id", "DPEkuUbeK1ZXMsRuUHqgk6iE4l7ShgyrJntkqIbLaSJ5646Ptc2Xew==" + ], + [ + "content-length", + "23866" ] ], "contentLength": 23866, @@ -814,10 +818,6 @@ "server", "AmazonS3" ], - [ - "content-encoding", - "gzip" - ], [ "date", "Wed, 29 Mar 2023 19:52:06 GMT" @@ -845,10 +845,14 @@ [ "x-amz-cf-id", "EufbwzXQheESUTNil_OCjKK8cvVL51cQpYfmF7iZSHloCTvVhfZ8yQ==" + ], + [ + "content-length", + "11800" ] ], - "contentLength": 3969, - "contentHash": "3c4880b4b424071aa5e5c5f652b934179099ee8786ea67520b2fadbc4305e5a8", + "contentLength": 11800, + "contentHash": "a68ed14d0bc3ac8990bf6e6fc3f9f23134ea22032786a07680dc9468af39ab4e", "timestamp_start": 1680134339.495, "timestamp_end": 1680134339.495 } @@ -990,10 +994,6 @@ "server", "AmazonS3" ], - [ - "content-encoding", - "gzip" - ], [ "date", "Wed, 29 Mar 2023 16:03:05 GMT" @@ -1021,10 +1021,14 @@ [ "x-amz-cf-id", "UuHHTyGhTqqTO07G_oZCw7rxjb9RJUGTN3OW0EUS77RH4GiQ-LkAvw==" + ], + [ + "content-length", + "10452" ] ], - "contentLength": 3346, - "contentHash": "e6c21f88023539515a971172a00e500b7e4444fbf9506e47ceee126ace246808", + "contentLength": 10452, + "contentHash": "ebe20255d8922ecbc1a159357d0cb0eb1ef05b8cc5a9d59f2a9f7e6fb585d7d3", "timestamp_start": 1680134339.498, "timestamp_end": 1680134339.498 } @@ -1166,10 +1170,6 @@ "server", "AmazonS3" ], - [ - "content-encoding", - "gzip" - ], [ "date", "Wed, 29 Mar 2023 02:43:50 GMT" @@ -1197,10 +1197,14 @@ [ "x-amz-cf-id", "TOLqHpQWMFHQDWnv2yHHFWI5xkA3R13TTJQDJe1ARViKrgihxZdhxA==" + ], + [ + "content-length", + "2219" ] ], - "contentLength": 794, - "contentHash": "43cb84ef784bafbab5472abc7c396d95fc4468973d6501c83709e40963b2a953", + "contentLength": 2219, + "contentHash": "6c5cab1c5c34336ac526bb119abe71d870f246cebb4253a4c420b5c4601a22e5", "timestamp_start": 1680134339.5, "timestamp_end": 1680134339.5 } @@ -1380,6 +1384,10 @@ [ "x-amz-cf-id", "nnIrWtgAMt42ua4HYBtNAao6m_iD9WjIzLAFyURb8mjOr5MriSQXRA==" + ], + [ + "content-length", + "9689" ] ], "contentLength": 9689, @@ -1563,6 +1571,10 @@ [ "x-amz-cf-id", "PMTLvP_yUCVocnhd1i1ir7_FRAJRw0ayMhK3KaZKELDO3pxxoqLWjg==" + ], + [ + "content-length", + "9689" ] ], "contentLength": 9689, @@ -1905,6 +1917,10 @@ [ "x-amz-cf-id", "0okGWJw6nYo7R-4egQWE-WfonThN2EXyRSLO9MlCNKyMfD-2v1AU0Q==" + ], + [ + "content-length", + "6986" ] ], "contentLength": 6986, diff --git a/test/mitmproxy/data/har_files/safari.json b/test/mitmproxy/data/har_files/safari.json index 32ff04fff..15872c052 100644 --- a/test/mitmproxy/data/har_files/safari.json +++ b/test/mitmproxy/data/har_files/safari.json @@ -115,10 +115,6 @@ "Via", "1.1 39464b01f314ad3cb531f46c3049bf58.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 14:59:54 GMT" @@ -150,10 +146,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "23866" ] ], - "contentLength": 4946, - "contentHash": "b643b55c326524222b66cf8d6676c9b640e6417d23aaaa12c8a4ac58216d6586", + "contentLength": 23866, + "contentHash": "7fd5f643a86976f5711df86ae2d5f9f8137a47c705dee31ccc550215564a5364", "timestamp_start": 1680135212.418, "timestamp_end": 1680135212.5293427 } @@ -243,10 +243,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 09:06:44 GMT" @@ -278,10 +274,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "248261" ] ], - "contentLength": 36819, - "contentHash": "62c365a16e642d4b512700140d3e99371aed31b74edc736f9927b6375b1230c0", + "contentLength": 248261, + "contentHash": "81d59b89e2c656c6e4aa508b5455f255325d744ec390be54f34c2a7dad4976c1", "timestamp_start": 1680135212.542, "timestamp_end": 1680135212.5420642 } @@ -883,10 +883,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 22:44:19 GMT" @@ -918,10 +914,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "22238" ] ], - "contentLength": 5167, - "contentHash": "8a74d8c765558a54c3fb4eeb2e24367cfca6a889f0d56b7fc179eb722e5f8ebf", + "contentLength": 22238, + "contentHash": "9bdcfaca52fa8e575767659b70498dd86609e4fd50e913e957fdfa398086c595", "timestamp_start": 1680135212.557, "timestamp_end": 1680135212.5573125 } @@ -1011,10 +1011,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 16:03:05 GMT" @@ -1046,10 +1042,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "10452" ] ], - "contentLength": 3346, - "contentHash": "e6c21f88023539515a971172a00e500b7e4444fbf9506e47ceee126ace246808", + "contentLength": 10452, + "contentHash": "ebe20255d8922ecbc1a159357d0cb0eb1ef05b8cc5a9d59f2a9f7e6fb585d7d3", "timestamp_start": 1680135212.559, "timestamp_end": 1680135212.5590725 } @@ -1139,10 +1139,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 02:43:50 GMT" @@ -1174,10 +1170,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "2219" ] ], - "contentLength": 794, - "contentHash": "43cb84ef784bafbab5472abc7c396d95fc4468973d6501c83709e40963b2a953", + "contentLength": 2219, + "contentHash": "6c5cab1c5c34336ac526bb119abe71d870f246cebb4253a4c420b5c4601a22e5", "timestamp_start": 1680135212.559, "timestamp_end": 1680135212.5590615 } @@ -1279,10 +1279,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 20:15:23 GMT" @@ -1314,10 +1310,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "9689" ] ], - "contentLength": 3346, - "contentHash": "1f3ac146af1c45c1a2b4e6c694ecb234382d77b4256524d5ffc365fc8d6130b0", + "contentLength": 9689, + "contentHash": "a4dcfad01ab92fbd09cad3477fb26184fbb26f164d1302ee79489519b280e22a", "timestamp_start": 1680135212.56, "timestamp_end": 1680135212.5948346 } @@ -1419,10 +1419,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 20:15:23 GMT" @@ -1454,10 +1450,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "9689" ] ], - "contentLength": 3346, - "contentHash": "1f3ac146af1c45c1a2b4e6c694ecb234382d77b4256524d5ffc365fc8d6130b0", + "contentLength": 9689, + "contentHash": "a4dcfad01ab92fbd09cad3477fb26184fbb26f164d1302ee79489519b280e22a", "timestamp_start": 1680135212.56, "timestamp_end": 1680135212.5948346 } @@ -1559,10 +1559,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 20:15:23 GMT" @@ -1594,10 +1590,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "9689" ] ], - "contentLength": 3346, - "contentHash": "1f3ac146af1c45c1a2b4e6c694ecb234382d77b4256524d5ffc365fc8d6130b0", + "contentLength": 9689, + "contentHash": "a4dcfad01ab92fbd09cad3477fb26184fbb26f164d1302ee79489519b280e22a", "timestamp_start": 1680135212.56, "timestamp_end": 1680135212.5999687 } @@ -1699,10 +1699,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 20:15:23 GMT" @@ -1734,10 +1730,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "9689" ] ], - "contentLength": 3346, - "contentHash": "1f3ac146af1c45c1a2b4e6c694ecb234382d77b4256524d5ffc365fc8d6130b0", + "contentLength": 9689, + "contentHash": "a4dcfad01ab92fbd09cad3477fb26184fbb26f164d1302ee79489519b280e22a", "timestamp_start": 1680135212.56, "timestamp_end": 1680135212.5999687 } @@ -2211,10 +2211,6 @@ "Via", "1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 19:52:06 GMT" @@ -2246,10 +2242,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "11800" ] ], - "contentLength": 3969, - "contentHash": "3c4880b4b424071aa5e5c5f652b934179099ee8786ea67520b2fadbc4305e5a8", + "contentLength": 11800, + "contentHash": "a68ed14d0bc3ac8990bf6e6fc3f9f23134ea22032786a07680dc9468af39ab4e", "timestamp_start": 1680135212.583, "timestamp_end": 1680135212.5831468 } @@ -2521,10 +2521,6 @@ "Via", "1.1 39464b01f314ad3cb531f46c3049bf58.cloudfront.net (CloudFront)" ], - [ - "Content-Encoding", - "gzip" - ], [ "Date", "Wed, 29 Mar 2023 23:55:35 GMT" @@ -2556,10 +2552,14 @@ [ "x-cache", "Hit from cloudfront" + ], + [ + "content-length", + "6986" ] ], - "contentLength": 1421, - "contentHash": "81de6d4a4bdb984627d61de60369ec4f0ce182170fbe6d9a980b15574d5f6c50", + "contentLength": 6986, + "contentHash": "ebb5ca702c6b7f09fe1c10e8992602bad67989e25151f0cb6928ea51299bf4e8", "timestamp_start": 1680135212.6, "timestamp_end": 1680135212.609897 } diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py index 247a3e390..24d271547 100644 --- a/test/mitmproxy/test_command.py +++ b/test/mitmproxy/test_command.py @@ -8,6 +8,7 @@ import mitmproxy.types from mitmproxy import command from mitmproxy import exceptions from mitmproxy import flow +from mitmproxy.flow import Flow from mitmproxy.test import taddons from mitmproxy.test import tflow @@ -56,7 +57,7 @@ class TAddon: pass @command.command("flow") - def flow(self, f: flow.Flow, s: str) -> None: + def flow(self, f: Flow, s: str) -> None: pass diff --git a/uv.lock b/uv.lock index f890297e1..ff24b00c1 100644 --- a/uv.lock +++ b/uv.lock @@ -643,15 +643,15 @@ wheels = [ [[package]] name = "hypothesis" -version = "6.141.0" +version = "6.130.6" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "attrs" }, { name = "sortedcontainers" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/7d/ca/31352c7e7aa623eeb712efb415e7934d7bb7068983e8edfd688c647dcbff/hypothesis-6.141.0.tar.gz", hash = "sha256:a66861954dc1768945eda83ca28a9bbb5bc59a45edae899c219e2dd85a8ddd43", size = 467168, upload-time = "2025-10-15T05:00:28.494Z" } +sdist = { url = "https://files.pythonhosted.org/packages/82/26/01514ec525bbeb2cd166347e5c33e2aa5ec39406fcf24d91a884a6d72e96/hypothesis-6.130.6.tar.gz", hash = "sha256:994abd048924e365dbb8c21e3ea44c2ac576e02fa3d34b04288281768ae83b53", size = 427182, upload-time = "2025-03-31T14:49:48.139Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/8e/e4/c92740135f9ad1cfe85aa7187eb72804fd5610d4a6ad72e39b6574e51588/hypothesis-6.141.0-py3-none-any.whl", hash = "sha256:29a1b4301611bdd2833a5ad5fc422c72b60071a169ee048e28b1435ac410d072", size = 534788, upload-time = "2025-10-15T05:00:24.387Z" }, + { url = "https://files.pythonhosted.org/packages/0d/18/153434ef2449be66c618695f74eeaec5db438e5a5d1f1ddfbf075d3ffd7b/hypothesis-6.130.6-py3-none-any.whl", hash = "sha256:fe457a716797dbcc9c3dd77fe4164d65f77296010ce5b931910276242a90ed0e", size = 491956, upload-time = "2025-03-31T14:49:44.802Z" }, ] [[package]] @@ -969,7 +969,6 @@ dev = [ { name = "tox-uv" }, { name = "types-requests" }, { name = "wheel" }, - { name = "windows-curses", marker = "sys_platform == 'win32'" }, ] ruff = [ { name = "ruff" }, @@ -1007,7 +1006,7 @@ requires-dist = [ { name = "typing-extensions", marker = "python_full_version < '3.13'", specifier = ">=4.13.2,<=4.14" }, { name = "urwid", specifier = ">=2.6.14,<=3.0.3" }, { name = "wsproto", specifier = ">=1.0,<=1.2.0" }, - { name = "zstandard", specifier = ">=0.15,<=0.25.0" }, + { name = "zstandard", specifier = "<=0.25.0,>=0.25" }, ] [package.metadata.requires-dev] @@ -1018,7 +1017,7 @@ deploy = [ dev = [ { name = "build", specifier = "==1.3.0" }, { name = "click", specifier = "==8.3.0" }, - { name = "hypothesis", specifier = "==6.141.0" }, + { name = "hypothesis", specifier = "==6.130.6" }, { name = "maturin", specifier = "==1.9.6" }, { name = "mypy", specifier = "==1.18.2" }, { name = "pdoc", specifier = "==15.0.4" }, @@ -1035,7 +1034,6 @@ dev = [ { name = "tox-uv", specifier = "==1.29.0" }, { name = "types-requests", specifier = "==2.32.4.20250913" }, { name = "wheel", specifier = "==0.45.1" }, - { name = "windows-curses", marker = "sys_platform == 'win32'", specifier = "==2.4.1" }, ] ruff = [{ name = "ruff", specifier = "==0.14.0" }] tox = [ @@ -1973,17 +1971,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0b/2c/87f3254fd8ffd29e4c02732eee68a83a1d3c346ae39bc6822dcbcb697f2b/wheel-0.45.1-py3-none-any.whl", hash = "sha256:708e7481cc80179af0e556bbf0cc00b8444c7321e2700b8d8580231d13017248", size = 72494, upload-time = "2024-11-23T00:18:21.207Z" }, ] -[[package]] -name = "windows-curses" -version = "2.4.1" -source = { registry = "https://pypi.org/simple" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/f4/99/60f34e51514c82631aa5c6d21eab88ce1701562de9844608411e39462a46/windows_curses-2.4.1-cp312-cp312-win32.whl", hash = "sha256:bdbe7d58747408aef8a9128b2654acf6fbd11c821b91224b9a046faba8c6b6ca", size = 71489, upload-time = "2025-01-11T00:26:22.726Z" }, - { url = "https://files.pythonhosted.org/packages/62/8f/d908bcab1954375b156a9300fa86ceccb110f39457cd6fd59c72777626ab/windows_curses-2.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:5c9c2635faf171a229caca80e1dd760ab00db078e2a285ba2f667bbfcc31777c", size = 81777, upload-time = "2025-01-11T00:26:25.273Z" }, - { url = "https://files.pythonhosted.org/packages/25/a0/e8d074f013117633f6b502ca123ecfc377fe0bd36818fe65e8935c91ca9c/windows_curses-2.4.1-cp313-cp313-win32.whl", hash = "sha256:05d1ca01e5199a435ccb6c8c2978df4a169cdff1ec99ab15f11ded9de8e5be26", size = 71390, upload-time = "2025-01-11T00:26:27.66Z" }, - { url = "https://files.pythonhosted.org/packages/2b/4b/2838a829b074a68c570d54ae0ae8539979657d3e619a4dc5a4b03eb69745/windows_curses-2.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:8cf653f8928af19c103ae11cfed38124f418dcdd92643c4cd17239c0cec2f9da", size = 81636, upload-time = "2025-01-11T00:26:29.595Z" }, -] - [[package]] name = "wsproto" version = "1.2.0"