mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-31 16:49:34 +00:00
- Use std::sync::LazyLock to construct Sanitizer, Validator, and LeakDetector once instead of on every fuzz iteration (they compile regex/Aho-Corasick) - Remove fuzz_config_env assertion that panics on null-byte-only input - Remove no-op length check with misleading comment in fuzz_config_env - Update fuzz_config_env description in README to match actual behavior Co-Authored-By: Claude Opus 4.6 <[email protected]>
26 lines
722 B
Rust
26 lines
722 B
Rust
#![no_main]
|
|
use libfuzzer_sys::fuzz_target;
|
|
use std::sync::LazyLock;
|
|
|
|
use ironclaw::safety::LeakDetector;
|
|
|
|
static DETECTOR: LazyLock<LeakDetector> = LazyLock::new(LeakDetector::new);
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
|
if let Ok(s) = std::str::from_utf8(data) {
|
|
// Exercise scan path
|
|
let result = DETECTOR.scan(s);
|
|
// Invariant: if should_block, there must be matches
|
|
if result.should_block {
|
|
assert!(!result.matches.is_empty());
|
|
}
|
|
// Invariant: match locations must be valid
|
|
for m in &result.matches {
|
|
assert!(m.location.end <= s.len());
|
|
}
|
|
|
|
// Exercise scan_and_clean path
|
|
let _ = DETECTOR.scan_and_clean(s);
|
|
}
|
|
});
|