apollo-smith

apollo-smith

A test case generator for GraphQL language.

Crates.io Download docs.rs docs

About

The goal of apollo-smith is to generate valid GraphQL documents by sampling from all available possibilities of [GraphQL grammar].

We've written apollo-smith to use in fuzzing, but you may wish to use it for anything that requires GraphQL document generation.

apollo-smith is inspired by bytecodealliance's [wasm-smith] crate, and the [article written by Nick Fitzgerald] on writing test case generators in Rust.

This is still a work in progress, for outstanding issues, checkout out the [apollo-smith label] in our issue tracker.

Using apollo-smith with cargo fuzz

Define a new target with [cargo fuzz],

shell $ cargo fuzz add my_apollo_smith_fuzz_target

and add apollo-smith to your Cargo.toml:

```toml

fuzz/Cargo.toml

[dependencies] apollo-smith = "0.1.0" ```

It can then be used in a fuzz_target along with the [arbitrary] crate,

```rust,compilefail // fuzz/fuzztargets/myapollosmithfuzztarget.rs

![no_main]

use libfuzzersys::fuzztarget; use arbitrary::Unstructured; use apollo_smith::DocumentBuilder;

fuzztarget!(|input: &[u8]| { let mut u = Unstructured::new(input); let gqldoc = DocumentBuilder::new(&mut u)?; let document = gqldoc.finish(); let documentstr = String::from(document);

}); ```

and fuzzed with the following command:

shell $ cargo +nightly fuzz run my_apollo_smith_fuzz_target

Limitations

License

Licensed under either of

at your option.