Add fuzz testing to qcode
This commit is contained in:
parent
bdf76fcd5e
commit
7f8ab26218
21
corpus/1
Normal file
21
corpus/1
Normal 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
14
corpus/2
Normal 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
12
corpus/3
Normal 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
12
corpus/4
Normal file
@ -0,0 +1,12 @@
|
||||
query {
|
||||
products(
|
||||
where: {
|
||||
and: [
|
||||
{ not: { id: { is_null: true } } },
|
||||
{ price: { gt: 10 } },
|
||||
] } ) {
|
||||
id
|
||||
name
|
||||
price
|
||||
}
|
||||
}
|
21
corpus/6
Normal file
21
corpus/6
Normal 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
|
||||
}
|
||||
}
|
22
corpus/8
Normal file
22
corpus/8
Normal 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
15
fuzz.yaml
Normal 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
14
qcode/fuzz.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user