mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
style: fix Style/BlockDelimiters cop check
This commit is contained in:
parent
c0328707b1
commit
8fafa7602b
5 changed files with 9 additions and 10 deletions
|
|
@ -37,6 +37,7 @@ Security:
|
|||
|
||||
Style/BlockDelimiters:
|
||||
Enabled: true
|
||||
IgnoredMethods: [] # Workaround rubocop bug: https://github.com/rubocop-hq/rubocop/issues/6179
|
||||
|
||||
Style/BracesAroundHashParameters:
|
||||
Enabled: true
|
||||
|
|
|
|||
|
|
@ -138,10 +138,10 @@ module Rack
|
|||
@anonymous_safelists = []
|
||||
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
|
||||
@blocklisted_response = lambda { |_env| [403, { 'Content-Type' => 'text/plain' }, ["Forbidden\n"]] }
|
||||
@throttled_response = lambda { |env|
|
||||
@throttled_response = lambda do |env|
|
||||
retry_after = (env['rack.attack.match_data'] || {})[:period]
|
||||
[429, { 'Content-Type' => 'text/plain', 'Retry-After' => retry_after.to_s }, ["Retry later\n"]]
|
||||
}
|
||||
end
|
||||
|
||||
def initialize(app)
|
||||
@app = app
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ if defined?(::ConnectionPool) && defined?(::Dalli)
|
|||
Rack::Attack.cache.store.clear
|
||||
end
|
||||
|
||||
it_works_for_cache_backed_features(fetch_from_store: ->(key) {
|
||||
Rack::Attack.cache.store.read(key)
|
||||
})
|
||||
it_works_for_cache_backed_features(fetch_from_store: ->(key) { Rack::Attack.cache.store.read(key) })
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ if defined?(::Dalli) && defined?(::ConnectionPool)
|
|||
Rack::Attack.cache.store.with { |client| client.flush_all }
|
||||
end
|
||||
|
||||
it_works_for_cache_backed_features(fetch_from_store: ->(key) {
|
||||
Rack::Attack.cache.store.with { |client| client.fetch(key) }
|
||||
})
|
||||
it_works_for_cache_backed_features(
|
||||
fetch_from_store: ->(key) { Rack::Attack.cache.store.with { |client| client.fetch(key) } }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ describe 'Rack::Attack' do
|
|||
Rack::Attack.blocklist("ip #{@bad_ip}") { |req| req.ip == @bad_ip }
|
||||
end
|
||||
|
||||
it('has a blocklist') {
|
||||
it 'has a blocklist' do
|
||||
Rack::Attack.blocklists.key?("ip #{@bad_ip}").must_equal true
|
||||
}
|
||||
end
|
||||
|
||||
describe "a bad request" do
|
||||
before { get '/', {}, 'REMOTE_ADDR' => @bad_ip }
|
||||
|
|
|
|||
Loading…
Reference in a new issue