Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pass_import/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ def report(conf, paths_imported, paths_exported, audit):
for entry in audit['duplicated']:
conf.warning(f"Duplicated passwords detected: "
f"{', '.join([item['path'] for item in entry])}")
for entry in audit.get('skipped', []):
conf.warning(f"Password too long for strength estimation (>72 chars),"
f" skipped: {entry.get('path', entry.get('title', ''))}")

for paths, header in [
(paths_imported, "Passwords imported"),
Expand Down
7 changes: 6 additions & 1 deletion pass_import/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ def __init__(self, data):
self.breached = []
self.weak = []
self.duplicated = []
self.skipped = []

@property
def report(self):
"""Get audit result."""
return {
'breached': self.breached,
'weak': self.weak,
'duplicated': self.duplicated
'duplicated': self.duplicated,
'skipped': self.skipped,
}

def password(self):
Expand Down Expand Up @@ -89,6 +91,9 @@ def zxcvbn(self):
if entry.get('password', '') == '':
continue
password = entry['password']
if len(password) > 72:
self.skipped.append(entry)
continue
user_input = list(entry.values())
if password in user_input:
user_input.remove(password)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ def test_zxcvbn_strong(self):
audit.zxcvbn()
self.assertTrue(len(audit.weak) == 0)

def test_zxcvbn_long(self):
"""Testing: audit skips passwords exceeding zxcvbn's 72-char limit."""
data = [{
'path': 'Password/long/1',
'password': 'x' * 73,
'group': 'Password/long'
}]
audit = pass_import.audit.Audit(data)
audit.zxcvbn()
self.assertTrue(len(audit.weak) == 0)
self.assertTrue(len(audit.skipped) == 1)

def test_duplicates_yes(self):
"""Testing: audit for duplicates password."""
data = getpath('Password/notpwned/1')
Expand Down
Loading