[domistream] Tests: fuzz targets assert invariants
Every target now checks properties instead of only calling the parser: parse -> encode -> parse stability (RTSP request, ENet, input), caps and TooLarge past them, chunking invariance of the framer, XML vs status parser agreement, seal/open round trips, no forged GCM tags. New targets for the parsers and state machines that had none: server_cert_der, enet_client, media_decrypt, video_depacketizer, audio_depacketizer, fec_reconstruct, pairing_session, rtsp_client (25 targets).
This commit is contained in:
@@ -1,11 +1,26 @@
|
||||
//! Fuzzes `/serverinfo` answers: never panics, whatever the bytes.
|
||||
//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic.
|
||||
//! Fuzzes `/serverinfo` answers.
|
||||
//! Asserts invariants, not only "no panic": string fields within MAX_SERVERINFO_FIELD_BYTES, required fields non-empty, oversize is TooLarge.
|
||||
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
|
||||
|
||||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
use domistream::http::serverinfo::{MAX_SERVERINFO_BYTES, MAX_SERVERINFO_FIELD_BYTES};
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let _ = domistream::http::parse_server_info(data);
|
||||
let r = domistream::http::parse_server_info(data);
|
||||
if data.len() > MAX_SERVERINFO_BYTES {
|
||||
assert!(matches!(r, Err(domistream::Error::TooLarge { .. })));
|
||||
}
|
||||
if let Ok(s) = r {
|
||||
for f in [&s.hostname, &s.app_version, &s.unique_id, &s.state] {
|
||||
assert!(f.len() <= MAX_SERVERINFO_FIELD_BYTES);
|
||||
}
|
||||
for f in [&s.gfe_version, &s.local_ip].into_iter().flatten() {
|
||||
assert!(f.len() <= MAX_SERVERINFO_FIELD_BYTES);
|
||||
}
|
||||
assert!(!s.hostname.is_empty() && !s.unique_id.is_empty());
|
||||
let _ = s.is_busy();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user