Commit 1cb4ce2
authored
feat(sandbox): bound proxy connections and finish the SOCKS5 fuzzing (#290)
* feat(sandbox): bound proxy connections and finish the SOCKS5 fuzzing
Three gaps #246 left open.
The accept loop spawned a thread per connection with no bound, so anything
that can reach the port could make the proxy spawn threads, and for IP-mode
clients drive a DNS lookup per allowlist hostname on each. Past 64 in flight
the proxy now closes the connection rather than queuing it; a SOCKS5 client
sees a failed connect. The counter is raised before the spawn and lowered by
a failed one, so the cap cannot drift downward.
Case-insensitive matching is documented but was not asserted: the target now
requires the same verdict for a host with its case flipped. Removing the fold
in is_host_allowed fails it on "c" vs "C".
is_ip_allowed had no coverage because it resolves allowlisted hostnames. It is
reachable through NetAllowlist::is_ip_allowed, and the target restricts its
patterns to the shapes that function never resolves — literal IPs, "*" and
"*." wildcards — so it stays off the network. The resolving branch needs a
stubbed resolver and is still uncovered.
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
* test(sandbox): unit-test NetAllowlist::is_ip_allowed
The method was added for the fuzz target, and fuzz targets are not in the
coverage build, so a new public method arrived with nothing exercising it —
codecov put the patch at 79.6%.
Literal IPv4 and IPv6 matches, deny-by-default on an empty list, the "*"
short-circuit ahead of address parsing, and a "*." pattern that cannot match
an address on its own. All patterns are literals or wildcards so the tests
never reach the resolver.
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
* refactor(sandbox): make the connection permit RAII and cover the rest
Measuring locally rather than reading codecov's per-line field left five
uncovered lines among the change.
Three were the failed-spawn branch that lowered the counter by hand. A permit
that lowers it on drop removes the branch instead of testing it: the handler
holds it, and a spawn that never runs the closure drops it too. One exit path
per counter beats one branch per exit path.
The other two were a poisoned-lock arm, now tested — a panic while the
allowlist was held must not become permission to connect — and an Err arm in
the shedding test's own connect loop, which cannot fire below the cap and is
now an outright failure instead.
Every added line in net_proxy.rs is covered.
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
---------
Signed-off-by: Luca Muscariello <muscariello@ieee.org>1 parent 488446e commit 1cb4ce2
2 files changed
Lines changed: 207 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
50 | 103 | | |
51 | 104 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
| |||
303 | 315 | | |
304 | 316 | | |
305 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
306 | 344 | | |
307 | 345 | | |
308 | 346 | | |
309 | 347 | | |
310 | 348 | | |
311 | 349 | | |
| 350 | + | |
312 | 351 | | |
313 | 352 | | |
314 | 353 | | |
315 | 354 | | |
316 | 355 | | |
317 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
318 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
319 | 374 | | |
320 | 375 | | |
321 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
322 | 380 | | |
323 | 381 | | |
324 | 382 | | |
| |||
803 | 861 | | |
804 | 862 | | |
805 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
806 | 959 | | |
807 | 960 | | |
808 | 961 | | |
| |||
0 commit comments