Skip to content

(CAT-1919) - Handle scenario when user input password in <anything-in-caps-with-alpha-numeric>*<alpha-numeric-40-chars-in-caps> #1634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

Ramesh7
Copy link
Contributor

@Ramesh7 Ramesh7 commented Jun 30, 2024

Summary

When the password is passed in <anything-in-caps-with-alpha-numeric>*<alpha-numeric-40-chars-in-caps> format with Sensitive then the current implementation fails with below error :

Error: Only mysql_native_password (*ABCD...XXX) hashes are supported.
Error: /Stage[main]/Main/Mysql_user[test1@127.0.0.1]/password_hash: change from [old password hash redacted] to [new password hash redacted] failed: Only mysql_native_password (*ABCD...XXX) hashes are supported.

This is because the mysql::password doesn't handle mentioned condition properly.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

@Ramesh7 Ramesh7 requested review from alexjfisher, bastelfreak and a team as code owners June 30, 2024 06:02
@Ramesh7 Ramesh7 added the bugfix label Jun 30, 2024
@Ramesh7 Ramesh7 force-pushed the CAT-1919-fixing-password-issue branch 2 times, most recently from 51a60dc to 476ec95 Compare June 30, 2024 07:29
…-caps-with-alpha-numeric>*<alpha-numeric-40-chars-in-caps>
@Ramesh7 Ramesh7 force-pushed the CAT-1919-fixing-password-issue branch from 476ec95 to c88d048 Compare June 30, 2024 07:31
@@ -22,7 +22,7 @@
def password(password, sensitive = false)
password = password.unwrap if password.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)

result_string = if %r{\*[A-F0-9]{40}$}.match?(password)
result_string = if %r{^\*[A-F0-9]{40}$}.match?(password)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just have a few minutes right now, but I'm wondering why we have this regex at all? Does it check if it's a hash and otherwise runs into the last else block and runs SHA1?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention is if it's already a Hash, then don't hash it, but since the regex isn't anchored it can pick up other passwords. The other password looks incredibly unlikely in the real world though. But I guess @Ramesh7 bumped into this in their environment??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bastelfreak yeah, if its hash then it will return that otherwise it will hash it with SHA1.
@alexjfisher yeah, recently we encountered this and found there is flow in regex which needs to fix, so took it here.

@Ramesh7 Ramesh7 merged commit c9c41e8 into main Jul 5, 2024
36 of 38 checks passed
@Ramesh7 Ramesh7 deleted the CAT-1919-fixing-password-issue branch July 5, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants