[Python-modules-commits] [python-zxcvbn] 01/01: 4.4.16 version

Sabino Par sprab-guest at moszumanska.debian.org
Sun Sep 10 16:40:07 UTC 2017


This is an automated email from the git hooks/post-receive script.

sprab-guest pushed a commit to branch upstream
in repository python-zxcvbn.

commit 43a1f391c2eac62e56bfb5bbdf7c4d8b96a5dfa2
Author: sprab-guest <sprab at onenetbeyond.org>
Date:   Sun Sep 10 18:39:38 2017 +0200

    4.4.16 version
---
 PKG-INFO           |  4 ++--
 setup.py           |  4 ++--
 zxcvbn/__init__.py |  5 +++--
 zxcvbn/matching.py | 34 ++++++++++++++--------------------
 zxcvbn/scoring.py  |  2 +-
 5 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index b4cabf4..d04ec3c 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: zxcvbn-python
-Version: 4.4.15
+Version: 4.4.16
 Summary: Python implementation of Dropbox's realistic password strength estimator, zxcvbn
 Home-page: https://github.com/dwolfhub/zxcvbn-python
 Author: Daniel Wolf
 Author-email: danielrwolf5 at gmail.com
 License: MIT
-Download-URL: https://github.com/dwolfhub/zxcvbn-python/tarball/v4.4.15
+Download-URL: https://github.com/dwolfhub/zxcvbn-python/tarball/v4.4.16
 Description: UNKNOWN
 Keywords: zxcvbn,password,security
 Platform: UNKNOWN
diff --git a/setup.py b/setup.py
index aa814e7..193208c 100644
--- a/setup.py
+++ b/setup.py
@@ -2,10 +2,10 @@ from distutils.core import setup
 
 setup(
     name='zxcvbn-python',
-    version='4.4.15',
+    version='4.4.16',
     packages=['zxcvbn'],
     url='https://github.com/dwolfhub/zxcvbn-python',
-    download_url='https://github.com/dwolfhub/zxcvbn-python/tarball/v4.4.15',
+    download_url='https://github.com/dwolfhub/zxcvbn-python/tarball/v4.4.16',
     license='MIT',
     author='Daniel Wolf',
     author_email='danielrwolf5 at gmail.com',
diff --git a/zxcvbn/__init__.py b/zxcvbn/__init__.py
index 02aa347..dd161a8 100644
--- a/zxcvbn/__init__.py
+++ b/zxcvbn/__init__.py
@@ -22,9 +22,10 @@ def zxcvbn(password, user_inputs=None):
             arg = str(arg)
         sanitized_inputs.append(arg.lower())
 
-    matching.set_user_input_dictionary(sanitized_inputs)
+    ranked_dictionaries = matching.RANKED_DICTIONARIES
+    ranked_dictionaries['user_inputs'] = matching.build_ranked_dict(sanitized_inputs)
 
-    matches = matching.omnimatch(password)
+    matches = matching.omnimatch(password, ranked_dictionaries)
     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 713aa16..11bc865 100644
--- a/zxcvbn/matching.py
+++ b/zxcvbn/matching.py
@@ -82,7 +82,7 @@ DATE_SPLITS = {
 
 
 # omnimatch -- perform all matches
-def omnimatch(password):
+def omnimatch(password, _ranked_dictionaries=RANKED_DICTIONARIES):
     matches = []
     for matcher in [
         dictionary_match,
@@ -94,7 +94,7 @@ def omnimatch(password):
         regex_match,
         date_match,
     ]:
-        matches.extend(matcher(password))
+        matches.extend(matcher(password, _ranked_dictionaries=_ranked_dictionaries))
 
     return sorted(matches, key=lambda x: (x['i'], x['j']))
 
@@ -138,10 +138,6 @@ 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):
@@ -192,7 +188,7 @@ def enumerate_l33t_subs(table):
                     sub_extension.append([l33t_chr, first_key])
                     next_subs.append(sub_extension)
                 else:
-                    sub_alternative = sub
+                    sub_alternative = list(sub)
                     sub_alternative.pop(dup_l33t_index)
                     sub_alternative.append([l33t_chr, first_key])
                     next_subs.append(sub)
@@ -258,7 +254,7 @@ def l33t_match(password, _ranked_dictionaries=RANKED_DICTIONARIES,
 
 
 # repeats (aaa, abcabcabc) and sequences (abcdef)
-def repeat_match(password):
+def repeat_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
     matches = []
     greedy = re.compile(r'(.+)\1+')
     lazy = re.compile(r'(.+?)\1+')
@@ -309,7 +305,7 @@ def repeat_match(password):
     return matches
 
 
-def spatial_match(password, _graphs=GRAPHS):
+def spatial_match(password, _graphs=GRAPHS, _ranked_dictionaries=RANKED_DICTIONARIES):
     matches = []
     for graph_name, graph in _graphs.items():
         matches.extend(spatial_match_helper(password, graph, graph_name))
@@ -390,7 +386,7 @@ def spatial_match_helper(password, graph, graph_name):
 MAX_DELTA = 5
 
 
-def sequence_match(password):
+def sequence_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
     # 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.
@@ -407,7 +403,7 @@ def sequence_match(password):
         return []
 
     def update(i, j, delta):
-        if j - 1 > 1 or delta and abs(delta) == 1:
+        if j - i > 1 or (delta and abs(delta) == 1):
             if 0 < abs(delta) <= MAX_DELTA:
                 token = password[i:j + 1]
                 if re.compile(r'^[a-z]+$').match(token):
@@ -438,7 +434,7 @@ def sequence_match(password):
 
     for k in range(1, len(password)):
         delta = ord(password[k]) - ord(password[k - 1])
-        if not last_delta:
+        if last_delta is None:
             last_delta = delta
         if delta == last_delta:
             continue
@@ -451,17 +447,15 @@ def sequence_match(password):
     return result
 
 
-def regex_match(password, _regexen=REGEXEN):
+def regex_match(password, _regexen=REGEXEN, _ranked_dictionaries=RANKED_DICTIONARIES):
     matches = []
     for name, regex in _regexen.items():
-        rx_match = regex.match(password)
-        if rx_match:
-            token = rx_match.group(0)
+        for rx_match in regex.finditer(password):
             matches.append({
                 'pattern': 'regex',
-                'token': token,
-                'i': rx_match.span()[0],
-                'j': rx_match.span()[0] + len(token) - 1,
+                'token': rx_match.group(0),
+                'i': rx_match.start(),
+                'j': rx_match.end()-1,
                 'regex_name': name,
                 'regex_match': rx_match,
             })
@@ -469,7 +463,7 @@ def regex_match(password, _regexen=REGEXEN):
     return sorted(matches, key=lambda x: (x['i'], x['j']))
 
 
-def date_match(password):
+def date_match(password, _ranked_dictionaries=RANKED_DICTIONARIES):
     # 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),
diff --git a/zxcvbn/scoring.py b/zxcvbn/scoring.py
index 250ab49..cd2e96a 100644
--- a/zxcvbn/scoring.py
+++ b/zxcvbn/scoring.py
@@ -140,7 +140,7 @@ def most_guessable_match_sequence(password, matches, _exclude_additive=False):
         # see if a single bruteforce match spanning the k-prefix is optimal.
         m = make_bruteforce_match(0, k)
         update(m, 1)
-        for i in range(1, k):
+        for i in range(1, k + 1):
             # generate k bruteforce matches, spanning from (i=1, j=k) up to
             # (i=k, j=k). see if adding these new matches to any of the
             # sequences in optimal[i-1] leads to new bests.

-- 
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