Add secure setting for watcher email password#31620
Conversation
Other watcher actions already account for secure settings in their sensitive settings, whereas the email sending action did not. This adds the ability to optionally set a secure_password for email accounts.
|
Pinging @elastic/es-core-infra |
spinscale
left a comment
There was a problem hiding this comment.
can you add a test as well?
| @@ -232,7 +254,10 @@ static Properties loadSmtpProperties(Settings settings) { | |||
| settings = builder.build(); | |||
| Properties props = new Properties(); | |||
| for (String key : settings.keySet()) { | |||
There was a problem hiding this comment.
how about using settings.filter(s -> s.startsWith("_secure") == false).keySet()?
| * Finds a setting, and then a secure setting if the setting is null, or returns null if one does not exist. This differs | ||
| * from other getSetting calls in that it allows for null whereas the other methods throw an exception. | ||
| */ | ||
| private static String getNullableSetting(String settingName, Settings settings, Setting<SecureString> secureSetting) { |
There was a problem hiding this comment.
the name is not too descriptive but I dont have a good alternative at the moment either
There was a problem hiding this comment.
yea was only cuz the other classes have a method like this called getSetting that throws up on null :)
| port = settings.getAsInt("port", settings.getAsInt("localport", settings.getAsInt("local_port", 25))); | ||
| user = settings.get("user", settings.get("from", null)); | ||
| String passStr = settings.get("password", null); | ||
| String passStr = getNullableSetting(SMTP_PASSWORD, settings, SECURE_PASSWORD_SETTING); |
There was a problem hiding this comment.
how about storing the password as a SecureString and have getNullableSettings return SecureString as well?
|
test added @spinscale |
spinscale
left a comment
There was a problem hiding this comment.
LGTM. can you add the commit line to sth like Watcher: Allow email account passwords to be a secure setting
| public class Account { | ||
|
|
||
| static final String SMTP_PROTOCOL = "smtp"; | ||
| static final String SMTP_PASSWORD = "password"; |
Other watcher actions already account for secure settings in their sensitive settings, whereas the email sending action did not. This adds the ability to optionally set a secure_password for email accounts.
* 6.x: Watcher: Make settings reloadable (#31746) [Rollup] Histo group config should support scaled_floats (#32048) lazy snapshot repository initialization (#31606) Add secure setting for watcher email password (#31620) Watcher: cleanup ensureWatchExists use (#31926) Add second level of field collapsing (#31808) Added lenient flag for synonym token filter (#31484) (#31970) Test: Fix a second case of bad watch creation [Rollup] Use composite's missing_bucket (#31402) Docs: Restyled cloud link in getting started Docs: Change formatting of Cloud options Re-instate link in StringFunctionUtils javadocs Correct spelling of AnalysisPlugin#requriesAnalysisSettings (#32025) Fix problematic chars in javadoc [ML] Move open job failure explanation out of root cause (#31925) [ML] Switch ML native QA tests to use a 3 node cluster (#32011)
Other watcher actions already account for secure settings in their
sensitive settings, whereas the email sending action did not. This adds
the ability to optionally set a secure_password for email accounts.