提交 42f4a9ee 编写于 作者: Z Zhangyifan 提交者: chenyanpan

limit password length in generate_password and patch-tracking-cli

上级 0badc26d
......@@ -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
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册