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