mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-26 23:50:17 +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]>
18 lines
586 B
Rust
18 lines
586 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) {
|
|
// Try parsing as JSON and validating as tool parameters
|
|
if let Ok(value) = serde_json::from_str::<serde_json::Value>(s) {
|
|
let validator = Validator::new();
|
|
let result = validator.validate_tool_params(&value);
|
|
// Invariant: result should always be well-formed
|
|
if !result.is_valid {
|
|
assert!(!result.errors.is_empty());
|
|
}
|
|
}
|
|
}
|
|
});
|