From 2a58462006df90a5c8e83831fc03c8e0573abb4f Mon Sep 17 00:00:00 2001 From: Dan Iverson Date: Tue, 6 Sep 2022 10:04:49 -0500 Subject: [PATCH 1/3] Add -cm flag for Cloud Manager mode --- psst/psst.py | 12 +++++++++--- psst/secrets/access_pwd.py | 11 ++++++++--- psst/secrets/db_user_pwd.py | 11 ++++++++--- setup.py | 2 +- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/psst/psst.py b/psst/psst.py index 3444d8f..bb6a112 100644 --- a/psst/psst.py +++ b/psst/psst.py @@ -12,7 +12,9 @@ def __init__(self): pass_config = click.make_pass_decorator(Config, ensure=True) @click.group(no_args_is_help=True) +# @click.pass_obj @pass_config + def cli(config): """PeopleSoft Secrets Tool""" pass @@ -23,13 +25,17 @@ def secrets(): pass @secrets.command() -def generate(): +@click.option('-cm', '--cloud-manager', + default=False, + help="Set Cloud Manager Mode for password lengths", + is_flag=True) +def generate(cloud_manager): """Generate a dictionary of secrets""" dict = {} - dict["access_pwd"] = psst.secrets.access_pwd.generate() + dict["access_pwd"] = psst.secrets.access_pwd.generate(cloud_manager) dict["db_connect_pwd"] = psst.secrets.db_connect_pwd.generate() - dict["db_user_pwd"] = psst.secrets.db_user_pwd.generate() + dict["db_user_pwd"] = psst.secrets.db_user_pwd.generate(cloud_manager) dict["domain_conn_pwd"] = psst.secrets.domain_conn_pwd.generate() dict["pia_gateway_admin_pwd"] = psst.secrets.pia_gateway_admin_pwd.generate() dict["pia_webprofile_user_pwd"] = psst.secrets.pia_webprofile_user_pwd.generate() diff --git a/psst/secrets/access_pwd.py b/psst/secrets/access_pwd.py index e516721..ce6776c 100644 --- a/psst/secrets/access_pwd.py +++ b/psst/secrets/access_pwd.py @@ -2,12 +2,12 @@ import array # Database Access ID password. -# No more than 8 characters in length. +# No more than 8 characters in length for Cloud Manager +# 25 characters default # The first character must be a letter # Remaining 7 characters may be a mixture of letters and numbers." MIN_LEN = 8 -MAX_LEN = 8 DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] LOCASE_CHARACTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', @@ -23,7 +23,12 @@ COMBINED_LIST = DIGITS + UPCASE_CHARACTERS + LOCASE_CHARACTERS LETTERS_LIST = UPCASE_CHARACTERS + LOCASE_CHARACTERS -def generate(): +def generate(cloud_manager): + if cloud_manager: + MAX_LEN = 8 + else: + MAX_LEN = 25 + # randomly select at least one character from each character set above rand_digit = random.choice(DIGITS) rand_upper = random.choice(UPCASE_CHARACTERS) diff --git a/psst/secrets/db_user_pwd.py b/psst/secrets/db_user_pwd.py index 449fac4..6f6b9da 100644 --- a/psst/secrets/db_user_pwd.py +++ b/psst/secrets/db_user_pwd.py @@ -3,10 +3,10 @@ # Domain boot user (CLADM/PS/VP1) password. # Only alphanumeric characters . -# 8 characters in length. +# 8 characters in length for Cloud Manager +# 25 characters default MIN_LEN = 8 -MAX_LEN = 8 DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] LOCASE_CHARACTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', @@ -21,7 +21,12 @@ COMBINED_LIST = DIGITS + UPCASE_CHARACTERS + LOCASE_CHARACTERS -def generate(): +def generate(cloud_manager): + if cloud_manager: + MAX_LEN = 8 + else: + MAX_LEN = 25 + # randomly select at least one character from each character set above rand_digit = random.choice(DIGITS) rand_upper = random.choice(UPCASE_CHARACTERS) diff --git a/setup.py b/setup.py index 2dd3e1c..c408fe3 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup_args = dict( name='psst', - version='0.0.1', + version='0.0.2', description='psst', long_description_content_type="text/markdown", long_description=README, From acf12245898ee63c6b5d61dd4060301fc6691037 Mon Sep 17 00:00:00 2001 From: Dan Iverson Date: Tue, 6 Sep 2022 10:16:39 -0500 Subject: [PATCH 2/3] Remove commented code --- psst/psst.py | 1 - 1 file changed, 1 deletion(-) diff --git a/psst/psst.py b/psst/psst.py index bb6a112..3860339 100644 --- a/psst/psst.py +++ b/psst/psst.py @@ -12,7 +12,6 @@ def __init__(self): pass_config = click.make_pass_decorator(Config, ensure=True) @click.group(no_args_is_help=True) -# @click.pass_obj @pass_config def cli(config): From 36aa08f99b70b1c24bcd9cba31d58a9759687149 Mon Sep 17 00:00:00 2001 From: Dan Iverson Date: Tue, 6 Sep 2022 10:37:49 -0500 Subject: [PATCH 3/3] Remove whitespace --- psst/psst.py | 1 - 1 file changed, 1 deletion(-) diff --git a/psst/psst.py b/psst/psst.py index 2cee68b..4b15a03 100644 --- a/psst/psst.py +++ b/psst/psst.py @@ -13,7 +13,6 @@ def __init__(self): @click.group(no_args_is_help=True) @pass_config - def cli(config): """PeopleSoft Secrets Tool""" pass