fix(deps): update module github.com/gorilla/schema to v1.4.1 [security]

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot] 2024-07-01 23:11:04 +00:00 committed by GitHub
parent 3a41bccf7d
commit 1c704157c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 5 deletions

2
go.mod
View File

@ -40,7 +40,7 @@ require (
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/gorilla/handlers v1.5.2 github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1
github.com/gorilla/schema v1.4.0 github.com/gorilla/schema v1.4.1
github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-multierror v1.1.1
github.com/hugelgupf/p9 v0.3.1-0.20230822151754-54f5c5530921 github.com/hugelgupf/p9 v0.3.1-0.20230822151754-54f5c5530921
github.com/json-iterator/go v1.1.12 github.com/json-iterator/go v1.1.12

4
go.sum
View File

@ -277,8 +277,8 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/schema v1.4.0 h1:l2N+lRTJtev9SUhBtj6NmSxd/6+8LhvN0kV+H2Y8R9k= github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
github.com/gorilla/schema v1.4.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=

View File

@ -12,9 +12,13 @@ import (
"strings" "strings"
) )
const (
defaultMaxSize = 16000
)
// NewDecoder returns a new Decoder. // NewDecoder returns a new Decoder.
func NewDecoder() *Decoder { func NewDecoder() *Decoder {
return &Decoder{cache: newCache()} return &Decoder{cache: newCache(), maxSize: defaultMaxSize}
} }
// Decoder decodes values from a map[string][]string to a struct. // Decoder decodes values from a map[string][]string to a struct.
@ -22,6 +26,7 @@ type Decoder struct {
cache *cache cache *cache
zeroEmpty bool zeroEmpty bool
ignoreUnknownKeys bool ignoreUnknownKeys bool
maxSize int
} }
// SetAliasTag changes the tag used to locate custom field aliases. // SetAliasTag changes the tag used to locate custom field aliases.
@ -54,6 +59,13 @@ func (d *Decoder) IgnoreUnknownKeys(i bool) {
d.ignoreUnknownKeys = i d.ignoreUnknownKeys = i
} }
// MaxSize limits the size of slices for URL nested arrays or object arrays.
// Choose MaxSize carefully; large values may create many zero-value slice elements.
// Example: "items.100000=apple" would create a slice with 100,000 empty strings.
func (d *Decoder) MaxSize(size int) {
d.maxSize = size
}
// RegisterConverter registers a converter function for a custom type. // RegisterConverter registers a converter function for a custom type.
func (d *Decoder) RegisterConverter(value interface{}, converterFunc Converter) { func (d *Decoder) RegisterConverter(value interface{}, converterFunc Converter) {
d.cache.registerConverter(value, converterFunc) d.cache.registerConverter(value, converterFunc)
@ -302,6 +314,10 @@ func (d *Decoder) decode(v reflect.Value, path string, parts []pathPart, values
// Slice of structs. Let's go recursive. // Slice of structs. Let's go recursive.
if len(parts) > 1 { if len(parts) > 1 {
idx := parts[0].index idx := parts[0].index
// a defensive check to avoid creating a large slice based on user input index
if idx > d.maxSize {
return fmt.Errorf("%v index %d is larger than the configured maxSize %d", v.Kind(), idx, d.maxSize)
}
if v.IsNil() || v.Len() < idx+1 { if v.IsNil() || v.Len() < idx+1 {
value := reflect.MakeSlice(t, idx+1, idx+1) value := reflect.MakeSlice(t, idx+1, idx+1)
if v.Len() < idx+1 { if v.Len() < idx+1 {

2
vendor/modules.txt vendored
View File

@ -684,7 +684,7 @@ github.com/gorilla/handlers
# github.com/gorilla/mux v1.8.1 # github.com/gorilla/mux v1.8.1
## explicit; go 1.20 ## explicit; go 1.20
github.com/gorilla/mux github.com/gorilla/mux
# github.com/gorilla/schema v1.4.0 # github.com/gorilla/schema v1.4.1
## explicit; go 1.20 ## explicit; go 1.20
github.com/gorilla/schema github.com/gorilla/schema
# github.com/hashicorp/errwrap v1.1.0 # github.com/hashicorp/errwrap v1.1.0