forked from graphql-rust/juniper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Depends on graphql-rust#1032.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target | ||
corpus | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[package] | ||
name = "fuzz" | ||
version = "0.0.0" | ||
authors = ["Automatically generated"] | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] } | ||
apollo-smith = "0.1.0" | ||
|
||
[dependencies.juniper] | ||
path = "../juniper" | ||
features = ["arbitrary1"] | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[[bin]] | ||
name = "document_fuzzer" | ||
path = "fuzz_targets/document_fuzzer.rs" | ||
test = false | ||
doc = false | ||
|
||
[[bin]] | ||
name = "introspection_fuzzer" | ||
path = "fuzz_targets/introspection_fuzzer.rs" | ||
test = false | ||
doc = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![no_main] | ||
use apollo_smith::DocumentBuilder; | ||
use libfuzzer_sys::{ | ||
arbitrary::{self, Unstructured}, | ||
fuzz_target, | ||
}; | ||
|
||
use juniper::{DefaultScalarValue, EmptyMutation, EmptySubscription, GraphQLObject, RootNode}; | ||
|
||
#[derive(Default, GraphQLObject, arbitrary::Arbitrary)] | ||
struct Query { | ||
x: i32, | ||
y: String, | ||
z: Vec<bool>, | ||
} | ||
|
||
fuzz_target!(|input: &[u8]| { | ||
let mut u = Unstructured::new(input); | ||
let mut u2 = Unstructured::new(input); | ||
if let Ok(gql_doc) = DocumentBuilder::new(&mut u) { | ||
let document = gql_doc.finish(); | ||
let doc = String::from(document); | ||
|
||
let arbitrary_schema: arbitrary::Result< | ||
RootNode<Query, EmptyMutation<()>, EmptySubscription<()>, DefaultScalarValue>, | ||
> = u2.arbitrary(); | ||
|
||
if let Ok(schema) = arbitrary_schema { | ||
let _ = juniper::parser::parse_document_source(doc.as_str(), &schema.schema); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![no_main] | ||
use libfuzzer_sys::{ | ||
arbitrary::{self, Unstructured}, | ||
fuzz_target, | ||
}; | ||
|
||
use juniper::{ | ||
DefaultScalarValue, EmptyMutation, EmptySubscription, GraphQLObject, IntrospectionFormat, | ||
}; | ||
|
||
#[derive(Default, GraphQLObject, arbitrary::Arbitrary)] | ||
struct Query { | ||
x: i32, | ||
y: String, | ||
z: Vec<bool>, | ||
} | ||
|
||
fuzz_target!(|input: &[u8]| { | ||
let mut u = Unstructured::new(input); | ||
let arbitrary_schema: arbitrary::Result< | ||
juniper::RootNode<Query, EmptyMutation<()>, EmptySubscription<()>, DefaultScalarValue>, | ||
> = u.arbitrary(); | ||
|
||
if let Ok(schema) = arbitrary_schema { | ||
let _ = juniper::introspect(&schema, &(), IntrospectionFormat::default()); | ||
} | ||
}); |