From 51b9ef5c346f333e558eca38fd954464322f3b7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 09:43:56 +0200 Subject: [chore]: Bump github.com/gin-contrib/gzip from 1.2.2 to 1.2.3 (#4000) Bumps [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/gin-contrib/gzip/releases) - [Changelog](https://github.com/gin-contrib/gzip/blob/master/.goreleaser.yaml) - [Commits](https://github.com/gin-contrib/gzip/compare/v1.2.2...v1.2.3) --- updated-dependencies: - dependency-name: github.com/gin-contrib/gzip dependency-version: 1.2.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../go-playground/validator/v10/.golangci.yaml | 102 +++++++++++++++++++++ .../go-playground/validator/v10/Makefile | 2 +- .../go-playground/validator/v10/README.md | 6 +- .../go-playground/validator/v10/baked_in.go | 51 +++++++++-- .../go-playground/validator/v10/cache.go | 7 +- .../github.com/go-playground/validator/v10/doc.go | 8 +- .../go-playground/validator/v10/regexes.go | 4 +- .../go-playground/validator/v10/struct_level.go | 6 +- .../go-playground/validator/v10/validator.go | 17 ++++ .../validator/v10/validator_instance.go | 1 + 10 files changed, 186 insertions(+), 18 deletions(-) create mode 100644 vendor/github.com/go-playground/validator/v10/.golangci.yaml (limited to 'vendor/github.com/go-playground') diff --git a/vendor/github.com/go-playground/validator/v10/.golangci.yaml b/vendor/github.com/go-playground/validator/v10/.golangci.yaml new file mode 100644 index 000000000..eab557ee2 --- /dev/null +++ b/vendor/github.com/go-playground/validator/v10/.golangci.yaml @@ -0,0 +1,102 @@ +version: "2" +linters: + default: all + disable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - canonicalheader + - containedctx + - contextcheck + - copyloopvar + - cyclop + - decorder + - depguard + - dogsled + - dupl + - dupword + - durationcheck + - err113 + - errcheck + - errchkjson + - errname + - errorlint + - exhaustive + - exhaustruct + - exptostd + - fatcontext + - forbidigo + - forcetypeassert + - funlen + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals + - gochecknoinits + - gochecksumtype + - gocognit + - goconst + - gocritic + - gocyclo + - godot + - godox + - goheader + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - gosmopolitan + - govet + - grouper + - iface + - importas + - inamedparam + - ineffassign + - interfacebloat + - intrange + - ireturn + - lll + - loggercheck + - maintidx + - makezero + - mirror + - misspell + - mnd + - musttag + - nakedret + - nestif + - nilerr + - nilnesserr + - nilnil + - nlreturn + - noctx + - nolintlint + - nonamedreturns + - nosprintfhostport + - paralleltest + - perfsprint + - prealloc + - predeclared + - promlinter + - protogetter + - reassign + - recvcheck + - revive + - rowserrcheck + - sloglint + - spancheck + - sqlclosecheck + - staticcheck + - tagalign + - tagliatelle + - testableexamples + - testifylint + - testpackage + - thelper + - tparallel + - unparam + - varnamelen + - whitespace + - wrapcheck + - wsl + - zerologlint \ No newline at end of file diff --git a/vendor/github.com/go-playground/validator/v10/Makefile b/vendor/github.com/go-playground/validator/v10/Makefile index e097dfaf2..e7caab7f1 100644 --- a/vendor/github.com/go-playground/validator/v10/Makefile +++ b/vendor/github.com/go-playground/validator/v10/Makefile @@ -3,7 +3,7 @@ GOCMD=go linters-install: @golangci-lint --version >/dev/null 2>&1 || { \ echo "installing linting tools..."; \ - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v2.0.2; \ } lint: linters-install diff --git a/vendor/github.com/go-playground/validator/v10/README.md b/vendor/github.com/go-playground/validator/v10/README.md index 25eadf026..368b966a6 100644 --- a/vendor/github.com/go-playground/validator/v10/README.md +++ b/vendor/github.com/go-playground/validator/v10/README.md @@ -1,8 +1,7 @@ Package validator ================= -[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -![Project status](https://img.shields.io/badge/version-10.24.0-green.svg) -[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator) +![Project status](https://img.shields.io/badge/version-10.25.0-green.svg) +[![Build Status](https://github.com/go-playground/validator/actions/workflows/workflow.yml/badge.svg)](https://github.com/go-playground/validator/actions) [![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator) [![GoDoc](https://godoc.org/github.com/go-playground/validator?status.svg)](https://pkg.go.dev/github.com/go-playground/validator/v10) @@ -173,6 +172,7 @@ validate := validator.New(validator.WithRequiredStructEnabled()) | spicedb | SpiceDb ObjectID/Permission/Type | | datetime | Datetime | | e164 | e164 formatted phone number | +| ein | U.S. Employeer Identification Number | | email | E-mail String | eth_addr | Ethereum Address | | hexadecimal | Hexadecimal String | diff --git a/vendor/github.com/go-playground/validator/v10/baked_in.go b/vendor/github.com/go-playground/validator/v10/baked_in.go index 2f66c1836..5332cf3fa 100644 --- a/vendor/github.com/go-playground/validator/v10/baked_in.go +++ b/vendor/github.com/go-playground/validator/v10/baked_in.go @@ -9,6 +9,7 @@ import ( "fmt" "io/fs" "net" + "net/mail" "net/url" "os" "reflect" @@ -50,6 +51,7 @@ var ( keysTag: {}, endKeysTag: {}, structOnlyTag: {}, + omitzero: {}, omitempty: {}, omitnil: {}, skipValidationTag: {}, @@ -241,6 +243,7 @@ var ( "mongodb_connection_string": isMongoDBConnectionString, "cron": isCron, "spicedb": isSpiceDB, + "ein": isEIN, } ) @@ -257,7 +260,7 @@ func parseOneOfParam2(s string) []string { oneofValsCacheRWLock.Lock() vals = splitParamsRegex().FindAllString(s, -1) for i := 0; i < len(vals); i++ { - vals[i] = strings.Replace(vals[i], "'", "", -1) + vals[i] = strings.ReplaceAll(vals[i], "'", "") } oneofValsCache[s] = vals oneofValsCacheRWLock.Unlock() @@ -1375,7 +1378,6 @@ func isEqIgnoreCase(fl FieldLevel) bool { param := fl.Param() switch field.Kind() { - case reflect.String: return strings.EqualFold(field.String(), param) } @@ -1417,6 +1419,7 @@ func isPostcodeByIso3166Alpha2Field(fl FieldLevel) bool { panic(fmt.Sprintf("Bad field type %T", currentField.Interface())) } + postcodeRegexInit.Do(initPostcodes) reg, found := postCodeRegexDict[currentField.String()] if !found { return false @@ -1604,7 +1607,6 @@ func isImage(fl FieldLevel) bool { case reflect.String: filePath := field.String() fileInfo, err := os.Stat(filePath) - if err != nil { return false } @@ -1617,7 +1619,9 @@ func isImage(fl FieldLevel) bool { if err != nil { return false } - defer file.Close() + defer func() { + _ = file.Close() + }() mime, err := mimetype.DetectReader(file) if err != nil { @@ -1633,7 +1637,6 @@ func isImage(fl FieldLevel) bool { // isFilePath is the validation function for validating if the current field's value is a valid file path. func isFilePath(fl FieldLevel) bool { - var exists bool var err error @@ -1693,6 +1696,10 @@ func isE164(fl FieldLevel) bool { // isEmail is the validation function for validating if the current field's value is a valid email address. func isEmail(fl FieldLevel) bool { + _, err := mail.ParseAddress(fl.Field().String()) + if err != nil { + return false + } return emailRegex().MatchString(fl.Field().String()) } @@ -1796,6 +1803,20 @@ func hasValue(fl FieldLevel) bool { } } +// hasNotZeroValue is the validation function for validating if the current field's value is not the zero value for its type. +func hasNotZeroValue(fl FieldLevel) bool { + field := fl.Field() + switch field.Kind() { + case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func: + return !field.IsNil() + default: + if fl.(*validate).fldIsPointer && field.Interface() != nil { + return !field.IsZero() + } + return field.IsValid() && !field.IsZero() + } +} + // requireCheckFieldKind is a func for check field kind func requireCheckFieldKind(fl FieldLevel, param string, defaultNotFoundValue bool) bool { field := fl.Field() @@ -2211,7 +2232,6 @@ func isGt(fl FieldLevel) bool { case reflect.Struct: if field.Type().ConvertibleTo(timeType) { - return field.Convert(timeType).Interface().(time.Time).After(time.Now().UTC()) } } @@ -2448,7 +2468,6 @@ func isLt(fl FieldLevel) bool { case reflect.Struct: if field.Type().ConvertibleTo(timeType) { - return field.Convert(timeType).Interface().(time.Time).Before(time.Now().UTC()) } } @@ -2628,7 +2647,6 @@ func isDir(fl FieldLevel) bool { // isDirPath is the validation function for validating if the current field's value is a valid directory. func isDirPath(fl FieldLevel) bool { - var exists bool var err error @@ -2941,6 +2959,12 @@ func isCveFormat(fl FieldLevel) bool { // a valid dns RFC 1035 label, defined in RFC 1035. func isDnsRFC1035LabelFormat(fl FieldLevel) bool { val := fl.Field().String() + + size := len(val) + if size > 63 { + return false + } + return dnsRegexRFC1035Label().MatchString(val) } @@ -3044,3 +3068,14 @@ func isCron(fl FieldLevel) bool { cronString := fl.Field().String() return cronRegex().MatchString(cronString) } + +// isEIN is the validation function for validating if the current field's value is a valid U.S. Employer Identification Number (EIN) +func isEIN(fl FieldLevel) bool { + field := fl.Field() + + if field.Len() != 10 { + return false + } + + return einRegex().MatchString(field.String()) +} diff --git a/vendor/github.com/go-playground/validator/v10/cache.go b/vendor/github.com/go-playground/validator/v10/cache.go index 2063e1b79..41d40bfea 100644 --- a/vendor/github.com/go-playground/validator/v10/cache.go +++ b/vendor/github.com/go-playground/validator/v10/cache.go @@ -21,6 +21,7 @@ const ( typeKeys typeEndKeys typeOmitNil + typeOmitZero ) const ( @@ -249,6 +250,10 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s } return + case omitzero: + current.typeof = typeOmitZero + continue + case omitempty: current.typeof = typeOmitEmpty continue @@ -304,7 +309,7 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s } if len(vals) > 1 { - current.param = strings.Replace(strings.Replace(vals[1], utf8HexComma, ",", -1), utf8Pipe, "|", -1) + current.param = strings.ReplaceAll(strings.ReplaceAll(vals[1], utf8HexComma, ","), utf8Pipe, "|") } } current.isBlockEnd = true diff --git a/vendor/github.com/go-playground/validator/v10/doc.go b/vendor/github.com/go-playground/validator/v10/doc.go index c9b1616ee..e7a241fbc 100644 --- a/vendor/github.com/go-playground/validator/v10/doc.go +++ b/vendor/github.com/go-playground/validator/v10/doc.go @@ -959,7 +959,7 @@ Although an empty string is a valid base64 URL safe value, this will report an empty string as an error, if you wish to accept an empty string as valid you can use this with the omitempty tag. - Usage: base64url + Usage: base64rawurl # Bitcoin Address @@ -1134,6 +1134,12 @@ This validates that a string value contains a valid longitude. Usage: longitude +# Employeer Identification Number EIN + +This validates that a string value contains a valid U.S. Employer Identification Number. + + Usage: ein + # Social Security Number SSN This validates that a string value contains a valid U.S. Social Security Number. diff --git a/vendor/github.com/go-playground/validator/v10/regexes.go b/vendor/github.com/go-playground/validator/v10/regexes.go index 871cf7df7..93909b2e5 100644 --- a/vendor/github.com/go-playground/validator/v10/regexes.go +++ b/vendor/github.com/go-playground/validator/v10/regexes.go @@ -69,7 +69,7 @@ const ( splitParamsRegexString = `'[^']*'|\S+` bicRegexString = `^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$` semverRegexString = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$` // numbered capture groups https://semver.org/ - dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9]){0,62}$" + dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9])?$" cveRegexString = `^CVE-(1999|2\d{3})-(0[^0]\d{2}|0\d[^0]\d{1}|0\d{2}[^0]|[1-9]{1}\d{3,})$` // CVE Format Id https://cve.mitre.org/cve/identifiers/syntaxchange.html mongodbIdRegexString = "^[a-f\\d]{24}$" mongodbConnStringRegexString = "^mongodb(\\+srv)?:\\/\\/(([a-zA-Z\\d]+):([a-zA-Z\\d$:\\/?#\\[\\]@]+)@)?(([a-z\\d.-]+)(:[\\d]+)?)((,(([a-z\\d.-]+)(:(\\d+))?))*)?(\\/[a-zA-Z-_]{1,64})?(\\?(([a-zA-Z]+)=([a-zA-Z\\d]+))(&(([a-zA-Z\\d]+)=([a-zA-Z\\d]+))?)*)?$" @@ -77,6 +77,7 @@ const ( spicedbIDRegexString = `^(([a-zA-Z0-9/_|\-=+]{1,})|\*)$` spicedbPermissionRegexString = "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$" spicedbTypeRegexString = "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)?[a-z][a-z0-9_]{1,62}[a-z0-9]$" + einRegexString = "^(\\d{2}-\\d{7})$" ) func lazyRegexCompile(str string) func() *regexp.Regexp { @@ -160,4 +161,5 @@ var ( spicedbIDRegex = lazyRegexCompile(spicedbIDRegexString) spicedbPermissionRegex = lazyRegexCompile(spicedbPermissionRegexString) spicedbTypeRegex = lazyRegexCompile(spicedbTypeRegexString) + einRegex = lazyRegexCompile(einRegexString) ) diff --git a/vendor/github.com/go-playground/validator/v10/struct_level.go b/vendor/github.com/go-playground/validator/v10/struct_level.go index 271328f71..fa7af9dd5 100644 --- a/vendor/github.com/go-playground/validator/v10/struct_level.go +++ b/vendor/github.com/go-playground/validator/v10/struct_level.go @@ -46,9 +46,9 @@ type StructLevel interface { // // NOTES: // - // fieldName and altName get appended to the existing namespace that - // validator is on. e.g. pass 'FirstName' or 'Names[0]' depending - // on the nesting + // fieldName and structFieldName get appended to the existing + // namespace that validator is on. e.g. pass 'FirstName' or + // 'Names[0]' depending on the nesting // // tag can be an existing validation tag or just something you make up // and process on the flip side it's up to you. diff --git a/vendor/github.com/go-playground/validator/v10/validator.go b/vendor/github.com/go-playground/validator/v10/validator.go index 901e7b50a..d7c2e6586 100644 --- a/vendor/github.com/go-playground/validator/v10/validator.go +++ b/vendor/github.com/go-playground/validator/v10/validator.go @@ -117,6 +117,10 @@ func (v *validate) traverseField(ctx context.Context, parent reflect.Value, curr return } + if ct.typeof == typeOmitZero { + return + } + if ct.hasTag { if kind == reflect.Invalid { v.str1 = string(append(ns, cf.altName...)) @@ -238,6 +242,19 @@ OUTER: ct = ct.next continue + case typeOmitZero: + v.slflParent = parent + v.flField = current + v.cf = cf + v.ct = ct + + if !hasNotZeroValue(v) { + return + } + + ct = ct.next + continue + case typeOmitNil: v.slflParent = parent v.flField = current diff --git a/vendor/github.com/go-playground/validator/v10/validator_instance.go b/vendor/github.com/go-playground/validator/v10/validator_instance.go index d9f148dba..779f689a8 100644 --- a/vendor/github.com/go-playground/validator/v10/validator_instance.go +++ b/vendor/github.com/go-playground/validator/v10/validator_instance.go @@ -21,6 +21,7 @@ const ( tagKeySeparator = "=" structOnlyTag = "structonly" noStructLevelTag = "nostructlevel" + omitzero = "omitzero" omitempty = "omitempty" omitnil = "omitnil" isdefault = "isdefault" -- cgit v1.2.3