vendor: update github.com/valyala/fastjson from v1.4.1 to v1.4.2

This fixes parsing of `inf` and `nan` values in json lines passed to `/api/v1/import`
This commit is contained in:
Aliaksandr Valialkin 2020-01-08 20:46:41 +02:00
parent a973df6d79
commit 1c436b2723
8 changed files with 58 additions and 7 deletions

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/golang/snappy v0.0.1
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.9.4
github.com/valyala/fastjson v1.4.1
github.com/valyala/fastjson v1.4.2
github.com/valyala/fastrand v1.0.0
github.com/valyala/gozstd v1.6.4
github.com/valyala/histogram v1.0.1

4
go.sum
View file

@ -97,8 +97,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
github.com/valyala/fastjson v1.4.1 h1:hrltpHpIpkaxll8QltMU8c3QZ5+qIiCL8yKqPFJI/yE=
github.com/valyala/fastjson v1.4.1/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
github.com/valyala/fastjson v1.4.2 h1:vJXOwCenHuSyEfxWBUtzZl9LqyfgN2YkaNQBPHHEYbk=
github.com/valyala/fastjson v1.4.2/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
github.com/valyala/fastrand v1.0.0 h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2ObdkI=
github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/gozstd v1.6.4 h1:nFLddjEf90SFl5cVWyElSHozQDsbvLljPK703/skBS0=

View file

@ -102,6 +102,21 @@ See also [examples](https://godoc.org/github.com/valyala/fastjson#pkg-examples).
* Prefer iterating over array returned from [Value.GetArray](https://godoc.org/github.com/valyala/fastjson#Object.Visit)
with a range loop instead of calling `Value.Get*` for each array item.
## Fuzzing
Install [go-fuzz](https://github.com/dvyukov/go-fuzz) & optionally the go-fuzz-corpus.
```bash
go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
```
Build using `go-fuzz-build` and run `go-fuzz` with an optional corpus.
```bash
mkdir -p workdir/corpus
cp $GOPATH/src/github.com/dvyukov/go-fuzz-corpus/json/corpus/* workdir/corpus
go-fuzz-build github.com/valyala/fastjson
go-fuzz -bin=fastjson-fuzz.zip -workdir=workdir
```
## Benchmarks

View file

@ -2,6 +2,7 @@ package fastfloat
import (
"math"
"strings"
"strconv"
)
@ -132,6 +133,15 @@ func ParseBestEffort(s string) float64 {
break
}
if i <= j {
if strings.EqualFold(s[i:], "inf") {
if minus {
return -inf
}
return inf
}
if strings.EqualFold(s[i:], "nan") {
return nan
}
return 0
}
f := float64(d)
@ -229,3 +239,6 @@ func ParseBestEffort(s string) float64 {
}
return 0
}
var inf = math.Inf(1)
var nan = math.NaN()

22
vendor/github.com/valyala/fastjson/fuzz.go generated vendored Normal file
View file

@ -0,0 +1,22 @@
// +build gofuzz
package fastjson
func Fuzz(data []byte) int {
err := ValidateBytes(data)
if err != nil {
return 0
}
v := MustParseBytes(data)
dst := make([]byte, 0)
dst = v.MarshalTo(dst)
err = ValidateBytes(dst)
if err != nil {
panic(err)
}
return 1
}

View file

@ -159,7 +159,7 @@ func ParseBytes(b []byte) (*Value, error) {
// MustParseBytes parses b containing json.
//
// The function banics if b cannot be parsed.
// The function panics if b cannot be parsed.
// The function is slower than the Parser.ParseBytes for re-used Parser.
func MustParseBytes(b []byte) *Value {
v, err := ParseBytes(b)

View file

@ -484,8 +484,9 @@ func (o *Object) unescapeKeys() {
if o.keysUnescaped {
return
}
for i := range o.kvs {
kv := &o.kvs[i]
kvs := o.kvs
for i := range kvs {
kv := &kvs[i]
kv.k = unescapeStringBestEffort(kv.k)
}
o.keysUnescaped = true

2
vendor/modules.txt vendored
View file

@ -90,7 +90,7 @@ github.com/klauspost/compress/zstd
github.com/klauspost/compress/zstd/internal/xxhash
# github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/bytebufferpool
# github.com/valyala/fastjson v1.4.1
# github.com/valyala/fastjson v1.4.2
github.com/valyala/fastjson
github.com/valyala/fastjson/fastfloat
# github.com/valyala/fastrand v1.0.0