diff options
author | Catena cyber <35799796+catenacyber@users.noreply.github.com> | 2020-11-22 20:05:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-22 11:05:32 -0800 |
commit | 91a6a12dbeea3169ed03355a3203e6af9a589ded (patch) | |
tree | 7d2cf2f8d33ce17bd509b556d1b690ec9ccc4f93 /projects/go-json-iterator | |
parent | bb8b2fb354ebdd85108a642af090a7fa039dd76e (diff) | |
download | oss-fuzz-91a6a12dbeea3169ed03355a3203e6af9a589ded.tar.gz |
Go json coverage (#4689)
* Good fuzz target for golang coverage with modules
* Place target in right directory for go-json-iterator
So that coverage gets access to the right package
Diffstat (limited to 'projects/go-json-iterator')
-rw-r--r-- | projects/go-json-iterator/Dockerfile | 4 | ||||
-rwxr-xr-x | projects/go-json-iterator/build.sh | 3 | ||||
-rw-r--r-- | projects/go-json-iterator/fuzz_json.go | 13 |
3 files changed, 8 insertions, 12 deletions
diff --git a/projects/go-json-iterator/Dockerfile b/projects/go-json-iterator/Dockerfile index bcbb635f8..3d6a90c56 100644 --- a/projects/go-json-iterator/Dockerfile +++ b/projects/go-json-iterator/Dockerfile @@ -17,7 +17,5 @@ FROM gcr.io/oss-fuzz-base/base-builder RUN go get github.com/json-iterator/go -RUN mkdir fuzz -COPY fuzz_json.go fuzz +COPY fuzz_json.go $GOPATH/src/github.com/json-iterator/go/ COPY build.sh $SRC/ -WORKDIR fuzz diff --git a/projects/go-json-iterator/build.sh b/projects/go-json-iterator/build.sh index 060bb7c76..f247b2422 100755 --- a/projects/go-json-iterator/build.sh +++ b/projects/go-json-iterator/build.sh @@ -16,5 +16,4 @@ ################################################################################ - -compile_go_fuzzer . Fuzz fuzz_json +compile_go_fuzzer github.com/json-iterator/go Fuzz fuzz_json diff --git a/projects/go-json-iterator/fuzz_json.go b/projects/go-json-iterator/fuzz_json.go index c057a63bf..e5236be2e 100644 --- a/projects/go-json-iterator/fuzz_json.go +++ b/projects/go-json-iterator/fuzz_json.go @@ -2,12 +2,11 @@ // Use of this source code is governed by Apache 2 LICENSE. // Modified from original file https://github.com/dvyukov/go-fuzz-corpus/blob/master/json/json.go -package jsonfuzz +package jsoniter import ( "encoding/json" "fmt" - jsoniter "github.com/json-iterator/go" "reflect" ) @@ -21,7 +20,7 @@ func Fuzz(data []byte) int { func() interface{} { return new(S) }, } { v := ctor() - if jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, v) != nil { + if ConfigCompatibleWithStandardLibrary.Unmarshal(data, v) != nil { continue } score = 1 @@ -36,12 +35,12 @@ func Fuzz(data []byte) int { panic("not equal") } - data1, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(v) + data1, err := ConfigCompatibleWithStandardLibrary.Marshal(v) if err != nil { panic(err) } v1 := ctor() - if jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data1, v1) != nil { + if ConfigCompatibleWithStandardLibrary.Unmarshal(data1, v1) != nil { continue } if !reflect.DeepEqual(v, v1) { @@ -85,9 +84,9 @@ type Marshaller struct { } func (m *Marshaller) MarshalJSON() ([]byte, error) { - return jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(m.v) + return ConfigCompatibleWithStandardLibrary.Marshal(m.v) } func (m *Marshaller) UnmarshalJSON(data []byte) error { - return jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, &m.v) + return ConfigCompatibleWithStandardLibrary.Unmarshal(data, &m.v) } |