mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
controller/robot: use global regexp vars (#17915)
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io> Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
parent
24a091018c
commit
7dc452ccab
@ -395,12 +395,12 @@ func CreateSec(salt ...string) (string, string, string, error) {
|
||||
return secret, pwd, saltTmp, nil
|
||||
}
|
||||
|
||||
var (
|
||||
hasLower = regexp.MustCompile(`[a-z]`)
|
||||
hasUpper = regexp.MustCompile(`[A-Z]`)
|
||||
hasNumber = regexp.MustCompile(`\d`)
|
||||
)
|
||||
|
||||
func IsValidSec(secret string) bool {
|
||||
hasLower := regexp.MustCompile(`[a-z]`)
|
||||
hasUpper := regexp.MustCompile(`[A-Z]`)
|
||||
hasNumber := regexp.MustCompile(`\d`)
|
||||
if len(secret) >= 8 && hasLower.MatchString(secret) && hasUpper.MatchString(secret) && hasNumber.MatchString(secret) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return len(secret) >= 8 && hasLower.MatchString(secret) && hasUpper.MatchString(secret) && hasNumber.MatchString(secret)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user