mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-09-01 17:19:24 +00:00
Add cargo-fuzz infrastructure with 5 fuzz targets exercising security-critical code paths: - fuzz_safety_sanitizer: Aho-Corasick + regex injection detection - fuzz_safety_validator: Input validation (length, encoding, patterns) - fuzz_leak_detector: Secret leak scanning (API keys, tokens) - fuzz_tool_params: Tool parameter JSON validation - fuzz_config_env: TOML/JSON config parsing Each target exercises real IronClaw business logic with invariant assertions. Includes corpus directories and setup documentation. Co-Authored-By: Claude Opus 4.6 <[email protected]>
22 lines
626 B
Rust
22 lines
626 B
Rust
#![no_main]
|
|
use libfuzzer_sys::fuzz_target;
|
|
use ironclaw::safety::Validator;
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
|
if let Ok(s) = std::str::from_utf8(data) {
|
|
let validator = Validator::new();
|
|
|
|
// Exercise input validation
|
|
let result = validator.validate(s);
|
|
// Invariant: empty input is always invalid
|
|
if s.is_empty() {
|
|
assert!(!result.is_valid);
|
|
}
|
|
|
|
// Exercise tool parameter validation with arbitrary JSON
|
|
if let Ok(value) = serde_json::from_str::<serde_json::Value>(s) {
|
|
let _ = validator.validate_tool_params(&value);
|
|
}
|
|
}
|
|
});
|