the_big_username_blacklist 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +10 -0
- data/data/list.txt +204 -0
- data/lib/the_big_username_blacklist.rb +42 -0
- data/lib/the_big_username_blacklist/configuration.rb +5 -0
- data/lib/the_big_username_blacklist/data.rb +19 -0
- data/lib/the_big_username_blacklist/version.rb +3 -0
- data/spec/spec_helper.rb +97 -0
- data/spec/the_big_username_blacklist/configure_spec.rb +46 -0
- data/spec/the_big_username_blacklist/data_spec.rb +18 -0
- data/spec/the_big_username_blacklist/user_valid_spec.rb +17 -0
- data/spec/the_big_username_blacklist/valid_spec.rb +15 -0
- data/the_big_username_blacklist.gemspec +30 -0
- metadata +127 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6d3a58c008fbe17846a4df1966a8897a6250f379
|
|
4
|
+
data.tar.gz: 4a5ba6a6086f9e0a46df45b73985cf3d91dee270
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 712f59af0c00af715f9649b5bf16169be779d1791f961550455d056ac7ecb2e7e0c719ad13e9c5b7b43b2e34c188071f87078fe6ead71f2f0adf2b3f16a8e9a8
|
|
7
|
+
data.tar.gz: dde1f10281e69bc5314cb831504e4d7f6f6b42db6f823dc64a687cae5e1975ce3760e10d61b4b974ae0c1e2063d5a10dd79aec67f4b5e48d8f514b5c4d26e38e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015 Takashi Uesugi
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# TheBigUsernameBlacklist
|
|
2
|
+
|
|
3
|
+
This library lets you validate usernames against a blacklist. The blacklist data is based on the data from The-Big-Username-Blacklist and contains privilege, programming terms, section names, financial terms and actions.
|
|
4
|
+
|
|
5
|
+
see also...
|
|
6
|
+
- https://github.com/marteinn/The-Big-Username-Blacklist
|
|
7
|
+
- https://pypi.python.org/pypi/the_big_username_blacklist
|
|
8
|
+
- https://www.npmjs.com/package/the-big-username-blacklist
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'the_big_username_blacklist'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
And then execute:
|
|
19
|
+
|
|
20
|
+
$ bundle
|
|
21
|
+
|
|
22
|
+
Or install it yourself as:
|
|
23
|
+
|
|
24
|
+
$ gem install the_big_username_blacklist
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Validating a username is easy, if the word is in the blacklist, return False (validation failed), otherwise True.
|
|
29
|
+
Example:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
> require 'the_big_username_blacklist'
|
|
33
|
+
> TheBigUsernameBlacklist.valid? 'martin'
|
|
34
|
+
true
|
|
35
|
+
> TheBigUsernameBlacklist.valid? 'root'
|
|
36
|
+
false
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
If you want to use it as instance method, it's easy.
|
|
41
|
+
Example:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
class YourClass
|
|
45
|
+
include TheBigUsernameBlacklist
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
YourClass.new.username_valid?('martin')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
You want to add optional blacklist, you can use configuration on rails initializer
|
|
53
|
+
Example: `config/initializers/the_big_username_blacklist.rb`
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
TheBigUsernameBlacklist.configure do |config|
|
|
57
|
+
config.optional_usernames = %w(james)
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
TheBigUsernameBlacklist.valid? 'james' # => false
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
1. Fork it ( https://github.com/[my-github-username]/the_big_username_blacklist/fork )
|
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
71
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/data/list.txt
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
about
|
|
2
|
+
account
|
|
3
|
+
account
|
|
4
|
+
add
|
|
5
|
+
admin
|
|
6
|
+
administration
|
|
7
|
+
administrator
|
|
8
|
+
advertise
|
|
9
|
+
affiliate
|
|
10
|
+
affiliates
|
|
11
|
+
ajax
|
|
12
|
+
api
|
|
13
|
+
app
|
|
14
|
+
apps
|
|
15
|
+
auth
|
|
16
|
+
backup
|
|
17
|
+
billing
|
|
18
|
+
billings
|
|
19
|
+
blog
|
|
20
|
+
blogs
|
|
21
|
+
bookmark
|
|
22
|
+
bookmarks
|
|
23
|
+
cache
|
|
24
|
+
campaign
|
|
25
|
+
careers
|
|
26
|
+
cart
|
|
27
|
+
change
|
|
28
|
+
checkout
|
|
29
|
+
comment
|
|
30
|
+
comments
|
|
31
|
+
compose
|
|
32
|
+
config
|
|
33
|
+
connect
|
|
34
|
+
contact
|
|
35
|
+
contest
|
|
36
|
+
cookies
|
|
37
|
+
create
|
|
38
|
+
deals
|
|
39
|
+
delete
|
|
40
|
+
disconnect
|
|
41
|
+
docs
|
|
42
|
+
documentation
|
|
43
|
+
download
|
|
44
|
+
downvote
|
|
45
|
+
edit
|
|
46
|
+
enterprise
|
|
47
|
+
error
|
|
48
|
+
event
|
|
49
|
+
events
|
|
50
|
+
exception
|
|
51
|
+
exit
|
|
52
|
+
false
|
|
53
|
+
faq
|
|
54
|
+
features
|
|
55
|
+
feed
|
|
56
|
+
feedback
|
|
57
|
+
feeds
|
|
58
|
+
feeds
|
|
59
|
+
follow
|
|
60
|
+
follower
|
|
61
|
+
followers
|
|
62
|
+
following
|
|
63
|
+
forgot
|
|
64
|
+
forgot-password
|
|
65
|
+
forum
|
|
66
|
+
forums
|
|
67
|
+
friend
|
|
68
|
+
friends
|
|
69
|
+
group
|
|
70
|
+
groups
|
|
71
|
+
head
|
|
72
|
+
header
|
|
73
|
+
help
|
|
74
|
+
home
|
|
75
|
+
host
|
|
76
|
+
hosting
|
|
77
|
+
hostmaster
|
|
78
|
+
htpasswd
|
|
79
|
+
investors
|
|
80
|
+
invitations
|
|
81
|
+
invite
|
|
82
|
+
invite
|
|
83
|
+
invites
|
|
84
|
+
invoice
|
|
85
|
+
issues
|
|
86
|
+
jobs
|
|
87
|
+
join
|
|
88
|
+
json
|
|
89
|
+
learn
|
|
90
|
+
load
|
|
91
|
+
local
|
|
92
|
+
login
|
|
93
|
+
logout
|
|
94
|
+
lost-password
|
|
95
|
+
mail
|
|
96
|
+
marketing
|
|
97
|
+
marketplace
|
|
98
|
+
master
|
|
99
|
+
message
|
|
100
|
+
messages
|
|
101
|
+
moderator
|
|
102
|
+
modify
|
|
103
|
+
more
|
|
104
|
+
my
|
|
105
|
+
new
|
|
106
|
+
news
|
|
107
|
+
newsletter
|
|
108
|
+
newsletters
|
|
109
|
+
next
|
|
110
|
+
nil
|
|
111
|
+
none
|
|
112
|
+
null
|
|
113
|
+
oauth
|
|
114
|
+
offer
|
|
115
|
+
offers
|
|
116
|
+
online
|
|
117
|
+
openid
|
|
118
|
+
order
|
|
119
|
+
orders
|
|
120
|
+
owner
|
|
121
|
+
page
|
|
122
|
+
pages
|
|
123
|
+
partners
|
|
124
|
+
passwd
|
|
125
|
+
password
|
|
126
|
+
pay
|
|
127
|
+
payment
|
|
128
|
+
plans
|
|
129
|
+
popular
|
|
130
|
+
postmaster
|
|
131
|
+
poweruser
|
|
132
|
+
previous
|
|
133
|
+
privacy
|
|
134
|
+
product
|
|
135
|
+
profile
|
|
136
|
+
profiles
|
|
137
|
+
put
|
|
138
|
+
quota
|
|
139
|
+
redirect
|
|
140
|
+
register
|
|
141
|
+
remove
|
|
142
|
+
replies
|
|
143
|
+
reply
|
|
144
|
+
request
|
|
145
|
+
request-password
|
|
146
|
+
reset
|
|
147
|
+
reset-password
|
|
148
|
+
response
|
|
149
|
+
review
|
|
150
|
+
reviews
|
|
151
|
+
root
|
|
152
|
+
rootuser
|
|
153
|
+
rss
|
|
154
|
+
rules
|
|
155
|
+
save
|
|
156
|
+
search
|
|
157
|
+
security
|
|
158
|
+
select
|
|
159
|
+
session
|
|
160
|
+
sessions
|
|
161
|
+
settings
|
|
162
|
+
share
|
|
163
|
+
shift
|
|
164
|
+
shop
|
|
165
|
+
signup
|
|
166
|
+
sitemap
|
|
167
|
+
sort
|
|
168
|
+
ssl
|
|
169
|
+
stats
|
|
170
|
+
status
|
|
171
|
+
store
|
|
172
|
+
subscribe
|
|
173
|
+
sudo
|
|
174
|
+
super
|
|
175
|
+
superuser
|
|
176
|
+
support
|
|
177
|
+
sync
|
|
178
|
+
system
|
|
179
|
+
tag
|
|
180
|
+
tags
|
|
181
|
+
team
|
|
182
|
+
terms
|
|
183
|
+
terms-of-use
|
|
184
|
+
topic
|
|
185
|
+
topics
|
|
186
|
+
tour
|
|
187
|
+
translations
|
|
188
|
+
true
|
|
189
|
+
undefined
|
|
190
|
+
unfollow
|
|
191
|
+
unsubscribe
|
|
192
|
+
update
|
|
193
|
+
user
|
|
194
|
+
username
|
|
195
|
+
var
|
|
196
|
+
view
|
|
197
|
+
void
|
|
198
|
+
vote
|
|
199
|
+
website
|
|
200
|
+
widget
|
|
201
|
+
widgets
|
|
202
|
+
write
|
|
203
|
+
www
|
|
204
|
+
you
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'the_big_username_blacklist/version'
|
|
2
|
+
require 'the_big_username_blacklist/data'
|
|
3
|
+
require 'the_big_username_blacklist/configuration'
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'pry'
|
|
7
|
+
rescue LoadError
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module TheBigUsernameBlacklist
|
|
11
|
+
def username_valid?(username)
|
|
12
|
+
TheBigUsernameBlacklist.valid?(username)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.valid?(username)
|
|
16
|
+
!(data.match?(username) || optional_data.match?(username))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.configure
|
|
20
|
+
yield(config)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def data
|
|
27
|
+
@data ||= Data.default
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def optional_data
|
|
31
|
+
return @optional_data if defined? @optional_data
|
|
32
|
+
if config.optional_usernames && config.optional_usernames.is_a?(Array)
|
|
33
|
+
return @optional_data = Data.new(config.optional_usernames)
|
|
34
|
+
end
|
|
35
|
+
@optional_data = Data.new([])
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def config
|
|
39
|
+
@config ||= Configuration.new
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module TheBigUsernameBlacklist
|
|
2
|
+
class Data
|
|
3
|
+
def self.default
|
|
4
|
+
file_path = File.expand_path('../../../data/list.txt', __FILE__)
|
|
5
|
+
usernames = File.open(file_path, 'r').read.split("\n")
|
|
6
|
+
new(usernames)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def initialize(usernames)
|
|
10
|
+
@usernames = usernames.each_with_object({}) do |username, hash|
|
|
11
|
+
hash[username] = true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def match?(username)
|
|
16
|
+
@usernames[username] || false
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require 'the_big_username_blacklist'
|
|
2
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
4
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
5
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
|
6
|
+
# files.
|
|
7
|
+
#
|
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
13
|
+
# the additional setup, and require it from the spec files that actually need
|
|
14
|
+
# it.
|
|
15
|
+
#
|
|
16
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
17
|
+
# users commonly want.
|
|
18
|
+
#
|
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
20
|
+
RSpec.configure do |config|
|
|
21
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
22
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
23
|
+
# assertions if you prefer.
|
|
24
|
+
config.expect_with :rspec do |expectations|
|
|
25
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
26
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
27
|
+
# defined using `chain`, e.g.:
|
|
28
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
29
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
30
|
+
# ...rather than:
|
|
31
|
+
# # => "be bigger than 2"
|
|
32
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
36
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
37
|
+
config.mock_with :rspec do |mocks|
|
|
38
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
39
|
+
# a real object. This is generally recommended, and will default to
|
|
40
|
+
# `true` in RSpec 4.
|
|
41
|
+
mocks.verify_partial_doubles = true
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The settings below are suggested to provide a good initial experience
|
|
45
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
46
|
+
=begin
|
|
47
|
+
# These two settings work together to allow you to limit a spec run
|
|
48
|
+
# to individual examples or groups you care about by tagging them with
|
|
49
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
50
|
+
# get run.
|
|
51
|
+
config.filter_run :focus
|
|
52
|
+
config.run_all_when_everything_filtered = true
|
|
53
|
+
|
|
54
|
+
# Allows RSpec to persist some state between runs in order to support
|
|
55
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
|
56
|
+
# you configure your source control system to ignore this file.
|
|
57
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
58
|
+
|
|
59
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
60
|
+
# recommended. For more details, see:
|
|
61
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
62
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
63
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
64
|
+
config.disable_monkey_patching!
|
|
65
|
+
|
|
66
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
67
|
+
# be too noisy due to issues in dependencies.
|
|
68
|
+
config.warnings = true
|
|
69
|
+
|
|
70
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
71
|
+
# file, and it's useful to allow more verbose output when running an
|
|
72
|
+
# individual spec file.
|
|
73
|
+
if config.files_to_run.one?
|
|
74
|
+
# Use the documentation formatter for detailed output,
|
|
75
|
+
# unless a formatter has already been configured
|
|
76
|
+
# (e.g. via a command-line flag).
|
|
77
|
+
config.default_formatter = 'doc'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Print the 10 slowest examples and example groups at the
|
|
81
|
+
# end of the spec run, to help surface which specs are running
|
|
82
|
+
# particularly slow.
|
|
83
|
+
config.profile_examples = 10
|
|
84
|
+
|
|
85
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
86
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
87
|
+
# the seed, which is printed after each run.
|
|
88
|
+
# --seed 1234
|
|
89
|
+
config.order = :random
|
|
90
|
+
|
|
91
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
92
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
93
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
94
|
+
# as the one that triggered the failure.
|
|
95
|
+
Kernel.srand config.seed
|
|
96
|
+
=end
|
|
97
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
describe TheBigUsernameBlacklist do
|
|
3
|
+
describe '.configure' do
|
|
4
|
+
before do
|
|
5
|
+
TheBigUsernameBlacklist.configure { |c| c.optional_usernames = %w(james) }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
context 'class method' do
|
|
9
|
+
subject { TheBigUsernameBlacklist.valid?(username) }
|
|
10
|
+
context 'matched username' do
|
|
11
|
+
let(:username) { 'administrator' }
|
|
12
|
+
it { should be false }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'matched optional username' do
|
|
16
|
+
let(:username) { 'james' }
|
|
17
|
+
it { should be false }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'unmatched username' do
|
|
21
|
+
let(:username) { 'ababa' }
|
|
22
|
+
it { should be true }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'instance method' do
|
|
27
|
+
let(:test_class) { Struct.new(:hoge) { include TheBigUsernameBlacklist } }
|
|
28
|
+
subject { test_class.new.username_valid?(username) }
|
|
29
|
+
|
|
30
|
+
context 'matched username' do
|
|
31
|
+
let(:username) { 'administrator' }
|
|
32
|
+
it { should be false }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context 'matched optional username' do
|
|
36
|
+
let(:username) { 'james' }
|
|
37
|
+
it { should be false }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'unmatched username' do
|
|
41
|
+
let(:username) { 'ababa' }
|
|
42
|
+
it { should be true }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module TheBigUsernameBlacklist
|
|
3
|
+
describe 'Data' do
|
|
4
|
+
describe '#match?' do
|
|
5
|
+
subject { TheBigUsernameBlacklist::Data.default.match?(username) }
|
|
6
|
+
|
|
7
|
+
context 'matched username' do
|
|
8
|
+
let(:username) { 'administrator' }
|
|
9
|
+
it { should be true }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'unmatched username' do
|
|
13
|
+
let(:username) { 'ababa' }
|
|
14
|
+
it { should be false }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
describe TheBigUsernameBlacklist do
|
|
3
|
+
describe '#user_valid?' do
|
|
4
|
+
let(:test_class) { Struct.new(:hoge) { include TheBigUsernameBlacklist } }
|
|
5
|
+
subject { test_class.new.username_valid?(username) }
|
|
6
|
+
|
|
7
|
+
context 'matched username' do
|
|
8
|
+
let(:username) { 'administrator' }
|
|
9
|
+
it { should be false }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'unmatched username' do
|
|
13
|
+
let(:username) { 'ababa' }
|
|
14
|
+
it { should be true }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
describe TheBigUsernameBlacklist do
|
|
3
|
+
describe '.valid?' do
|
|
4
|
+
subject { TheBigUsernameBlacklist.valid?(username) }
|
|
5
|
+
context 'matched username' do
|
|
6
|
+
let(:username) { 'administrator' }
|
|
7
|
+
it { should be false }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context 'unmatched username' do
|
|
11
|
+
let(:username) { 'jamess' }
|
|
12
|
+
it { should be true }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'the_big_username_blacklist/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'the_big_username_blacklist'
|
|
7
|
+
spec.version = TheBigUsernameBlacklist::VERSION
|
|
8
|
+
spec.authors = ['Takashi Uesugi']
|
|
9
|
+
spec.email = ['tksuesg@gmail.com']
|
|
10
|
+
spec.summary = %q{This library lets you validate usernames against a blacklist.}
|
|
11
|
+
spec.description = %q{This library lets you validate usernames against a blacklist. The blacklist data is based on the data from The-Big-Username-Blacklist and contains privilege, programming terms, section names, financial terms and actions.
|
|
12
|
+
|
|
13
|
+
see also...
|
|
14
|
+
- https://github.com/marteinn/The-Big-Username-Blacklist
|
|
15
|
+
- https://pypi.python.org/pypi/the_big_username_blacklist
|
|
16
|
+
- https://www.npmjs.com/package/the-big-username-blacklist
|
|
17
|
+
}
|
|
18
|
+
spec.homepage = 'https://github.com/unlearned/the_big_username_blacklist'
|
|
19
|
+
spec.license = 'MIT'
|
|
20
|
+
|
|
21
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
24
|
+
spec.require_paths = ['lib']
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
28
|
+
spec.add_development_dependency 'rspec'
|
|
29
|
+
spec.add_development_dependency 'pry'
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: the_big_username_blacklist
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Takashi Uesugi
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.7'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: |
|
|
70
|
+
This library lets you validate usernames against a blacklist. The blacklist data is based on the data from The-Big-Username-Blacklist and contains privilege, programming terms, section names, financial terms and actions.
|
|
71
|
+
|
|
72
|
+
see also...
|
|
73
|
+
- https://github.com/marteinn/The-Big-Username-Blacklist
|
|
74
|
+
- https://pypi.python.org/pypi/the_big_username_blacklist
|
|
75
|
+
- https://www.npmjs.com/package/the-big-username-blacklist
|
|
76
|
+
email:
|
|
77
|
+
- tksuesg@gmail.com
|
|
78
|
+
executables: []
|
|
79
|
+
extensions: []
|
|
80
|
+
extra_rdoc_files: []
|
|
81
|
+
files:
|
|
82
|
+
- ".gitignore"
|
|
83
|
+
- Gemfile
|
|
84
|
+
- LICENSE.txt
|
|
85
|
+
- README.md
|
|
86
|
+
- Rakefile
|
|
87
|
+
- data/list.txt
|
|
88
|
+
- lib/the_big_username_blacklist.rb
|
|
89
|
+
- lib/the_big_username_blacklist/configuration.rb
|
|
90
|
+
- lib/the_big_username_blacklist/data.rb
|
|
91
|
+
- lib/the_big_username_blacklist/version.rb
|
|
92
|
+
- spec/spec_helper.rb
|
|
93
|
+
- spec/the_big_username_blacklist/configure_spec.rb
|
|
94
|
+
- spec/the_big_username_blacklist/data_spec.rb
|
|
95
|
+
- spec/the_big_username_blacklist/user_valid_spec.rb
|
|
96
|
+
- spec/the_big_username_blacklist/valid_spec.rb
|
|
97
|
+
- the_big_username_blacklist.gemspec
|
|
98
|
+
homepage: https://github.com/unlearned/the_big_username_blacklist
|
|
99
|
+
licenses:
|
|
100
|
+
- MIT
|
|
101
|
+
metadata: {}
|
|
102
|
+
post_install_message:
|
|
103
|
+
rdoc_options: []
|
|
104
|
+
require_paths:
|
|
105
|
+
- lib
|
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
requirements: []
|
|
117
|
+
rubyforge_project:
|
|
118
|
+
rubygems_version: 2.2.2
|
|
119
|
+
signing_key:
|
|
120
|
+
specification_version: 4
|
|
121
|
+
summary: This library lets you validate usernames against a blacklist.
|
|
122
|
+
test_files:
|
|
123
|
+
- spec/spec_helper.rb
|
|
124
|
+
- spec/the_big_username_blacklist/configure_spec.rb
|
|
125
|
+
- spec/the_big_username_blacklist/data_spec.rb
|
|
126
|
+
- spec/the_big_username_blacklist/user_valid_spec.rb
|
|
127
|
+
- spec/the_big_username_blacklist/valid_spec.rb
|