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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74a16ce122dc738bb09ed51b95a2665020e998e484b8b58cbf1f66608d79985d
4
- data.tar.gz: ca0d3becb070feb3f82988f999d66fd2b8e46934f399e9750a260f7372973e81
3
+ metadata.gz: 1f9ca1edca79f1e3509a577234b4bb273753f0a1ad7ec48ce245731a0ee10117
4
+ data.tar.gz: d10de41fe650f3d9f3549ef56ec954bd526ebedb943158d7d83ed95c6fea39b1
5
5
  SHA512:
6
- metadata.gz: a2ad26569385375009f3600d7349c2f0c8e7ac53a56ded39598974cef91ca3534b20f36fa0ce49fcbe4188ce887eeba8f0cbe95deb1ffb7b023c8f217864da1d
7
- data.tar.gz: 366963f6c9b6fe1483ff4a15cf5433c62eb6d825d9d68eb2d5f035ccfbbaf504843fce759b164129f04fd8c379d5f779fe804b2b44214c35b19902a7aa3b5a03
6
+ metadata.gz: 5fa8ea500a7c0303baa3f7f19764cef831b792fb508b400829cfd9d44d4d1a7a797db83abaaf2ee045b86471887f3c059baea54c245c1e21d9982b47ce776ea0
7
+ data.tar.gz: 66cb3443e86cad7ceb5f65fd7ad7ce1e641364a5430aa7fc8643052d447e698d324b63ef816ac701ec2663ff4f3d5f923c8ece1abcae0cbc8b5a4cda7ffa6c71
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passweird (0.1.1)
4
+ passweird (0.1.2)
5
5
  activerecord (~> 6.0)
6
6
 
7
7
  GEM
@@ -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("LOWER(term) IN ?", possible_terms).exists?
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("LOWER(term) IN ?", possible_terms)
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 ||= (substrings + unleeted_substrings).uniq
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passweird
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passweird
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rupert Señga