dwolfhub / zxcvbn-python

Python implementation of Dropbox's realistic password strength estimator
MIT License
656 stars 70 forks source link

IndexError: list index out of range, on empty password #64

Open Tronic opened 3 years ago

Tronic commented 3 years ago
>>> zxcvbn.zxcvbn('')

zxcvbn\__init__.py in zxcvbn(password, user_inputs)
     26
     27     matches = matching.omnimatch(password, ranked_dictionaries)
---> 28     result = scoring.most_guessable_match_sequence(password, matches)
     29     result['calc_time'] = datetime.now() - start
     30

zxcvbn\scoring.py in most_guessable_match_sequence(password, matches, _exclude_additive)
    202         bruteforce_update(k)
    203
--> 204     optimal_match_sequence = unwind(n)
    205     optimal_l = len(optimal_match_sequence)
    206

zxcvbn\scoring.py in unwind(n)
    179         l = None
    180         g = float('inf')
--> 181         for candidate_l, candidate_g in optimal['g'][k].items():
    182             if candidate_g < g:
    183                 l = candidate_l

IndexError: list index out of range

As a workaround, password or ' ' works, but I gather that this should also not crash on an empty string.

abdullah-alnahas commented 8 months ago

Thank you for providing the Python implementation of zxcvbn.

I would like to report that it still raises an IndexError when an empty string is passed as input.