Add fuzz testing to qcode

This commit is contained in:
Vikram Rangnekar 2019-04-18 21:08:14 -04:00
parent bdf76fcd5e
commit 7f8ab26218
10 changed files with 143 additions and 0 deletions

21
corpus/1 Normal file
View File

@ -0,0 +1,21 @@
query {
products(
# returns only 30 items
limit: 30,
# starts from item 10, commented out for now
# offset: 10,
# orders the response items by highest price
order_by: { price: desc },
# no duplicate prices returned
distinct: [ price ]
# only items with an id >= 30 and < 30 are returned
where: { id: { and: { greater_or_equals: 20, lt: 28 } } }) {
id
name
price
}
}

14
corpus/2 Normal file
View File

@ -0,0 +1,14 @@
query {
products(
where: {
or: {
not: { id: { is_null: true } },
price: { gt: 10 },
price: { lt: 20 }
} }
) {
id
name
price
}
}

12
corpus/3 Normal file
View File

@ -0,0 +1,12 @@
query {
products(
where: {
and: {
not: { id: { is_null: true } },
price: { gt: 10 }
}}) {
id
name
price
}
}

12
corpus/4 Normal file
View File

@ -0,0 +1,12 @@
query {
products(
where: {
and: [
{ not: { id: { is_null: true } } },
{ price: { gt: 10 } },
] } ) {
id
name
price
}
}

6
corpus/5 Normal file
View File

@ -0,0 +1,6 @@
query {
product(id: 15) {
id
name
}
}

21
corpus/6 Normal file
View File

@ -0,0 +1,21 @@
query {
products(
# returns only 30 items
limit: 30,
# starts from item 10, commented out for now
# offset: 10,
# orders the response items by highest price
order_by: { price: desc },
# no duplicate prices returned
distinct: [ price ]
# only items with an id >= 30 and < 30 are returned
where: { id: { and: { greater_or_equals: 20, lt: 28 } } }) {
id
name
price
}
}

6
corpus/7 Normal file
View File

@ -0,0 +1,6 @@
query {
products(search: "Imperial") {
id
name
}
}

22
corpus/8 Normal file
View File

@ -0,0 +1,22 @@
query {
products(
# returns only 30 items
limit: 30,
# starts from item 10, commented out for now
# offset: 10,
# orders the response items by highest price
order_by: { price: desc },
# only items with an id >= 30 and < 30 are returned
where: { id: { and: { greater_or_equals: 20, lt: 28 } } }) {
id
name
price
user {
full_name
picture : avatar
}
}
}

15
fuzz.yaml Normal file
View File

@ -0,0 +1,15 @@
base: ubuntu:16.04
targets:
- name: tutorial
language: go
version: "1.12"
corpus: ./corpus
#memory_limit: 1000 # in megabytes
#timeout: 500 # in milliseconds
harness:
function: FuzzerEntrypoint
# package defines where to import FuzzerEntrypoint from
package: github.com/dosco/super-graph/qcode
# the repository will be cloned to
# $GOPATH/src/github.com/fuzzbuzz/tutorial
checkout: github.com/dosco/super-graph/

14
qcode/fuzz.go Normal file
View File

@ -0,0 +1,14 @@
package qcode
// FuzzerEntrypoint for Fuzzbuzz
func FuzzerEntrypoint(data []byte) int {
testData := string(data)
qcompile, _ := NewCompiler(Config{})
_, err := qcompile.CompileQuery(testData)
if err != nil {
return -1
}
return 0
}