zxcvbn-ruby 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3766aaa59eeb07a17e377051ad39091f2c96d52a76a5851476b7b163f81fdb10
4
- data.tar.gz: d4b054399683992fca7845b4e175d372dd98a2e8bba7338841938529a7b80853
3
+ metadata.gz: 871b2fb9d5b2db321db8625aae3ecff0f0ae13f3e9eb834ca79153c950951a89
4
+ data.tar.gz: 1eba0af7e3e6b6e982149d45a43356f91890b71328db17d03ee0bfa3cc45f37e
5
5
  SHA512:
6
- metadata.gz: 1860d4d74a4bc1f578c888fb9bd7f825ea05b36bcf5770a238be2630b1b928176908477650228522a30a5dc423ee25b45012bb091f72d1eafb951a7c0fef4657
7
- data.tar.gz: 6453adfe0fc5c05a2a84ea319df97bd46a41ff0aed7ac875d19637e7aace42f8cc81df992fe3f454ed30e5c00d84113e9ceeecea2972336f562a18c39a81cb38
6
+ metadata.gz: 6dd4ec7906a109a2094e6f2d44606748a778c6aa35111f967cbaa143313b8b7e149b21bb926dc9d31d96c14a53489a7ec879fbc5618c6f804117a262673b5d81
7
+ data.tar.gz: d2b3b14f62904c31db52da50066fe6a4cccdb3acb058407fd1fdef5bbdac0b9e045eca99835f2875c8cb31350158f868276976a3f54d15e85d4d02ce5f3052db
@@ -2,10 +2,9 @@ before_install:
2
2
  - gem install bundler
3
3
  language: ruby
4
4
  rvm:
5
- - '2.3'
6
- - '2.4'
7
5
  - '2.5'
8
6
  - '2.6'
7
+ - '2.7'
9
8
  - ruby-head
10
9
  matrix:
11
10
  allow_failures:
@@ -6,14 +6,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ [Unreleased]: https://github.com/envato/zxcvbn-ruby/compare/v1.1.0...HEAD
10
+
11
+ ## [1.1.0] - 2020-07-16
12
+ ### Added
13
+ - Support for Ruby 2.7 ([#29])
14
+ - Gem metadata ([#29])
15
+
16
+ ### Removed
17
+ - Support for Ruby 2.3 ([#29])
18
+ - Support for Ruby 2.4 ([#29])
19
+
20
+ ### Fixed
21
+ - Invalid user dictionaries are handled more robustly ([#28])
22
+
23
+ [1.1.0]: https://github.com/envato/zxcvbn-ruby/compare/v1.0.0...v1.1.0
24
+ [28]: https://github.com/envato/zxcvbn-ruby/pull/28
25
+ [29]: https://github.com/envato/zxcvbn-ruby/pull/29
26
+
9
27
  ## [1.0.0] - 2019-05-14
10
28
  ### Added
11
- Adds more ported password checking features to bring this gem more up to date.
12
- spatial - Keyboard patterns
13
- repeat - Repeated characters
14
- sequence - easily guessable sequences
15
- date - date associations
16
- [PR for further details](https://github.com/envato/zxcvbn-ruby/pull/22)
29
+ - License info in the gemspec ([#21])
30
+ - More ported password checking features to bring this gem more up to date. ([#22])
31
+ - spatial - Keyboard patterns
32
+ - repeat - Repeated characters
33
+ - sequence - easily guessable sequences
34
+ - date - date associations
17
35
 
18
36
  ### Removed
19
- - This gem will no longer run on Ruby versions < 2.3
37
+ - This gem will no longer run on Ruby versions < 2.3 ([#25])
38
+
39
+ [1.0.0]: https://github.com/envato/zxcvbn-ruby/compare/v0.1.2...v1.0.0
40
+ [#21]: https://github.com/envato/zxcvbn-ruby/pull/21
41
+ [#22]: https://github.com/envato/zxcvbn-ruby/pull/22
42
+ [#25]: https://github.com/envato/zxcvbn-ruby/pull/25
@@ -0,0 +1,130 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ pete.johns@envato.com
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.0, available at
120
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
121
+
122
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
123
+ enforcement ladder](https://github.com/mozilla/diversity).
124
+
125
+ [homepage]: https://www.contributor-covenant.org
126
+
127
+ For answers to common questions about this code of conduct, see the FAQ at
128
+ https://www.contributor-covenant.org/faq. Translations are available at
129
+ https://www.contributor-covenant.org/translations.
130
+
data/Gemfile CHANGED
@@ -3,5 +3,8 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
+ gem 'guard'
7
+ gem 'guard-bundler', require: false
8
+ gem 'guard-rspec', require: false
6
9
  gem 'rake'
7
10
  end
@@ -0,0 +1,26 @@
1
+ guard :bundler do
2
+ require 'guard/bundler'
3
+ require 'guard/bundler/verify'
4
+ helper = Guard::Bundler::Verify.new
5
+
6
+ files = ['Gemfile']
7
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
8
+
9
+ # Assume files are symlinked from somewhere
10
+ files.each { |file| watch(helper.real_path(file)) }
11
+ end
12
+
13
+ guard :rspec, cmd: "bundle exec rspec" do
14
+ require "guard/rspec/dsl"
15
+ dsl = Guard::RSpec::Dsl.new(self)
16
+
17
+ # RSpec files
18
+ rspec = dsl.rspec
19
+ watch(rspec.spec_helper) { rspec.spec_dir }
20
+ watch(rspec.spec_support) { rspec.spec_dir }
21
+ watch(rspec.spec_files)
22
+
23
+ # Ruby files
24
+ ruby = dsl.ruby
25
+ dsl.watch_spec_files_for(ruby.lib_files)
26
+ end
File without changes
data/README.md CHANGED
@@ -1,17 +1,30 @@
1
- # zxcvbn-ruby [![Build Status](https://travis-ci.org/envato/zxcvbn-ruby.svg?branch=master)](https://travis-ci.org/envato/zxcvbn-ruby)
1
+ # zxcvbn-ruby
2
2
 
3
- Ruby port of [zxcvbn.js](https://github.com/dropbox/zxcvbn)
3
+ This is a Ruby port of Dropbox's [zxcvbn.js][zxcvbn.js] JavaScript library.
4
4
 
5
- ## Usage
5
+ ## Development status [![Build Status](https://travis-ci.org/envato/zxcvbn-ruby.svg?branch=master)](https://travis-ci.org/envato/zxcvbn-ruby)
6
6
 
7
- Gemfile:
7
+ `zxcvbn-ruby` is considered stable and is used in projects around [Envato][envato].
8
+
9
+ After checking out the repository, run `bundle install` to install dependencies.
10
+ Then, run `rake spec` to run the tests.
11
+
12
+ To install this gem onto your local machine, run `bundle exec rake install`.
13
+
14
+ To release a new version, update the version number in `version.rb`, and then
15
+ run `bundle exec rake release`, which will create a git tag for the version,
16
+ push git commits and tags, and push the `.gem` file to
17
+ [rubygems.org](https://rubygems.org).
18
+
19
+
20
+ ## Getting started [![Gem version](https://img.shields.io/gem/v/zxcvbn-ruby.svg?style=flat-square)](https://github.com/envato/zxcvbn-ruby) [![Gem downloads](https://img.shields.io/gem/dt/zxcvbn-ruby.svg?style=flat-square)](https://rubygems.org/gems/zxcvbn-ruby)
21
+
22
+ Add the following to your project's `Gemfile`:
8
23
 
9
24
  ```ruby
10
25
  gem 'zxcvbn-ruby', require: 'zxcvbn'
11
26
  ```
12
27
 
13
- [RubyGems.org gem replacement vulnerability and mitigation](http://blog.rubygems.org/2016/04/06/gem-replacement-vulnerability-and-mitigation.html): not affected.
14
-
15
28
  Example usage:
16
29
 
17
30
  ```ruby
@@ -107,3 +120,60 @@ $ irb
107
120
  information that can make cracking the value orders of magnitude easier for an
108
121
  attacker. For this reason we advise you not to store the results of
109
122
  `Zxcvbn::Tester#test`. Further reading: [A Tale of Security Gone Wrong](http://gavinmiller.io/2016/a-tale-of-security-gone-wrong/).
123
+
124
+ ## Contact
125
+
126
+ - [GitHub project](https://github.com/envato/zxcvbn-ruby)
127
+ - Bug reports and feature requests are welcome via [GitHub Issues](https://github.com/envato/zxcvbn-ruby/issues)
128
+
129
+ ## Maintainers
130
+
131
+ - [Pete Johns](https://github.com/johnsyweb)
132
+ - [Steve Hodgkiss](https://github.com/stevehodgkiss)
133
+
134
+ ## Authors
135
+
136
+ - [Steve Hodgkiss](https://github.com/stevehodgkiss)
137
+ - [Matthieu Aussaguel](https://github.com/matthieua)
138
+ - [_et al._](https://github.com/envato/zxcvbn-ruby/graphs/contributors)
139
+
140
+ ## License [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/envato/zxcvbn-ruby/blob/master/LICENSE.txt)
141
+
142
+ `zxcvbn-ruby` uses MIT license, the same as [zxcvbn.js][zxcvbn.js] itself. See
143
+ [`LICENSE.txt`](https://github.com/envato/zxcvbn-ruby/blob/master/LICENSE.txt)
144
+ for details.
145
+
146
+ ## Code of Conduct
147
+
148
+ We welcome contribution from everyone. Read more about it in
149
+ [`CODE_OF_CONDUCT.md`](https://github.com/envato/zxcvbn-ruby/blob/master/CODE_OF_CONDUCT.md).
150
+
151
+ ## Contributing [![PRs welcome](https://img.shields.io/badge/PRs-welcome-orange.svg?style=flat-square)](https://github.com/envato/zxcvbn-ruby/issues)
152
+
153
+ For bug fixes, documentation changes, and features:
154
+
155
+ 1. [Fork it](./fork)
156
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
157
+ 1. Commit your changes (`git commit -am 'Add some feature'`)
158
+ 1. Push to the branch (`git push origin my-new-feature`)
159
+ 1. Create a new Pull Request
160
+
161
+ For larger new features: Do everything as above, but first also make contact with the project maintainers to be sure your change fits with the project direction and you won't be wasting effort going in the wrong direction.
162
+
163
+ ## About [![code with heart by Envato](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-Envato-ff69b4.svg?style=flat-square)](https://github.com/envato/zxcvbn-ruby)
164
+
165
+ This project is maintained by the [Envato engineering team][webuild] and funded by [Envato][envato].
166
+
167
+ [<img src="http://opensource.envato.com/images/envato-oss-readme-logo.png" alt="Envato logo">][envato]
168
+
169
+ Encouraging the use and creation of open source software is one of the ways we
170
+ serve our community. See [our other projects][oss] or [come work with us][careers]
171
+ where you'll find an incredibly diverse, intelligent and capable group of people
172
+ who help make our company succeed and make our workplace fun, friendly and
173
+ happy.
174
+
175
+ [careers]: https://envato.com/careers/?utm_source=github
176
+ [envato]: https://envato.com?utm_source=github
177
+ [oss]: https://opensource.envato.com/?utm_source=github
178
+ [webuild]: https://webuild.envato.com?utm_source=github
179
+ [zxcvbn.js]: https://github.com/dropbox/zxcvbn
@@ -31,8 +31,8 @@ module Zxcvbn
31
31
  token = password[match.i..match.j]
32
32
  next if token.downcase == match.matched_word.downcase
33
33
  match_substitutions = {}
34
- substitution.each do |substitution, letter|
35
- match_substitutions[substitution] = letter if token.include?(substitution)
34
+ substitution.each do |s, letter|
35
+ match_substitutions[s] = letter if token.include?(s)
36
36
  end
37
37
  match.l33t = true
38
38
  match.token = password[match.i..match.j]
@@ -1,5 +1,7 @@
1
- require 'zxcvbn/data'
2
- require 'zxcvbn/password_strength'
1
+ # frozen_string_literal: true
2
+
3
+ require "zxcvbn/data"
4
+ require "zxcvbn/password_strength"
3
5
 
4
6
  module Zxcvbn
5
7
  # Allows you to test the strength of multiple passwords without reading and
@@ -21,15 +23,21 @@ module Zxcvbn
21
23
  end
22
24
 
23
25
  def test(password, user_inputs = [])
24
- PasswordStrength.new(@data).test(password, user_inputs)
26
+ PasswordStrength.new(@data).test(password, sanitize(user_inputs))
25
27
  end
26
28
 
27
29
  def add_word_lists(lists)
28
- lists.each_pair {|name, words| @data.add_word_list(name, words)}
30
+ lists.each_pair { |name, words| @data.add_word_list(name, sanitize(words)) }
29
31
  end
30
32
 
31
33
  def inspect
32
- "#<#{self.class}:0x#{self.__id__.to_s(16)}>"
34
+ "#<#{self.class}:0x#{__id__.to_s(16)}>"
35
+ end
36
+
37
+ private
38
+
39
+ def sanitize(user_inputs)
40
+ user_inputs.select { |i| i.respond_to?(:downcase) }
33
41
  end
34
42
  end
35
43
  end
@@ -1,3 +1,3 @@
1
1
  module Zxcvbn
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -1,19 +1,30 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
2
4
 
3
5
  describe Zxcvbn::Matchers::Dictionary do
4
- let(:matcher) { described_class.new('english', dictionary) }
5
- let(:dictionary) { Zxcvbn::Data.new.ranked_dictionaries['english'] }
6
+ subject(:matcher) { described_class.new("Test dictionary", dictionary) }
6
7
 
7
- it 'finds all the matches' do
8
- matches = matcher.matches('whatisinit')
9
- expect(matches.count).to eq(14)
10
- expected_matches = ['wha', 'what', 'ha', 'hat', 'a', 'at', 'tis', 'i', 'is',
11
- 'sin', 'i', 'in', 'i', 'it']
12
- expect(matches.map(&:matched_word)).to eq(expected_matches)
13
- end
8
+ describe "#matches" do
9
+ let(:matches) { matcher.matches(password) }
10
+ let(:matched_words) { matches.map(&:matched_word) }
11
+
12
+ context "Given a dictionary of English words" do
13
+ let(:dictionary) { Zxcvbn::Data.new.ranked_dictionaries["english"] }
14
+ let(:password) { "whatisinit" }
15
+
16
+ it "finds all the matches" do
17
+ expect(matched_words).to match_array %w[wha what ha hat a at tis i is sin i in i it]
18
+ end
19
+ end
20
+
21
+ context "Given a custom dictionary" do
22
+ let(:dictionary) { Zxcvbn::DictionaryRanker.rank_dictionary(%w[test AB10CD]) }
23
+ let(:password) { "AB10CD" }
14
24
 
15
- it 'matches uppercase' do
16
- matcher = described_class.new('user_inputs', Zxcvbn::DictionaryRanker.rank_dictionary(['test','AB10CD']))
17
- expect(matcher.matches('AB10CD')).not_to be_empty
25
+ it "matches uppercase passwords with normalised dictionary entries" do
26
+ expect(matched_words).to match_array(%w[ab10cd])
27
+ end
28
+ end
18
29
  end
19
- end
30
+ end
@@ -51,12 +51,14 @@ describe Zxcvbn::Matchers::L33t do
51
51
  end
52
52
 
53
53
  describe '#matches' do
54
- let(:matches) { matcher.matches('p@ssword') }
55
- # it doesn't match on 'password' because that's not in the english
56
- # dictionary/frequency list
54
+ subject(:matches) { matcher.matches('p@ssword') }
55
+
56
+ it "doesn't find 'password' because it's not in english.txt" do
57
+ expect(matches.map(&:matched_word)).not_to include "password"
58
+ end
57
59
 
58
60
  it 'finds the correct matches' do
59
- expect(matches.map(&:matched_word)).to eq([
61
+ expect(matches.map(&:matched_word)).to match_array([
60
62
  'pas',
61
63
  'a',
62
64
  'as',
@@ -65,7 +67,7 @@ describe Zxcvbn::Matchers::L33t do
65
67
  end
66
68
 
67
69
  it 'sets the token correctly on those matches' do
68
- expect(matches.map(&:token)).to eq([
70
+ expect(matches.map(&:token)).to match_array([
69
71
  'p@s',
70
72
  '@',
71
73
  '@s',
@@ -74,7 +76,7 @@ describe Zxcvbn::Matchers::L33t do
74
76
  end
75
77
 
76
78
  it 'sets the substituions used' do
77
- expect(matches.map(&:sub)).to eq([
79
+ expect(matches.map(&:sub)).to match_array([
78
80
  {'@' => 'a'},
79
81
  {'@' => 'a'},
80
82
  {'@' => 'a'},
@@ -82,4 +84,4 @@ describe Zxcvbn::Matchers::L33t do
82
84
  ])
83
85
  end
84
86
  end
85
- end
87
+ end
@@ -1,4 +1,7 @@
1
- require 'spec_helper'
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ require "spec_helper"
2
5
 
3
6
  describe Zxcvbn::Tester do
4
7
  let(:tester) { Zxcvbn::Tester.new }
@@ -9,13 +12,13 @@ describe Zxcvbn::Tester do
9
12
  js_result = js_zxcvbn(password)
10
13
 
11
14
  expect(ruby_result.calc_time).not_to be_nil
12
- expect(ruby_result.password).to eq js_result['password']
13
- expect(ruby_result.entropy).to eq js_result['entropy']
14
- expect(ruby_result.crack_time).to eq js_result['crack_time']
15
- expect(ruby_result.crack_time_display).to eq js_result['crack_time_display']
16
- expect(ruby_result.score).to eq js_result['score']
17
- expect(ruby_result.pattern).to eq js_result['pattern']
18
- expect(ruby_result.match_sequence.count).to eq js_result['match_sequence'].count
15
+ expect(ruby_result.password).to eq js_result["password"]
16
+ expect(ruby_result.entropy).to eq js_result["entropy"]
17
+ expect(ruby_result.crack_time).to eq js_result["crack_time"]
18
+ expect(ruby_result.crack_time_display).to eq js_result["crack_time_display"]
19
+ expect(ruby_result.score).to eq js_result["score"]
20
+ expect(ruby_result.pattern).to eq js_result["pattern"]
21
+ expect(ruby_result.match_sequence.count).to eq js_result["match_sequence"].count
19
22
 
20
23
  # NOTE: feedback didn't exist in the version of the JS library this gem
21
24
  # is based on, so instead we just check that it put `Feedback` in
@@ -24,33 +27,73 @@ describe Zxcvbn::Tester do
24
27
  end
25
28
  end
26
29
 
27
- context 'with a custom user dictionary' do
28
- it 'scores them against the user dictionary' do
29
- result = tester.test('themeforest', ['themeforest'])
30
+ context "with a custom user dictionary" do
31
+ it "scores them against the user dictionary" do
32
+ result = tester.test("themeforest", ["themeforest"])
30
33
  expect(result.entropy).to eq 0
31
34
  expect(result.score).to eq 0
32
35
  end
33
36
 
34
- it 'matches l33t substitutions on this dictionary' do
35
- result = tester.test('th3m3for3st', ['themeforest'])
37
+ it "matches l33t substitutions on this dictionary" do
38
+ result = tester.test("th3m3for3st", ["themeforest"])
36
39
  expect(result.entropy).to eq 1
37
40
  expect(result.score).to eq 0
38
41
  end
39
42
  end
40
43
 
41
- context 'with a custom global dictionary' do
42
- before { tester.add_word_lists('envato' => ['envato']) }
44
+ context "with Unicode entries in the password" do
45
+ it "validates the password" do
46
+ result = tester.test("✅🐴🔋staple", %w[Theme Forest themeforest])
47
+ expect(result.entropy).to be_positive
48
+ expect(result.score).to be_positive
49
+ end
50
+ end
51
+
52
+ context "with Unicode entries in the dictionary" do
53
+ it "validates the password" do
54
+ result = tester.test("correct horse battery staple", %w[✅ 🐴 🔋])
55
+ expect(result.entropy).to be_positive
56
+ expect(result.score).to be_positive
57
+ end
58
+ end
59
+
60
+ context "with Unicode entries in the password and the dictionary" do
61
+ it "validates the password" do
62
+ result = tester.test("✅🐴🔋staple", %w[✅ 🐴 🔋])
63
+ expect(result.entropy).to be_positive
64
+ expect(result.score).to be_zero
65
+ end
66
+ end
67
+
68
+ context "with invalid entries in the dictionary" do
69
+ it "ignores those entries" do
70
+ result = tester.test("themeforest", [nil, 1, "themeforest"])
71
+ expect(result.entropy).to eq 0
72
+ expect(result.score).to eq 0
73
+ end
74
+ end
75
+
76
+ context "with a custom global dictionary" do
77
+ before { tester.add_word_lists("envato" => ["envato"]) }
43
78
 
44
- it 'scores them against the dictionary' do
45
- result = tester.test('envato')
79
+ it "scores them against the dictionary" do
80
+ result = tester.test("envato")
46
81
  expect(result.entropy).to eq 0
47
82
  expect(result.score).to eq 0
48
83
  end
84
+
85
+ context "with invalid entries in a custom dictionary" do
86
+ before { tester.add_word_lists("themeforest" => [nil, 1, "themeforest"]) }
87
+
88
+ it "ignores those entries" do
89
+ expect(tester.test("themeforest")).to have_attributes(entropy: 0, score: 0, crack_time: 0)
90
+ end
91
+ end
49
92
  end
50
93
 
51
- context 'nil password' do
94
+ context "nil password" do
52
95
  specify do
53
- expect { tester.test(nil) }.to_not raise_error
96
+ expect(tester.test(nil)).to have_attributes(entropy: 0, score: 0, crack_time: 0)
54
97
  end
55
98
  end
56
- end
99
+ end
@@ -16,8 +16,16 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Zxcvbn::VERSION
17
17
  gem.license = 'MIT'
18
18
 
19
- gem.required_ruby_version = '~> 2.3'
19
+ gem.required_ruby_version = '~> 2.5'
20
20
 
21
21
  gem.add_development_dependency 'therubyracer'
22
22
  gem.add_development_dependency 'rspec'
23
+
24
+ gem.metadata = {
25
+ "bug_tracker_uri" => "https://github.com/envato/zxcvbn-ruby/issues",
26
+ "changelog_uri" => "https://github.com/envato/zxcvbn-ruby/blob/master/CHANGELOG.md",
27
+ "documentation_uri" => "https://github.com/envato/zxcvbn-ruby/blob/master/README.md",
28
+ "homepage_uri" => "https://github.com/envato/zxcvbn-ruby",
29
+ "source_code_uri" => "https://github.com/envato/zxcvbn-ruby"
30
+ }
23
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zxcvbn-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Hodgkiss
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-05-14 00:00:00.000000000 Z
12
+ date: 2020-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: therubyracer
@@ -51,8 +51,10 @@ files:
51
51
  - ".rspec"
52
52
  - ".travis.yml"
53
53
  - CHANGELOG.md
54
+ - CODE_OF_CONDUCT.md
54
55
  - Gemfile
55
- - LICENSE
56
+ - Guardfile
57
+ - LICENSE.txt
56
58
  - README.md
57
59
  - Rakefile
58
60
  - data/adjacency_graphs.json
@@ -119,7 +121,12 @@ files:
119
121
  homepage: http://github.com/envato/zxcvbn-ruby
120
122
  licenses:
121
123
  - MIT
122
- metadata: {}
124
+ metadata:
125
+ bug_tracker_uri: https://github.com/envato/zxcvbn-ruby/issues
126
+ changelog_uri: https://github.com/envato/zxcvbn-ruby/blob/master/CHANGELOG.md
127
+ documentation_uri: https://github.com/envato/zxcvbn-ruby/blob/master/README.md
128
+ homepage_uri: https://github.com/envato/zxcvbn-ruby
129
+ source_code_uri: https://github.com/envato/zxcvbn-ruby
123
130
  post_install_message:
124
131
  rdoc_options: []
125
132
  require_paths:
@@ -128,14 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
135
  requirements:
129
136
  - - "~>"
130
137
  - !ruby/object:Gem::Version
131
- version: '2.3'
138
+ version: '2.5'
132
139
  required_rubygems_version: !ruby/object:Gem::Requirement
133
140
  requirements:
134
141
  - - ">="
135
142
  - !ruby/object:Gem::Version
136
143
  version: '0'
137
144
  requirements: []
138
- rubygems_version: 3.0.3
145
+ rubygems_version: 3.1.2
139
146
  signing_key:
140
147
  specification_version: 4
141
148
  summary: ''