chore: security updates for dependencies
1 |
package security |
|
2 |
|
|
3 |
import ( |
|
4 |
"regexp"
|
|
5 |
)
|
|
6 |
|
|
7 |
// ValidUUID checks if `uuid` is a valid UUID-v4 string
|
|
8 |
func ValidUUID(uuid string) bool { |
|
9 | 1 |
r := regexp.MustCompile("^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[8|9|aA|bB][a-f0-9]{3}-[a-f0-9]{12}$") |
10 | 1 |
return r.MatchString(uuid) |
11 |
}
|
|
12 |
|
|
13 |
// ValidBase64 checks if `encoded` is a valid base64 string
|
|
14 |
func ValidBase64(encoded string) bool { |
|
15 | 1 |
r := regexp.MustCompile("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$") |
16 | 1 |
return r.MatchString(encoded) |
17 |
}
|
|
18 |
|
|
19 |
// ValidRandomString checks if `random` is a valid random string
|
|
20 |
func ValidRandomString(random string) bool { |
|
21 | 1 |
r := regexp.MustCompile("^[a-zA-Z0-9]+$") |
22 | 1 |
return r.MatchString(random) |
23 |
}
|
|
24 |
|
|
25 |
// ValidToken checks if `token` is a valid token/random string
|
|
26 |
func ValidToken(token string) bool { |
|
27 |
return ValidRandomString(token) |
|
28 |
}
|
|
29 |
|
|
30 |
// ValidEmail checks if `email` is a valid e-mail address
|
|
31 |
func ValidEmail(email string) bool { |
|
32 | 1 |
r := regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`) |
33 | 1 |
return r.MatchString(email) |
34 |
}
|
Read our documentation on viewing source code .