zxcvbn 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,10 @@ module Zxcvbn
15
15
  build_ranked_dict(lst)
16
16
  end
17
17
 
18
+ RANKED_DICTIONARIES_MAX_WORD_SIZE = RANKED_DICTIONARIES.transform_values do |word_scores|
19
+ word_scores.keys.max_by(&:size).size
20
+ end
21
+
18
22
  GRAPHS = {
19
23
  "qwerty" => ADJACENCY_GRAPHS["qwerty"],
20
24
  "dvorak" => ADJACENCY_GRAPHS["dvorak"],
@@ -151,8 +155,13 @@ module Zxcvbn
151
155
  len = password.length
152
156
  password_lower = password.downcase
153
157
  _ranked_dictionaries.each do |dictionary_name, ranked_dict|
158
+ longest_dict_word_size = RANKED_DICTIONARIES_MAX_WORD_SIZE.fetch(dictionary_name) do
159
+ ranked_dict.keys.max_by(&:size)&.size || 0
160
+ end
161
+ search_width = [longest_dict_word_size, len].min
154
162
  (0...len).each do |i|
155
- (i...len).each do |j|
163
+ search_end = [i + search_width, len].min
164
+ (i...search_end).each do |j|
156
165
  if ranked_dict.key?(password_lower[i..j])
157
166
  word = password_lower[i..j]
158
167
  rank = ranked_dict[word]
@@ -187,7 +196,9 @@ module Zxcvbn
187
196
  end
188
197
 
189
198
  def self.user_input_dictionary=(ordered_list)
190
- RANKED_DICTIONARIES["user_inputs"] = build_ranked_dict(ordered_list.dup)
199
+ ranked_dict = build_ranked_dict(ordered_list.dup)
200
+ RANKED_DICTIONARIES["user_inputs"] = ranked_dict
201
+ RANKED_DICTIONARIES_MAX_WORD_SIZE["user_inputs"] = ranked_dict.keys.max_by(&:size)&.size || 0
191
202
  end
192
203
 
193
204
  #-------------------------------------------------------------------------------
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zxcvbn
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.9"
5
5
  end
data/lib/zxcvbn.rb CHANGED
@@ -31,7 +31,7 @@ module Zxcvbn
31
31
  end
32
32
 
33
33
  def self.test(password, user_inputs = [])
34
- OpenStruct.new(Zxcvbn.zxcvbn(password, user_inputs))
34
+ OpenStruct.new(Zxcvbn.zxcvbn(password, user_inputs)) # rubocop:disable Style/OpenStructUse
35
35
  end
36
36
 
37
37
  class Tester
data/zxcvbn.gemspec CHANGED
@@ -20,9 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
- end
23
+ # spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ # end
26
+ spec.files = Dir["*.gemspec", "lib/**/*", "CHANGELOG.md", "LICENSE.txt", "README.md"]
27
+
26
28
  spec.bindir = "exe"
27
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
30
  spec.require_paths = ["lib"]
@@ -32,4 +34,5 @@ Gem::Specification.new do |spec|
32
34
 
33
35
  # For more information and examples about making a new gem, checkout our
34
36
  # guide at: https://bundler.io/guides/creating_gem.html
37
+ spec.metadata["rubygems_mfa_required"] = "true"
35
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zxcvbn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Santos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-12 00:00:00.000000000 Z
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 100% native Ruby 100% compatible port of Dropbox's zxcvbn.js
14
14
  email:
@@ -17,19 +17,9 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".gitignore"
21
- - ".rspec"
22
- - ".rubocop.yml"
23
- - ".travis.yml"
24
20
  - CHANGELOG.md
25
- - CODE_OF_CONDUCT.md
26
- - Gemfile
27
- - Gemfile.lock
28
21
  - LICENSE.txt
29
22
  - README.md
30
- - Rakefile
31
- - bin/console
32
- - bin/setup
33
23
  - lib/zxcvbn.rb
34
24
  - lib/zxcvbn/adjacency_graphs.rb
35
25
  - lib/zxcvbn/feedback.rb
@@ -46,6 +36,7 @@ metadata:
46
36
  homepage_uri: http://github.com/formigarafa/zxcvbn-rb
47
37
  source_code_uri: http://github.com/formigarafa/zxcvbn-rb
48
38
  changelog_uri: http://github.com/formigarafa/zxcvbn-rb/blob/HEAD/CHANGELOG.md
39
+ rubygems_mfa_required: 'true'
49
40
  post_install_message:
50
41
  rdoc_options: []
51
42
  require_paths:
@@ -61,8 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
52
  - !ruby/object:Gem::Version
62
53
  version: '0'
63
54
  requirements: []
64
- rubyforge_project:
65
- rubygems_version: 2.7.6.3
55
+ rubygems_version: 3.0.3.1
66
56
  signing_key:
67
57
  specification_version: 4
68
58
  summary: ''
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,45 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.5
3
- NewCops: enable
4
- SuggestExtensions: false
5
-
6
- Layout/EndAlignment:
7
- EnforcedStyleAlignWith: start_of_line
8
-
9
- Layout/LineLength:
10
- Max: 120
11
-
12
- Lint/UnderscorePrefixedVariableName:
13
- Enabled: false
14
-
15
- Metrics:
16
- Enabled: false
17
-
18
- Naming/VariableNumber:
19
- Enabled: false
20
-
21
- Style/Documentation:
22
- Enabled: false
23
-
24
- Style/Next:
25
- Enabled: false
26
-
27
- Style/NumericPredicate:
28
- Enabled: false
29
-
30
- Style/StringLiterals:
31
- Enabled: true
32
- EnforcedStyle: double_quotes
33
-
34
- Style/StringLiteralsInInterpolation:
35
- Enabled: true
36
- EnforcedStyle: double_quotes
37
-
38
- Style/NegatedIf:
39
- Enabled: false
40
-
41
- Style/SymbolArray:
42
- Enabled: false
43
-
44
- Style/WordArray:
45
- Enabled: false
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.5.9
6
- - 2.6.7
7
- - 2.7.3
8
- - 3.0.1
9
- before_install: gem install bundler -v 2.2.15
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at formigarafa@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in zxcvbn.gemspec
6
- gemspec
7
-
8
- group :development do
9
- gem "mini_racer"
10
- gem "rake", "~> 13.0"
11
- gem "rspec", "~> 3.0"
12
- gem "rubocop", "~> 1.7"
13
-
14
- gem "pry"
15
- gem "pry-byebug"
16
- gem "simplecov", require: false
17
- end
data/Gemfile.lock DELETED
@@ -1,80 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- zxcvbn (0.1.7)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- byebug (11.1.3)
11
- coderay (1.1.3)
12
- diff-lcs (1.4.4)
13
- docile (1.4.0)
14
- libv8-node (15.14.0.1-x86_64-darwin-19)
15
- libv8-node (15.14.0.1-x86_64-linux)
16
- method_source (1.0.0)
17
- mini_racer (0.4.0)
18
- libv8-node (~> 15.14.0.0)
19
- parallel (1.20.1)
20
- parser (3.0.1.1)
21
- ast (~> 2.4.1)
22
- pry (0.14.1)
23
- coderay (~> 1.1)
24
- method_source (~> 1.0)
25
- pry-byebug (3.8.0)
26
- byebug (~> 11.0)
27
- pry (~> 0.10)
28
- rainbow (3.0.0)
29
- rake (13.0.3)
30
- regexp_parser (2.1.1)
31
- rexml (3.2.5)
32
- rspec (3.10.0)
33
- rspec-core (~> 3.10.0)
34
- rspec-expectations (~> 3.10.0)
35
- rspec-mocks (~> 3.10.0)
36
- rspec-core (3.10.1)
37
- rspec-support (~> 3.10.0)
38
- rspec-expectations (3.10.1)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.10.0)
41
- rspec-mocks (3.10.2)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.10.0)
44
- rspec-support (3.10.2)
45
- rubocop (1.14.0)
46
- parallel (~> 1.10)
47
- parser (>= 3.0.0.0)
48
- rainbow (>= 2.2.2, < 4.0)
49
- regexp_parser (>= 1.8, < 3.0)
50
- rexml
51
- rubocop-ast (>= 1.5.0, < 2.0)
52
- ruby-progressbar (~> 1.7)
53
- unicode-display_width (>= 1.4.0, < 3.0)
54
- rubocop-ast (1.5.0)
55
- parser (>= 3.0.1.1)
56
- ruby-progressbar (1.11.0)
57
- simplecov (0.21.2)
58
- docile (~> 1.1)
59
- simplecov-html (~> 0.11)
60
- simplecov_json_formatter (~> 0.1)
61
- simplecov-html (0.12.3)
62
- simplecov_json_formatter (0.1.3)
63
- unicode-display_width (2.0.0)
64
-
65
- PLATFORMS
66
- x86_64-darwin-19
67
- x86_64-linux
68
-
69
- DEPENDENCIES
70
- mini_racer
71
- pry
72
- pry-byebug
73
- rake (~> 13.0)
74
- rspec (~> 3.0)
75
- rubocop (~> 1.7)
76
- simplecov
77
- zxcvbn!
78
-
79
- BUNDLED WITH
80
- 2.2.15
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
data/bin/console DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "zxcvbn"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- # require "irb"
15
- # IRB.start(__FILE__)
16
-
17
- require "pry"
18
- Pry.start("main")
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here