diff --git a/daemon/logger/jsonfilelog/jsonlog/fuzz_test.go b/daemon/logger/jsonfilelog/jsonlog/fuzz_test.go index fcade0e895..78b1c1b237 100644 --- a/daemon/logger/jsonfilelog/jsonlog/fuzz_test.go +++ b/daemon/logger/jsonfilelog/jsonlog/fuzz_test.go @@ -2,20 +2,23 @@ package jsonlog import ( "bytes" + "encoding/json" "testing" - - fuzz "github.com/AdaLogics/go-fuzz-headers" + "time" ) func FuzzJSONLogsMarshalJSONBuf(f *testing.F) { - f.Fuzz(func(t *testing.T, data []byte) { - ff := fuzz.NewConsumer(data) - l := &JSONLogs{} - err := ff.GenerateStruct(l) - if err != nil { - return + f.Fuzz(func(t *testing.T, log []byte, stream string, created int64, rawAttrs []byte) { + l := &JSONLogs{ + Log: log, + Stream: stream, + Created: time.Unix(0, created), + RawAttrs: json.RawMessage(rawAttrs), } + // Exercise MarshalJSONBuf with arbitrary inputs. Errors are expected + // for some generated times; the fuzz target is only checking that it + // doesn't panic. var buf bytes.Buffer - l.MarshalJSONBuf(&buf) + _ = l.MarshalJSONBuf(&buf) }) }