diff --git a/cmd/crowdsec-cli/dashboard.go b/cmd/crowdsec-cli/dashboard.go index 0eb6e33be..b44cd4074 100644 --- a/cmd/crowdsec-cli/dashboard.go +++ b/cmd/crowdsec-cli/dashboard.go @@ -8,6 +8,7 @@ import ( "path/filepath" "strconv" "strings" + "unicode" "github.com/AlecAivazis/survey/v2" "github.com/crowdsecurity/crowdsec/pkg/metabase" @@ -86,7 +87,11 @@ cscli dashboard setup -l 0.0.0.0 -p 443 --password } if metabasePassword == "" { - metabasePassword = generatePassword(16) + isValid := passwordIsValid(metabasePassword) + for !isValid { + metabasePassword = generatePassword(16) + isValid = passwordIsValid(metabasePassword) + } } var answer bool groupExist := false @@ -251,3 +256,19 @@ cscli dashboard remove --force return cmdDashboard } + +func passwordIsValid(password string) bool { + hasDigit := false + for _, j := range password { + if unicode.IsDigit(j) { + hasDigit = true + break + } + } + + if !hasDigit || len(password) < 6 { + return false + } + return true + +}