devlup-labs / dev-playground

This repository serves as a sandbox environment for experimenting with various workflows, tools, and development practices
MIT License
0 stars 71 forks source link

Incorrect digit check in check_strength function only verifies if the first character is a number, missing digits elsewhere in the password. #14

Open Advaitgaur004 opened 1 month ago

Advaitgaur004 commented 1 month ago

Description

The PasswordChecker class currently has a bug in the check_strength function, where it only checks if the first character of the password is a digit. This leads to incorrect strength scoring when passwords contain digits in any position other than the first.

Files

password_checker.py

To Reproduce

1) Initialize the PasswordChecker class. 2) Run the check_strength method with a password that contains numbers not at the start, e.g., "weakpass2". 3) Observe that the feedback suggests the password lacks a number, despite containing one.

Expected Behavior

The check_strength function should correctly identify numbers anywhere in the password and adjust the strength score and feedback accordingly.

Actual Behavior

The function only checks if the first character is a digit. If the number is placed elsewhere in the password, the feedback incorrectly states that a number is missing.

Tasks

Possible Fixes

Replace if password[0].isdigit() with if any(c.isdigit() for c in password) to properly check for digits throughout the entire password.

gitdevjin commented 1 month ago

I think I can handle this. I will open a PR

Advaitgaur004 commented 1 month ago

@gitdevjin go ahead, i'll assign this issue to you