pwned 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/docs/NotPwnedValidator.html +79 -16
- data/docs/Pwned.html +2 -2
- data/docs/Pwned/Error.html +1 -1
- data/docs/Pwned/Password.html +1 -1
- data/docs/Pwned/TimeoutError.html +1 -1
- data/docs/PwnedValidator.html +1 -1
- data/docs/_index.html +1 -1
- data/docs/file.README.html +4 -2
- data/docs/index.html +4 -2
- data/docs/top-level-namespace.html +1 -1
- data/lib/pwned/not_pwned_validator.rb +14 -0
- data/lib/pwned/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6891bb23ef6923eaad6c5af0b4fa2d36471c9a6903fbb66940720c6a5a69c2b
|
4
|
+
data.tar.gz: d138630dcac1204a01adfa731cce9a52ca984b67544f4c0beabe3e51f56d28ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89fca08322c92a4866d774dd5d2bce8d495326a99d7dfa8b2e8fe12b43ab3d57c0ed29f9aa8dab5d94ed5c002127701cd57daa43f9a621804232c02a4122d15
|
7
|
+
data.tar.gz: 67a0aaf46f9d84ee81b36e39e72d761aa7b08293246d7fec3abb35bb122d38cf2cd17519850b97573d16bbe346680de6478b1a569c47a1600085b4167e7faa51
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--output-dir docs
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# Changelog for `Pwned`
|
2
2
|
|
3
|
-
## Ongoing [☰](https://github.com/philnash/pwned/compare/v1.1
|
3
|
+
## Ongoing [☰](https://github.com/philnash/pwned/compare/v1.2.1...master)
|
4
4
|
|
5
5
|
...
|
6
6
|
|
7
|
+
## 1.2.1 (March 17, 2018) [☰](https://github.com/philnash/pwned/commits/v1.2.1)
|
8
|
+
|
9
|
+
* Minor updates
|
10
|
+
* Validator no longer raises `TypeError` when password is `nil`
|
11
|
+
|
7
12
|
## 1.2.0 (March 15, 2018) [☰](https://github.com/philnash/pwned/commits/v1.2.0)
|
8
13
|
|
9
14
|
* Major updates
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
An easy, Ruby way to use the Pwned Passwords API.
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/pwned.svg)](https://rubygems.org/gems/pwned) [![Build Status](https://travis-ci.org/philnash/pwned.svg?branch=master)](https://travis-ci.org/philnash/pwned) [![Maintainability](https://codeclimate.com/github/philnash/pwned/badges/gpa.svg)](https://codeclimate.com/github/philnash/pwned/maintainability)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/pwned.svg)](https://rubygems.org/gems/pwned) [![Build Status](https://travis-ci.org/philnash/pwned.svg?branch=master)](https://travis-ci.org/philnash/pwned) [![Maintainability](https://codeclimate.com/github/philnash/pwned/badges/gpa.svg)](https://codeclimate.com/github/philnash/pwned/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/pwned.svg?branch=master)](https://inch-ci.org/github/philnash/pwned)
|
6
6
|
|
7
7
|
[API docs](https://philnash.github.io/pwned/) | [GitHub repo](https://github.com/philnash/pwned)
|
8
8
|
|
data/docs/NotPwnedValidator.html
CHANGED
@@ -335,11 +335,72 @@ then the record is marked as invalid.</p>
|
|
335
335
|
valid or invalid. Alternatively it will run an associated proc or re-raise
|
336
336
|
the original error.</p>
|
337
337
|
|
338
|
+
<p>The validation will short circuit and return with no errors added if the
|
339
|
+
password is blank. The <code>Pwned::Password</code> initializer expects the
|
340
|
+
password to be a string and will throw a <code>TypeError</code> if it is
|
341
|
+
<code>nil</code>. Also, technically the empty string is not a password that
|
342
|
+
is reported to be found in data breaches, so returns <code>false</code>,
|
343
|
+
short circuiting that using <code>value.blank?</code> saves us a trip to
|
344
|
+
the API.</p>
|
345
|
+
|
338
346
|
|
339
347
|
</div>
|
340
348
|
</div>
|
341
349
|
<div class="tags">
|
350
|
+
<p class="tag_title">Parameters:</p>
|
351
|
+
<ul class="param">
|
352
|
+
|
353
|
+
<li>
|
354
|
+
|
355
|
+
<span class='name'>record</span>
|
356
|
+
|
357
|
+
|
358
|
+
<span class='type'>(<tt>ActiveModel::Validations</tt>)</span>
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
—
|
363
|
+
<div class='inline'>
|
364
|
+
<p>The object being validated</p>
|
365
|
+
</div>
|
366
|
+
|
367
|
+
</li>
|
342
368
|
|
369
|
+
<li>
|
370
|
+
|
371
|
+
<span class='name'>attribute</span>
|
372
|
+
|
373
|
+
|
374
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
—
|
379
|
+
<div class='inline'>
|
380
|
+
<p>The attribute on the record that is currently being validated.</p>
|
381
|
+
</div>
|
382
|
+
|
383
|
+
</li>
|
384
|
+
|
385
|
+
<li>
|
386
|
+
|
387
|
+
<span class='name'>value</span>
|
388
|
+
|
389
|
+
|
390
|
+
<span class='type'>(<tt>String</tt>)</span>
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
—
|
395
|
+
<div class='inline'>
|
396
|
+
<p>The value of the attribute on the record that is the subject of the
|
397
|
+
validation</p>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
</li>
|
401
|
+
|
402
|
+
</ul>
|
403
|
+
|
343
404
|
<p class="tag_title">Since:</p>
|
344
405
|
<ul class="since">
|
345
406
|
|
@@ -363,30 +424,32 @@ the original error.</p>
|
|
363
424
|
<pre class="lines">
|
364
425
|
|
365
426
|
|
366
|
-
64
|
367
|
-
65
|
368
|
-
66
|
369
|
-
67
|
370
|
-
68
|
371
|
-
69
|
372
|
-
70
|
373
|
-
71
|
374
|
-
72
|
375
|
-
73
|
376
|
-
74
|
377
|
-
75
|
378
|
-
76
|
379
427
|
77
|
380
428
|
78
|
381
429
|
79
|
382
430
|
80
|
383
431
|
81
|
384
|
-
82
|
432
|
+
82
|
433
|
+
83
|
434
|
+
84
|
435
|
+
85
|
436
|
+
86
|
437
|
+
87
|
438
|
+
88
|
439
|
+
89
|
440
|
+
90
|
441
|
+
91
|
442
|
+
92
|
443
|
+
93
|
444
|
+
94
|
445
|
+
95
|
446
|
+
96</pre>
|
385
447
|
</td>
|
386
448
|
<td>
|
387
|
-
<pre class="code"><span class="info file"># File 'lib/pwned/not_pwned_validator.rb', line
|
449
|
+
<pre class="code"><span class="info file"># File 'lib/pwned/not_pwned_validator.rb', line 77</span>
|
388
450
|
|
389
451
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_each'>validate_each</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
452
|
+
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
|
390
453
|
<span class='kw'>begin</span>
|
391
454
|
<span class='id identifier rubyid_pwned_check'>pwned_check</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_request_options'>request_options</span><span class='rparen'>)</span>
|
392
455
|
<span class='kw'>if</span> <span class='id identifier rubyid_pwned_check'>pwned_check</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span> <span class='op'>></span> <span class='id identifier rubyid_threshold'>threshold</span>
|
@@ -415,7 +478,7 @@ the original error.</p>
|
|
415
478
|
</div>
|
416
479
|
|
417
480
|
<div id="footer">
|
418
|
-
Generated on
|
481
|
+
Generated on Sat Mar 17 09:15:06 2018 by
|
419
482
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
420
483
|
0.9.12 (ruby-2.5.0).
|
421
484
|
</div>
|
data/docs/Pwned.html
CHANGED
@@ -125,7 +125,7 @@ getting the results for a password.</p>
|
|
125
125
|
|
126
126
|
</div>
|
127
127
|
</dt>
|
128
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.1
|
128
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.2.1</span><span class='tstring_end'>"</span></span></pre></dd>
|
129
129
|
|
130
130
|
</dl>
|
131
131
|
|
@@ -503,7 +503,7 @@ getting the results for a password.</p>
|
|
503
503
|
</div>
|
504
504
|
|
505
505
|
<div id="footer">
|
506
|
-
Generated on
|
506
|
+
Generated on Sat Mar 17 09:15:06 2018 by
|
507
507
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
508
508
|
0.9.12 (ruby-2.5.0).
|
509
509
|
</div>
|
data/docs/Pwned/Error.html
CHANGED
@@ -139,7 +139,7 @@ requests to the Pwned Passwords API.</p>
|
|
139
139
|
</div>
|
140
140
|
|
141
141
|
<div id="footer">
|
142
|
-
Generated on
|
142
|
+
Generated on Sat Mar 17 09:15:06 2018 by
|
143
143
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
144
144
|
0.9.12 (ruby-2.5.0).
|
145
145
|
</div>
|
data/docs/Pwned/Password.html
CHANGED
@@ -915,7 +915,7 @@ A user agent is provided as requested in the documentation.</p>
|
|
915
915
|
</div>
|
916
916
|
|
917
917
|
<div id="footer">
|
918
|
-
Generated on
|
918
|
+
Generated on Sat Mar 17 09:15:06 2018 by
|
919
919
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
920
920
|
0.9.12 (ruby-2.5.0).
|
921
921
|
</div>
|
@@ -142,7 +142,7 @@
|
|
142
142
|
</div>
|
143
143
|
|
144
144
|
<div id="footer">
|
145
|
-
Generated on
|
145
|
+
Generated on Sat Mar 17 09:15:06 2018 by
|
146
146
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
147
147
|
0.9.12 (ruby-2.5.0).
|
148
148
|
</div>
|
data/docs/PwnedValidator.html
CHANGED
@@ -182,7 +182,7 @@ removed</p>
|
|
182
182
|
</div>
|
183
183
|
|
184
184
|
<div id="footer">
|
185
|
-
Generated on
|
185
|
+
Generated on Sat Mar 17 09:15:06 2018 by
|
186
186
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
187
187
|
0.9.12 (ruby-2.5.0).
|
188
188
|
</div>
|
data/docs/_index.html
CHANGED
@@ -152,7 +152,7 @@
|
|
152
152
|
</div>
|
153
153
|
|
154
154
|
<div id="footer">
|
155
|
-
Generated on
|
155
|
+
Generated on Sat Mar 17 09:15:05 2018 by
|
156
156
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
157
157
|
0.9.12 (ruby-2.5.0).
|
158
158
|
</div>
|
data/docs/file.README.html
CHANGED
@@ -67,7 +67,9 @@ src="https://badge.fury.io/rb/pwned.svg"></a> <a
|
|
67
67
|
href="https://travis-ci.org/philnash/pwned"><img
|
68
68
|
src="https://travis-ci.org/philnash/pwned.svg?branch=master"></a> <a
|
69
69
|
href="https://codeclimate.com/github/philnash/pwned/maintainability"><img
|
70
|
-
src="https://codeclimate.com/github/philnash/pwned/badges/gpa.svg"></a
|
70
|
+
src="https://codeclimate.com/github/philnash/pwned/badges/gpa.svg"></a> <a
|
71
|
+
href="https://inch-ci.org/github/philnash/pwned"><img
|
72
|
+
src="https://inch-ci.org/github/philnash/pwned.svg?branch=master"></a></p>
|
71
73
|
|
72
74
|
<p><a href="https://philnash.github.io/pwned/">API docs</a> | <a
|
73
75
|
href="https://github.com/philnash/pwned">GitHub repo</a></p>
|
@@ -282,7 +284,7 @@ of conduct</a>.</p>
|
|
282
284
|
</div></div>
|
283
285
|
|
284
286
|
<div id="footer">
|
285
|
-
Generated on
|
287
|
+
Generated on Sat Mar 17 09:15:05 2018 by
|
286
288
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
287
289
|
0.9.12 (ruby-2.5.0).
|
288
290
|
</div>
|
data/docs/index.html
CHANGED
@@ -67,7 +67,9 @@ src="https://badge.fury.io/rb/pwned.svg"></a> <a
|
|
67
67
|
href="https://travis-ci.org/philnash/pwned"><img
|
68
68
|
src="https://travis-ci.org/philnash/pwned.svg?branch=master"></a> <a
|
69
69
|
href="https://codeclimate.com/github/philnash/pwned/maintainability"><img
|
70
|
-
src="https://codeclimate.com/github/philnash/pwned/badges/gpa.svg"></a
|
70
|
+
src="https://codeclimate.com/github/philnash/pwned/badges/gpa.svg"></a> <a
|
71
|
+
href="https://inch-ci.org/github/philnash/pwned"><img
|
72
|
+
src="https://inch-ci.org/github/philnash/pwned.svg?branch=master"></a></p>
|
71
73
|
|
72
74
|
<p><a href="https://philnash.github.io/pwned/">API docs</a> | <a
|
73
75
|
href="https://github.com/philnash/pwned">GitHub repo</a></p>
|
@@ -282,7 +284,7 @@ of conduct</a>.</p>
|
|
282
284
|
</div></div>
|
283
285
|
|
284
286
|
<div id="footer">
|
285
|
-
Generated on
|
287
|
+
Generated on Sat Mar 17 09:15:05 2018 by
|
286
288
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
287
289
|
0.9.12 (ruby-2.5.0).
|
288
290
|
</div>
|
@@ -102,7 +102,7 @@
|
|
102
102
|
</div>
|
103
103
|
|
104
104
|
<div id="footer">
|
105
|
-
Generated on
|
105
|
+
Generated on Sat Mar 17 09:15:05 2018 by
|
106
106
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
107
|
0.9.12 (ruby-2.5.0).
|
108
108
|
</div>
|
@@ -61,7 +61,21 @@ class NotPwnedValidator < ActiveModel::EachValidator
|
|
61
61
|
# In the case of an API error the validator will either mark the
|
62
62
|
# record as valid or invalid. Alternatively it will run an associated proc or
|
63
63
|
# re-raise the original error.
|
64
|
+
#
|
65
|
+
# The validation will short circuit and return with no errors added if the
|
66
|
+
# password is blank. The +Pwned::Password+ initializer expects the password to
|
67
|
+
# be a string and will throw a +TypeError+ if it is +nil+. Also, technically
|
68
|
+
# the empty string is not a password that is reported to be found in data
|
69
|
+
# breaches, so returns +false+, short circuiting that using +value.blank?+
|
70
|
+
# saves us a trip to the API.
|
71
|
+
#
|
72
|
+
# @param record [ActiveModel::Validations] The object being validated
|
73
|
+
# @param attribute [Symbol] The attribute on the record that is currently
|
74
|
+
# being validated.
|
75
|
+
# @param value [String] The value of the attribute on the record that is the
|
76
|
+
# subject of the validation
|
64
77
|
def validate_each(record, attribute, value)
|
78
|
+
return if value.blank?
|
65
79
|
begin
|
66
80
|
pwned_check = Pwned::Password.new(value, request_options)
|
67
81
|
if pwned_check.pwned_count > threshold
|
data/lib/pwned/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwned
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- ".yardopts"
|
93
94
|
- CHANGELOG.md
|
94
95
|
- CODE_OF_CONDUCT.md
|
95
96
|
- Gemfile
|