Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Bailey committed Jul 13, 2017
1 parent 385794c commit 0d45c2a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
43 changes: 43 additions & 0 deletions fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// +build gofuzz

package e3db

func dieErr(err error) {
panic(err)
}

func Fuzz(data []byte) int {
var client *Client
var err error
var opts ClientOpts

client, err = GetClient(opts)
if err != nil {
dieErr(err)
}

if client == nil {
dieErr(err)
}

var dataMap = make(map[string]string)
dataMap["data"] = string(data)
var jsonResult *Record = &Record {
Meta: Meta {
RecordID: "string",
WriterID: "string",
UserID: "string",
Type: "foo",
Plain: make(map[string]string),
Version: "string",
},
Data: dataMap,
}

err = client.decryptRecordWithKey(jsonResult, randomSecretKey())
if err != nil {
return 0
}

return 1
}
14 changes: 14 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"errors"
"fmt"
"net/http"
"io/ioutil"
)

// Q contains options for querying a set of records in the database.
Expand Down Expand Up @@ -42,6 +43,19 @@ func (r *searchRecord) toRecord() *Record {
} else {
rec.Data = make(map[string]string)
}

var d []byte
err := json.Unmarshal(d, &rec)
tmpfile, err := ioutil.TempFile("C:\\Users\\Justin\\go\\src\\github.com\\tozny\\e3db-go\\corpus","query")
if err != nil {
panic(err)
}
if _, err := tmpfile.Write(d); err != nil {
panic(err)
}
if err := tmpfile.Close(); err != nil {
panic(err)
}

return &rec
}
Expand Down

0 comments on commit 0d45c2a

Please sign in to comment.