From f3f5b9eeb3072fe6974b52da55fb06f5f2121a97 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 3 Sep 2015 14:20:51 -0700 Subject: [PATCH 1/6] adding password commandline option --- lemur/manage.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lemur/manage.py b/lemur/manage.py index 5f9418ad..1d1ae2d7 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -263,18 +263,23 @@ class InitializeApp(Command): Additionally a Lemur user will be created as a default user and be used when certificates are discovered by Lemur. """ - def run(self): + option_list = ( + Option('-p', '--password', dest='password') + ) + + def run(self, password): create() user = user_service.get_by_username("lemur") if not user: - sys.stdout.write("We need to set Lemur's password to continue!\n") - password1 = prompt_pass("Password") - password2 = prompt_pass("Confirm Password") + if not password: + sys.stdout.write("We need to set Lemur's password to continue!\n") + password1 = prompt_pass("Password") + password2 = prompt_pass("Confirm Password") - if password1 != password2: - sys.stderr.write("[!] Passwords do not match!\n") - sys.exit(1) + if password1 != password2: + sys.stderr.write("[!] Passwords do not match!\n") + sys.exit(1) role = role_service.get_by_name('admin') From 2f4aee49e28422feb5f4f58a52c59ddf9a558e01 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 3 Sep 2015 16:45:49 -0700 Subject: [PATCH 2/6] adding logging --- lemur/manage.py | 2 +- setup.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lemur/manage.py b/lemur/manage.py index 1d1ae2d7..ccf0629e 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -264,7 +264,7 @@ class InitializeApp(Command): and be used when certificates are discovered by Lemur. """ option_list = ( - Option('-p', '--password', dest='password') + Option('-p', '--password', dest='password'), ) def run(self, password): diff --git a/setup.py b/setup.py index fa1a844a..62952ba1 100644 --- a/setup.py +++ b/setup.py @@ -100,7 +100,8 @@ class BuildStatic(Command): pass def run(self): - log.info("running [npm install --quiet]") + log.info("running [npm install --quiet] in {0}".format(ROOT)) + check_output(['npm', 'install', '--quiet'], cwd=ROOT) log.info("running [gulp build]") From 48a53ad436a35fcbd979da3a0e03024a8c723ecc Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 8 Sep 2015 17:42:57 -0700 Subject: [PATCH 3/6] fixing error in default password creation --- lemur/manage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lemur/manage.py b/lemur/manage.py index ccf0629e..90d59224 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -274,10 +274,10 @@ class InitializeApp(Command): if not user: if not password: sys.stdout.write("We need to set Lemur's password to continue!\n") - password1 = prompt_pass("Password") - password2 = prompt_pass("Confirm Password") + password = prompt_pass("Password") + password1 = prompt_pass("Confirm Password") - if password1 != password2: + if password != password1: sys.stderr.write("[!] Passwords do not match!\n") sys.exit(1) @@ -290,7 +290,7 @@ class InitializeApp(Command): role = role_service.create('admin', description='this is the lemur administrator role') sys.stdout.write("[+] Created 'admin' role\n") - user_service.create("lemur", password1, 'lemur@nobody', True, None, [role]) + user_service.create("lemur", password, 'lemur@nobody', True, None, [role]) sys.stdout.write("[+] Added a 'lemur' user and added it to the 'admin' role!\n") else: From 84d0afae4caf3ab03282b094021baa22dbf4d7dc Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 8 Sep 2015 17:56:20 -0700 Subject: [PATCH 4/6] fixing email internvals --- lemur/manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/manage.py b/lemur/manage.py index 90d59224..5164474d 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -299,7 +299,7 @@ class InitializeApp(Command): sys.stdout.write("[+] Creating expiration email notifications!\n") sys.stdout.write("[!] Using {recipients} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n") - intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS") + intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write( "[!] Creating {num} notifications for {intervals} days as specified by LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS\n".format( num=len(intervals), From ef9a80ebfdd5f543499e16288b81c6c916e4b7a7 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 8 Sep 2015 18:03:18 -0700 Subject: [PATCH 5/6] adding actual recipients --- lemur/manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/manage.py b/lemur/manage.py index 5164474d..d2dbe28e 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -297,7 +297,7 @@ class InitializeApp(Command): sys.stdout.write("[-] Default user has already been created, skipping...!\n") sys.stdout.write("[+] Creating expiration email notifications!\n") - sys.stdout.write("[!] Using {recipients} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n") + sys.stdout.write("[!] Using {recipients} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n".format("LEMUR_SECURITY_TEAM_EMAIL")) intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write( From 1e314b505fa27c47212303af802e02a0cc8c15f3 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 8 Sep 2015 18:18:14 -0700 Subject: [PATCH 6/6] fixing keyerror --- lemur/manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/manage.py b/lemur/manage.py index d2dbe28e..e7521038 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -297,7 +297,7 @@ class InitializeApp(Command): sys.stdout.write("[-] Default user has already been created, skipping...!\n") sys.stdout.write("[+] Creating expiration email notifications!\n") - sys.stdout.write("[!] Using {recipients} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n".format("LEMUR_SECURITY_TEAM_EMAIL")) + sys.stdout.write("[!] Using {0} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n".format("LEMUR_SECURITY_TEAM_EMAIL")) intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write(