Files
kestrove-core/fuzz/fuzz_targets/url_match.rs
T
samiandClaude Opus 5.5 83ab00c03c Add cargo-fuzz targets for the untrusted-input parsers and the hardening report
envelope_json, manifest_decode, item_replay, secret_key_parse, totp_parse, url_match,
with seeds. fuzz/README.md records the runs (and the server/desktop targets), the two
bugs fixed in the previous commits, dependency-policy results, CI changes and the
deploy check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 01:01:44 +09:00

18 lines
660 B
Rust

//! kv-model URL matching: never panics, a URL always matches itself at least at host level, and an
//! https item never matches an http page.
#![no_main]
use kv_model::{match_url, MatchLevel};
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
let Ok(s) = std::str::from_utf8(data) else { return };
let (a, b) = s.split_once('\n').unwrap_or((s, ""));
let m = match_url(a, b);
if b.trim_start().to_ascii_lowercase().starts_with("http://")
&& a.trim_start().to_ascii_lowercase().starts_with("https://")
{
assert_eq!(m, MatchLevel::None, "downgrade matched: {a:?} -> {b:?}");
}
let _ = match_url(a, a);
});