Skip to content
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

try db_password to be Sensitive #1190

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

try db_password to be Sensitive #1190

wants to merge 3 commits into from

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Oct 16, 2024

  • properly escape quotes in passwords by calling to_ruby
  • try db_password to be Sensitive

database passwords can contain special characters, especially " and '
so we can't just print the value of the field enclosed by double quotes
as that would break whenever the user uses a literal " in their password

using to_ruby here and not to_yaml, as the former gives us correct escaping
without the whole `---` and `\n` enclosing that to_yaml forces.
using to_yaml would require to pass *the whole* config hash to it
@@ -30,6 +30,6 @@
username: <%= $username %>
<% } -%>
<% if $password { -%>
password: "<%= $password %>"
password: <%= stdlib::to_ruby($password) %>
Copy link
Member Author

Choose a reason for hiding this comment

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

If I drop this, I get:

expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to /password: "secret"/ but it is set to #<Sensitive [value redacted]>

so maybe with_content is a bad idea to begin with?

Copy link
Member Author

Choose a reason for hiding this comment

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

with_content(sensitive(…)) works for the plain case, but not once to_ruby is involved. yay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant