Studio: reject whitespace-only passwords (#7341)

* Studio: reject whitespace-only passwords

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: reject any whitespace in passwords

* Studio: surface whitespace error in setup form, isolate auth test import

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
This commit is contained in:
Nilay 2026-07-23 13:14:37 +05:30 committed by GitHub
commit 13c7db1965
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 136 additions and 6 deletions

View file

@ -191,6 +191,10 @@ def prompt_new_password(verify_current: Callable[[str], bool], out: TextIO | Non
out.write(f"Password must be at least {MIN_PASSWORD_LENGTH} characters. Try again.\n")
out.flush()
continue
if any(ch.isspace() for ch in password):
out.write("Password cannot contain spaces. Try again.\n")
out.flush()
continue
if verify_current(password):
out.write("New password must differ from the current password. Try again.\n")
out.flush()
@ -233,6 +237,8 @@ def validate_new_password(candidate: str, verify_current: Callable[[str], bool])
current password), else None. Same policy as the interactive loop."""
if len(candidate) < MIN_PASSWORD_LENGTH:
return f"Password must be at least {MIN_PASSWORD_LENGTH} characters."
if any(ch.isspace() for ch in candidate):
return "Password cannot contain spaces."
if verify_current(candidate):
return "New password must differ from the current password."
return None