From 787ca4f860bafcf3ef375ef186271b7a0b25905d Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Tue, 15 Dec 2020 13:03:55 -0800 Subject: [PATCH 1/3] Fix incorrect expectation of return type for summary emails in notification cli, and add 1 to days in summary email --- lemur/notifications/cli.py | 8 +++----- .../plugins/lemur_email/templates/expiration_summary.html | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lemur/notifications/cli.py b/lemur/notifications/cli.py index d86028c0..a26dc8c5 100644 --- a/lemur/notifications/cli.py +++ b/lemur/notifications/cli.py @@ -85,15 +85,13 @@ def security_expiration_summary(exclude): status = FAILURE_METRIC_STATUS try: print("Starting to notify security team about expiring certificates!") - success, failed = send_security_expiration_summary(exclude) + status = send_security_expiration_summary(exclude) print( - "Finished notifying security team about expiring certificates! " - f"Sent: {success} Failed: {failed}" + "Finished notifying security team about expiring certificates!" ) - status = SUCCESS_METRIC_STATUS except Exception: sentry.captureException() metrics.send( - "security_expiration_notification_job", "counter", 1, metric_tags={"status": status} + "security_expiration_summary_notification_job", "counter", 1, metric_tags={"status": status} ) diff --git a/lemur/plugins/lemur_email/templates/expiration_summary.html b/lemur/plugins/lemur_email/templates/expiration_summary.html index d2e98196..ca6b3c6a 100644 --- a/lemur/plugins/lemur_email/templates/expiration_summary.html +++ b/lemur/plugins/lemur_email/templates/expiration_summary.html @@ -77,7 +77,6 @@
This is a summary of all certificates expiring soon. - Only certificates matching the configured expiration intervals are included here. Certificates with notifications disabled have been omitted. @@ -87,7 +86,7 @@ From de98586c133735ff8173f7827a70637c2d30c3af Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Tue, 15 Dec 2020 13:05:55 -0800 Subject: [PATCH 2/3] Undo metric name change --- lemur/notifications/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/notifications/cli.py b/lemur/notifications/cli.py index a26dc8c5..0a76bad5 100644 --- a/lemur/notifications/cli.py +++ b/lemur/notifications/cli.py @@ -93,5 +93,5 @@ def security_expiration_summary(exclude): sentry.captureException() metrics.send( - "security_expiration_summary_notification_job", "counter", 1, metric_tags={"status": status} + "security_expiration_notification_job", "counter", 1, metric_tags={"status": status} ) From 33e46d4a5349fe67fb2ac25e76af231cdd18681c Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Tue, 15 Dec 2020 13:37:24 -0800 Subject: [PATCH 3/3] Fix return type --- lemur/notifications/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lemur/notifications/cli.py b/lemur/notifications/cli.py index 0a76bad5..042a54fb 100644 --- a/lemur/notifications/cli.py +++ b/lemur/notifications/cli.py @@ -85,10 +85,12 @@ def security_expiration_summary(exclude): status = FAILURE_METRIC_STATUS try: print("Starting to notify security team about expiring certificates!") - status = send_security_expiration_summary(exclude) + success = send_security_expiration_summary(exclude) print( - "Finished notifying security team about expiring certificates!" + f"Finished notifying security team about expiring certificates! Success: {success}" ) + if success: + status = SUCCESS_METRIC_STATUS except Exception: sentry.captureException()
-
Expiring in {{ interval_and_certs["interval"] }} days
+
Expiring in {{ interval_and_certs["interval"] + 1 }} days