zxcvbn-ruby 1.2.0 β†’ 1.2.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -1
  3. data/README.md +1 -1
  4. data/lib/zxcvbn/clock.rb +11 -0
  5. data/lib/zxcvbn/crack_time.rb +4 -2
  6. data/lib/zxcvbn/data.rb +6 -4
  7. data/lib/zxcvbn/dictionary_ranker.rb +2 -0
  8. data/lib/zxcvbn/entropy.rb +38 -33
  9. data/lib/zxcvbn/feedback.rb +2 -0
  10. data/lib/zxcvbn/feedback_giver.rb +2 -0
  11. data/lib/zxcvbn/match.rb +2 -0
  12. data/lib/zxcvbn/matchers/date.rb +11 -8
  13. data/lib/zxcvbn/matchers/dictionary.rb +3 -1
  14. data/lib/zxcvbn/matchers/digits.rb +2 -0
  15. data/lib/zxcvbn/matchers/l33t.rb +6 -2
  16. data/lib/zxcvbn/matchers/new_l33t.rb +7 -4
  17. data/lib/zxcvbn/matchers/regex_helpers.rb +2 -0
  18. data/lib/zxcvbn/matchers/repeat.rb +3 -1
  19. data/lib/zxcvbn/matchers/sequences.rb +4 -2
  20. data/lib/zxcvbn/matchers/spatial.rb +5 -3
  21. data/lib/zxcvbn/matchers/year.rb +3 -1
  22. data/lib/zxcvbn/math.rb +3 -0
  23. data/lib/zxcvbn/omnimatch.rb +3 -1
  24. data/lib/zxcvbn/password_strength.rb +5 -3
  25. data/lib/zxcvbn/score.rb +3 -1
  26. data/lib/zxcvbn/scorer.rb +11 -7
  27. data/lib/zxcvbn/version.rb +1 -1
  28. data/lib/zxcvbn.rb +2 -0
  29. metadata +6 -102
  30. data/.github/workflows/ci.yml +0 -23
  31. data/.gitignore +0 -18
  32. data/.rspec +0 -1
  33. data/CODE_OF_CONDUCT.md +0 -130
  34. data/Gemfile +0 -10
  35. data/Guardfile +0 -26
  36. data/Rakefile +0 -22
  37. data/spec/dictionary_ranker_spec.rb +0 -12
  38. data/spec/feedback_giver_spec.rb +0 -212
  39. data/spec/matchers/date_spec.rb +0 -109
  40. data/spec/matchers/dictionary_spec.rb +0 -30
  41. data/spec/matchers/digits_spec.rb +0 -15
  42. data/spec/matchers/l33t_spec.rb +0 -87
  43. data/spec/matchers/repeat_spec.rb +0 -18
  44. data/spec/matchers/sequences_spec.rb +0 -21
  45. data/spec/matchers/spatial_spec.rb +0 -20
  46. data/spec/matchers/year_spec.rb +0 -15
  47. data/spec/omnimatch_spec.rb +0 -24
  48. data/spec/scorer_spec.rb +0 -5
  49. data/spec/scoring/crack_time_spec.rb +0 -106
  50. data/spec/scoring/entropy_spec.rb +0 -216
  51. data/spec/scoring/math_spec.rb +0 -135
  52. data/spec/spec_helper.rb +0 -54
  53. data/spec/support/js_helpers.rb +0 -34
  54. data/spec/support/js_source/adjacency_graphs.js +0 -8
  55. data/spec/support/js_source/compiled.js +0 -1188
  56. data/spec/support/js_source/frequency_lists.js +0 -10
  57. data/spec/support/js_source/init.coffee +0 -63
  58. data/spec/support/js_source/init.js +0 -95
  59. data/spec/support/js_source/matching.coffee +0 -444
  60. data/spec/support/js_source/matching.js +0 -685
  61. data/spec/support/js_source/scoring.coffee +0 -270
  62. data/spec/support/js_source/scoring.js +0 -390
  63. data/spec/support/matcher.rb +0 -35
  64. data/spec/tester_spec.rb +0 -99
  65. data/spec/zxcvbn_spec.rb +0 -24
  66. data/zxcvbn-ruby.gemspec +0 -33
data/spec/tester_spec.rb DELETED
@@ -1,99 +0,0 @@
1
- # coding: utf-8
2
- # frozen_string_literal: true
3
-
4
- require "spec_helper"
5
-
6
- describe Zxcvbn::Tester do
7
- let(:tester) { Zxcvbn::Tester.new }
8
-
9
- TEST_PASSWORDS.each do |password|
10
- it "gives back the same score for #{password}" do
11
- ruby_result = tester.test(password)
12
- js_result = js_zxcvbn(password)
13
-
14
- expect(ruby_result.calc_time).not_to be_nil
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
22
-
23
- # NOTE: feedback didn't exist in the version of the JS library this gem
24
- # is based on, so instead we just check that it put `Feedback` in
25
- # there. Real tests for its values go in `feedback_giver_spec.rb`.
26
- expect(ruby_result.feedback).to be_a Zxcvbn::Feedback
27
- end
28
- end
29
-
30
- context "with a custom user dictionary" do
31
- it "scores them against the user dictionary" do
32
- result = tester.test("themeforest", ["themeforest"])
33
- expect(result.entropy).to eq 0
34
- expect(result.score).to eq 0
35
- end
36
-
37
- it "matches l33t substitutions on this dictionary" do
38
- result = tester.test("th3m3for3st", ["themeforest"])
39
- expect(result.entropy).to eq 1
40
- expect(result.score).to eq 0
41
- end
42
- end
43
-
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"]) }
78
-
79
- it "scores them against the dictionary" do
80
- result = tester.test("envato")
81
- expect(result.entropy).to eq 0
82
- expect(result.score).to eq 0
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
92
- end
93
-
94
- context "nil password" do
95
- specify do
96
- expect(tester.test(nil)).to have_attributes(entropy: 0, score: 0, crack_time: 0)
97
- end
98
- end
99
- end
data/spec/zxcvbn_spec.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Zxcvbn.test' do
4
- context 'with a password' do
5
- it 'returns a result' do
6
- result = Zxcvbn.test('password')
7
- expect(result.entropy).to_not be_nil
8
- end
9
- end
10
-
11
- context 'with a password and user input' do
12
- it 'returns a result' do
13
- result = Zxcvbn.test('password', ['inputs'])
14
- expect(result.entropy).to_not be_nil
15
- end
16
- end
17
-
18
- context 'with a password, user input and custom word lists' do
19
- it 'returns a result' do
20
- result = Zxcvbn.test('password', ['inputs'], {'list' => ['words']})
21
- expect(result.entropy).to_not be_nil
22
- end
23
- end
24
- end
data/zxcvbn-ruby.gemspec DELETED
@@ -1,33 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/zxcvbn/version', __FILE__)
3
-
4
- GITHUB_URL = 'https://github.com/envato/zxcvbn-ruby'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.authors = ["Steve Hodgkiss", "Matthieu Aussaguel"]
8
- gem.email = ["steve@hodgkiss.me", "matthieu.aussaguel@gmail.com"]
9
- gem.description = %q{Ruby port of Dropboxs zxcvbn.js}
10
- gem.summary = %q{}
11
- gem.homepage = "http://github.com/envato/zxcvbn-ruby"
12
-
13
- gem.files = `git ls-files`.split($\)
14
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
- gem.name = "zxcvbn-ruby"
17
- gem.require_paths = ["lib"]
18
- gem.version = Zxcvbn::VERSION
19
- gem.license = 'MIT'
20
-
21
- gem.required_ruby_version = '>= 2.5'
22
-
23
- gem.add_development_dependency 'mini_racer'
24
- gem.add_development_dependency 'rspec'
25
-
26
- gem.metadata = {
27
- 'bug_tracker_uri' => "#{GITHUB_URL}/issues",
28
- 'changelog_uri' => "#{GITHUB_URL}/blob/HEAD/CHANGELOG.md",
29
- 'documentation_uri' => "#{GITHUB_URL}/blob/HEAD/README.md",
30
- 'homepage_uri' => GITHUB_URL,
31
- 'source_code_uri' => GITHUB_URL
32
- }
33
- end