mirror of
https://github.com/chatmail/core.git
synced 2026-05-10 18:36:29 +03:00
Add fuzzing tests
This commit is contained in:
10
fuzz/fuzz_targets/fuzz_dateparse.rs
Normal file
10
fuzz/fuzz_targets/fuzz_dateparse.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use bolero::check;
|
||||
|
||||
fn main() {
|
||||
check!().for_each(|data: &[u8]| match std::str::from_utf8(data) {
|
||||
Ok(input) => {
|
||||
mailparse::dateparse(input).ok();
|
||||
}
|
||||
Err(_err) => {}
|
||||
});
|
||||
}
|
||||
25
fuzz/fuzz_targets/fuzz_format_flowed.rs
Normal file
25
fuzz/fuzz_targets/fuzz_format_flowed.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use bolero::check;
|
||||
use format_flowed::{format_flowed, unformat_flowed};
|
||||
|
||||
fn round_trip(input: &str) -> String {
|
||||
let mut input = format_flowed(input);
|
||||
input.retain(|c| c != '\r');
|
||||
unformat_flowed(&input, false)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
check!().for_each(|data: &[u8]| {
|
||||
if let Ok(input) = std::str::from_utf8(data.into()) {
|
||||
let mut input = input.to_string();
|
||||
|
||||
// Only consider inputs that don't contain quotes.
|
||||
input.retain(|c| c != '>');
|
||||
|
||||
// Only consider inputs that are the result of unformatting format=flowed text.
|
||||
// At least this means that lines don't contain any trailing whitespace.
|
||||
let input = round_trip(&input);
|
||||
let output = round_trip(&input);
|
||||
assert_eq!(input, output);
|
||||
}
|
||||
});
|
||||
}
|
||||
7
fuzz/fuzz_targets/fuzz_mailparse.rs
Normal file
7
fuzz/fuzz_targets/fuzz_mailparse.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use bolero::check;
|
||||
|
||||
fn main() {
|
||||
check!().for_each(|data: &[u8]| {
|
||||
mailparse::parse_mail(data).ok();
|
||||
});
|
||||
}
|
||||
13
fuzz/fuzz_targets/fuzz_simplify.rs
Normal file
13
fuzz/fuzz_targets/fuzz_simplify.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use bolero::check;
|
||||
|
||||
use deltachat::fuzzing::simplify;
|
||||
|
||||
fn main() {
|
||||
check!().for_each(|data: &[u8]| match String::from_utf8(data.to_vec()) {
|
||||
Ok(input) => {
|
||||
simplify(input.clone(), true);
|
||||
simplify(input, false);
|
||||
}
|
||||
Err(_err) => {}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user