diff --git a/integrations/mail-templates/manifest.yaml b/integrations/mail-templates/manifest.yaml index 46f96c5..25ce07a 100644 --- a/integrations/mail-templates/manifest.yaml +++ b/integrations/mail-templates/manifest.yaml @@ -1,8 +1,8 @@ id: mail_templates name: Mail Templates (ACKnowledge) -version: 1.0.0 +version: 1.0.1 description: "Turns a subject and a markdown description into an ACKnowledge SOC email (dark theme, header badge, signature with the logo, footer) — nothing is sent: chain the output into exchange-send-mail or mail-sender (`subject` → subject, `html_body` → html_body, `text_body` → body). Eight templates, each with its own badge and colour: sla_breach, incident_notification (colour follows `severity`), incident_update, incident_closure, action_required, escalation, threat_bulletin, info. The description takes markdown: headings (## is the blue capitalised section title), bold, italic, links, lists, quotes, rules, GFM tables, `code` and ``` blocks (hashes, IPs, command lines), and level pills `{{critical}}` `{{high}}` `{{medium}}` `{{low}}` `{{info}}` `{{ok}}` — `{{high:Élevée}}` changes the label. Raw HTML in the inputs is escaped, so alert data can be interpolated safely. The logo is an inline data-URI PNG: exchange-send-mail and mail-sender embed it; the Gmail integration does not, and the logo is lost there. No connection, no secret; stdlib-only." -changelog: "1.0.0 — Initial release: render-mail-template (8 templates, markdown description with tables, code and level pills, optional callout, action button, case reference and severity, SOC or client footer, French or English) and a self-test." +changelog: "1.0.1 — The Test button failed (NameError: __file__) and render-mail-template printed nothing: Riposte runs a script with exec(), without __file__ or __name__. The test no longer imports the renderer and the renderer runs main() unconditionally. | 1.0.0 — Initial release: render-mail-template (8 templates, markdown description with tables, code and level pills, optional callout, action button, case reference and severity, SOC or client footer, French or English) and a self-test." category: email # Nothing to connect to. The only setting names the bot in the SOC footer @@ -61,7 +61,7 @@ commands: - id: test_connection name: mail-templates-test - description: "Render every template with a sample description, without sending anything (used by the Test button)." + description: "Check the integration is installed and list its templates; nothing to connect to (used by the Test button)." risk: read inputs_schema: properties: {} diff --git a/integrations/mail-templates/scripts/render_mail_template.py b/integrations/mail-templates/scripts/render_mail_template.py index 7cf0bd6..1c5e7fe 100644 --- a/integrations/mail-templates/scripts/render_mail_template.py +++ b/integrations/mail-templates/scripts/render_mail_template.py @@ -580,5 +580,4 @@ def main(): sys.exit(1) -if __name__ == "__main__": - main() +main() diff --git a/integrations/mail-templates/scripts/test_connection.py b/integrations/mail-templates/scripts/test_connection.py index 8201aa8..6f1ca7d 100644 --- a/integrations/mail-templates/scripts/test_connection.py +++ b/integrations/mail-templates/scripts/test_connection.py @@ -1,27 +1,8 @@ -import json, os, sys +import json -sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +# Nothing to connect to. Riposte runs one script per command through exec(), +# so this cannot import the renderer: it only answers the Test button. +TEMPLATES = ["sla_breach", "incident_notification", "incident_update", "incident_closure", + "action_required", "escalation", "threat_bulletin", "info"] -SAMPLE = "## Sample\n\n**1 ticket** waiting.\n\n| Ticket | Priority |\n|---|---|\n| SOC-1 | {{medium}} |\n\n```\n8.8.8.8\n```" - - -def main(): - try: - import render_mail_template as r - except ImportError: - # The runner ships one script per command: say so instead of failing the Test button. - print(json.dumps({"ok": True, "detail": "No connection to test; render a template to check the output."})) - return - try: - cfg = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) - sizes = {} - for name in r.TEMPLATES: - out = r.render(cfg, {"template": name, "subject": "Test", "description": SAMPLE, "severity": "high"}) - sizes[name] = out["html_bytes"] - print(json.dumps({"ok": True, "templates": sizes})) - except Exception as e: - print(json.dumps({"error": str(e)})) - sys.exit(1) - - -main() +print(json.dumps({"ok": True, "templates": TEMPLATES}))