Skip to content

Prevent nested sensitive wrap of password alter query #1418

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

Closed
wants to merge 1 commit into from
Closed

Prevent nested sensitive wrap of password alter query #1418

wants to merge 1 commit into from

Conversation

laugmanuel
Copy link

Fixes #1417

@laugmanuel laugmanuel requested a review from a team as a code owner April 21, 2023 11:26
@CLAassistant
Copy link

CLAassistant commented Apr 21, 2023

CLA assistant check
All committers have signed the CLA.

@puppet-community-rangefinder
Copy link

postgresql::server::role is a type

Breaking changes to this file WILL impact these 22 modules (exact match):
Breaking changes to this file MAY impact these 6 modules (near match):

This module is declared in 70 of 580 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@ekohl
Copy link
Collaborator

ekohl commented Apr 23, 2023

There are some related PRs. I think this is a better fix than #1404 but #1405 would improve the tests to catch this. Can you take a look and see if you can combine those tests into your PR?

@laugmanuel
Copy link
Author

There are some related PRs. I think this is a better fix than #1404 but #1405 would improve the tests to catch this. Can you take a look and see if you can combine those tests into your PR?

Thanks for the heads-up. Somehow I did miss the existing Issue and PR - sorry for that.

I've cherry-picked the tests from #1404 to this PR.

@laugmanuel
Copy link
Author

Broken tests for RHEL9 and SLES15 seem to be infrastructure related...

@cruelsmith
Copy link
Contributor

cruelsmith commented Apr 26, 2023

Sry to be the party popper but make it even sense to call the postgresql::postgresql_password function with forcing it to be sensitive and instantly unwarping its result?

That is why in #1404 i just turned the sensitive return of the value off:

$password_hash =~ Sensitive[String],

This also means that the unwrap for the Deferred is not needed in this change because the function already returns a not sensitive value.
if sensitive
Puppet::Pops::Types::PSensitiveType::Sensitive.new(pass)
else
pass
end

@laugmanuel
Copy link
Author

I guess both ways are valid and it's mostly personal preference. However, I do prefer unwrapping in Puppet, as passing in a Sensitive also returns a Sensitive in this case - so the function itself does not change the datatype.

@ekohl
Copy link
Collaborator

ekohl commented Jul 12, 2023

I've merged #1404 because it was a quick fix, but I still wouldn't mind merging this. If you're still interested in this then please rebase.

@laugmanuel
Copy link
Author

I've merged #1404 because it was a quick fix, but I still wouldn't mind merging this. If you're still interested in this then please rebase.

Rebased this MR against current main.

Copy link
Collaborator

@smortex smortex left a comment

Choose a reason for hiding this comment

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

I am confused. Can you provide a non-working unit test that this change fix?

I feel like this got fixed by accident while fixing other misbehavior.

@@ -160,7 +160,7 @@
$hash,
$salt,
]
)
).unwrap
Copy link
Collaborator

Choose a reason for hiding this comment

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

The 3rd arguments should prevent the return value from being a Sensitive, so this should be noop.

@@ -169,7 +169,7 @@
false,
$hash,
$salt,
)
).unwrap
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

@laugmanuel
Copy link
Author

I am confused. Can you provide a non-working unit test that this change fix?

I feel like this got fixed by accident while fixing other misbehavior.

This PR fixes the same problem as #1404 does, but in a different way (as I wrote on Apr 28). Because of that, there are no broken tests at the moment.

I just followed the advice of @ekohl to rebase. However, I'm fine with closing this as well...

@smortex
Copy link
Collaborator

smortex commented Jul 25, 2023

I see, it looks like the bugfix was also in main and the commit in this PR now only show the differences between the two bugfix attempts. Since the problem is now fixed, I will close this PR and the corresponding issue.

Thanks!

@smortex smortex closed this Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing in a Sensitive to postgresql::server::db as "password" causes broken user
7 participants