test: fuzz the HTTP and PROXY v2 parsers, make PROXY parsing pure

- PROXY v2 header parsing is now the pure, total function
  `parse_v2_header(buf, limit) -> (SocketAddr, consumed)`; the async reader
  only reads bytes and delegates. This makes the parser reachable from tests
  and fuzz targets and keeps every index bounds-checked.
- tests/proxy_v2_parser.rs: valid v4/v6 headers, bad signature, non-PROXY
  command, TLVs, every truncated prefix, oversized header, unsupported
  family, short address block, and a deterministic sweep over family/length.
- fuzz/: cargo-fuzz targets `http_head` (scan_head + evaluate) and `proxy_v2`
  with invariants (no panic, no out-of-buffer consumption, family matches the
  header). Seeds for the HTTP head keep coverage useful; `make fuzz` runs
  60 s per target. Both targets ran clean (7M and 3M executions).
- docs/testing.md documents the fuzz workflow; .gitignore covers the
  generated corpus/artifacts.
This commit is contained in:
Loki 2026-11-16 12:47:25 +01:00
parent da87d2a11f
commit 08b7292ac4
Signed by: boba
GPG key ID: 6CDE87BC9A778D97
289 changed files with 4837 additions and 31 deletions

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
ost:om
User-Agent: Accep

View file

@ -0,0 +1,2 @@
GGET / HTTP/1.1
Hc G

View file

@ -0,0 +1,17 @@
GET / HTTP/1.1
H-ot-t:
:
H-ot-t:
.1
:
1 */*1
A
Co-t:
.1
H-ot:
!
eLe-

View file

@ -0,0 +1,4 @@
GET / HTTP/1.1
e.co:
ept:

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
Ho]t:t

View file

@ -0,0 +1,2 @@
POST /#dQmin HTTP/1.1
Hosv:

View file

@ -0,0 +1,2 @@
POPOST in HTTP/1.1
Hot

View file

@ -0,0 +1,2 @@
GE / HTTP/1.1
exa

View file

@ -0,0 +1 @@
T / H`TP /*

View file

@ -0,0 +1,6 @@
GET , HTTP/1.1
Hosr-AgJnt: fuzz
Act: example.com
User-AgJnt: fuzz
Accept: */*

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
Ho]t:
󷐢(0.1

View file

@ -0,0 +1,36 @@
GET / HTTP/1.1
H-ot-t:
.1
:

1
H-ot-t:
.1
:
1 */*1
A
Co-t:
.1
H-o :
1t:
.11
H-ot-t:
.1
:
1 */*1
A
Co-t:
.1
H-o :
1t:
.1
:

1
H-ot-t:
.1
:
1 */*1
eLe-

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
H,G:T
UsermgJAKt:

View file

@ -0,0 +1,5 @@
GET / HTTP/1.1
Host:: ex /0HTTP/1.1TP/1.1
Host: example.com
User-Agent: f

View file

@ -0,0 +1,5 @@
GET / HTTP/1.1
Host: example.com
User-AgJnt: fuzz
Accept: */*
/

View file

@ -0,0 +1,6 @@
GET /1 HTTP/1.1
osHt:
AcceTTP/1.1
osHt:
AccTTP1.

View file

@ -0,0 +1,2 @@
G)T / HTTP/1.1
H

View file

@ -0,0 +1,3 @@
GET , HTTP/1.1
Hosr-AgJot:

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
Ho-t:
AcceT

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
H1.t:יuzzept:*/*

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
*/*

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
Host: exGET / HT
User-Agent:

View file

@ -0,0 +1,13 @@
GET / HTTP/1.1
H-ot:
Act*/*1
H
Co-t:*/*1
H
:
AP/1.1
H-o:
0
e

View file

@ -0,0 +1,3 @@
GET , HTTP/1.1
HHot:z 

View file

@ -0,0 +1,4 @@
POST /admin HTTP/1.1
H
Cgth: 0

View file

@ -0,0 +1,2 @@
POST n HTTP/1.1
H[to:sTP1 Host

View file

@ -0,0 +1,2 @@
.At

View file

@ -0,0 +1,2 @@
P qi HTTP/1.0

View file

@ -0,0 +1,4 @@
GET / HTTP/1.1
Host:
Acce

View file

@ -0,0 +1,9 @@
GET / HTTP/1.1
H-ot:
/*1
H
Co-t:*/*1
-t:/1.1
H-ot:0555
e

View file

@ -0,0 +1,4 @@
GET / HTTP/1.1
st:pl
UsermgJAKt:*

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
sx:mpl/c

View file

@ -0,0 +1,9 @@
GET /1 HTTP/1.1
osHt:TT1
osHt:
AcceTTP/1.1
osHt:
AccP/1.1
osHt:
AccTTP/1.1

View file

@ -0,0 +1,3 @@
GET / HTTP/1.1
ost: excom
User-Ageot: fPOTep

View file

@ -0,0 +1,7 @@
GET / HTTP/1.1
H-ot:
AcGGG/1.1
Host:
Ac Ggetx: 0
eLe

View file

@ -0,0 +1,2 @@
GET /' HTTP/1.1
zost:

View file

@ -0,0 +1,4 @@
POST HTTP/1.1
Host: x: x
Co: 0

View file

@ -0,0 +1,4 @@
GET UUUUW/ HTTP/1.1
Host:Acce
Host:AccepHTTP.1
Host:Accep

View file

@ -0,0 +1,5 @@
GET / HTTP/1.1
Host: eampl
UsermgJAKt: fl
UsermgJAKt: fuzz : */*

View file

@ -0,0 +1,5 @@
GET / HTTP/1.1
Host:xa.com
User-AgJnt: fuzz
Accept: */*

View file

@ -0,0 +1,8 @@
GET / HTTP/1.1
Host:
: f
GET / HTTP/1.1
H
o]t:
󷐢(0.1

View file

@ -0,0 +1,4 @@
n HTTP/1.0
Hsx ov
C

View file

@ -0,0 +1 @@
P

View file

@ -0,0 +1,5 @@
GET / HTTP/1.1
H-ot:
Accep :t*/*1 h: 0
eLe

View file

@ -0,0 +1,4 @@
GET / HTTP/1.1
Host: Qempl
User-gJAKt: fu*/*

Some files were not shown because too many files have changed in this diff Show more