-
Notifications
You must be signed in to change notification settings - Fork 25k
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using settings.filter(s -> s.startsWith("_secure") == false).keySet()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is not too descriptive but I dont have a good alternative at the moment either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about storing the password as a SecureString
and have getNullableSettings
return SecureString
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
test added @spinscale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be made private?
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.