Adds Custom Rules ability for our email integration#149
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds custom rules capability to the email integration (Email::V3), allowing users to define YAML-based rules that determine how incoming emails are processed. The implementation follows the pattern established by the CustomWebhook::V3 integration, enabling users to match email properties (subject, body, from, to) against custom rules and trigger different actions (create, acknowledge, resolve, ignore).
Changes:
- Added custom rule processing support to Email::V3 integration using a custom webhook v3 service
- Added UI components for enabling and configuring custom YAML definitions
- Added comprehensive test coverage for all custom rule action types
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| app/models/pager_tree/integrations/email/v3.rb | Core implementation of custom rule processing, including HTTP calls to custom webhook service and result parsing |
| test/models/pager_tree/integrations/email/v3_test.rb | Test suite covering custom definition functionality for all action types |
| test/vcr_cassettes/*.yml | VCR cassettes for recording HTTP interactions with custom webhook service |
| app/views/pager_tree/integrations/email/v3/_form_options.html.erb | Form UI for enabling and editing custom YAML definitions |
| app/views/pager_tree/integrations/email/v3/_show_options.html.erb | Display UI showing whether custom definition is enabled |
| config/locales/en.yml | Localization strings for custom definition options |
| test/fixtures/pager_tree/integrations/integrations.yml | Test fixture for email_v3 integration |
| app/models/pager_tree/integrations/email/v3_examples/example.yml | Example YAML configuration showing custom rule syntax |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @_body = custom_definition? ? | ||
| (document.at_css("body")&.inner_html || document.to_html) : | ||
| ::Sanitize.fragment(document, _sanitize_config) |
There was a problem hiding this comment.
When custom_definition is enabled, the _body method extracts unsanitized HTML (document.at_css("body")&.inner_html || document.to_html) directly without applying the sanitization that's used when custom_definition is disabled. This unsanitized HTML body is then sent to the custom webhook service and potentially used in the description field of alerts. If the custom webhook service doesn't properly sanitize this HTML, it could lead to security issues such as XSS vulnerabilities when the alert description is displayed. Consider whether sanitization should still be applied even when using custom definitions, or ensure the downstream service properly sanitizes this content.
| @_body = custom_definition? ? | |
| (document.at_css("body")&.inner_html || document.to_html) : | |
| ::Sanitize.fragment(document, _sanitize_config) | |
| html_body = document.at_css("body")&.inner_html || document.to_html | |
| @_body = if custom_definition? | |
| ::Sanitize.fragment(html_body, _sanitize_config) | |
| else | |
| ::Sanitize.fragment(document, _sanitize_config) | |
| end |
app/views/pager_tree/integrations/email/v3/_form_options.html.erb
Outdated
Show resolved
Hide resolved
|
Looks good |
… the email integration