Expand description
§Fuzzerang
Useful random generators and distributions for use in fuzzers and mutators
Instead of being very random, very fast, or very secure, these generators
and distributions are designed to be useful for fuzzing and mutation by efficiently
utilizing available input data. For example, the default [Standard] distribution
in the rand crate wastes 31 bits of input for every boolean value generated.
In comparison, StandardBuffered uses the input data more efficiently by consuming
only 1 bit for a boolean, the minimum number of bits to generate a value in a range, and so
on.
§Examples
use fuzzerang::{StandardSeedableRng, StandardBuffered, Ranged};
use rand::{SeedableRng, distributions::Distribution};
// Use a constant seed of 8 bytes, or 64 bits
let mut rng = StandardSeedableRng::from_seed((0..255).take(8).collect());
let dist = StandardBuffered::new();
// We can generate 10 bools from 8 bytes of input because we're only using 1 bit each
for i in 0..10 {
let x: bool = dist.sample(&mut rng);
println!("{}: {}", i, x);
}
// In fact, we are so efficient we can generate some alphabetic characters too, which
// each use 4 bits
for i in 0..10 {
let x: char = dist.sample_range_inclusive(&mut rng, 'A'..='Z');
println!("{}: {}", i, x);
}
Structs§
- Standard
Buffered - Similar to the
rand::distributions::Standarddistribution in that it generates values in the “expected” way for each type - Standard
Seedable Rng - An RNG that generates values directly from a seed (similar to proptest’s
PassThroughRNG). This is mostly only useful in conjunction with the provided distributions like [StandardBuffered] because although the [RandCore] trait is restrictive and only allows byte-level resolution, we want to do better than this. - TryDist
Iter - An iterator that generates random values of
Twith distributionD, usingRas the source of randomness. - TryDist
Map - A distribution of values of type
Sderived from the distributionDby mapping its output of typeTthrough the closureF.
Traits§
- Buffered
- Ranged
- TryDistribution
- Types (distributions) that can be used to create a random instance of
T. - TryRanged