From a616310eb74622386ca39337e141774eb8ecd390 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 17 Nov 2016 14:47:10 -0800 Subject: [PATCH] Fixing an issue were aws certificates plugins might not have a chain. (#512) --- lemur/certificates/schemas.py | 2 +- lemur/certificates/service.py | 5 ++++- lemur/manage.py | 4 ++-- lemur/plugins/lemur_aws/iam.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lemur/certificates/schemas.py b/lemur/certificates/schemas.py index b87b1193..036def3b 100644 --- a/lemur/certificates/schemas.py +++ b/lemur/certificates/schemas.py @@ -160,7 +160,7 @@ class CertificateUploadInputSchema(CertificateCreationSchema): private_key = fields.String(validate=validators.private_key) body = fields.String(required=True, validate=validators.public_certificate) - chain = fields.String(validate=validators.public_certificate) # TODO this could be multiple certificates + chain = fields.String(validate=validators.public_certificate, missing=None) # TODO this could be multiple certificates destinations = fields.Nested(AssociatedDestinationSchema, missing=[], many=True) notifications = fields.Nested(AssociatedNotificationSchema, missing=[], many=True) diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py index 2b8ec48e..3b54913e 100644 --- a/lemur/certificates/service.py +++ b/lemur/certificates/service.py @@ -86,7 +86,10 @@ def find_duplicates(cert): :param cert: :return: """ - return Certificate.query.filter_by(body=cert['body'].strip(), chain=cert['chain'].strip()).all() + if cert.get('chain'): + return Certificate.query.filter_by(body=cert['body'].strip(), chain=cert['chain'].strip()).all() + else: + return Certificate.query.filter_by(body=cert['body'].strip(), chain=None).all() def export(cert, export_plugin): diff --git a/lemur/manage.py b/lemur/manage.py index a5024ecb..9f55ba5f 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -858,8 +858,8 @@ class Sources(Command): Defines a set of actions to take against Lemur's sources. """ option_list = ( - Option('-s', '--sources', dest='source_strings', action='append', help='Sources to operate on.'), - Option('-a', '--action', choices=['sync', 'clean'], dest='action', help='Action to take on source.') + Option('-s', '--sources', dest='source_strings', action='append', help='Sources to operate on.', required=True), + Option('-a', '--action', choices=['sync', 'clean'], dest='action', help='Action to take on source.', required=True) ) def run(self, source_strings, action): diff --git a/lemur/plugins/lemur_aws/iam.py b/lemur/plugins/lemur_aws/iam.py index 6a9994d3..03124599 100644 --- a/lemur/plugins/lemur_aws/iam.py +++ b/lemur/plugins/lemur_aws/iam.py @@ -94,4 +94,4 @@ def digest_aws_cert_response(response): if 'certificate_chain' in cert: chain = cert['certificate_chain'] - return str(body), str(chain), + return body, chain