1{
2 lib,
3 aioquic,
4 argon2-cffi,
5 asgiref,
6 brotli,
7 buildPythonPackage,
8 certifi,
9 cryptography,
10 fetchFromGitHub,
11 flask,
12 h11,
13 h2,
14 hyperframe,
15 hypothesis,
16 kaitaistruct,
17 ldap3,
18 mitmproxy-rs,
19 msgpack,
20 passlib,
21 publicsuffix2,
22 pyopenssl,
23 pyparsing,
24 pyperclip,
25 pytest-asyncio,
26 pytest-timeout,
27 pytest-xdist,
28 pytestCheckHook,
29 requests,
30 ruamel-yaml,
31 setuptools,
32 sortedcontainers,
33 tornado,
34 urwid,
35 wsproto,
36 zstandard,
37}:
38
39buildPythonPackage rec {
40 pname = "mitmproxy";
41 version = "12.1.2";
42 pyproject = true;
43
44 src = fetchFromGitHub {
45 owner = "mitmproxy";
46 repo = "mitmproxy";
47 tag = "v${version}";
48 hash = "sha256-XYZ14JlVYG/OLlEze+C1L/HP3HD5GEW+jG2YYSXW/8Y=";
49 };
50
51 pythonRelaxDeps = [
52 "cryptography"
53 "flask"
54 "h2"
55 "kaitaistruct"
56 "passlib"
57 "pyopenssl"
58 "tornado"
59 "typing-extensions"
60 "urwid"
61 ];
62
63 build-system = [ setuptools ];
64
65 dependencies = [
66 aioquic
67 argon2-cffi
68 asgiref
69 brotli
70 certifi
71 cryptography
72 flask
73 h11
74 h2
75 hyperframe
76 kaitaistruct
77 ldap3
78 mitmproxy-rs
79 msgpack
80 passlib
81 publicsuffix2
82 pyopenssl
83 pyparsing
84 pyperclip
85 ruamel-yaml
86 sortedcontainers
87 tornado
88 urwid
89 wsproto
90 zstandard
91 ];
92
93 nativeCheckInputs = [
94 hypothesis
95 pytest-asyncio
96 pytest-timeout
97 pytest-xdist
98 pytestCheckHook
99 requests
100 ];
101
102 __darwinAllowLocalNetworking = true;
103
104 preCheck = ''
105 export HOME=$(mktemp -d)
106 '';
107
108 disabledTests = [
109 # Tests require a git repository
110 "test_get_version"
111 # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03
112 # Tests require terminal
113 "test_commands_exist"
114 "test_contentview_flowview"
115 "test_flowview"
116 "test_get_hex_editor"
117 "test_integration"
118 "test_spawn_editor"
119 "test_statusbar"
120 # FileNotFoundError: [Errno 2] No such file or directory
121 # likely wireguard is also not working in the sandbox
122 "test_tun_mode"
123 "test_wireguard"
124 # test require a DNS server
125 # RuntimeError: failed to get dns servers: io error: entity not found
126 "test_errorcheck"
127 "test_errorcheck"
128 "test_dns"
129 "test_order"
130 ];
131
132 disabledTestPaths = [
133 # test require a DNS server
134 # RuntimeError: failed to get dns servers: io error: entity not found
135 "test/mitmproxy/addons/test_dns_resolver.py"
136 "test/mitmproxy/tools/test_dump.py"
137 "test/mitmproxy/tools/test_main.py"
138 "test/mitmproxy/tools/web/test_app.py"
139 "test/mitmproxy/tools/web/test_app.py" # 2 out of 31 tests work
140 "test/mitmproxy/tools/web/test_master.py"
141 ];
142
143 dontUsePytestXdist = true;
144
145 pythonImportsCheck = [ "mitmproxy" ];
146
147 meta = with lib; {
148 description = "Man-in-the-middle proxy";
149 homepage = "https://mitmproxy.org/";
150 changelog = "https://github.com/mitmproxy/mitmproxy/blob/${src.tag}/CHANGELOG.md";
151 license = licenses.mit;
152 maintainers = with maintainers; [ SuperSandro2000 ];
153 };
154}