[Python-modules-commits] [python-zxcvbn] 03/03: Sync with upstream tarball
Gianfranco Costamagna
locutusofborg at moszumanska.debian.org
Tue Sep 12 10:50:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
locutusofborg pushed a commit to branch master
in repository python-zxcvbn.
commit 461790a5a1db49d51e6adfea579531cb5bfd3799
Author: Gianfranco Costamagna <costamagnagianfranco at yahoo.it>
Date: Tue Sep 12 12:50:15 2017 +0200
Sync with upstream tarball
---
zxcvbn/__init__.py | 5 ++---
zxcvbn/matching.py | 18 +++++++++++-------
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/zxcvbn/__init__.py b/zxcvbn/__init__.py
index dd161a8..02aa347 100644
--- a/zxcvbn/__init__.py
+++ b/zxcvbn/__init__.py
@@ -22,10 +22,9 @@ def zxcvbn(password, user_inputs=None):
arg = str(arg)
sanitized_inputs.append(arg.lower())
- ranked_dictionaries = matching.RANKED_DICTIONARIES
- ranked_dictionaries['user_inputs'] = matching.build_ranked_dict(sanitized_inputs)
+ matching.set_user_input_dictionary(sanitized_inputs)
- matches = matching.omnimatch(password, ranked_dictionaries)
+ matches = matching.omnimatch(password)
result = scoring.most_guessable_match_sequence(password, matches)
result['calc_time'] = datetime.now() - start
diff --git a/zxcvbn/matching.py b/zxcvbn/matching.py
index 11bc865..ff973ba 100644
--- a/zxcvbn/matching.py
+++ b/zxcvbn/matching.py
@@ -82,7 +82,7 @@ DATE_SPLITS = {
# omnimatch -- perform all matches
-def omnimatch(password, _ranked_dictionaries=RANKED_DICTIONARIES):
+def omnimatch(password):
matches = []
for matcher in [
dictionary_match,
@@ -94,7 +94,7 @@ def omnimatch(password, _ranked_dictionaries=RANKED_DICTIONARIES):
regex_match,
date_match,
]:
- matches.extend(matcher(password, _ranked_dictionaries=_ranked_dictionaries))
+ matches.extend(matcher(password))
return sorted(matches, key=lambda x: (x['i'], x['j']))
@@ -138,6 +138,10 @@ def reverse_dictionary_match(password,
return sorted(matches, key=lambda x: (x['i'], x['j']))
+def set_user_input_dictionary(ordered_list):
+ RANKED_DICTIONARIES['user_inputs'] = build_ranked_dict(ordered_list)
+
+
def relevant_l33t_subtable(password, table):
password_chars = {}
for char in list(password):
@@ -254,7 +258,7 @@ def l33t_match(password, _ranked_dictionaries=RANKED_DICTIONARIES,
# repeats (aaa, abcabcabc) and sequences (abcdef)
-def repeat_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
+def repeat_match(password):
matches = []
greedy = re.compile(r'(.+)\1+')
lazy = re.compile(r'(.+?)\1+')
@@ -305,7 +309,7 @@ def repeat_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
return matches
-def spatial_match(password, _graphs=GRAPHS, _ranked_dictionaries=RANKED_DICTIONARIES):
+def spatial_match(password, _graphs=GRAPHS):
matches = []
for graph_name, graph in _graphs.items():
matches.extend(spatial_match_helper(password, graph, graph_name))
@@ -386,7 +390,7 @@ def spatial_match_helper(password, graph, graph_name):
MAX_DELTA = 5
-def sequence_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
+def sequence_match(password):
# Identifies sequences by looking for repeated differences in unicode codepoint.
# this allows skipping, such as 9753, and also matches some extended unicode sequences
# such as Greek and Cyrillic alphabets.
@@ -447,7 +451,7 @@ def sequence_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
return result
-def regex_match(password, _regexen=REGEXEN, _ranked_dictionaries=RANKED_DICTIONARIES):
+def regex_match(password, _regexen=REGEXEN):
matches = []
for name, regex in _regexen.items():
for rx_match in regex.finditer(password):
@@ -463,7 +467,7 @@ def regex_match(password, _regexen=REGEXEN, _ranked_dictionaries=RANKED_DICTIONA
return sorted(matches, key=lambda x: (x['i'], x['j']))
-def date_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
+def date_match(password):
# a "date" is recognized as:
# any 3-tuple that starts or ends with a 2- or 4-digit year,
# with 2 or 0 separator chars (1.1.91 or 1191),
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-zxcvbn.git
More information about the Python-modules-commits
mailing list