Skip to content

Conversation

@aboettger-tuhh
Copy link

A robust analysis for zxcvbn results has been added to handle missing keys and output user-friendly messages. The cause was the following exception:

Traceback (most recent call last):
  File "/home/<censored>/.local/bin/pimport", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/<censored>/.local/share/pipx/venvs/pass-import/lib/python3.12/site-packages/pass_import/__main__.py", line 512, in main
    paths_imported, paths_exported, audit = pass_export(conf, cls_export, data)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<censored>/.local/share/pipx/venvs/pass-import/lib/python3.12/site-packages/pass_import/__main__.py", line 400, in pass_export
    report = exporter.audit(conf['pwned'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<censored>/.local/share/pipx/venvs/pass-import/lib/python3.12/site-packages/pass_import/manager.py", line 186, in audit
    audit.zxcvbn()
  File "/home/<censored>/.local/share/pipx/venvs/pass-import/lib/python3.12/site-packages/pass_import/audit.py", line 95, in zxcvbn
    results = zxcvbn(password, user_inputs=user_input)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<censored>/.local/share/pipx/venvs/pass-import/lib/python3.12/site-packages/zxcvbn/__init__.py", line 10, in zxcvbn
    raise ValueError(f"Password exceeds max length of {max_length} characters.")
ValueError: Password exceeds max length of 72 characters.

Added robust parsing for zxcvbn results to handle missing keys and provide user-friendly messages.
'feedback': {'warning': 'zxcvbn raised an error; strength check skipped', 'suggestions': []}
}

result_parsed = zxcvbn_parse(results)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot a self here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it could be.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move zxcvbn_parse outside the class, since that function is not using self at all?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My patch is more of a quick and dirty hack. I don’t think I can contribute anything more intelligent without delving deeper into the code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's something quicker and dirtier, then: #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants