diff --git a/plugins/database/cassandra/cassandra.go b/plugins/database/cassandra/cassandra.go index 3ed59a8465c8..c0b5fd5d4254 100644 --- a/plugins/database/cassandra/cassandra.go +++ b/plugins/database/cassandra/cassandra.go @@ -96,6 +96,7 @@ func (c *Cassandra) CreateUser(statements dbplugin.Statements, usernameConfig db } username, err = c.GenerateUsername(usernameConfig) + username = strings.Replace(username, "-", "_", -1) if err != nil { return "", "", err } diff --git a/plugins/helper/database/credsutil/credsutil.go b/plugins/helper/database/credsutil/credsutil.go index 4449699e3691..9d2b9167c373 100644 --- a/plugins/helper/database/credsutil/credsutil.go +++ b/plugins/helper/database/credsutil/credsutil.go @@ -19,12 +19,12 @@ type CredentialsProducer interface { } const ( - reqStr = `A1a` + reqStr = `A1a-` minStrLen = 10 ) -// RandomAlphaNumeric returns a random string of characters [A-Za-z0-9] -// of the provided length. The string generated takes up to 3 characters +// RandomAlphaNumeric returns a random string of characters [A-Za-z0-9-] +// of the provided length. The string generated takes up to 4 characters // of space that are predefined and prepended to ensure password // character requirements. It also requires a min length of 10 characters. func RandomAlphaNumeric(length int) (string, error) { @@ -40,7 +40,7 @@ func RandomAlphaNumeric(length int) (string, error) { for size < length { // Extend the len of the random byte slice to lower odds of having to // re-roll. - c := length + 3 + c := length + len(reqStr) bArr := make([]byte, c) _, err := rand.Read(bArr) if err != nil {