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 "pyperclip"
59 "tornado"
60 "typing-extensions"
61 "urwid"
62 ];
63
64 build-system = [ setuptools ];
65
66 dependencies = [
67 aioquic
68 argon2-cffi
69 asgiref
70 brotli
71 certifi
72 cryptography
73 flask
74 h11
75 h2
76 hyperframe
77 kaitaistruct
78 ldap3
79 mitmproxy-rs
80 msgpack
81 passlib
82 publicsuffix2
83 pyopenssl
84 pyparsing
85 pyperclip
86 ruamel-yaml
87 sortedcontainers
88 tornado
89 urwid
90 wsproto
91 zstandard
92 ];
93
94 nativeCheckInputs = [
95 hypothesis
96 pytest-asyncio
97 pytest-timeout
98 pytest-xdist
99 pytestCheckHook
100 requests
101 ];
102
103 __darwinAllowLocalNetworking = true;
104
105 preCheck = ''
106 export HOME=$(mktemp -d)
107 '';
108
109 disabledTests = [
110 # Tests require a git repository
111 "test_get_version"
112 # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03
113 # Tests require terminal
114 "test_commands_exist"
115 "test_contentview_flowview"
116 "test_flowview"
117 "test_get_hex_editor"
118 "test_integration"
119 "test_spawn_editor"
120 "test_statusbar"
121 # FileNotFoundError: [Errno 2] No such file or directory
122 # likely wireguard is also not working in the sandbox
123 "test_tun_mode"
124 "test_wireguard"
125 # test require a DNS server
126 # RuntimeError: failed to get dns servers: io error: entity not found
127 "test_errorcheck"
128 "test_errorcheck"
129 "test_dns"
130 "test_order"
131 ];
132
133 disabledTestPaths = [
134 # test require a DNS server
135 # RuntimeError: failed to get dns servers: io error: entity not found
136 "test/mitmproxy/addons/test_dns_resolver.py"
137 "test/mitmproxy/tools/test_dump.py"
138 "test/mitmproxy/tools/test_main.py"
139 "test/mitmproxy/tools/web/test_app.py"
140 "test/mitmproxy/tools/web/test_app.py" # 2 out of 31 tests work
141 "test/mitmproxy/tools/web/test_master.py"
142 ];
143
144 dontUsePytestXdist = true;
145
146 pythonImportsCheck = [ "mitmproxy" ];
147
148 meta = with lib; {
149 description = "Man-in-the-middle proxy";
150 homepage = "https://mitmproxy.org/";
151 changelog = "https://github.com/mitmproxy/mitmproxy/blob/${src.tag}/CHANGELOG.md";
152 license = licenses.mit;
153 maintainers = with maintainers; [ SuperSandro2000 ];
154 };
155}