diff --git a/patch-tracking/patch_tracking/cli/generate_password b/patch-tracking/patch_tracking/cli/generate_password index 25eb2131df37b06727636967f281e4c9ec83020e..e126ac71b18ab645d20ff1f350eee73f93ed80f8 100644 --- a/patch-tracking/patch_tracking/cli/generate_password +++ b/patch-tracking/patch_tracking/cli/generate_password @@ -16,7 +16,7 @@ def usage(): Requirements: 1. PASSWORD must be within the 'latin1' character set 2. PASSWORD strength require: - 6 characters or more + length must be between 6 and 32 at least 1 digit [0-9] at least 1 alphabet [a-z] at least 1 alphabet of Upper Case [A-Z] @@ -41,7 +41,7 @@ def password_strength_check(password): """ # calculating the length - length_error = len(password) < 6 + length_error = len(password) < 6 or len(password) > 32 # searching for digits digit_error = re.search(r"\d", password) is None diff --git a/patch-tracking/patch_tracking/cli/patch_tracking_cli.py b/patch-tracking/patch_tracking/cli/patch_tracking_cli.py index ec712eac22d8436a412cc0f19329d57e17b91633..c5f21c73cfb19baf292001f510235b8c8496c6fc 100755 --- a/patch-tracking/patch_tracking/cli/patch_tracking_cli.py +++ b/patch-tracking/patch_tracking/cli/patch_tracking_cli.py @@ -193,6 +193,9 @@ def add(args): """ add tracking """ + if not check_password_length(args.password): + print('PASSWORD: Password length must be between 6 and 32') + return style1 = bool(args.version_control) or bool(args.repo) or bool(args.branch) or bool(args.scm_repo) or bool( args.scm_branch ) or bool(args.enabled) @@ -235,6 +238,10 @@ def delete(args): user = args.user password = args.password + if not check_password_length(password): + print('PASSWORD: Password length must be between 6 and 32') + return + err = latin1_encode(user) if err: print("ERROR: user: only latin1 character set are allowed.") @@ -321,6 +328,15 @@ def dir_input_track(dir_path, args): print('error: dir path error. Params error in {}'.format(dir_path)) +def check_password_length(password): + """ + Password length must be between 6 and 32 + """ + if 6 <= len(password) <= 32: + return True + return False + + parser = argparse.ArgumentParser( prog='patch_tracking_cli', allow_abbrev=False,