Skip to content

Commit

Permalink
Merge pull request puppetlabs#71 from runningman/security
Browse files Browse the repository at this point in the history
Fixed regex of database user.
  • Loading branch information
bodepd committed May 7, 2012
2 parents ed62777 + eaf9ee5 commit 05f7807
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/puppet/type/database_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
newparam(:name, :namevar=>true) do
desc "The name of the user. This uses the 'username@hostname' or username@hostname."
validate do |value|
raise(ArgumentError, "Invalid database user #{value}") unless value =~ /\w+@[\w%]+/
# https://dev.mysql.com/doc/refman/5.1/en/account-names.html
# Regex should problably be more like this: /^[`'"]?[^`'"]*[`'"]?@[`'"]?[\w%\.]+[`'"]?$/
raise(ArgumentError, "Invalid database user #{value}") unless value =~ /[\w-]*@[\w%\.]+/
username = value.split('@')[0]
if username.size > 16
raise ArgumentError, "MySQL usernames are limited to a maximum of 16 characters"
Expand Down

0 comments on commit 05f7807

Please sign in to comment.