From df9b3455414bc0370f94ee71ba2e3de1deef726d Mon Sep 17 00:00:00 2001 From: kevgliss Date: Sat, 29 Aug 2015 13:20:17 -0700 Subject: [PATCH 1/2] Adding a better error message for really long common names Fixes #38 --- lemur/plugins/lemur_cloudca/plugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lemur/plugins/lemur_cloudca/plugin.py b/lemur/plugins/lemur_cloudca/plugin.py index 2d26666a..14a4cb8f 100644 --- a/lemur/plugins/lemur_cloudca/plugin.py +++ b/lemur/plugins/lemur_cloudca/plugin.py @@ -7,6 +7,7 @@ .. moduleauthor:: Kevin Glisson """ +import re import ssl import base64 from json import dumps @@ -297,7 +298,7 @@ class CloudCAIssuerPlugin(IssuerPlugin, CloudCA): 'ownerEmail': options['owner'], 'caName': options['authority'].name, 'csr': csr, - 'comment': options['description'] + 'comment': re.sub(r'^[\w\-\s]+$', '', options['description']) } response = self.post(endpoint, remove_none(cloudca_options)) From 7471984ecfd4a25387f096f0cbd5fc687da86a74 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Sat, 29 Aug 2015 13:49:08 -0700 Subject: [PATCH 2/2] removing silly description validation from lemur and enforcing it on the cloudca plugin (who actually cares) --- lemur/plugins/lemur_cloudca/plugin.py | 3 ++- .../app/angular/authorities/authority/tracking.tpl.html | 8 ++++---- .../angular/certificates/certificate/tracking.tpl.html | 8 ++++---- .../app/angular/certificates/certificate/upload.tpl.html | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lemur/plugins/lemur_cloudca/plugin.py b/lemur/plugins/lemur_cloudca/plugin.py index 14a4cb8f..2cf35b75 100644 --- a/lemur/plugins/lemur_cloudca/plugin.py +++ b/lemur/plugins/lemur_cloudca/plugin.py @@ -246,6 +246,7 @@ class CloudCAIssuerPlugin(IssuerPlugin, CloudCA): options['validityStart'] = convert_date_to_utc_time(options['validityStart']).isoformat() options['validityEnd'] = convert_date_to_utc_time(options['validityEnd']).isoformat() + options['description'] = re.sub(r'[^a-zA-Z0-9]', '', options['caDescription']) try: response = self.session.post(self.url + endpoint, data=dumps(remove_none(options)), timeout=10, @@ -298,7 +299,7 @@ class CloudCAIssuerPlugin(IssuerPlugin, CloudCA): 'ownerEmail': options['owner'], 'caName': options['authority'].name, 'csr': csr, - 'comment': re.sub(r'^[\w\-\s]+$', '', options['description']) + 'comment': re.sub(r'[^a-zA-Z0-9]', '', options['description']) } response = self.post(endpoint, remove_none(cloudca_options)) diff --git a/lemur/static/app/angular/authorities/authority/tracking.tpl.html b/lemur/static/app/angular/authorities/authority/tracking.tpl.html index 5d9e9b58..a2d0def6 100644 --- a/lemur/static/app/angular/authorities/authority/tracking.tpl.html +++ b/lemur/static/app/angular/authorities/authority/tracking.tpl.html @@ -26,8 +26,8 @@ Description
- -

You must give a short description about this authority will be used for, it should contain only alphanumeric characters

+ +

You must give a short description about this authority will be used for

- -

You must enter a common name

+ +

You must enter a common name and it must be less than 64 characters in length

- -

You must give a short description about this authority will be used for, this description should only include alphanumeric characters

+ +

You must give a short description about this authority will be used for.

- -

You must enter a common name

+ +

You must enter a common name and it must be less than 64 characters

diff --git a/lemur/static/app/angular/certificates/certificate/upload.tpl.html b/lemur/static/app/angular/certificates/certificate/upload.tpl.html index 928e923e..55dc850f 100644 --- a/lemur/static/app/angular/certificates/certificate/upload.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/upload.tpl.html @@ -33,8 +33,8 @@ Description
- -

You must give a short description about this authority will be used for, this description should only include alphanumeric characters

+ +

You must give a short description about this authority will be used for.