The Arbitrary
crate lets you construct arbitrary instance of a type.
This crate is primarily intended to be combined with a fuzzer like libFuzzer and cargo-fuzz
or AFL, and to help you turn the raw, untyped byte buffers that they produce into well-typed, valid, structured values. This allows you to combine structure-aware test case generation with coverage-guided, mutation-based fuzzers.
Learn more:
And the arbitrary
crate is approaching 1.0! We've already released two 1.0 release candidates. Now we're asking for your help: Please try out the latest release candidate with your existing fuzz targets (or new ones) and let us know if there is anything that isn't smooth, feels like a regression, etc.
# Update your Cargo.toml to take the release
# candidate for a spin.
[dependencies]
arbitrary = "1.0.0-rc2"
If all goes smoothly, we intend to release 1.0 in two weeks on February 23rd.
CHANGELOG
1.0.0-rc2
Released 2021-02-09.
Added
- The
Arbitrary
trait is now implemented for&[u8]
. #67
Changed
- Rename
Unstructured#get_bytes
toUnstructured#bytes
. #70 - Passing an empty slice of choices to
Unstructured#choose
returns an error. Previously it would panic. 71
1.0.0-rc1
Released 2020-11-25.
Added
- The
Arbitrary
trait is now implemented for&str
. #63
Changed
- The
Arbitrary
trait now has a lifetime parameter, allowingArbitrary
implementations that borrow from the raw input (e.g. the new&str
implementaton). Thederive(Arbitrary)
macro also supports derivingArbitrary
on types with lifetimes now. #63
Removed
-
The
shrink
method on theArbitrary
trait has been removed.We have found that, in practice, using internal reduction via approaches like
cargo fuzz tmin
, where the raw input bytes are reduced rather than theT: Arbitrary
type constructed from those raw bytes, has the best efficiency-to-maintenance ratio. To the best of our knowledge, no one is relying on or using theArbitrary::shrink
method. If you are using and relying on theArbitrary::shrink
method, please reach out by dropping a comment here and explaining how you're using it and what your use case is. We'll figure out what the best solution is, including potentially adding shrinking functionality back to thearbitrary
crate.