mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
vendor: bump containers/(storage, common, buildah, image)
Bump containers/(storage, common, buildah and image) Changes since 2023-01-01: - skip mount-cache-selinux-long-name test under remote, with a FIXME requesting that someone see if it can be made to work. - skip six tests that fail under rootless-remote - add new --build-arg-file option: - update man page Squash of: *cf56eb1865
*561f082772
Signed-off-by: Ed Santiago <santiago@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
4
vendor/github.com/go-playground/locales/README.md
generated
vendored
4
vendor/github.com/go-playground/locales/README.md
generated
vendored
@ -1,10 +1,8 @@
|
||||
## locales
|
||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/locales/master/logo.png">
|
||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/locales/master/logo.png">
|
||||
[](https://travis-ci.org/go-playground/locales)
|
||||
[](https://goreportcard.com/report/github.com/go-playground/locales)
|
||||
[](https://godoc.org/github.com/go-playground/locales)
|
||||

|
||||
[](https://gitter.im/go-playground/locales?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
Locales is a set of locales generated from the [Unicode CLDR Project](http://cldr.unicode.org/) which can be used independently or within
|
||||
an i18n package; these were built for use with, but not exclusive to, [Universal Translator](https://github.com/go-playground/universal-translator).
|
||||
|
4
vendor/github.com/go-playground/universal-translator/README.md
generated
vendored
4
vendor/github.com/go-playground/universal-translator/README.md
generated
vendored
@ -1,11 +1,9 @@
|
||||
## universal-translator
|
||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/universal-translator/master/logo.png">
|
||||
[](https://travis-ci.org/go-playground/universal-translator)
|
||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/universal-translator/master/logo.png">
|
||||
[](https://coveralls.io/github/go-playground/universal-translator)
|
||||
[](https://goreportcard.com/report/github.com/go-playground/universal-translator)
|
||||
[](https://godoc.org/github.com/go-playground/universal-translator)
|
||||

|
||||
[](https://gitter.im/go-playground/universal-translator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
Universal Translator is an i18n Translator for Go/Golang using CLDR data + pluralization rules
|
||||
|
||||
|
6
vendor/github.com/go-playground/universal-translator/import_export.go
generated
vendored
6
vendor/github.com/go-playground/universal-translator/import_export.go
generated
vendored
@ -3,7 +3,6 @@ package ut
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -41,7 +40,6 @@ const (
|
||||
func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string) error {
|
||||
|
||||
_, err := os.Stat(dirname)
|
||||
fmt.Println(dirname, err, os.IsNotExist(err))
|
||||
if err != nil {
|
||||
|
||||
if !os.IsNotExist(err) {
|
||||
@ -138,7 +136,7 @@ func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string)
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644)
|
||||
err = os.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -200,7 +198,7 @@ func (t *UniversalTranslator) Import(format ImportExportFormat, dirnameOrFilenam
|
||||
// NOTE: generally used when assets have been embedded into the binary and are already in memory.
|
||||
func (t *UniversalTranslator) ImportByReader(format ImportExportFormat, reader io.Reader) error {
|
||||
|
||||
b, err := ioutil.ReadAll(reader)
|
||||
b, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
1
vendor/github.com/go-playground/validator/v10/.gitignore
generated
vendored
1
vendor/github.com/go-playground/validator/v10/.gitignore
generated
vendored
@ -28,3 +28,4 @@ _testmain.go
|
||||
*.txt
|
||||
cover.html
|
||||
README.html
|
||||
.idea
|
||||
|
24
vendor/github.com/go-playground/validator/v10/README.md
generated
vendored
24
vendor/github.com/go-playground/validator/v10/README.md
generated
vendored
@ -1,7 +1,7 @@
|
||||
Package validator
|
||||
=================
|
||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v9/logo.png">[](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||

|
||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v10/logo.png">[](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||

|
||||
[](https://travis-ci.org/go-playground/validator)
|
||||
[](https://coveralls.io/github/go-playground/validator?branch=master)
|
||||
[](https://goreportcard.com/report/github.com/go-playground/validator)
|
||||
@ -73,8 +73,8 @@ Baked-in Validations
|
||||
| - | - |
|
||||
| eqcsfield | Field Equals Another Field (relative)|
|
||||
| eqfield | Field Equals Another Field |
|
||||
| fieldcontains | NOT DOCUMENTED IN doc.go |
|
||||
| fieldexcludes | NOT DOCUMENTED IN doc.go |
|
||||
| fieldcontains | Check the indicated characters are present in the Field |
|
||||
| fieldexcludes | Check the indicated characters are not present in the field |
|
||||
| gtcsfield | Field Greater Than Another Relative Field |
|
||||
| gtecsfield | Field Greater Than or Equal To Another Relative Field |
|
||||
| gtefield | Field Greater Than or Equal To Another Field |
|
||||
@ -114,6 +114,7 @@ Baked-in Validations
|
||||
| unix_addr | Unix domain socket end point Address |
|
||||
| uri | URI String |
|
||||
| url | URL String |
|
||||
| http_url | HTTP URL String |
|
||||
| url_encoded | URL Encoded |
|
||||
| urn_rfc2141 | Urn RFC 2141 String |
|
||||
|
||||
@ -137,7 +138,7 @@ Baked-in Validations
|
||||
| excludesrune | Excludes Rune |
|
||||
| lowercase | Lowercase |
|
||||
| multibyte | Multi-Byte Characters |
|
||||
| number | NOT DOCUMENTED IN doc.go |
|
||||
| number | Number |
|
||||
| numeric | Numeric |
|
||||
| printascii | Printable ASCII |
|
||||
| startsnotwith | Starts Not With |
|
||||
@ -149,11 +150,14 @@ Baked-in Validations
|
||||
| - | - |
|
||||
| base64 | Base64 String |
|
||||
| base64url | Base64URL String |
|
||||
| base64rawurl | Base64RawURL String |
|
||||
| bic | Business Identifier Code (ISO 9362) |
|
||||
| bcp47_language_tag | Language tag (BCP 47) |
|
||||
| btc_addr | Bitcoin Address |
|
||||
| btc_addr_bech32 | Bitcoin Bech32 Address (segwit) |
|
||||
| credit_card | Credit Card Number |
|
||||
| mongodb | MongoDB ObjectID |
|
||||
| cron | Cron |
|
||||
| datetime | Datetime |
|
||||
| e164 | e164 formatted phone number |
|
||||
| email | E-mail String
|
||||
@ -176,6 +180,7 @@ Baked-in Validations
|
||||
| jwt | JSON Web Token (JWT) |
|
||||
| latitude | Latitude |
|
||||
| longitude | Longitude |
|
||||
| luhn_checksum | Luhn Algorithm Checksum (for strings and (u)int) |
|
||||
| postcode_iso3166_alpha2 | Postcode |
|
||||
| postcode_iso3166_alpha2_field | Postcode |
|
||||
| rgb | RGB String |
|
||||
@ -202,22 +207,27 @@ Baked-in Validations
|
||||
| tiger192 | TIGER192 hash |
|
||||
| semver | Semantic Versioning 2.0.0 |
|
||||
| ulid | Universally Unique Lexicographically Sortable Identifier ULID |
|
||||
| cve | Common Vulnerabilities and Exposures Identifier (CVE id) |
|
||||
|
||||
### Comparisons:
|
||||
| Tag | Description |
|
||||
| - | - |
|
||||
| eq | Equals |
|
||||
| eq_ignore_case | Equals ignoring case |
|
||||
| gt | Greater than|
|
||||
| gte | Greater than or equal |
|
||||
| lt | Less Than |
|
||||
| lte | Less Than or Equal |
|
||||
| ne | Not Equal |
|
||||
| ne_ignore_case | Not Equal ignoring case |
|
||||
|
||||
### Other:
|
||||
| Tag | Description |
|
||||
| - | - |
|
||||
| dir | Directory |
|
||||
| file | File path |
|
||||
| dir | Existing Directory |
|
||||
| dirpath | Directory Path |
|
||||
| file | Existing File |
|
||||
| filepath | File Path |
|
||||
| isdefault | Is Default |
|
||||
| len | Length |
|
||||
| max | Maximum |
|
||||
|
311
vendor/github.com/go-playground/validator/v10/baked_in.go
generated
vendored
311
vendor/github.com/go-playground/validator/v10/baked_in.go
generated
vendored
@ -7,6 +7,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -14,13 +15,14 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"golang.org/x/crypto/sha3"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
urn "github.com/leodido/go-urn"
|
||||
"github.com/leodido/go-urn"
|
||||
)
|
||||
|
||||
// Func accepts a FieldLevel interface for all validation needs. The return
|
||||
@ -86,7 +88,9 @@ var (
|
||||
"min": hasMinOf,
|
||||
"max": hasMaxOf,
|
||||
"eq": isEq,
|
||||
"eq_ignore_case": isEqIgnoreCase,
|
||||
"ne": isNe,
|
||||
"ne_ignore_case": isNeIgnoreCase,
|
||||
"lt": isLt,
|
||||
"lte": isLte,
|
||||
"gt": isGt,
|
||||
@ -121,11 +125,14 @@ var (
|
||||
"e164": isE164,
|
||||
"email": isEmail,
|
||||
"url": isURL,
|
||||
"http_url": isHttpURL,
|
||||
"uri": isURI,
|
||||
"urn_rfc2141": isUrnRFC2141, // RFC 2141
|
||||
"file": isFile,
|
||||
"filepath": isFilePath,
|
||||
"base64": isBase64,
|
||||
"base64url": isBase64URL,
|
||||
"base64rawurl": isBase64RawURL,
|
||||
"contains": contains,
|
||||
"containsany": containsAny,
|
||||
"containsrune": containsRune,
|
||||
@ -140,6 +147,7 @@ var (
|
||||
"isbn10": isISBN10,
|
||||
"isbn13": isISBN13,
|
||||
"eth_addr": isEthereumAddress,
|
||||
"eth_addr_checksum": isEthereumAddressChecksum,
|
||||
"btc_addr": isBitcoinAddress,
|
||||
"btc_addr_bech32": isBitcoinBech32Address,
|
||||
"uuid": isUUID,
|
||||
@ -194,6 +202,7 @@ var (
|
||||
"html_encoded": isHTMLEncoded,
|
||||
"url_encoded": isURLEncoded,
|
||||
"dir": isDir,
|
||||
"dirpath": isDirPath,
|
||||
"json": isJSON,
|
||||
"jwt": isJWT,
|
||||
"hostname_port": isHostnamePort,
|
||||
@ -214,6 +223,10 @@ var (
|
||||
"semver": isSemverFormat,
|
||||
"dns_rfc1035_label": isDnsRFC1035LabelFormat,
|
||||
"credit_card": isCreditCard,
|
||||
"cve": isCveFormat,
|
||||
"luhn_checksum": hasLuhnChecksum,
|
||||
"mongodb": isMongoDB,
|
||||
"cron": isCron,
|
||||
}
|
||||
)
|
||||
|
||||
@ -307,18 +320,42 @@ func isUnique(fl FieldLevel) bool {
|
||||
}
|
||||
|
||||
m := reflect.MakeMap(reflect.MapOf(sfTyp, v.Type()))
|
||||
var fieldlen int
|
||||
for i := 0; i < field.Len(); i++ {
|
||||
m.SetMapIndex(reflect.Indirect(reflect.Indirect(field.Index(i)).FieldByName(param)), v)
|
||||
key := reflect.Indirect(reflect.Indirect(field.Index(i)).FieldByName(param))
|
||||
if key.IsValid() {
|
||||
fieldlen++
|
||||
m.SetMapIndex(key, v)
|
||||
}
|
||||
}
|
||||
return field.Len() == m.Len()
|
||||
return fieldlen == m.Len()
|
||||
case reflect.Map:
|
||||
m := reflect.MakeMap(reflect.MapOf(field.Type().Elem(), v.Type()))
|
||||
var m reflect.Value
|
||||
if field.Type().Elem().Kind() == reflect.Ptr {
|
||||
m = reflect.MakeMap(reflect.MapOf(field.Type().Elem().Elem(), v.Type()))
|
||||
} else {
|
||||
m = reflect.MakeMap(reflect.MapOf(field.Type().Elem(), v.Type()))
|
||||
}
|
||||
|
||||
for _, k := range field.MapKeys() {
|
||||
m.SetMapIndex(field.MapIndex(k), v)
|
||||
m.SetMapIndex(reflect.Indirect(field.MapIndex(k)), v)
|
||||
}
|
||||
|
||||
return field.Len() == m.Len()
|
||||
default:
|
||||
if parent := fl.Parent(); parent.Kind() == reflect.Struct {
|
||||
uniqueField := parent.FieldByName(param)
|
||||
if uniqueField == reflect.ValueOf(nil) {
|
||||
panic(fmt.Sprintf("Bad field name provided %s", param))
|
||||
}
|
||||
|
||||
if uniqueField.Kind() != field.Kind() {
|
||||
panic(fmt.Sprintf("Bad field type %T:%T", field.Interface(), uniqueField.Interface()))
|
||||
}
|
||||
|
||||
return field.Interface() != uniqueField.Interface()
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
}
|
||||
@ -613,14 +650,16 @@ func isISBN10(fl FieldLevel) bool {
|
||||
func isEthereumAddress(fl FieldLevel) bool {
|
||||
address := fl.Field().String()
|
||||
|
||||
return ethAddressRegex.MatchString(address)
|
||||
}
|
||||
|
||||
// isEthereumAddressChecksum is the validation function for validating if the field's value is a valid checksumed Ethereum address.
|
||||
func isEthereumAddressChecksum(fl FieldLevel) bool {
|
||||
address := fl.Field().String()
|
||||
|
||||
if !ethAddressRegex.MatchString(address) {
|
||||
return false
|
||||
}
|
||||
|
||||
if ethAddressRegexUpper.MatchString(address) || ethAddressRegexLower.MatchString(address) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Checksum validation. Reference: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
|
||||
address = address[2:] // Skip "0x" prefix.
|
||||
h := sha3.NewLegacyKeccak256()
|
||||
@ -889,6 +928,12 @@ func isNe(fl FieldLevel) bool {
|
||||
return !isEq(fl)
|
||||
}
|
||||
|
||||
// isNe is the validation function for validating that the field's string value does not equal the
|
||||
// provided param value. The comparison is case-insensitive
|
||||
func isNeIgnoreCase(fl FieldLevel) bool {
|
||||
return !isEqIgnoreCase(fl)
|
||||
}
|
||||
|
||||
// isLteCrossStructField is the validation function for validating if the current field's value is less than or equal to the field, within a separate struct, specified by the param's value.
|
||||
func isLteCrossStructField(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
@ -1260,6 +1305,22 @@ func isEq(fl FieldLevel) bool {
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isEqIgnoreCase is the validation function for validating if the current field's string value is
|
||||
// equal to the param's value.
|
||||
// The comparison is case-insensitive.
|
||||
func isEqIgnoreCase(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
param := fl.Param()
|
||||
|
||||
switch field.Kind() {
|
||||
|
||||
case reflect.String:
|
||||
return strings.EqualFold(field.String(), param)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isPostcodeByIso3166Alpha2 validates by value which is country code in iso 3166 alpha 2
|
||||
// example: `postcode_iso3166_alpha2=US`
|
||||
func isPostcodeByIso3166Alpha2(fl FieldLevel) bool {
|
||||
@ -1311,6 +1372,11 @@ func isBase64URL(fl FieldLevel) bool {
|
||||
return base64URLRegex.MatchString(fl.Field().String())
|
||||
}
|
||||
|
||||
// isBase64RawURL is the validation function for validating if the current field's value is a valid base64 URL safe string without '=' padding.
|
||||
func isBase64RawURL(fl FieldLevel) bool {
|
||||
return base64RawURLRegex.MatchString(fl.Field().String())
|
||||
}
|
||||
|
||||
// isURI is the validation function for validating if the current field's value is a valid URI.
|
||||
func isURI(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
@ -1370,6 +1436,23 @@ func isURL(fl FieldLevel) bool {
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isHttpURL is the validation function for validating if the current field's value is a valid HTTP(s) URL.
|
||||
func isHttpURL(fl FieldLevel) bool {
|
||||
if !isURL(fl) {
|
||||
return false
|
||||
}
|
||||
|
||||
field := fl.Field()
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
|
||||
s := strings.ToLower(field.String())
|
||||
return strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://")
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isUrnRFC2141 is the validation function for validating if the current field's value is a valid URN as per RFC 2141.
|
||||
func isUrnRFC2141(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
@ -1387,7 +1470,7 @@ func isUrnRFC2141(fl FieldLevel) bool {
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isFile is the validation function for validating if the current field's value is a valid file path.
|
||||
// isFile is the validation function for validating if the current field's value is a valid existing file path.
|
||||
func isFile(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
|
||||
@ -1404,6 +1487,57 @@ func isFile(fl FieldLevel) bool {
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
field := fl.Field()
|
||||
|
||||
// If it exists, it obviously is valid.
|
||||
// This is done first to avoid code duplication and unnecessary additional logic.
|
||||
if exists = isFile(fl); exists {
|
||||
return true
|
||||
}
|
||||
|
||||
// It does not exist but may still be a valid filepath.
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
// Every OS allows for whitespace, but none
|
||||
// let you use a file with no filename (to my knowledge).
|
||||
// Unless you're dealing with raw inodes, but I digress.
|
||||
if strings.TrimSpace(field.String()) == "" {
|
||||
return false
|
||||
}
|
||||
// We make sure it isn't a directory.
|
||||
if strings.HasSuffix(field.String(), string(os.PathSeparator)) {
|
||||
return false
|
||||
}
|
||||
if _, err = os.Stat(field.String()); err != nil {
|
||||
switch t := err.(type) {
|
||||
case *fs.PathError:
|
||||
if t.Err == syscall.EINVAL {
|
||||
// It's definitely an invalid character in the filepath.
|
||||
return false
|
||||
}
|
||||
// It could be a permission error, a does-not-exist error, etc.
|
||||
// Out-of-scope for this validation, though.
|
||||
return true
|
||||
default:
|
||||
// Something went *seriously* wrong.
|
||||
/*
|
||||
Per https://pkg.go.dev/os#Stat:
|
||||
"If there is an error, it will be of type *PathError."
|
||||
*/
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isE164 is the validation function for validating if the current field's value is a valid e.164 formatted phone number.
|
||||
func isE164(fl FieldLevel) bool {
|
||||
return e164Regex.MatchString(fl.Field().String())
|
||||
@ -1539,7 +1673,9 @@ func requireCheckFieldKind(fl FieldLevel, param string, defaultNotFoundValue boo
|
||||
}
|
||||
|
||||
// requireCheckFieldValue is a func for check field value
|
||||
func requireCheckFieldValue(fl FieldLevel, param string, value string, defaultNotFoundValue bool) bool {
|
||||
func requireCheckFieldValue(
|
||||
fl FieldLevel, param string, value string, defaultNotFoundValue bool,
|
||||
) bool {
|
||||
field, kind, _, found := fl.GetStructFieldOKAdvanced2(fl.Parent(), param)
|
||||
if !found {
|
||||
return defaultNotFoundValue
|
||||
@ -1623,10 +1759,10 @@ func excludedUnless(fl FieldLevel) bool {
|
||||
}
|
||||
for i := 0; i < len(params); i += 2 {
|
||||
if !requireCheckFieldValue(fl, params[i], params[i+1], false) {
|
||||
return true
|
||||
return !hasValue(fl)
|
||||
}
|
||||
}
|
||||
return !hasValue(fl)
|
||||
return true
|
||||
}
|
||||
|
||||
// excludedWith is the validation function
|
||||
@ -2275,7 +2411,7 @@ func isFQDN(fl FieldLevel) bool {
|
||||
return fqdnRegexRFC1123.MatchString(val)
|
||||
}
|
||||
|
||||
// isDir is the validation function for validating if the current field's value is a valid directory.
|
||||
// isDir is the validation function for validating if the current field's value is a valid existing directory.
|
||||
func isDir(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
|
||||
@ -2291,6 +2427,64 @@ func isDir(fl FieldLevel) bool {
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
field := fl.Field()
|
||||
|
||||
// If it exists, it obviously is valid.
|
||||
// This is done first to avoid code duplication and unnecessary additional logic.
|
||||
if exists = isDir(fl); exists {
|
||||
return true
|
||||
}
|
||||
|
||||
// It does not exist but may still be a valid path.
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
// Every OS allows for whitespace, but none
|
||||
// let you use a dir with no name (to my knowledge).
|
||||
// Unless you're dealing with raw inodes, but I digress.
|
||||
if strings.TrimSpace(field.String()) == "" {
|
||||
return false
|
||||
}
|
||||
if _, err = os.Stat(field.String()); err != nil {
|
||||
switch t := err.(type) {
|
||||
case *fs.PathError:
|
||||
if t.Err == syscall.EINVAL {
|
||||
// It's definitely an invalid character in the path.
|
||||
return false
|
||||
}
|
||||
// It could be a permission error, a does-not-exist error, etc.
|
||||
// Out-of-scope for this validation, though.
|
||||
// Lastly, we make sure it is a directory.
|
||||
if strings.HasSuffix(field.String(), string(os.PathSeparator)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
// Something went *seriously* wrong.
|
||||
/*
|
||||
Per https://pkg.go.dev/os#Stat:
|
||||
"If there is an error, it will be of type *PathError."
|
||||
*/
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
// We repeat the check here to make sure it is an explicit directory in case the above os.Stat didn't trigger an error.
|
||||
if strings.HasSuffix(field.String(), string(os.PathSeparator)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
|
||||
// isJSON is the validation function for validating if the current field's value is a valid json string.
|
||||
func isJSON(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
@ -2316,7 +2510,9 @@ func isHostnamePort(fl FieldLevel) bool {
|
||||
return false
|
||||
}
|
||||
// Port must be a iny <= 65535.
|
||||
if portNum, err := strconv.ParseInt(port, 10, 32); err != nil || portNum > 65535 || portNum < 1 {
|
||||
if portNum, err := strconv.ParseInt(
|
||||
port, 10, 32,
|
||||
); err != nil || portNum > 65535 || portNum < 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -2479,6 +2675,13 @@ func isSemverFormat(fl FieldLevel) bool {
|
||||
return semverRegex.MatchString(semverString)
|
||||
}
|
||||
|
||||
// isCveFormat is the validation function for validating if the current field's value is a valid cve id, defined in CVE mitre org
|
||||
func isCveFormat(fl FieldLevel) bool {
|
||||
cveString := fl.Field().String()
|
||||
|
||||
return cveRegex.MatchString(cveString)
|
||||
}
|
||||
|
||||
// isDnsRFC1035LabelFormat is the validation function
|
||||
// for validating if the current field's value is
|
||||
// a valid dns RFC 1035 label, defined in RFC 1035.
|
||||
@ -2487,6 +2690,35 @@ func isDnsRFC1035LabelFormat(fl FieldLevel) bool {
|
||||
return dnsRegexRFC1035Label.MatchString(val)
|
||||
}
|
||||
|
||||
// digitsHaveLuhnChecksum returns true if and only if the last element of the given digits slice is the Luhn checksum of the previous elements
|
||||
func digitsHaveLuhnChecksum(digits []string) bool {
|
||||
size := len(digits)
|
||||
sum := 0
|
||||
for i, digit := range digits {
|
||||
value, err := strconv.Atoi(digit)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if size%2 == 0 && i%2 == 0 || size%2 == 1 && i%2 == 1 {
|
||||
v := value * 2
|
||||
if v >= 10 {
|
||||
sum += 1 + (v % 10)
|
||||
} else {
|
||||
sum += v
|
||||
}
|
||||
} else {
|
||||
sum += value
|
||||
}
|
||||
}
|
||||
return (sum % 10) == 0
|
||||
}
|
||||
|
||||
// isMongoDB is the validation function for validating if the current field's value is valid mongoDB objectID
|
||||
func isMongoDB(fl FieldLevel) bool {
|
||||
val := fl.Field().String()
|
||||
return mongodbRegex.MatchString(val)
|
||||
}
|
||||
|
||||
// isCreditCard is the validation function for validating if the current field's value is a valid credit card number
|
||||
func isCreditCard(fl FieldLevel) bool {
|
||||
val := fl.Field().String()
|
||||
@ -2505,22 +2737,33 @@ func isCreditCard(fl FieldLevel) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
sum := 0
|
||||
for i, digit := range ccDigits {
|
||||
value, err := strconv.Atoi(digit)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if size%2 == 0 && i%2 == 0 || size%2 == 1 && i%2 == 1 {
|
||||
v := value * 2
|
||||
if v >= 10 {
|
||||
sum += 1 + (v % 10)
|
||||
} else {
|
||||
sum += v
|
||||
}
|
||||
} else {
|
||||
sum += value
|
||||
}
|
||||
}
|
||||
return (sum % 10) == 0
|
||||
return digitsHaveLuhnChecksum(ccDigits)
|
||||
}
|
||||
|
||||
// hasLuhnChecksum is the validation for validating if the current field's value has a valid Luhn checksum
|
||||
func hasLuhnChecksum(fl FieldLevel) bool {
|
||||
field := fl.Field()
|
||||
var str string // convert to a string which will then be split into single digits; easier and more readable than shifting/extracting single digits from a number
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
str = field.String()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
str = strconv.FormatInt(field.Int(), 10)
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
str = strconv.FormatUint(field.Uint(), 10)
|
||||
default:
|
||||
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
|
||||
}
|
||||
size := len(str)
|
||||
if size < 2 { // there has to be at least one digit that carries a meaning + the checksum
|
||||
return false
|
||||
}
|
||||
digits := strings.Split(str, "")
|
||||
return digitsHaveLuhnChecksum(digits)
|
||||
}
|
||||
|
||||
// isCron is the validation function for validating if the current field's value is a valid cron expression
|
||||
func isCron(fl FieldLevel) bool {
|
||||
cronString := fl.Field().String()
|
||||
return cronRegex.MatchString(cronString)
|
||||
}
|
||||
|
2
vendor/github.com/go-playground/validator/v10/cache.go
generated
vendored
2
vendor/github.com/go-playground/validator/v10/cache.go
generated
vendored
@ -120,7 +120,7 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
|
||||
var fld reflect.StructField
|
||||
var tag string
|
||||
var customName string
|
||||
|
||||
|
||||
for i := 0; i < numFields; i++ {
|
||||
|
||||
fld = typ.Field(i)
|
||||
|
6
vendor/github.com/go-playground/validator/v10/country_codes.go
generated
vendored
6
vendor/github.com/go-playground/validator/v10/country_codes.go
generated
vendored
@ -51,7 +51,7 @@ var iso3166_1_alpha2 = map[string]bool{
|
||||
"TV": true, "UG": true, "UA": true, "AE": true, "GB": true,
|
||||
"US": true, "UM": true, "UY": true, "UZ": true, "VU": true,
|
||||
"VE": true, "VN": true, "VG": true, "VI": true, "WF": true,
|
||||
"EH": true, "YE": true, "ZM": true, "ZW": true,
|
||||
"EH": true, "YE": true, "ZM": true, "ZW": true, "XK": true,
|
||||
}
|
||||
|
||||
var iso3166_1_alpha3 = map[string]bool{
|
||||
@ -105,7 +105,7 @@ var iso3166_1_alpha3 = map[string]bool{
|
||||
"UGA": true, "UKR": true, "ARE": true, "GBR": true, "UMI": true,
|
||||
"USA": true, "URY": true, "UZB": true, "VUT": true, "VEN": true,
|
||||
"VNM": true, "VGB": true, "VIR": true, "WLF": true, "ESH": true,
|
||||
"YEM": true, "ZMB": true, "ZWE": true, "ALA": true,
|
||||
"YEM": true, "ZMB": true, "ZWE": true, "ALA": true, "UNK": true,
|
||||
}
|
||||
var iso3166_1_alpha_numeric = map[int]bool{
|
||||
// see: https://www.iso.org/iso-3166-country-codes.html
|
||||
@ -158,7 +158,7 @@ var iso3166_1_alpha_numeric = map[int]bool{
|
||||
800: true, 804: true, 784: true, 826: true, 581: true,
|
||||
840: true, 858: true, 860: true, 548: true, 862: true,
|
||||
704: true, 92: true, 850: true, 876: true, 732: true,
|
||||
887: true, 894: true, 716: true, 248: true,
|
||||
887: true, 894: true, 716: true, 248: true, 153:true,
|
||||
}
|
||||
|
||||
var iso3166_2 = map[string]bool{
|
||||
|
374
vendor/github.com/go-playground/validator/v10/doc.go
generated
vendored
374
vendor/github.com/go-playground/validator/v10/doc.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5
vendor/github.com/go-playground/validator/v10/errors.go
generated
vendored
5
vendor/github.com/go-playground/validator/v10/errors.go
generated
vendored
@ -44,12 +44,9 @@ func (ve ValidationErrors) Error() string {
|
||||
|
||||
buff := bytes.NewBufferString("")
|
||||
|
||||
var fe *fieldError
|
||||
|
||||
for i := 0; i < len(ve); i++ {
|
||||
|
||||
fe = ve[i].(*fieldError)
|
||||
buff.WriteString(fe.Error())
|
||||
buff.WriteString(ve[i].Error())
|
||||
buff.WriteString("\n")
|
||||
}
|
||||
|
||||
|
10
vendor/github.com/go-playground/validator/v10/regexes.go
generated
vendored
10
vendor/github.com/go-playground/validator/v10/regexes.go
generated
vendored
@ -19,6 +19,7 @@ const (
|
||||
e164RegexString = "^\\+[1-9]?[0-9]{7,14}$"
|
||||
base64RegexString = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
|
||||
base64URLRegexString = "^(?:[A-Za-z0-9-_]{4})*(?:[A-Za-z0-9-_]{2}==|[A-Za-z0-9-_]{3}=|[A-Za-z0-9-_]{4})$"
|
||||
base64RawURLRegexString = "^(?:[A-Za-z0-9-_]{4})*(?:[A-Za-z0-9-_]{2,4})$"
|
||||
iSBN10RegexString = "^(?:[0-9]{9}X|[0-9]{10})$"
|
||||
iSBN13RegexString = "^(?:(?:97(?:8|9))[0-9]{10})$"
|
||||
uUID3RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
||||
@ -64,6 +65,9 @@ const (
|
||||
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}$"
|
||||
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
|
||||
mongodbRegexString = "^[a-f\\d]{24}$"
|
||||
cronRegexString = `(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})`
|
||||
)
|
||||
|
||||
var (
|
||||
@ -83,6 +87,7 @@ var (
|
||||
emailRegex = regexp.MustCompile(emailRegexString)
|
||||
base64Regex = regexp.MustCompile(base64RegexString)
|
||||
base64URLRegex = regexp.MustCompile(base64URLRegexString)
|
||||
base64RawURLRegex = regexp.MustCompile(base64RawURLRegexString)
|
||||
iSBN10Regex = regexp.MustCompile(iSBN10RegexString)
|
||||
iSBN13Regex = regexp.MustCompile(iSBN13RegexString)
|
||||
uUID3Regex = regexp.MustCompile(uUID3RegexString)
|
||||
@ -118,8 +123,6 @@ var (
|
||||
btcUpperAddressRegexBech32 = regexp.MustCompile(btcAddressUpperRegexStringBech32)
|
||||
btcLowerAddressRegexBech32 = regexp.MustCompile(btcAddressLowerRegexStringBech32)
|
||||
ethAddressRegex = regexp.MustCompile(ethAddressRegexString)
|
||||
ethAddressRegexUpper = regexp.MustCompile(ethAddressUpperRegexString)
|
||||
ethAddressRegexLower = regexp.MustCompile(ethAddressLowerRegexString)
|
||||
uRLEncodedRegex = regexp.MustCompile(uRLEncodedRegexString)
|
||||
hTMLEncodedRegex = regexp.MustCompile(hTMLEncodedRegexString)
|
||||
hTMLRegex = regexp.MustCompile(hTMLRegexString)
|
||||
@ -128,4 +131,7 @@ var (
|
||||
bicRegex = regexp.MustCompile(bicRegexString)
|
||||
semverRegex = regexp.MustCompile(semverRegexString)
|
||||
dnsRegexRFC1035Label = regexp.MustCompile(dnsRegexStringRFC1035Label)
|
||||
cveRegex = regexp.MustCompile(cveRegexString)
|
||||
mongodbRegex = regexp.MustCompile(mongodbRegexString)
|
||||
cronRegex = regexp.MustCompile(cronRegexString)
|
||||
)
|
||||
|
1
vendor/github.com/go-playground/validator/v10/validator.go
generated
vendored
1
vendor/github.com/go-playground/validator/v10/validator.go
generated
vendored
@ -452,7 +452,6 @@ OUTER:
|
||||
v.ct = ct
|
||||
|
||||
if !ct.fn(ctx, v) {
|
||||
|
||||
v.str1 = string(append(ns, cf.altName...))
|
||||
|
||||
if v.v.hasTagNameFunc {
|
||||
|
19
vendor/github.com/go-playground/validator/v10/validator_instance.go
generated
vendored
19
vendor/github.com/go-playground/validator/v10/validator_instance.go
generated
vendored
@ -190,14 +190,14 @@ func (v *Validate) ValidateMap(data map[string]interface{}, rules map[string]int
|
||||
//
|
||||
// eg. to use the names which have been specified for JSON representations of structs, rather than normal Go field names:
|
||||
//
|
||||
// validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
|
||||
// name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
|
||||
// // skip if tag key says it should be ignored
|
||||
// if name == "-" {
|
||||
// return ""
|
||||
// }
|
||||
// return name
|
||||
// })
|
||||
// validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
|
||||
// name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
|
||||
// // skip if tag key says it should be ignored
|
||||
// if name == "-" {
|
||||
// return ""
|
||||
// }
|
||||
// return name
|
||||
// })
|
||||
func (v *Validate) RegisterTagNameFunc(fn TagNameFunc) {
|
||||
v.tagNameFunc = fn
|
||||
v.hasTagNameFunc = true
|
||||
@ -613,7 +613,7 @@ func (v *Validate) Var(field interface{}, tag string) error {
|
||||
}
|
||||
|
||||
// VarCtx validates a single variable using tag style validation and allows passing of contextual
|
||||
// validation validation information via context.Context.
|
||||
// validation information via context.Context.
|
||||
// eg.
|
||||
// var i int
|
||||
// validate.Var(i, "gt=1,lt=10")
|
||||
@ -632,6 +632,7 @@ func (v *Validate) VarCtx(ctx context.Context, field interface{}, tag string) (e
|
||||
}
|
||||
|
||||
ctag := v.fetchCacheTag(tag)
|
||||
|
||||
val := reflect.ValueOf(field)
|
||||
vd := v.pool.Get().(*validate)
|
||||
vd.top = val
|
||||
|
Reference in New Issue
Block a user