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

try some fuzzing?

no joy

+30 -5
Cargo.lock
··· 116 116 checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" 117 117 118 118 [[package]] 119 + name = "arbitrary" 120 + version = "1.4.1" 121 + source = "registry+https://github.com/rust-lang/crates.io-index" 122 + checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" 123 + 124 + [[package]] 119 125 name = "arrayvec" 120 126 version = "0.7.6" 121 127 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1106 1112 checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" 1107 1113 dependencies = [ 1108 1114 "libc", 1109 - "windows-sys 0.52.0", 1115 + "windows-sys 0.59.0", 1110 1116 ] 1111 1117 1112 1118 [[package]] ··· 1809 1815 dependencies = [ 1810 1816 "hermit-abi", 1811 1817 "libc", 1812 - "windows-sys 0.52.0", 1818 + "windows-sys 0.59.0", 1813 1819 ] 1814 1820 1815 1821 [[package]] ··· 1934 1940 checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" 1935 1941 1936 1942 [[package]] 1943 + name = "libfuzzer-sys" 1944 + version = "0.4.9" 1945 + source = "registry+https://github.com/rust-lang/crates.io-index" 1946 + checksum = "cf78f52d400cf2d84a3a973a78a592b4adc535739e0a5597a0da6f0c357adc75" 1947 + dependencies = [ 1948 + "arbitrary", 1949 + "cc", 1950 + ] 1951 + 1952 + [[package]] 1937 1953 name = "libloading" 1938 1954 version = "0.8.6" 1939 1955 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2900 2916 "errno", 2901 2917 "libc", 2902 2918 "linux-raw-sys 0.4.15", 2903 - "windows-sys 0.52.0", 2919 + "windows-sys 0.59.0", 2904 2920 ] 2905 2921 2906 2922 [[package]] ··· 2913 2929 "errno", 2914 2930 "libc", 2915 2931 "linux-raw-sys 0.9.4", 2916 - "windows-sys 0.52.0", 2932 + "windows-sys 0.59.0", 2917 2933 ] 2918 2934 2919 2935 [[package]] ··· 3391 3407 "getrandom 0.3.2", 3392 3408 "once_cell", 3393 3409 "rustix 1.0.5", 3394 - "windows-sys 0.52.0", 3410 + "windows-sys 0.59.0", 3395 3411 ] 3396 3412 3397 3413 [[package]] ··· 3792 3808 "thiserror 2.0.12", 3793 3809 "tikv-jemallocator", 3794 3810 "tokio", 3811 + ] 3812 + 3813 + [[package]] 3814 + name = "ufos-fuzz" 3815 + version = "0.0.0" 3816 + dependencies = [ 3817 + "jetstream", 3818 + "libfuzzer-sys", 3819 + "ufos", 3795 3820 ] 3796 3821 3797 3822 [[package]]
+1
Cargo.toml
··· 5 5 "constellation", 6 6 "jetstream", 7 7 "ufos", 8 + "ufos/fuzz", 8 9 ]
+4
ufos/fuzz/.gitignore
··· 1 + target 2 + corpus 3 + artifacts 4 + coverage
+24
ufos/fuzz/Cargo.toml
··· 1 + [package] 2 + name = "ufos-fuzz" 3 + version = "0.0.0" 4 + publish = false 5 + edition = "2021" 6 + 7 + [package.metadata] 8 + cargo-fuzz = true 9 + 10 + [dependencies] 11 + libfuzzer-sys = "0.4" 12 + 13 + [dependencies.ufos] 14 + path = ".." 15 + 16 + [dependencies.jetstream] 17 + path = "../../jetstream" 18 + 19 + [[bin]] 20 + name = "counts_value" 21 + path = "fuzz_targets/counts_value.rs" 22 + test = false 23 + doc = false 24 + bench = false
+23
ufos/fuzz/fuzz_targets/counts_value.rs
··· 1 + #![no_main] 2 + 3 + // use jetstream::exports::Did; 4 + use ufos::db_types::DbBytes; 5 + use ufos::store_types::CountsValue; 6 + use libfuzzer_sys::fuzz_target; 7 + 8 + fuzz_target!(|data: &[u8]| { 9 + if let Ok((counts_value, n)) = CountsValue::from_db_bytes(data) { 10 + assert!(n <= data.len()); 11 + let serialized = counts_value.to_db_bytes().unwrap(); 12 + assert_eq!(serialized.len(), n); 13 + let (and_back, n_again) = CountsValue::from_db_bytes(&serialized).unwrap(); 14 + assert_eq!(n_again, n); 15 + assert_eq!(and_back.records(), counts_value.records()); 16 + assert_eq!(and_back.dids().estimate(), counts_value.dids().estimate()); 17 + // assert_eq!(serialized, data[..n]); 18 + // counts_value.prefix.0 += 1; 19 + // counts_value.suffix.0.insert(&Did::new("did:plc:blah".to_string()).unwrap()); 20 + // assert!(counts_value.records() > 0); 21 + // assert!(counts_value.dids().estimate() > 0); 22 + } 23 + });
+5
ufos/src/db_types.rs
··· 120 120 Self: Sized, 121 121 { 122 122 let (prefix, eaten) = P::from_db_bytes(bytes)?; 123 + assert!(eaten <= bytes.len(), "eaten({}) < len({})", eaten, bytes.len()); 123 124 let Some(suffix_bytes) = bytes.get(eaten..) else { 124 125 return Err(EncodingError::DecodeMissingSuffix); 125 126 }; 127 + if suffix_bytes.len() == 0 { 128 + return Err(EncodingError::DecodeMissingSuffix); 129 + }; 126 130 let (suffix, also_eaten) = S::from_db_bytes(suffix_bytes)?; 131 + assert!(also_eaten <= suffix_bytes.len(), "also eaten({}) < suffix len({})", also_eaten, suffix_bytes.len()); 127 132 Ok((Self { prefix, suffix }, eaten + also_eaten)) 128 133 } 129 134 }
+5 -5
ufos/src/store_types.rs
··· 211 211 impl SerdeBytes for EstimatedDidsValue {} 212 212 impl DbBytes for EstimatedDidsValue { 213 213 fn to_db_bytes(&self) -> Result<Vec<u8>, EncodingError> { 214 - Ok(vec![1, 2, 3]) 215 - // SerdeBytes::to_bytes(self) 214 + // Ok(vec![1, 2, 3]) 215 + SerdeBytes::to_bytes(self) 216 216 } 217 - fn from_db_bytes(_bytes: &[u8]) -> Result<(Self, usize), EncodingError> { 218 - Ok((Self(CardinalityEstimator::new()), 3)) 219 - // SerdeBytes::from_bytes(bytes) 217 + fn from_db_bytes(bytes: &[u8]) -> Result<(Self, usize), EncodingError> { 218 + // Ok((Self(CardinalityEstimator::new()), 3)) 219 + SerdeBytes::from_bytes(bytes) 220 220 } 221 221 } 222 222