Adding Digicert CIS Sourceplugin (#959)
* Adding necessary features to complete backfill * Fixing pagination logic.
This commit is contained in:
@ -17,6 +17,8 @@ from lemur.endpoints import service as endpoint_service
|
||||
from lemur.destinations import service as destination_service
|
||||
|
||||
from lemur.certificates.schemas import CertificateUploadInputSchema
|
||||
from lemur.common.utils import parse_certificate
|
||||
from lemur.common.defaults import serial
|
||||
|
||||
from lemur.plugins.base import plugins
|
||||
|
||||
@ -112,7 +114,15 @@ def sync_certificates(source, user):
|
||||
certificates = s.get_certificates(source.options)
|
||||
|
||||
for certificate in certificates:
|
||||
exists = certificate_service.get_by_name(certificate['name'])
|
||||
if certificate.get('name'):
|
||||
exists = certificate_service.get_by_name(certificate['name'])
|
||||
|
||||
elif certificate.get('serial'):
|
||||
exists = certificate_service.get_by_serial(certificate['serial'])
|
||||
|
||||
else:
|
||||
cert = parse_certificate(certificate['body'])
|
||||
exists = certificate_service.get_by_serial(serial(cert))
|
||||
|
||||
if not certificate.get('owner'):
|
||||
certificate['owner'] = user.email
|
||||
@ -120,12 +130,12 @@ def sync_certificates(source, user):
|
||||
certificate['creator'] = user
|
||||
|
||||
if not exists:
|
||||
current_app.logger.debug("Creating Certificate. Name: {name}".format(name=certificate['name']))
|
||||
certificate_create(certificate, source)
|
||||
new += 1
|
||||
|
||||
else:
|
||||
current_app.logger.debug("Updating Certificate. Name: {name}".format(name=certificate['name']))
|
||||
if certificate.get('external_id'):
|
||||
exists.external_id = certificate['external_id']
|
||||
certificate_update(exists, source)
|
||||
updated += 1
|
||||
|
||||
|
Reference in New Issue
Block a user