cracklib_reloaded 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf3c518445e1756f049ecf21ca6fa4c0b7359885
4
+ data.tar.gz: 88ca88adfe2b35e98556b1a76b741f79173b3962
5
+ SHA512:
6
+ metadata.gz: 74b9ca5b4349c6418aeb3f1a789fadb372591f6c9be86d38cc023468a61f3ad8db5f5af5d260f82236639c42c21e4193749b5b90dc5e0a5a1eac4fe548ffec73
7
+ data.tar.gz: 1ca16d928512534d37d9e10728b1095035189f7753953b35eaa52699027c27dd117b5932869d6cc3cbf32cf0557aa5c079847765b380f40813559dd011c015c4
data/.gitignore ADDED
@@ -0,0 +1,304 @@
1
+
2
+ # Created by https://www.gitignore.io/api/vim,git,ruby,macos,linux,emacs,rubymine,sublimetext,rails
3
+
4
+ ### Emacs ###
5
+ # -*- mode: gitignore; -*-
6
+ *~
7
+ \#*\#
8
+ /.emacs.desktop
9
+ /.emacs.desktop.lock
10
+ *.elc
11
+ auto-save-list
12
+ tramp
13
+ .\#*
14
+
15
+ # Org-mode
16
+ .org-id-locations
17
+ *_archive
18
+
19
+ # flymake-mode
20
+ *_flymake.*
21
+
22
+ # eshell files
23
+ /eshell/history
24
+ /eshell/lastdir
25
+
26
+ # elpa packages
27
+ /elpa/
28
+
29
+ # reftex files
30
+ *.rel
31
+
32
+ # AUCTeX auto folder
33
+ /auto/
34
+
35
+ # cask packages
36
+ .cask/
37
+ dist/
38
+
39
+ # Flycheck
40
+ flycheck_*.el
41
+
42
+ # server auth directory
43
+ /server/
44
+
45
+ # projectiles files
46
+ .projectile
47
+
48
+ # directory configuration
49
+ .dir-locals.el
50
+
51
+ ### Git ###
52
+ *.orig
53
+
54
+ ### Linux ###
55
+
56
+ # temporary files which can be created if a process still has a handle open of a deleted file
57
+ .fuse_hidden*
58
+
59
+ # KDE directory preferences
60
+ .directory
61
+
62
+ # Linux trash folder which might appear on any partition or disk
63
+ .Trash-*
64
+
65
+ # .nfs files are created when an open file is removed but is still being accessed
66
+ .nfs*
67
+
68
+ ### macOS ###
69
+ *.DS_Store
70
+ .AppleDouble
71
+ .LSOverride
72
+
73
+ # Icon must end with two \r
74
+ Icon
75
+
76
+ # Thumbnails
77
+ ._*
78
+
79
+ # Files that might appear in the root of a volume
80
+ .DocumentRevisions-V100
81
+ .fseventsd
82
+ .Spotlight-V100
83
+ .TemporaryItems
84
+ .Trashes
85
+ .VolumeIcon.icns
86
+ .com.apple.timemachine.donotpresent
87
+
88
+ # Directories potentially created on remote AFP share
89
+ .AppleDB
90
+ .AppleDesktop
91
+ Network Trash Folder
92
+ Temporary Items
93
+ .apdisk
94
+
95
+ ### Rails ###
96
+ *.rbc
97
+ capybara-*.html
98
+ .rspec
99
+ /log
100
+ /tmp
101
+ /db/*.sqlite3
102
+ /db/*.sqlite3-journal
103
+ /public/system
104
+ /coverage/
105
+ /spec/tmp
106
+ rerun.txt
107
+ pickle-email-*.html
108
+
109
+ # TODO Comment out this rule if you are OK with secrets being uploaded to the repo
110
+ config/initializers/secret_token.rb
111
+
112
+ # Only include if you have production secrets in this file, which is no longer a Rails default
113
+ # config/secrets.yml
114
+
115
+ # dotenv
116
+ # TODO Comment out this rule if environment variables can be committed
117
+ .env
118
+
119
+ ## Environment normalization:
120
+ /.bundle
121
+ /vendor/bundle
122
+
123
+ # these should all be checked in to normalize the environment:
124
+ Gemfile.lock
125
+ .ruby-version
126
+ .ruby-gemset
127
+
128
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
129
+ .rvmrc
130
+
131
+ # if using bower-rails ignore default bower_components path bower.json files
132
+ /vendor/assets/bower_components
133
+ *.bowerrc
134
+ bower.json
135
+
136
+ # Ignore pow environment settings
137
+ .powenv
138
+
139
+ # Ignore Byebug command history file.
140
+ .byebug_history
141
+
142
+ ### Ruby ###
143
+ *.gem
144
+ /.config
145
+ /InstalledFiles
146
+ /pkg/
147
+ /spec/reports/
148
+ /spec/examples.txt
149
+ /test/tmp/
150
+ /test/version_tmp/
151
+ /tmp/
152
+ .rspec-local
153
+
154
+ # Used by dotenv library to load environment variables.
155
+ # .env
156
+
157
+ ## Specific to RubyMotion:
158
+ .dat*
159
+ .repl_history
160
+ build/
161
+ *.bridgesupport
162
+ build-iPhoneOS/
163
+ build-iPhoneSimulator/
164
+
165
+ ## Specific to RubyMotion (use of CocoaPods):
166
+ #
167
+ # We recommend against adding the Pods directory to your .gitignore. However
168
+ # you should judge for yourself, the pros and cons are mentioned at:
169
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
170
+ #
171
+ # vendor/Pods/
172
+
173
+ ## Documentation cache and generated files:
174
+ /.yardoc/
175
+ /_yardoc/
176
+ /doc/
177
+ /rdoc/
178
+
179
+ ## Environment normalization:
180
+ /.bundle/
181
+ /lib/bundler/man/
182
+
183
+ # for a library or gem, you might want to ignore these files since the code is
184
+ # intended to run in multiple environments; otherwise, check them in:
185
+ # Gemfile.lock
186
+ # .ruby-version
187
+ # .ruby-gemset
188
+
189
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
190
+
191
+ ### RubyMine ###
192
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
193
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
194
+
195
+ # User-specific stuff:
196
+ .idea/**/workspace.xml
197
+ .idea/**/tasks.xml
198
+ .idea/dictionaries
199
+
200
+ # Sensitive or high-churn files:
201
+ .idea/**/dataSources/
202
+ .idea/**/dataSources.ids
203
+ .idea/**/dataSources.xml
204
+ .idea/**/dataSources.local.xml
205
+ .idea/**/sqlDataSources.xml
206
+ .idea/**/dynamic.xml
207
+ .idea/**/uiDesigner.xml
208
+
209
+ # Gradle:
210
+ .idea/**/gradle.xml
211
+ .idea/**/libraries
212
+
213
+ # CMake
214
+ cmake-build-debug/
215
+
216
+ # Mongo Explorer plugin:
217
+ .idea/**/mongoSettings.xml
218
+
219
+ ## File-based project format:
220
+ *.iws
221
+
222
+ ## Plugin-specific files:
223
+
224
+ # IntelliJ
225
+ /out/
226
+
227
+ # mpeltonen/sbt-idea plugin
228
+ .idea_modules/
229
+
230
+ # JIRA plugin
231
+ atlassian-ide-plugin.xml
232
+
233
+ # Cursive Clojure plugin
234
+ .idea/replstate.xml
235
+
236
+ # Crashlytics plugin (for Android Studio and IntelliJ)
237
+ com_crashlytics_export_strings.xml
238
+ crashlytics.properties
239
+ crashlytics-build.properties
240
+ fabric.properties
241
+
242
+ ### RubyMine Patch ###
243
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
244
+
245
+ # *.iml
246
+ # modules.xml
247
+ # .idea/misc.xml
248
+ # *.ipr
249
+
250
+ # Sonarlint plugin
251
+ .idea/sonarlint
252
+
253
+ ### SublimeText ###
254
+ # cache files for sublime text
255
+ *.tmlanguage.cache
256
+ *.tmPreferences.cache
257
+ *.stTheme.cache
258
+
259
+ # workspace files are user-specific
260
+ *.sublime-workspace
261
+
262
+ # project files should be checked into the repository, unless a significant
263
+ # proportion of contributors will probably not be using SublimeText
264
+ # *.sublime-project
265
+
266
+ # sftp configuration file
267
+ sftp-config.json
268
+
269
+ # Package control specific files
270
+ Package Control.last-run
271
+ Package Control.ca-list
272
+ Package Control.ca-bundle
273
+ Package Control.system-ca-bundle
274
+ Package Control.cache/
275
+ Package Control.ca-certs/
276
+ Package Control.merged-ca-bundle
277
+ Package Control.user-ca-bundle
278
+ oscrypto-ca-bundle.crt
279
+ bh_unicode_properties.cache
280
+
281
+ # Sublime-github package stores a github token in this file
282
+ # https://packagecontrol.io/packages/sublime-github
283
+ GitHub.sublime-settings
284
+
285
+ ### Vim ###
286
+ # swap
287
+ [._]*.s[a-v][a-z]
288
+ [._]*.sw[a-p]
289
+ [._]s[a-v][a-z]
290
+ [._]sw[a-p]
291
+ # session
292
+ Session.vim
293
+ # temporary
294
+ .netrwhist
295
+ # auto-generated tag files
296
+ tags
297
+
298
+ # End of https://www.gitignore.io/api/vim,git,ruby,macos,linux,emacs,rubymine,sublimetext,rails
299
+
300
+ # rspec failure tracking
301
+ .rspec_status
302
+
303
+ # Custom output
304
+ rubocop_output.json
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,37 @@
1
+ require: rubocop-rspec
2
+
3
+ # Use this to ingore current violations (and fix them later) run:
4
+ # bundle exec rubocop --auto-gen-config
5
+ inherit_from: .rubocop_todo.yml
6
+
7
+ # https://github.com/bbatsov/rubocop/blob/master/config/default.yml
8
+
9
+ AllCops:
10
+ DisplayCopNames: true
11
+ EnabledByDefault: true
12
+ TargetRubyVersion: 2.4
13
+
14
+ Metrics/LineLength:
15
+ Max: 120
16
+
17
+ Metrics/BlockLength:
18
+ Exclude:
19
+ - 'Guardfile'
20
+ - '**/*_spec.rb'
21
+ - '*.gemspec'
22
+
23
+ # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
24
+
25
+ Style/Documentation:
26
+ Enabled: false
27
+
28
+ # https://github.com/bbatsov/rubocop/blob/master/config/disabled.yml
29
+
30
+ Style/Copyright:
31
+ Enabled: false
32
+
33
+ Style/MethodCallWithArgsParentheses:
34
+ Enabled: false
35
+
36
+ Style/DocumentationMethod:
37
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-05-08 13:08:19 +0200 using RuboCop version 0.48.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Change Log
2
+
3
+
4
+
5
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rubyconvict@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in cracklib_reloaded.gemspec
6
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # USE PRIVATE GLOBAL CONFIG TO CUSTOMIZE:
21
+ # ~/.guard.rb
22
+ # notification :growl # on OSX with growl notifications installed
23
+ # clearing :on # clears terminal
24
+ #
25
+
26
+ guard 'reek' do
27
+ watch(/.+\.rb$/)
28
+ watch('.reek')
29
+ end
30
+
31
+ # Note: The cmd option is now required due to the increasing number of ways
32
+ # rspec may be run, below are examples of the most common uses.
33
+ # * bundler: 'bundle exec rspec'
34
+ # * bundler binstubs: 'bin/rspec'
35
+ # * spring: 'bin/rspec' (This will use spring if running and you have
36
+ # installed the spring binstubs per the docs)
37
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
38
+ # * 'just' rspec: 'rspec'
39
+
40
+ guard :rspec, cmd: 'bundle exec rspec' do
41
+ require 'guard/rspec/dsl'
42
+ dsl = Guard::RSpec::Dsl.new(self)
43
+
44
+ # Feel free to open issues for suggestions and improvements
45
+
46
+ # RSpec files
47
+ rspec = dsl.rspec
48
+ watch(rspec.spec_helper) { rspec.spec_dir }
49
+ watch(rspec.spec_support) { rspec.spec_dir }
50
+ watch(rspec.spec_files)
51
+
52
+ # Ruby files
53
+ ruby = dsl.ruby
54
+ dsl.watch_spec_files_for(ruby.lib_files)
55
+
56
+ # Rails files
57
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
58
+ dsl.watch_spec_files_for(rails.app_files)
59
+ dsl.watch_spec_files_for(rails.views)
60
+
61
+ watch(rails.controllers) do |m|
62
+ [
63
+ rspec.spec.call("routing/#{m[1]}_routing"),
64
+ rspec.spec.call("controllers/#{m[1]}_controller"),
65
+ rspec.spec.call("acceptance/#{m[1]}")
66
+ ]
67
+ end
68
+
69
+ # Rails config changes
70
+ watch(rails.spec_helper) { rspec.spec_dir }
71
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
72
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
73
+
74
+ # Capybara features specs
75
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
76
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
77
+
78
+ # Turnip features and steps
79
+ watch(%r{^spec/acceptance/(.+)\.feature$})
80
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
81
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
82
+ end
83
+ end
84
+
85
+ # guard :rubocop do
86
+ # watch(/.+\.rb$/)
87
+ # watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
88
+ # watch(%r{(?:.+/)?\.rubocop_todo\.yml$}) { |m| File.dirname(m[0]) }
89
+ # end
90
+ # split the development into parts (e.g. frontend and backend)
91
+ # guard -g <group>
92
+ scope group: :specs
93
+
94
+ group 'specs', halt_on_fail: false do
95
+ guard :bundler do
96
+ require 'guard/bundler'
97
+ require 'guard/bundler/verify'
98
+ helper = Guard::Bundler::Verify.new
99
+
100
+ files = ['Gemfile']
101
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
102
+
103
+ # Assume files are symlinked from somewhere
104
+ files.each { |file| watch(helper.real_path(file)) }
105
+ end
106
+
107
+ # cmd: show less output, but still provide enough info on a failed test
108
+ guard :rspec, all_on_start: true, cmd: 'rspec -c -fp' do
109
+ watch(%r{^spec/.+_spec\.rb$})
110
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
111
+ watch('spec/spec_helper.rb') { 'spec/lib' }
112
+ end
113
+
114
+ guard :rubocop, all_on_start: true, cmd: 'rubocop --format fuubar -F -D' do
115
+ watch(%r{^spec/.+_spec\.rb$})
116
+ watch(%r{^lib/(.+)\.rb$})
117
+ end
118
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Efigence S.A.
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # CracklibReloaded
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cracklib_reloaded`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ $ rvm use ruby-2.4
11
+ ```
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'cracklib_reloaded'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install cracklib_reloaded
26
+
27
+ ## Usage
28
+
29
+ ```
30
+ password = CracklibReloaded::Password.new
31
+ password.weak?('admin123')
32
+ => true
33
+ > password.errors
34
+ => #<CracklibReloaded::Password::Errors
35
+ # Equivalent of ActiveModel::Errors#messages'
36
+ > password.errors.to_h
37
+ => {:password=>["it is based on a dictionary word"]}
38
+ > password.errors.to_a
39
+ [[:password, ["it is based on a dictionary word"]]]
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ```
49
+ $ guard # require './lib/cracklib_reloaded'
50
+ ```
51
+
52
+ ## Run script
53
+
54
+ CAUTION: Using password as a script argument may not safe
55
+
56
+ ```
57
+ $ ruby init.rb 'admin123'
58
+ Equivalent of ActiveModel::Errors#messages
59
+ {:password=>["it is based on a dictionary word"]}
60
+ [[:password, ["it is based on a dictionary word"]]]
61
+ ```
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cracklib_reloaded. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
66
+
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
71
+
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.requires << 'rubocop-rspec'
11
+ task.formatters = ['json']
12
+ task.options = ['--display-cop-names', '-orubocop_output.json']
13
+ end
14
+
15
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'cracklib_reloaded'
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__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
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
data/config.reek ADDED
@@ -0,0 +1 @@
1
+ # https://github.com/troessner/reek/blob/master/defaults.reek
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'cracklib_reloaded/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'cracklib_reloaded'
9
+ spec.version = CracklibReloaded::VERSION
10
+ spec.authors = ['Marcin Kalita']
11
+ spec.email = ['rubyconvict@gmail.com']
12
+
13
+ spec.summary = 'Use CrackLib for Ruby to require stronger passwords.'
14
+ spec.description = 'CrackLib is a library for checking that a password is ' \
15
+ 'not based on a simple character pattern or on a dictionary word.'
16
+ spec.homepage = 'https://github.com/efigence/cracklib_reloaded'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
+ else
24
+ raise RuntimeError.new, 'RubyGems 2.0 or newer is required to protect against ' \
25
+ 'public gem pushes.'
26
+ end
27
+
28
+ spec.files =
29
+ # `git ls-files -z`.split("\x0")
30
+ # bundle exec manifest save
31
+ File.read('Manifest.txt').split("\n").reject do |f|
32
+ f.match(%r{^(test|spec|features)/})
33
+ end
34
+
35
+ spec.bindir = 'exe'
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ['lib']
38
+
39
+ spec.add_dependency 'ffi'
40
+
41
+ spec.add_development_dependency 'bundler', '~> 1.14'
42
+ spec.add_development_dependency 'rake', '~> 10.0'
43
+ spec.add_development_dependency 'rspec', '~> 3.0'
44
+ spec.add_development_dependency 'github_changelog_generator'
45
+ spec.add_development_dependency 'fuubar'
46
+ spec.add_development_dependency 'guard'
47
+ spec.add_development_dependency 'guard-bundler'
48
+ spec.add_development_dependency 'guard-reek'
49
+ spec.add_development_dependency 'guard-rspec'
50
+ spec.add_development_dependency 'guard-rubocop'
51
+ spec.add_development_dependency 'rubocop'
52
+ # rubocop + rubocop-rspec used by text editor from specific rvm ruby
53
+ # gem uninstall rubocop && gem install rubocop -v='0.39'
54
+ # https://github.com/backus/rubocop-rspec/issues/153
55
+ spec.add_development_dependency 'rubocop-rspec'
56
+ spec.add_development_dependency 'rubygems-manifest'
57
+ end
data/env.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
4
+
5
+ require 'rubygems'
6
+ # Set up gems listed in the Gemfile.
7
+ require 'bundler/setup'
8
+
9
+ unless defined?(RUBY_ENV)
10
+ RUBY_ENV = [ENV['RUBY_ENV'], 'development'].compact.first.freeze
11
+ end
12
+
13
+ # Require the gems listed in Gemfile, including any gems
14
+ # you've limited to :test, :development, or :production.
15
+ Bundler.require(:default, RUBY_ENV)
16
+
17
+ # binding.irb
18
+ require 'irb' if %w[development test].include?(RUBY_ENV)
data/init.rb ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'env'
4
+ require_relative 'lib/cracklib_reloaded/password.rb'
5
+
6
+ password = CracklibReloaded::Password.new
7
+ password.weak?(ARGV.first)
8
+ puts 'Equivalent of ActiveModel::Errors#messages'
9
+ puts password.errors.to_h
10
+ puts password.errors.to_a.inspect
11
+ exit 1 if password.errors.any?
data/lib/.keep ADDED
File without changes
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ffi'
4
+
5
+ module CracklibReloaded
6
+ module CracklibReloadedFfiMixin
7
+ extend FFI::Library
8
+
9
+ LIBCRACK_SO_PATH = [
10
+ ENV['LIBCRACK_SO_PATH'].to_s,
11
+ '/usr/lib/libcrack.so.2',
12
+ '/usr/lib64/libcrack.so.2',
13
+ '/usr/lib/x86_64-linux-gnu/libcrack.so.2'
14
+ ].select { |file| File.readable?(file) }.first.freeze
15
+
16
+ ffi_lib LIBCRACK_SO_PATH
17
+ attach_function :cracklib_default_dict, :GetDefaultCracklibDict, [], :string
18
+ attach_function :cracklib_check, :FascistCheck, %i[string string], :string
19
+ end
20
+
21
+ class Password
22
+ include CracklibReloadedFfiMixin
23
+
24
+ class Errors
25
+ include Enumerable
26
+
27
+ def initialize(messages)
28
+ @messages = messages.empty? ? [] : [[:password, messages]]
29
+ end
30
+
31
+ def each
32
+ return {} if @messages.empty?
33
+ @messages.each { |message| yield message }
34
+ end
35
+
36
+ def empty?
37
+ count.zero?
38
+ end
39
+
40
+ def [](key)
41
+ find { |item| item == key }
42
+ end
43
+ end
44
+
45
+ def initialize(dict_path = cracklib_default_dict)
46
+ @dict_path = dict_path
47
+ end
48
+
49
+ def weak?(password)
50
+ @message = cracklib_check(password.to_s, @dict_path)
51
+ !@message.nil?
52
+ end
53
+
54
+ def errors
55
+ return Errors.new([]) unless @message
56
+ Errors.new([@message])
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CracklibReloaded
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../env'
4
+ require 'cracklib_reloaded/version'
5
+ require 'cracklib_reloaded/password'
6
+
7
+ module CracklibReloaded
8
+ end
metadata ADDED
@@ -0,0 +1,264 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cracklib_reloaded
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Kalita
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github_changelog_generator
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: fuubar
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-reek
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: guard-rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubygems-manifest
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: CrackLib is a library for checking that a password is not based on a
210
+ simple character pattern or on a dictionary word.
211
+ email:
212
+ - rubyconvict@gmail.com
213
+ executables: []
214
+ extensions: []
215
+ extra_rdoc_files: []
216
+ files:
217
+ - ".gitignore"
218
+ - ".rspec"
219
+ - ".rubocop.yml"
220
+ - ".rubocop_todo.yml"
221
+ - ".travis.yml"
222
+ - CHANGELOG.md
223
+ - CODE_OF_CONDUCT.md
224
+ - Gemfile
225
+ - Guardfile
226
+ - LICENSE.txt
227
+ - README.md
228
+ - Rakefile
229
+ - bin/console
230
+ - bin/setup
231
+ - config.reek
232
+ - cracklib_reloaded.gemspec
233
+ - env.rb
234
+ - init.rb
235
+ - lib/.keep
236
+ - lib/cracklib_reloaded.rb
237
+ - lib/cracklib_reloaded/password.rb
238
+ - lib/cracklib_reloaded/version.rb
239
+ homepage: https://github.com/efigence/cracklib_reloaded
240
+ licenses:
241
+ - MIT
242
+ metadata:
243
+ allowed_push_host: https://rubygems.org
244
+ post_install_message:
245
+ rdoc_options: []
246
+ require_paths:
247
+ - lib
248
+ required_ruby_version: !ruby/object:Gem::Requirement
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ version: '0'
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ requirements: []
259
+ rubyforge_project:
260
+ rubygems_version: 2.6.11
261
+ signing_key:
262
+ specification_version: 4
263
+ summary: Use CrackLib for Ruby to require stronger passwords.
264
+ test_files: []