have-i-been-pwned 0.1.2 → 0.1.3

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: c1fae8e9609676b44b47bacba29a2ee73b9d326262592f016826d404d941d3a1
4
- data.tar.gz: 14560b63260a53af339ad2499faa4cbff780500e574ec0dd2a37466aaf4b4191
3
+ metadata.gz: 6f95a981da0f20f1e2c806004d2a3da6f7e79b8ed57ac42d9e6ffe273d57d271
4
+ data.tar.gz: cf2d95d6bbe8fc36194231a73df3064f5204c024e6a21721f352be403103642f
5
5
  SHA512:
6
- metadata.gz: 7b9d2e52e61e4751487bb89914ecb3fc313bd6bf5c093d79d8b83134a77927c1fd5064e0bfb475e783f2d587f6b3f78ca6b775d1e04f9aad7ff6f5477629179c
7
- data.tar.gz: 80fe8f5e423e9164a63b60e7fcb0832f5a7dab0ad21b2db701c058534deb3941917de2adef288164a6e34c384a8c4fe52fd1c4a7257a0350750601ad776d8c46
6
+ metadata.gz: 921d961fb4f5b67ad7a5722ab79b6e2d119dbeba59840ca42a4727d782a411b4d360c6987ebcb25f4644d4a94531e2dcedfd7541dfeb81a886e896f717153c82
7
+ data.tar.gz: a9871a8501af72618ee35f540f8a2f88e66bc60baa8049e24e587ed1da061b1bcb35f5b19f48e0d54a14a0952b4840b00bd3354bd1373b5bd995bdc461a9dd6c
@@ -0,0 +1,5 @@
1
+ Gemfile.lock
2
+ pkg/
3
+ coverage/
4
+ bin/*
5
+ *.gem
@@ -0,0 +1 @@
1
+ SimpleCov.start "test_frameworks"
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ script:
5
+ - bundle exec rake
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: s7JXwHn+i4yWBshlBfkAa6H0ePUsXOZa40r0yiFvziGqh5RGtqT4MlGcYp/en8vSlBq1cHqxk1rkqBhN6uUlaKRTfLTRmOqBX/bLVzTwO8uRO6MgU3JkGxkL1YAFmQs6w/q5ZnYVhI35LN0dEi0vk2eDJayFvo1zw4nBJYWqAKqAw0uzoiCarEjqfknh8ZmMDr0KstJ1pDBVTsrUiQ/K0mfBCRK2Ho5qxk4uDed0UKSvmghhIg644K5SEHSA9tj1gelQTKxROCQB4kOXKl2y9+klUfDXAd27pzCYzt3Jt8ggZxDCZmFIun0YZzFoiEkDeHW0l9sxhntKncxQxyR0m2s6H8jE3fJBFJhg3/NAa9NBmED0evCrn2u1gqWM6rsDqlvLV3mA2Kh1irZsrGx78c1A54QAgPVZbN5CCKDymZibtkrGANyLPHOF/1oLl08Y3Y80UW+859yiR0qeixe6cJ6GsEg0e0Nhe6qeUcMGAstItzY6SzHCQCjL+bknnYILvupnvZQHyFUmY5lWYJDCD8k4+hg00LyAILrk6uIAx/TdH270s6Ep0liXtE6uCoGtcqjrCl9ENOsK9W5xSSe6c8CjBUhhnwO5fYdMtNYR7G44QwGb5FvisD+6jR8xxjUYdQsVOfjTq01jFz+Lgr/XZIn3mLbd8HSzq6jLiUt2zmY=
10
+ gem: have-i-been-pwned
11
+ on:
12
+ tags: true
13
+ repo: Dales-Lab/haveibeenpwned-ruby-sdk
14
+ notification:
15
+ slack:
16
+ rooms:
17
+ secure: YtIdbbN6Fflga3zJI9mN6OLmz6+8fxcJuvHlQO77NIea2CvBUP9jvJ5b2nc2aBxw8MJjJtVwvc0p5DlnA2w3tMSrk5KTJuoGNQa83LgzZEBNZOrvwSTwXoHRVWP+KoSnMwdhzknzZqC7dbskku/1MAfVnEvgpJxdrjeGF4z6/lDMb2GPHhRyYOaIiTLM8Ig/j8TeGAB5Javt4MbrQOgmhl76lNzNb6BhHUgVice4HNAEJKnYB+aKElGdVC1L+gy1Qqf7bGBpciz0omODo0UXxADV+KA2NzApFctEiElarvb2MN+K9PAu70ouz5q9GQ97KbGuVQzzpNJ2R5WHxrYTj4tRsAkhjHeUnv1Otues6Uhnc6jYLGZZHtQs5qyC3sFJz2bVMqJd0VIUl9BLnBPhRaZ2pOHYHJoLpVgNUX2WurEDew46MwnvojBnxOQ1A4/PLttH/n8ApYSQVM2Ynrgr7ZRdPCm14YfCrG6jDZylL6RqX5NsJFUKLP5wl5q8siESDVgecyMBFcTSitKI+BF7asIAth4Mw/Q3IUEPT8LwcQqVvvzssYbMUsJayhOC5aNXBQbadJeFRDZBdMeL1buNuZnITtBQTOdkkTxnf2DbK3eb5rBz9MDaUICm01QArADbANDrIl8qugnKta7o7xgn3yxa8FghmoklC9z+QCyYHSM=
data/Gemfile CHANGED
@@ -1,3 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gem 'codecov', :require => false, :group => :test
3
2
  gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Dales-Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # haveibeenpwned-ruby-sdk
2
+ Ruby wrapper for V2 haveibeenpwned.com API.
3
+
4
+ [![Build Status](https://travis-ci.org/Dales-Lab/haveibeenpwned-ruby-sdk.svg?branch=master)](https://travis-ci.org/Dales-Lab/haveibeenpwned-ruby-sdk) [![codecov](https://codecov.io/gh/Dales-Lab/haveibeenpwned-ruby-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/Dales-Lab/haveibeenpwned-ruby-sdk) [![Gem](https://img.shields.io/gem/v/have-i-been-pwned.svg?style=flat)](http://rubygems.org/gems/have-i-been-pwned "View this project on Rubygems")
5
+
6
+ ## Installation
7
+ ```
8
+ gem install have-i-been-pwned
9
+ ```
10
+
11
+ ## Use
12
+ #### General Use
13
+ ```
14
+ require 'have-i-been-pwned'
15
+ ...
16
+ # returns true if the password is found, false otherwise
17
+ result = HaveIBeenPwned::pwned 'abc123'
18
+ ```
19
+
20
+ #### Rails
21
+ ```
22
+ # Gemfile
23
+ gem 'have-i-been-pwned'
24
+ ```
25
+
26
+ ```
27
+ # some controller
28
+ # check the password
29
+ if !HaveIBeenPwned::pwned params[:password]
30
+ puts "Yay! You can use this password!"
31
+ else
32
+ puts "No! Bad!!"
33
+ end
34
+ ```
35
+
36
+ ## Contributing
37
+ - Open an issue about your change
38
+ - Fork it, DL it
39
+ - Run `bundle`
40
+ - Run `rake test`
41
+ - Make your additions, changes, fixes, etc. (Do not make changes to version, Rakefile or spec
42
+ - Add tests for the above (no pr acceptance without them)
43
+ - Run `rake test`
44
+ - Make your PR. :smile:
@@ -0,0 +1,2 @@
1
+ ignore:
2
+ - "**/version.rb"
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
3
+ require "version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'have-i-been-pwned'
7
+ s.version = HaveIBeenPwned::VERSION # see: lib/version.rb
8
+ s.platform = Gem::Platform::RUBY
9
+ s.licenses = ['MIT']
10
+ s.date = '2019-06-27'
11
+ s.summary = 'Check to see if your passwords are safe'
12
+ s.description = 'A simple gem to check and see if a given password was compromised by a hack. Special thanks to Troy Hunt for facilitating haveibeenpwned.'
13
+ s.authors = ["Dale Myszewski"]
14
+ s.email = 'dale@daleslab.com'
15
+ s.homepage = "https://github.com/Dales-Lab/haveibeenpwned-ruby-sdk"
16
+
17
+ s.add_runtime_dependency "httparty"
18
+
19
+ s.add_development_dependency "simplecov"
20
+ s.add_development_dependency "codecov", ">= 0.1.10"
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "mocha"
23
+ s.add_development_dependency "test-unit"
24
+
25
+ all_files = `git ls-files`.split("\n")
26
+ test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+
28
+ s.files = all_files - test_files
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
30
+ s.require_paths = ["lib"]
31
+ end
@@ -9,28 +9,25 @@ module HaveIBeenPwned
9
9
  # get a digest of the password
10
10
  digest = Digest::SHA1.hexdigest password
11
11
  # get the first 5 characters of the hash
12
- firstFive = digest[0..4]
12
+ first_five = digest[0..4]
13
13
  # make the API call
14
- results = HTTParty.get("https://api.pwnedpasswords.com/range/#{firstFive}")
15
- # if we get something back
16
- if results.code == 200
17
- # split the string based on line breaks into an array
18
- resArray = results.split("\n")
19
- # interate through the list of hashes
20
- resArray.each do |partial_hash|
21
- # hashes are formatted hash:count
22
- # ex. 0018A45C4D1DEF81644B54AB7F969B88D65:1
23
- # return true if we find a match
24
- return true if "#{firstFive}#{partial_hash.split(":")[0]}".upcase == digest.upcase
25
- end
14
+ results = HTTParty.get("https://api.pwnedpasswords.com/range/#{first_five}")
15
+
16
+ # guard: if we dont get something back
17
+ return unless results.code == 200
26
18
 
27
- # return false if we dont find anything
28
- return false
29
- else
30
- raise 'Troy Hunt has failed us. The API returned something not 200.'
19
+ # split the string based on line breaks into an array
20
+ res_array = results.split("\n")
21
+ # interate through the list of hashes
22
+ res_array.each do |partial_hash|
23
+ # hashes are formatted hash:count
24
+ # ex. 0018A45C4D1DEF81644B54AB7F969B88D65:1
25
+ # return true if we find a match
26
+ return true if "#{first_five}#{partial_hash.split(":")[0]}".upcase == digest.upcase
31
27
  end
32
- else
33
- raise 'You must provide a password to check!'
28
+
29
+ # return false if we dont find anything
30
+ return false
34
31
  end
35
32
  end
36
33
  end
@@ -1,3 +1,3 @@
1
1
  module HaveIBeenPwned
2
- VERSION = "0.1.2"
2
+ VERSION = '0.1.3'.freeze
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ # SimpleCov.start
3
+ SimpleCov.start 'rails' do
4
+ add_filter "/test/"
5
+ end
6
+
7
+ require 'codecov'
8
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
9
+
10
+ require 'test/unit'
11
+ require 'mocha/setup'
12
+
13
+ require 'have_i_been_pwned'
14
+ require 'version'
@@ -1,7 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'have_i_been_pwned'
1
+ require 'helper'
3
2
 
4
- class HolaTest < Minitest::Test
3
+ class PwnedTest < Test::Unit::TestCase #Minitest::Test
5
4
  def test_abc123_is_found
6
5
  assert_equal true, HaveIBeenPwned::pwned('abc123')
7
6
  end
@@ -17,4 +16,10 @@ class HolaTest < Minitest::Test
17
16
  def test_not_actually_providing_a_password_is_silly
18
17
  assert_equal false, HaveIBeenPwned::pwned('')
19
18
  end
19
+
20
+ def test_no_password_at_all_raises
21
+ assert_raise("RuntimeError") {
22
+ HaveIBeenPwned::pwned
23
+ }
24
+ end
20
25
  end
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+
3
+ class VersionTest < Test::Unit::TestCase
4
+ def test_version_valid
5
+ assert_match(/^\d+.\d+.\d$/, HaveIBeenPwned::VERSION)
6
+ end
7
+
8
+ def test_version_exists
9
+ assert_not_nil(HaveIBeenPwned::VERSION)
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: have-i-been-pwned
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Myszewski
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.10
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.10
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rake
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +67,21 @@ dependencies:
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
- name: minitest
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - ">="
@@ -59,11 +101,20 @@ executables: []
59
101
  extensions: []
60
102
  extra_rdoc_files: []
61
103
  files:
104
+ - ".gitignore"
105
+ - ".simplecov"
106
+ - ".travis.yml"
62
107
  - Gemfile
108
+ - LICENSE
109
+ - README.md
63
110
  - Rakefile
111
+ - codecov.yml
112
+ - have-i-been-pwned.gemspec
64
113
  - lib/have_i_been_pwned.rb
65
114
  - lib/version.rb
115
+ - test/helper.rb
66
116
  - test/test_have_i_been_pwned.rb
117
+ - test/test_version.rb
67
118
  homepage: https://github.com/Dales-Lab/haveibeenpwned-ruby-sdk
68
119
  licenses:
69
120
  - MIT
@@ -72,7 +123,6 @@ post_install_message:
72
123
  rdoc_options: []
73
124
  require_paths:
74
125
  - lib
75
- - test
76
126
  required_ruby_version: !ruby/object:Gem::Requirement
77
127
  requirements:
78
128
  - - ">="