Skip to content

Commit

Permalink
credsutil: Include hyphen as part of reqStr (#3037)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvn authored and jefferai committed Aug 3, 2017
1 parent 8d99192 commit 7d55652
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions plugins/database/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/helper/database/credsutil/credsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit 7d55652

Please sign in to comment.