rack-attack/lib/rack/attack
Gonzalo Rodriguez 6af29fb44e Avoid 'defined?' buggy behavior in ruby 2.5.0. Fixes #253
'defined?' is buggy in ruby 2.5.0, which under certain circumstances
users using rack-attack can hit. See issue #253.

I reported (https://bugs.ruby-lang.org/issues/14407) and
fixed (https://github.com/ruby/ruby/pull/1800) the issue in
ruby already, but i guess i would take some time before there's
a new ruby release including that fix.

So for now we would need to circumvent this bug by using
'const_defined?' instead of 'defined?' for this particular case.

More details:

Anyone using:
  * ruby 2.5.0
  * redis
  * rack-attack without redis-store and using at least one throttle
  * having a toplevel class named Store

will hit this ruby 2.5.0 bug https://bugs.ruby-lang.org/issues/14407

That's because of the following buggy behavior of 'defined?' under ruby
2.5:

```
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

$ irb
> class Redis
> end
=> nil
> class Store
> end
=> nil
> defined?(::Redis::Store)
=> "constant"
> ::Redis::Store
  NameError (uninitialized constant Redis::Store
    Did you mean?  Store)
```
2018-01-29 12:25:18 -03:00
..
store_proxy Avoid 'defined?' buggy behavior in ruby 2.5.0. Fixes #253 2018-01-29 12:25:18 -03:00
allow2ban.rb Typo in comment 2017-02-21 17:07:26 +01:00
blocklist.rb suggesting changing whitelist/blacklist language to less controversial safelist/blocklist language 2016-07-01 21:44:45 -04:00
cache.rb Support the ability to reset Fail2Ban count and ban flag 2015-05-22 09:47:32 -04:00
check.rb Added limit and period options to track. Delegates [] to Throttle if they are present otherwise Check. 2014-05-19 11:11:01 -07:00
fail2ban.rb suggesting changing whitelist/blacklist language to less controversial safelist/blocklist language 2016-07-01 21:44:45 -04:00
path_normalizer.rb Drop support for Rails 3 2018-01-23 16:12:16 -03:00
request.rb suggesting changing whitelist/blacklist language to less controversial safelist/blocklist language 2016-07-01 21:44:45 -04:00
safelist.rb suggesting changing whitelist/blacklist language to less controversial safelist/blocklist language 2016-07-01 21:44:45 -04:00
store_proxy.rb Do not allow mutating constants 2018-01-25 12:22:40 -03:00
throttle.rb Do not allow mutating constants 2018-01-25 12:22:40 -03:00
track.rb Changed track checker to track filter. Made track filter tests more clear. 2014-05-22 10:11:23 -07:00
version.rb Fix args to deprecated methods 2016-08-11 13:39:22 -04:00