passweird 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/passweird/checker.rb +15 -3
- data/lib/passweird/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f9ca1edca79f1e3509a577234b4bb273753f0a1ad7ec48ce245731a0ee10117
|
4
|
+
data.tar.gz: d10de41fe650f3d9f3549ef56ec954bd526ebedb943158d7d83ed95c6fea39b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fa8ea500a7c0303baa3f7f19764cef831b792fb508b400829cfd9d44d4d1a7a797db83abaaf2ee045b86471887f3c059baea54c245c1e21d9982b47ce776ea0
|
7
|
+
data.tar.gz: 66cb3443e86cad7ceb5f65fd7ad7ce1e641364a5430aa7fc8643052d447e698d324b63ef816ac701ec2663ff4f3d5f923c8ece1abcae0cbc8b5a4cda7ffa6c71
|
data/Gemfile.lock
CHANGED
data/lib/passweird/checker.rb
CHANGED
@@ -24,25 +24,29 @@ module Passweird
|
|
24
24
|
#
|
25
25
|
# @return [Boolean] true if the password is blacklisted, false otherwise
|
26
26
|
def blacklisted?
|
27
|
-
@blacklisted ||= BlacklistedTerm.where(
|
27
|
+
@blacklisted ||= BlacklistedTerm.where(term: possible_terms).exists?
|
28
28
|
end
|
29
29
|
|
30
30
|
# Retrieves the blacklisted terms that match the possible terms
|
31
31
|
#
|
32
32
|
# @return [ActiveRecord::Relation] a collection of blacklisted terms
|
33
33
|
def blacklisted_terms
|
34
|
-
@blacklisted_terms ||= BlacklistedTerm.where(
|
34
|
+
@blacklisted_terms ||= BlacklistedTerm.where(term: possible_terms)
|
35
35
|
end
|
36
36
|
|
37
37
|
# Generates all possible terms from substrings and leet speak equivalents
|
38
38
|
#
|
39
39
|
# @return [Array<String>] an array of unique possible terms
|
40
40
|
def possible_terms
|
41
|
-
@possible_terms ||=
|
41
|
+
@possible_terms ||= all_substring_case_permutations.uniq
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
def all_substring_case_permutations
|
47
|
+
@all_substring_case_permutations ||= substrings + unleeted_substrings + downcased_substrings + upcased_substrings
|
48
|
+
end
|
49
|
+
|
46
50
|
def unleeted_substrings
|
47
51
|
@unleeted_substrings ||= LeetSpeak.unleet_all(substrings)
|
48
52
|
end
|
@@ -50,5 +54,13 @@ module Passweird
|
|
50
54
|
def substrings
|
51
55
|
@substrings ||= Substringer.substrings(password)
|
52
56
|
end
|
57
|
+
|
58
|
+
def downcased_substrings
|
59
|
+
@downcased_substrings ||= substrings.map(&:downcase)
|
60
|
+
end
|
61
|
+
|
62
|
+
def upcased_substrings
|
63
|
+
@upcased_substrings ||= substrings.map(&:upcase)
|
64
|
+
end
|
53
65
|
end
|
54
66
|
end
|
data/lib/passweird/version.rb
CHANGED