rack-attack 6.6.0 → 6.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rack/attack/configuration.rb +3 -3
- data/lib/rack/attack/store_proxy/redis_proxy.rb +3 -3
- data/lib/rack/attack/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0399127f00624959bafee349ab2e6010acda84373c3df24ff18c3ff701a6c274'
|
4
|
+
data.tar.gz: 88bbb4465f8b7ecd0f82d9ad7217a66da96bb829c6982b0151ea2c19b5bba3c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a4d3d278b7c814c909ae0e01128f076f2ffcda003a56f688d803ccdfc5f72eeaa6c60412dc8e06769026f407860ac1259668fc61c0e87f1ef7a03434e17d982
|
7
|
+
data.tar.gz: 492e4659338b489d9fcdc3bd315148ec2e1802c6197ce4dc5d7eaf598c918866468387d1a2346bfc30c454605aeaa59aa7d9a4e50bdc08910b24a72c681053dc
|
data/README.md
CHANGED
@@ -347,8 +347,8 @@ Rack::Attack.throttled_response_retry_after_header = true
|
|
347
347
|
Here's an example response that includes conventional `RateLimit-*` headers:
|
348
348
|
|
349
349
|
```ruby
|
350
|
-
Rack::Attack.
|
351
|
-
match_data = env['rack.attack.match_data']
|
350
|
+
Rack::Attack.throttled_responder = lambda do |request|
|
351
|
+
match_data = request.env['rack.attack.match_data']
|
352
352
|
now = match_data[:epoch_time]
|
353
353
|
|
354
354
|
headers = {
|
@@ -5,7 +5,7 @@ require "ipaddr"
|
|
5
5
|
module Rack
|
6
6
|
class Attack
|
7
7
|
class Configuration
|
8
|
-
DEFAULT_BLOCKLISTED_RESPONDER = lambda { |_req| [403, { '
|
8
|
+
DEFAULT_BLOCKLISTED_RESPONDER = lambda { |_req| [403, { 'content-type' => 'text/plain' }, ["Forbidden\n"]] }
|
9
9
|
|
10
10
|
DEFAULT_THROTTLED_RESPONDER = lambda do |req|
|
11
11
|
if Rack::Attack.configuration.throttled_response_retry_after_header
|
@@ -13,9 +13,9 @@ module Rack
|
|
13
13
|
now = match_data[:epoch_time]
|
14
14
|
retry_after = match_data[:period] - (now % match_data[:period])
|
15
15
|
|
16
|
-
[429, { '
|
16
|
+
[429, { 'content-type' => 'text/plain', 'retry-after' => retry_after.to_s }, ["Retry later\n"]]
|
17
17
|
else
|
18
|
-
[429, { '
|
18
|
+
[429, { 'content-type' => 'text/plain' }, ["Retry later\n"]]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -32,9 +32,9 @@ module Rack
|
|
32
32
|
|
33
33
|
def increment(key, amount, options = {})
|
34
34
|
rescuing do
|
35
|
-
pipelined do
|
36
|
-
incrby(key, amount)
|
37
|
-
expire(key, options[:expires_in]) if options[:expires_in]
|
35
|
+
pipelined do |redis|
|
36
|
+
redis.incrby(key, amount)
|
37
|
+
redis.expire(key, options[:expires_in]) if options[:expires_in]
|
38
38
|
end.first
|
39
39
|
end
|
40
40
|
end
|
data/lib/rack/attack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-attack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.6.
|
4
|
+
version: 6.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Suggs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -273,7 +273,7 @@ licenses:
|
|
273
273
|
- MIT
|
274
274
|
metadata:
|
275
275
|
bug_tracker_uri: https://github.com/rack/rack-attack/issues
|
276
|
-
changelog_uri: https://github.com/rack/rack-attack/blob/
|
276
|
+
changelog_uri: https://github.com/rack/rack-attack/blob/main/CHANGELOG.md
|
277
277
|
source_code_uri: https://github.com/rack/rack-attack
|
278
278
|
post_install_message:
|
279
279
|
rdoc_options:
|
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0'
|
293
293
|
requirements: []
|
294
|
-
rubygems_version: 3.3.
|
294
|
+
rubygems_version: 3.3.11
|
295
295
|
signing_key:
|
296
296
|
specification_version: 4
|
297
297
|
summary: Block & throttle abusive requests
|