Expand description
Fuzzing infrastructure for ELARA Protocol
This crate provides a trait-based framework for creating fuzz targets that can discover edge cases, panics, and security vulnerabilities in parsing and cryptographic code.
§Architecture
The fuzzing infrastructure consists of:
- FuzzTarget trait: Core abstraction for fuzz targets
- FuzzResult enum: Classification of fuzz outcomes
- Concrete fuzzers: Pre-built fuzzers for wire protocol, crypto, and state
§Example
use elara_fuzz::{FuzzTarget, FuzzResult};
use arbitrary::Arbitrary;
#[derive(Arbitrary, Debug)]
struct MyInput {
data: Vec<u8>,
}
struct MyFuzzer;
impl FuzzTarget for MyFuzzer {
type Input = MyInput;
fn fuzz_once(&mut self, input: Self::Input) -> FuzzResult {
// Test your code with arbitrary input
match process_data(&input.data) {
Ok(_) => FuzzResult::Ok,
Err(e) if e.is_expected() => FuzzResult::Invalid,
Err(e) => FuzzResult::Bug(format!("Unexpected error: {}", e)),
}
}
}§Integration with cargo-fuzz
To use with cargo-fuzz, create fuzz targets in fuzz/fuzz_targets/:
#![no_main]
use libfuzzer_sys::fuzz_target;
use elara_fuzz::FuzzTarget;
fuzz_target!(|data: <MyFuzzer as FuzzTarget>::Input| {
let mut fuzzer = MyFuzzer;
let _ = fuzzer.fuzz_once(data);
});Enums§
- Fuzz
Result - Result of a single fuzz iteration
Traits§
- Fuzz
Target - Trait for implementing fuzz targets