Background
The current alert email dispatcher (alertDispatcher.ts) uses a hardcoded HTML template with manual escapeHtml() for output encoding. This works for the current plain-text-into-template approach but limits customization.
From PR #67 review feedback (@koitococo):
- Consider using a template engine like EJS
- Consider using DOMPurify for HTML sanitization
- Make email templates a configurable item
Requirements
Template Engine
HTML Sanitization
Admin UI
Considerations
- Template validation before save (must compile without errors)
- Avoid breaking existing email delivery if template is malformed (fall back to default)
- Consider separate templates per alert rule type (budget, error_rate, latency, quota)
References
Background
The current alert email dispatcher (
alertDispatcher.ts) uses a hardcoded HTML template with manualescapeHtml()for output encoding. This works for the current plain-text-into-template approach but limits customization.From PR #67 review feedback (@koitococo):
Requirements
Template Engine
ruleName,ruleType,message,currentValue,threshold,detailsHTML Sanitization
escapeHtml()is correct for plain-text insertion; DOMPurify is needed when users can write arbitrary HTML in templatesAdmin UI
Considerations
References
alertDispatcher.tsbackend/src/services/alertDispatcher.ts(dispatchEmail)