From 19d90b8f1cb582d9867db6e24604f17ada0380fc Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Wed, 3 Feb 2021 17:08:25 -0800 Subject: [PATCH 1/3] Add issuer and ID fields to SNS notification format --- lemur/certificates/schemas.py | 1 + lemur/plugins/lemur_aws/sns.py | 2 + lemur/plugins/lemur_aws/tests/test_sns.py | 2 + .../lemur_email/templates/revocation.html | 163 ++++++++++++++++++ lemur/tests/factories.py | 1 + 5 files changed, 169 insertions(+) create mode 100644 lemur/plugins/lemur_email/templates/revocation.html diff --git a/lemur/certificates/schemas.py b/lemur/certificates/schemas.py index d3ed1776..691e554d 100644 --- a/lemur/certificates/schemas.py +++ b/lemur/certificates/schemas.py @@ -441,6 +441,7 @@ class CertificateExportInputSchema(LemurInputSchema): class CertificateNotificationOutputSchema(LemurOutputSchema): + id = fields.Integer() description = fields.String() issuer = fields.String() name = fields.String() diff --git a/lemur/plugins/lemur_aws/sns.py b/lemur/plugins/lemur_aws/sns.py index 14109c11..fab45b82 100644 --- a/lemur/plugins/lemur_aws/sns.py +++ b/lemur/plugins/lemur_aws/sns.py @@ -50,6 +50,8 @@ def format_message(certificate, notification_type): json_message = { "notification_type": notification_type, "certificate_name": certificate["name"], + "issuer": certificate["issuer"], + "id": certificate["id"], "expires": arrow.get(certificate["validityEnd"]).format("YYYY-MM-DDTHH:mm:ss"), # 2047-12-31T22:00:00 "endpoints_detected": len(certificate["endpoints"]), "owner": certificate["owner"], diff --git a/lemur/plugins/lemur_aws/tests/test_sns.py b/lemur/plugins/lemur_aws/tests/test_sns.py index 59ef30f2..c8688194 100644 --- a/lemur/plugins/lemur_aws/tests/test_sns.py +++ b/lemur/plugins/lemur_aws/tests/test_sns.py @@ -21,6 +21,8 @@ def test_format(certificate, endpoint): "notification_type": "expiration", "certificate_name": certificate["name"], "expires": arrow.get(certificate["validityEnd"]).format("YYYY-MM-DDTHH:mm:ss"), + "issuer": certificate["issuer"], + "id": certificate["id"], "endpoints_detected": 0, "owner": certificate["owner"], "details": "https://lemur.example.com/#/certificates/{name}".format(name=certificate["name"]) diff --git a/lemur/plugins/lemur_email/templates/revocation.html b/lemur/plugins/lemur_email/templates/revocation.html new file mode 100644 index 00000000..58625786 --- /dev/null +++ b/lemur/plugins/lemur_email/templates/revocation.html @@ -0,0 +1,163 @@ + + + + + + + + Lemur + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ Lemur +
+
+ + + + + + + + + + + + + + +
+ Your certificate has been revoked! +
+
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ Hi, +
This is a Lemur certificate revocation notice. +
+ + + + + + + + +
+ {{ message.certificates.name }} + +
{{ message.certificates.endpoints | length }} Endpoints +
{{ message.certificates.owner }} +
{{ message.certificates.validityEnd | time }} +
{{ message.certificates.status }} +
Details +
+
+
+ If this revocation was unexpected, please reach out to {{ ", ".join(message.certificates.security_email) }}. +
+
Best,
Lemur +
+ + + + + + +
*All times are in UTC
+
+
+
+ + + + + + + + + +
You received this mandatory email announcement to update you about + important changes to your TLS certificate. +
+
© 2016 Lemur
+
+
+
+
diff --git a/lemur/tests/factories.py b/lemur/tests/factories.py index fea4c59a..dd655510 100644 --- a/lemur/tests/factories.py +++ b/lemur/tests/factories.py @@ -55,6 +55,7 @@ class RotationPolicyFactory(BaseFactory): class CertificateFactory(BaseFactory): """Certificate factory.""" + id = Sequence(lambda n: n) name = Sequence(lambda n: "certificate{0}".format(n)) chain = INTERMEDIATE_CERT_STR body = SAN_CERT_STR From 3a6c80df9a3cabaaf61d98c90d267a1922b74173 Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Wed, 3 Feb 2021 17:09:03 -0800 Subject: [PATCH 2/3] Remove file --- .../lemur_email/templates/revocation.html | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 lemur/plugins/lemur_email/templates/revocation.html diff --git a/lemur/plugins/lemur_email/templates/revocation.html b/lemur/plugins/lemur_email/templates/revocation.html deleted file mode 100644 index 58625786..00000000 --- a/lemur/plugins/lemur_email/templates/revocation.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - Lemur - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- Lemur -
-
- - - - - - - - - - - - - - -
- Your certificate has been revoked! -
-
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- Hi, -
This is a Lemur certificate revocation notice. -
- - - - - - - - -
- {{ message.certificates.name }} - -
{{ message.certificates.endpoints | length }} Endpoints -
{{ message.certificates.owner }} -
{{ message.certificates.validityEnd | time }} -
{{ message.certificates.status }} -
Details -
-
-
- If this revocation was unexpected, please reach out to {{ ", ".join(message.certificates.security_email) }}. -
-
Best,
Lemur -
- - - - - - -
*All times are in UTC
-
-
-
- - - - - - - - - -
You received this mandatory email announcement to update you about - important changes to your TLS certificate. -
-
© 2016 Lemur
-
-
-
-
From b2afb2b38afa4350ea7431b5469dc3665f4b105f Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Wed, 3 Feb 2021 17:10:18 -0800 Subject: [PATCH 3/3] Remove unnecessary ID from factory --- lemur/tests/factories.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lemur/tests/factories.py b/lemur/tests/factories.py index dd655510..fea4c59a 100644 --- a/lemur/tests/factories.py +++ b/lemur/tests/factories.py @@ -55,7 +55,6 @@ class RotationPolicyFactory(BaseFactory): class CertificateFactory(BaseFactory): """Certificate factory.""" - id = Sequence(lambda n: n) name = Sequence(lambda n: "certificate{0}".format(n)) chain = INTERMEDIATE_CERT_STR body = SAN_CERT_STR