-
Notifications
You must be signed in to change notification settings - Fork 17
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
Email handler is not able to format nested HTML output #60
Comments
This handler will only format the message as html if the template it uses has the tag in it. Per this section of the code. Can you please post a copy of your template (as a code block) here for review? |
If you look at the below output, email handler is already formatting the template. the marked one on the above screenshot is not getting formatted. Script output is not getting formatted when loads using {{.Check.Output}} inside the template. Please find the template
In the above template if I paste the script output in place of {{.Check.Output}} then it works as expected. Only issue when it tries to load the output into the template. |
Okay, I've found where this is happening. When using an HTML template we are using the html/template package to expand the tokens. When it expands {{ .Check.Output }} which, in your case, contains HTML, it escapes it, producing the following:
@echlebek any thoughts on this? We want to continue the use of html/template to sanitize the html, but anything we can do to keep it from escaping a token containing html? |
I'm not sure it's possible to do this without creating a security vulnerability. For some users, that might be acceptable, if they control the system to the extent that they're sure they will never get malicious HTML. But I don't think we can make that decision for everyone. The Web UI can't be allowed to display arbitrary HTML in general. @nixwiz I believe we could support this use case in the email handler by allowing check output to be a template itself. The Go template engine supports nesting templates, so we could add a feature flag that would allow the check output to be parsed as a template and included that way. |
@echlebek , would be great if you can add the flag to load the check output as a template. |
@raihanchdy we are still discussing what, if any, action would be correct to take. It's not clear that adding complexity here would be beneficial. |
I am using email handler plugin and installed using below command.
sensuctl asset add sensu/sensu-email-handler -r email-handler
below is the check definition
{
“api_version”:“core/v2”,
“type”:“Check”,
“metadata”:{
“namespace”:“default”,
“name”:“app-gw-health-check”,
“labels”:{}
},
“spec”:{
“command”:“python3.6 /etc/sensu/plugins/app-gw-health-check.py”,
“subscriptions”:[
“roundrobin:worker”
],
“publish”:true,
“round_robin”:true,
“interval”:3600,
“handlers”:[
“alert_handler”,
“resolve_handler”
],
“proxy_entity_name”:“proxyclient”,
“timeout”:590
}
}
Output is not getting formatted while loading using {{.Check.Output}}
I have updated on sensu go forum as well.
https://discourse.sensu.io/t/html-output-for-mail-body-is-rendering-in-webui/2308/3
The text was updated successfully, but these errors were encountered: