Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

simpler fuzz targets take a lot longer to crash

phil 4a966494 a38ee2b5

+74 -6
+2
Cargo.lock
··· 3814 3814 name = "ufos-fuzz" 3815 3815 version = "0.0.0" 3816 3816 dependencies = [ 3817 + "bincode 2.0.1", 3818 + "cardinality-estimator", 3817 3819 "jetstream", 3818 3820 "libfuzzer-sys", 3819 3821 "tikv-jemallocator",
+18 -6
ufos/fuzz/Cargo.toml
··· 9 9 10 10 [dependencies] 11 11 libfuzzer-sys = "0.4" 12 - 13 - [dependencies.ufos] 14 - path = ".." 15 - 16 - [dependencies.jetstream] 17 - path = "../../jetstream" 12 + ufos = { path = ".." } 13 + jetstream = { path = "../../jetstream" } 14 + bincode = { version = "2.0.1", features = ["serde"] } 15 + cardinality-estimator = { version = "1.0.2", features = ["with_serde"] } 18 16 19 17 [target.'cfg(not(target_env = "msvc"))'.dependencies] 20 18 tikv-jemallocator = "0.6.0" ··· 25 23 test = false 26 24 doc = false 27 25 bench = false 26 + 27 + [[bin]] 28 + name = "estimated_dids_value" 29 + path = "fuzz_targets/estimated_dids_value.rs" 30 + test = false 31 + doc = false 32 + bench = false 33 + 34 + [[bin]] 35 + name = "cardinality_estimator" 36 + path = "fuzz_targets/cardinality_estimator.rs" 37 + test = false 38 + doc = false 39 + bench = false
+30
ufos/fuzz/fuzz_targets/cardinality_estimator.rs
··· 1 + #![no_main] 2 + 3 + use jetstream::exports::Did; 4 + use bincode::config::{Configuration, BigEndian, Fixint, Limit, standard}; 5 + use bincode::serde::decode_from_slice; 6 + use cardinality_estimator::CardinalityEstimator; 7 + use libfuzzer_sys::fuzz_target; 8 + 9 + #[cfg(not(target_env = "msvc"))] 10 + use tikv_jemallocator::Jemalloc; 11 + 12 + #[cfg(not(target_env = "msvc"))] 13 + #[global_allocator] 14 + static GLOBAL: Jemalloc = Jemalloc; 15 + 16 + type C = Configuration<BigEndian, Fixint, Limit<1048576>>; 17 + static BINCODE_CONF: C = 18 + standard() 19 + .with_big_endian() 20 + .with_fixed_int_encoding() 21 + .with_limit::<1048576>(); 22 + 23 + fuzz_target!(|data: &[u8]| { 24 + if let Ok((estimator, _n)) = decode_from_slice::<CardinalityEstimator<Did>, C>( 25 + data, 26 + BINCODE_CONF, 27 + ) { 28 + estimator.estimate(); 29 + } 30 + });
+24
ufos/fuzz/fuzz_targets/estimated_dids_value.rs
··· 1 + #![no_main] 2 + 3 + // use jetstream::exports::Did; 4 + use ufos::db_types::DbBytes; 5 + use ufos::store_types::EstimatedDidsValue; 6 + use libfuzzer_sys::fuzz_target; 7 + 8 + #[cfg(not(target_env = "msvc"))] 9 + use tikv_jemallocator::Jemalloc; 10 + 11 + #[cfg(not(target_env = "msvc"))] 12 + #[global_allocator] 13 + static GLOBAL: Jemalloc = Jemalloc; 14 + 15 + fuzz_target!(|data: &[u8]| { 16 + if let Ok((counts_value, n)) = EstimatedDidsValue::from_db_bytes(data) { 17 + assert!(n <= data.len()); 18 + let serialized = counts_value.to_db_bytes().unwrap(); 19 + assert_eq!(serialized.len(), n); 20 + let (and_back, n_again) = EstimatedDidsValue::from_db_bytes(&serialized).unwrap(); 21 + assert_eq!(n_again, n); 22 + assert_eq!(and_back.0.estimate(), counts_value.0.estimate()); 23 + } 24 + });