Skip to content

Comments

Pass secrets as sensitive data types to katello/candlepin#493

Open
ekohl wants to merge 1 commit intotheforeman:masterfrom
ekohl:be-sensitive
Open

Pass secrets as sensitive data types to katello/candlepin#493
ekohl wants to merge 1 commit intotheforeman:masterfrom
ekohl:be-sensitive

Conversation

@ekohl
Copy link
Member

@ekohl ekohl commented May 14, 2024

katello/candlepin 12.2.0 introduced support for Sensitive and this utilizes it. This allows Puppet to better avoid logging passwords.

katello/candlepin 12.2.0 introduced support for Sensitive and this
utilizes it. This allows Puppet to better avoid logging passwords.
@ekohl
Copy link
Member Author

ekohl commented May 14, 2024

@cocker-cc I think this replaces #436 and goes a step further. Would you mind taking a look?

String $db_name = 'candlepin',
String $db_user = 'candlepin',
Optional[String] $db_password = undef,
Variant[Undef, Sensitive[String], String] $db_password = undef,

Choose a reason for hiding this comment

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

Why do you prefer Variant[Undef… over Optional[?
The latter is more common.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. It's a bit shorter but perhaps also less readable

db_name => $candlepin_db_name,
db_user => $candlepin_db_user,
db_password => $candlepin_db_password,
db_password => if $candlepin_db_password { Sensitive($candlepin_db_password) } else { $candlepin_db_password },

Choose a reason for hiding this comment

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

A Sensitive[Sensitive[String]] could be produced here. This is not good.
Perhaps you mean

db_password       => if $candlepin_db_password =~ Sensitive { $candlepin_db_password } else { Sensitive($candlepin_db_password) },

but this could be written simpler with

db_password       => Sensitive($candlepin_db_password.unwrap),

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to avoid Sensitive[Undef]. Perhaps that's already solved. I suppose I can check for String explicitly

ca_cert => $certs::candlepin::ca_cert,
keystore_file => $certs::candlepin::keystore,
keystore_password => $certs::candlepin::keystore_password,
keystore_password => Sensitive($certs::candlepin::keystore_password),

Choose a reason for hiding this comment

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

Coding for the Future:

    keystore_password            => Sensitive($certs::candlepin::keystore_password.unwrap),

because the Day will come, when certs also uses Sensitive, and then you would have Sensitive[Sensitive[String]].

class { 'katello::params':
candlepin_oauth_key => $candlepin_oauth_key,
candlepin_oauth_secret => $candlepin_oauth_secret,
candlepin_oauth_key => Sensitive($candlepin_oauth_key),

Choose a reason for hiding this comment

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

IMHO wrong Order. Define in the Class-Header

Optional[Variant[Sensitive[String], String]] $candlepin_oauth_key = undef,

and just pass over the Variable here.

Choose a reason for hiding this comment

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

My Guideline is:
If You get a Sensitive, then you must pass it over as Sensitive, and if the receiving Module cannot deal with it, then Work should be done to improve this.
If you already get an un-Sensitive, then there is no need to cast it to Sensitive, because the Damage already happend. Work should be done on the sending Side to not receive this un-Sensitive.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was conservative here: I don't yet know if our installer handles it properly and only init.pp is exposed there. But I'll evaluate it more in depth

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.

2 participants