-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RBAC] az ad sp credential reset
: fix weak credential generation
#13357
Conversation
add to S169 |
Please title the PR with meaningful description, like "[RBAC] az ad sp credential reset: fix weak credential generation", so that |
def _random_password(length): | ||
import random | ||
import string | ||
random_source = string.ascii_letters + string.digits + string.punctuation | ||
password = random.choice(string.ascii_lowercase) | ||
password += random.choice(string.ascii_uppercase) | ||
password += random.choice(string.digits) | ||
password += random.choice(string.punctuation) | ||
|
||
for i in range(length - 4): | ||
password += random.choice(random_source) | ||
|
||
password_list = list(password) | ||
random.SystemRandom().shuffle(password_list) | ||
password = ''.join(password_list) | ||
return password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the code is borrowed from somewhere else, it is a good practice to put the source link in the comment: https://pynative.com/python-generate-random-string/
az ad sp credential reset
az ad sp credential reset
: fix weak credential generation
@fengzhou-msft I think we have decided not to include backticks |
password += random.choice(string.digits) | ||
password += random.choice(string.punctuation) | ||
|
||
for i in range(length - 4): # pylint: disable=unused-variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i in range(length - 4): # pylint: disable=unused-variable | |
for _ in range(length - 4): |
Description
Password autogenerated by
az ad sp credential reset
is a Guid which is not secure.Testing Guide
az ad sp credential reset -n test
Expected result: password should be a string with at least one special character
History Notes
[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.