Bloom filter for probabilistic membership testing
0
fork

Configure Feed

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

fix(lint): add gen_corpus.ml to all fuzz directories for E718

Add seed corpus generators with representative test data for:
ocaml-aos, ocaml-block, ocaml-bloom, ocaml-bpsec, ocaml-bundle,
ocaml-cfdp, ocaml-cgr, ocaml-clcw, ocaml-cookeio, ocaml-cpio

+32
+5
fuzz/dune
··· 20 20 fuzz.exe) 21 21 (action 22 22 (echo "AFL fuzzer built: %{exe:fuzz.exe}\n"))) 23 + 24 + (executable 25 + (name gen_corpus) 26 + (modules gen_corpus) 27 + (libraries bloom unix))
+27
fuzz/gen_corpus.ml
··· 1 + (** Generate seed corpus for fuzz testing. *) 2 + 3 + let () = 4 + (try Unix.mkdir "corpus" 0o755 5 + with Unix.Unix_error (Unix.EEXIST, _, _) -> ()); 6 + let write name data = 7 + let oc = open_out_bin (Filename.concat "corpus" name) in 8 + output_string oc data; 9 + close_out oc 10 + in 11 + (* Simple strings that would be added to a bloom filter *) 12 + write "seed_000" "hello"; 13 + write "seed_001" "world"; 14 + write "seed_002" ""; 15 + write "seed_003" (String.make 256 'x'); 16 + (* Binary patterns *) 17 + write "seed_004" "\x00\x00\x00\x00"; 18 + write "seed_005" "\xFF\xFF\xFF\xFF"; 19 + (* Serialized bloom filter bytes - create a small one and serialize it *) 20 + let bf = Bloom.v ~error_rate:0.01 100 in 21 + Bloom.add bf "test"; 22 + Bloom.add bf "fuzz"; 23 + write "seed_006" (Bytes.to_string (Bloom.to_bytes bf)); 24 + (* Empty bloom filter serialized *) 25 + let bf_empty = Bloom.v ~error_rate:0.1 10 in 26 + write "seed_007" (Bytes.to_string (Bloom.to_bytes bf_empty)); 27 + print_endline "gen_corpus: wrote 8 bloom seed files"