Class: Zxcvbn::Omnimatch Private
- Inherits:
-
Object
- Object
- Zxcvbn::Omnimatch
- Defined in:
- lib/zxcvbn/omnimatch.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Runs all registered matchers against a password and aggregates results.
Includes dictionary, l33t, spatial, digit, repeat, sequence, year, date, and reverse-dictionary matchers. User-supplied word lists are wrapped in transient matchers for each call to #matches.
Instance Method Summary collapse
-
#initialize(data) ⇒ Omnimatch
constructor
private
A new instance of Omnimatch.
-
#matches(password, user_inputs = [], reference_year: Time.now.year) ⇒ Array<MatchBuilder>
private
Returns all matches found in the password across every registered matcher.
Constructor Details
#initialize(data) ⇒ Omnimatch
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Omnimatch.
23 24 25 26 27 28 29 30 |
# File 'lib/zxcvbn/omnimatch.rb', line 23 def initialize(data) @data = data dicts = data.dictionaries @dictionary_matchers = dicts.ranked.map do |name, dictionary| Matchers::Dictionary.new(name, dictionary, dicts.tries[name]).freeze end.freeze @matchers = build_matchers.each(&:freeze).freeze end |
Instance Method Details
#matches(password, user_inputs = [], reference_year: Time.now.year) ⇒ Array<MatchBuilder>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all matches found in the password across every registered matcher.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zxcvbn/omnimatch.rb', line 39 def matches(password, user_inputs = [], reference_year: Time.now.year) user_dictionary = user_inputs.any? && Matchers::Dictionary.new('user_inputs', DictionaryRanker.rank_dictionary(user_inputs)) matchers = @matchers + user_input_matchers(user_dictionary) all_matches = matchers.flat_map do |matcher| case matcher when Matchers::Date matcher.matches(password, reference_year:) else matcher.matches(password) end end all_matches + reverse_dictionary_matches(password, user_dictionary) end |