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

Watcher: Validate email adresses when storing a watch #34042

Merged

Conversation

spinscale
Copy link
Contributor

Right now, watches fail on runtime, when invalid email addresses are
used.

All those fields can be checked on parsing, if no mustache is used in
any email address template. In that case we can return immediate
feedback, that invalid email addresses should not be specified when
trying to store a watch.

Reviewers note: This is rather for discussion than for review. Do you think this makes sense despite the additional check if mustache templates are used or not? When mustache is used, than this can still fail on runtime - even though the majority of the cases that I have seen are indeed using static email addresses when defining a watch.

Closes #33980

Right now, watches fail on runtime, when invalid email addresses are
used.

All those fields can be checked on parsing, if no mustache is used in
any email address template. In that case we can return immediate
feedback, that invalid email addresses should not be specified when
trying to store a watch.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

Big +1 for validation. Small nits on the way we evaluate using mustache, would love your thoughts.


public TextTemplate(String template) {
this.script = null;
this.inlineTemplate = template;
this.isUsingMustache = template.contains("{{") && template.indexOf("{{") < template.indexOf("}}");
Copy link
Contributor

Choose a reason for hiding this comment

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

sneak attack bring back the validation

this.inlineTemplate = null;
}

public TextTemplate(Script script) {
this.script = script;
this.inlineTemplate = null;
this.isUsingMustache = script.getIdOrCode().contains("{{") &&
Copy link
Contributor

Choose a reason for hiding this comment

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

can we lazy load this in the getter? maybe remove the word get so we know it "mutates state" and load it once only if we decide to actually validate if we care or not. At least it will appease the contains'ing every string is bad gods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this only to check for {{, and it #33978 will introduce a check for every text template, so that this will be called anyway...

Copy link
Contributor

Choose a reason for hiding this comment

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

oof, how did i miss that? I guess going backwards thru my review-requested emails is not such a good idea!!

@hub-cap
Copy link
Contributor

hub-cap commented Oct 2, 2018

still lgtm

@rjernst rjernst removed the review label Oct 10, 2018
@spinscale spinscale merged commit 4e36251 into elastic:master Oct 18, 2018
kcm pushed a commit that referenced this pull request Oct 30, 2018
Right now, watches fail on runtime, when invalid email addresses are
used.

All those fields can be checked on parsing, if no mustache is used in
any email address template. In that case we can return immediate
feedback, that invalid email addresses should not be specified when
trying to store a watch.
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.

5 participants