mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
style: enable Style/OptionalArguments rubocop
This commit is contained in:
parent
7daeac3401
commit
5a42fd3ac7
6 changed files with 13 additions and 10 deletions
|
|
@ -53,6 +53,9 @@ Style/FrozenStringLiteralComment:
|
|||
Style/HashSyntax:
|
||||
Enabled: true
|
||||
|
||||
Style/OptionalArguments:
|
||||
Enabled: true
|
||||
|
||||
Style/RaiseArgs:
|
||||
Enabled: true
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Rack::Attack
|
|||
attr_accessor :notifier, :blocklisted_response, :throttled_response, :anonymous_blocklists, :anonymous_safelists
|
||||
|
||||
def safelist(name = nil, &block)
|
||||
safelist = Safelist.new(name, block)
|
||||
safelist = Safelist.new(name, &block)
|
||||
|
||||
if name
|
||||
safelists[name] = safelist
|
||||
|
|
@ -40,7 +40,7 @@ class Rack::Attack
|
|||
end
|
||||
|
||||
def blocklist(name = nil, &block)
|
||||
blocklist = Blocklist.new(name, block)
|
||||
blocklist = Blocklist.new(name, &block)
|
||||
|
||||
if name
|
||||
blocklists[name] = blocklist
|
||||
|
|
@ -51,12 +51,12 @@ class Rack::Attack
|
|||
|
||||
def blocklist_ip(ip_address)
|
||||
ip_blocklist_proc = lambda { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) }
|
||||
anonymous_blocklists << Blocklist.new(nil, ip_blocklist_proc)
|
||||
anonymous_blocklists << Blocklist.new(nil, &ip_blocklist_proc)
|
||||
end
|
||||
|
||||
def safelist_ip(ip_address)
|
||||
ip_safelist_proc = lambda { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) }
|
||||
anonymous_safelists << Safelist.new(nil, ip_safelist_proc)
|
||||
anonymous_safelists << Safelist.new(nil, &ip_safelist_proc)
|
||||
end
|
||||
|
||||
def throttle(name, options, &block)
|
||||
|
|
@ -64,7 +64,7 @@ class Rack::Attack
|
|||
end
|
||||
|
||||
def track(name, options = {}, &block)
|
||||
tracks[name] = Track.new(name, options, block)
|
||||
tracks[name] = Track.new(name, options, &block)
|
||||
end
|
||||
|
||||
def safelists;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
module Rack
|
||||
class Attack
|
||||
class Blocklist < Check
|
||||
def initialize(name, block)
|
||||
def initialize(name, &block)
|
||||
super
|
||||
@type = :blocklist
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module Rack
|
|||
class Attack
|
||||
class Check
|
||||
attr_reader :name, :block, :type
|
||||
def initialize(name, options = {}, block)
|
||||
def initialize(name, options = {}, &block)
|
||||
@name, @block = name, block
|
||||
@type = options.fetch(:type, nil)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
module Rack
|
||||
class Attack
|
||||
class Safelist < Check
|
||||
def initialize(name, block)
|
||||
def initialize(name, &block)
|
||||
super
|
||||
@type = :safelist
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ module Rack
|
|||
class Track
|
||||
attr_reader :filter
|
||||
|
||||
def initialize(name, options = {}, block)
|
||||
def initialize(name, options = {}, &block)
|
||||
options[:type] = :track
|
||||
|
||||
if options[:limit] && options[:period]
|
||||
@filter = Throttle.new(name, options, block)
|
||||
else
|
||||
@filter = Check.new(name, options, block)
|
||||
@filter = Check.new(name, options, &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue