From 28e12a973f1bac8c8f11db96ee64abbd0edeaa39 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Wed, 19 Aug 2015 10:06:30 -0700 Subject: [PATCH] Misc fixed around certificate notifications --- lemur/notifications/service.py | 13 +++++--- lemur/plugins/lemur_email/plugin.py | 4 +-- .../lemur_email/templates/expiration.html | 31 +++++++++---------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/lemur/notifications/service.py b/lemur/notifications/service.py index e6e3ddf1..3c944580 100644 --- a/lemur/notifications/service.py +++ b/lemur/notifications/service.py @@ -59,13 +59,18 @@ def _deduplicate(messages): for m, r, o in roll_ups: if r == targets: - m.append(data) - current_app.logger.info( - "Sending expiration alert about {0} to {1}".format( - data['name'], ",".join(targets))) + for cert in m: + if cert['body'] == data['body']: + break + else: + m.append(data) + current_app.logger.info( + "Sending expiration alert about {0} to {1}".format( + data['name'], ",".join(targets))) break else: roll_ups.append(([data], targets, options)) + return roll_ups diff --git a/lemur/plugins/lemur_email/plugin.py b/lemur/plugins/lemur_email/plugin.py index 19dd50fe..f2166d78 100644 --- a/lemur/plugins/lemur_email/plugin.py +++ b/lemur/plugins/lemur_email/plugin.py @@ -53,12 +53,12 @@ class EmailNotificationPlugin(ExpirationNotificationPlugin): # jinja template depending on type template = env.get_template('{}.html'.format(event_type)) - body = template.render(**kwargs) + body = template.render(dict(messages=message, hostname=current_app.config.get('LEMUR_HOSTNAME'))) s_type = current_app.config.get("LEMUR_EMAIL_SENDER", 'ses').lower() if s_type == 'ses': conn = boto.connect_ses() - conn.send_email(current_app.config.get("LEMUR_EMAIL"), subject, body, ['kglisson@netflix.com'], format='html') + conn.send_email(current_app.config.get("LEMUR_EMAIL"), subject, body, targets, format='html') elif s_type == 'smtp': msg = Message(subject, recipients=targets) diff --git a/lemur/plugins/lemur_email/templates/expiration.html b/lemur/plugins/lemur_email/templates/expiration.html index f5459496..f3584bd2 100644 --- a/lemur/plugins/lemur_email/templates/expiration.html +++ b/lemur/plugins/lemur_email/templates/expiration.html @@ -52,8 +52,13 @@ Notice: Your SSL certificates are expiring!
- Lemur, Netflix's SSL management portal has noticed that the following certificates are expiring soon, if you rely on these certificates - you should create new certificates to replace the certificates that are expiring. Visit https://lemur.netflix.com/#/certificates/create to reissue them. +

+ Lemur, Netflix's SSL management portal has noticed that the following certificates are expiring soon, if you rely on these certificates + you should create new certificates to replace the certificates that are expiring. +

+

+ Visit https://{{ hostname }}/#/certificates/create to reissue them. +

{% for message in messages %} @@ -78,6 +83,12 @@ {{ message.creator }} + + Description + + + {{ message.description }} + Not Before @@ -104,20 +115,6 @@ Unknown {% endif %} - - Associated ELBs - - {% if message.listeners %} - {% for name in message.listeners %} - - {{ name }} - - {% endfor %} - {% else %} - - None - - {% endif %} Potentially Superseded by (Lemur's best guess) @@ -139,7 +136,7 @@ - Lemur is broken regularly by Security Operations + Lemur is broken regularly by Netflix