build: intergrate fuzz crate into workspace

This makes `fuzz` use the same lockfile
as the rest of the crates
and makes sure it fuzzes the same versions
of dependencies, e.g. `mailparse`.
This commit is contained in:
link2xt
2025-03-09 02:17:19 +00:00
parent 491d6abe49
commit d69db8f336
8 changed files with 112 additions and 7088 deletions

106
Cargo.lock generated
View File

@@ -606,6 +606,96 @@ dependencies = [
"cipher",
]
[[package]]
name = "bolero"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3387d308f66ed222bdbb19c6ba06b1517168c4e45dc64051c5f1b4845db2901c"
dependencies = [
"bolero-afl",
"bolero-engine",
"bolero-generator",
"bolero-honggfuzz",
"bolero-kani",
"bolero-libfuzzer",
"cfg-if",
"rand 0.8.5",
]
[[package]]
name = "bolero-afl"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "973bc6341b6a865dee93f17b78de4a100551014a527798ff1d7265d3bc0f7d89"
dependencies = [
"bolero-engine",
"cc",
]
[[package]]
name = "bolero-engine"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c506a476cea9e95f58c264b343ee279c353d93ceaebe98cbfb16e74bfaee2e2"
dependencies = [
"anyhow",
"backtrace",
"bolero-generator",
"lazy_static",
"pretty-hex",
"rand 0.8.5",
]
[[package]]
name = "bolero-generator"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48d52eca8714d110e581cf17eeacf0d1a0d409d38a9e9ce07efeda6125f7febb"
dependencies = [
"bolero-generator-derive",
"either",
"rand_core 0.6.4",
]
[[package]]
name = "bolero-generator-derive"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3c57c2a0967ad1a09ba4c2bf8f1c6b6db2f71e8c0db4fa280c65a0f6c249c3"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "bolero-honggfuzz"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7996a3fa8d93652358b9b3b805233807168f49740a8bf91a531cd61e4da65355"
dependencies = [
"bolero-engine",
]
[[package]]
name = "bolero-kani"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206879993fffa1cf2c703b1ef93b0febfa76bae85a0a5d4ae0ee6d99a2e3b74e"
dependencies = [
"bolero-engine",
]
[[package]]
name = "bolero-libfuzzer"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc5547411b84703d9020914f15a7d709cfb738c72b5e0f5a499fe56b8465c98"
dependencies = [
"bolero-engine",
"cc",
]
[[package]]
name = "bounded-integer"
version = "0.5.8"
@@ -1388,6 +1478,16 @@ dependencies = [
"rusqlite",
]
[[package]]
name = "deltachat-fuzz"
version = "0.0.0"
dependencies = [
"bolero",
"deltachat",
"format-flowed",
"mailparse",
]
[[package]]
name = "deltachat-jsonrpc"
version = "1.156.3"
@@ -4527,6 +4627,12 @@ dependencies = [
"ucd-parse",
]
[[package]]
name = "pretty-hex"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5"
[[package]]
name = "pretty_assertions"
version = "1.4.1"

View File

@@ -68,7 +68,7 @@ iroh = { version = "0.33", default-features = false }
kamadak-exif = "0.6.1"
libc = { workspace = true }
mail-builder = { version = "0.4.2", default-features = false }
mailparse = "0.16.1"
mailparse = { workspace = true }
mime = "0.3.17"
num_cpus = "1.16"
num-derive = "0.4"
@@ -135,6 +135,7 @@ members = [
"deltachat-time",
"format-flowed",
"deltachat-contact-tools",
"fuzz",
]
[[bench]]
@@ -182,6 +183,7 @@ futures = "0.3.31"
futures-lite = "2.6.0"
libc = "0.2"
log = "0.4"
mailparse = "0.16.1"
nu-ansi-term = "0.46"
num-traits = "0.2"
once_cell = "1.20.2"

7049
fuzz/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,28 +3,21 @@ name = "deltachat-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
license = "MPL-2.0"
[dev-dependencies]
bolero = "0.8"
[dependencies]
mailparse = "0.16"
mailparse = { workspace = true }
deltachat = { path = ".." }
format-flowed = { path = "../format-flowed" }
[workspace]
members = ["."]
[[test]]
name = "fuzz_dateparse"
path = "fuzz_targets/fuzz_dateparse.rs"
harness = false
[[test]]
name = "fuzz_simplify"
path = "fuzz_targets/fuzz_simplify.rs"
harness = false
[[test]]
name = "fuzz_mailparse"
path = "fuzz_targets/fuzz_mailparse.rs"

View File

@@ -9,7 +9,7 @@ fn round_trip(input: &str) -> String {
fn main() {
check!().for_each(|data: &[u8]| {
if let Ok(input) = std::str::from_utf8(data.into()) {
if let Ok(input) = std::str::from_utf8(data) {
let input = input.trim().to_string();
// Only consider inputs that are the result of unformatting format=flowed text.

View File

@@ -1,13 +0,0 @@
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) => {}
});
}

View File

@@ -1,12 +0,0 @@
//! # Fuzzing module.
//!
//! This module exposes private APIs for fuzzing.
/// Fuzzing target for simplify().
///
/// Calls simplify() and panics if simplify() panics.
/// Does not return any value to avoid exposing internal crate types.
#[cfg(fuzzing)]
pub fn simplify(input: String, is_chat_message: bool) {
crate::simplify::simplify(input, is_chat_message);
}

View File

@@ -116,6 +116,3 @@ pub const DCC_MIME_DEBUG: &str = "DCC_MIME_DEBUG";
mod test_utils;
#[cfg(test)]
mod tests;
#[cfg(fuzzing)]
pub mod fuzzing;