rack-dedos 0.7.2 → 1.0.0
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 +4 -4
- data/CHANGELOG.md +106 -69
- data/README.md +12 -1
- data/lib/rack/dedos/filters/base.rb +4 -14
- data/lib/rack/dedos/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: a08f36618682f6ea88356457ae136dd78a470598e8254f537a56952435baf744
|
|
4
|
+
data.tar.gz: 4c24311d19a2bc7e8be8593b43022b35569a00ffe9a8293dd08df614afa50809
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4ffc6eaf1591ccd9359f5df317e72f67fbd08bcfd0df2c06389c468e4f41292afe922b4ed81e6b4fe2094a6931824b5baf8d982e1deafc79604d3d57a44931f
|
|
7
|
+
data.tar.gz: d15648fe182352df2979a8c0307ba9bcdf2c481e356e97e080fc892d870422aa8a9eedf974f25095db66026b534e167d6c8039bbabc0c374e5d8dc11d9dce20d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,113 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/),
|
|
6
|
+
and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
2
9
|
|
|
3
10
|
Nothing so far
|
|
4
11
|
|
|
5
|
-
## 0.
|
|
12
|
+
## [1.0.0] - 2026-11-22
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **Breaking:** Modify the real IP detection added in [0.2.0]: If the default `request.ip` reported by Rack doesn't return the real IP, either use `Rack::Request.ip_filter` to fix it or pass the real IP of the connecting party explicitly (see README). `CF-Connecting-IP` and `X-Forwarded-For` headers are no longer consulted to prevent bypassing the filters by forging those.
|
|
17
|
+
|
|
18
|
+
## [0.7.3] - 2026-06-26
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Relaxed dependency on connection_pool for better legacy support
|
|
23
|
+
|
|
24
|
+
## [0.7.2] - 2026-06-26
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Spamhaus filter
|
|
29
|
+
|
|
30
|
+
## [0.7.1] - 2026-04-21
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- Enforce MFA for future gem releases
|
|
35
|
+
|
|
36
|
+
## [0.7.0] - 2026-03-11
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **Breaking:** Changed format of country code details in log
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- Dropped keyword arguments for Rack compatibility
|
|
45
|
+
- Fixed collision with Rack::Logger
|
|
46
|
+
|
|
47
|
+
## [0.6.0] - 2026-03-11
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- **Breaking:** Log to STDOUT (instead of STDERR) by default
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- Suppport custom loggers
|
|
56
|
+
- Optionally log request headers
|
|
57
|
+
|
|
58
|
+
## [0.5.1] - 2026-01-08
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- Fixed getcwd errors due to unlinked tmpdir
|
|
6
63
|
|
|
7
|
-
|
|
8
|
-
* Spamhaus filter
|
|
64
|
+
## [0.5.0] - 2026-01-06
|
|
9
65
|
|
|
10
|
-
|
|
66
|
+
### Changed
|
|
11
67
|
|
|
12
|
-
|
|
13
|
-
|
|
68
|
+
- Updated to Ruby 4.0
|
|
69
|
+
- Require Minitest >= 6
|
|
14
70
|
|
|
15
|
-
## 0.
|
|
71
|
+
## [0.4.2] - 2025-12-01
|
|
16
72
|
|
|
17
|
-
###
|
|
18
|
-
* Change format of country code details in log
|
|
73
|
+
### Changed
|
|
19
74
|
|
|
20
|
-
|
|
21
|
-
* Drop keyword arguments for Rack compatibility
|
|
22
|
-
* Fix collision with Rack::Logger
|
|
75
|
+
- Adhere to [BreakVer](https://www.taoensso.com/break-versioning) from this point forward
|
|
23
76
|
|
|
24
|
-
|
|
77
|
+
### Added
|
|
25
78
|
|
|
26
|
-
|
|
27
|
-
|
|
79
|
+
- Include the requested URL in warnings
|
|
80
|
+
- Added `only_paths` and `except_paths` options
|
|
28
81
|
|
|
29
|
-
|
|
30
|
-
* Suppport custom loggers
|
|
31
|
-
* Optionally log request headers
|
|
82
|
+
## [0.4.1] - 2025-11-04
|
|
32
83
|
|
|
33
|
-
|
|
84
|
+
### Fixed
|
|
34
85
|
|
|
35
|
-
|
|
36
|
-
* Fix getcwd errors due to unlinked tmpdir
|
|
86
|
+
- Correctly include details in warnings (i.e. country code)
|
|
37
87
|
|
|
38
|
-
## 0.
|
|
88
|
+
## [0.4.0] - 2025-07-21
|
|
39
89
|
|
|
40
|
-
###
|
|
41
|
-
* Update to Ruby 4.0
|
|
42
|
-
* Require Minitest >= 6
|
|
90
|
+
### Changed
|
|
43
91
|
|
|
44
|
-
|
|
92
|
+
- Dropped certs
|
|
93
|
+
- Addded action for trusted release
|
|
45
94
|
|
|
46
|
-
|
|
47
|
-
* Use [BreakVer](https://www.taoensso.com/break-versioning) from this point forward
|
|
95
|
+
## [0.3.2] - 2025-01-16
|
|
48
96
|
|
|
49
|
-
###
|
|
50
|
-
* Include the requested URL in warnings
|
|
51
|
-
* Add `only_paths` and `except_paths` options
|
|
97
|
+
### Changed
|
|
52
98
|
|
|
53
|
-
|
|
99
|
+
- Resolve all paths to prevent problems with relative paths
|
|
54
100
|
|
|
55
|
-
|
|
56
|
-
* Correctly include details in warnings (i.e. country code)
|
|
101
|
+
## [0.3.1] - 2025-01-16
|
|
57
102
|
|
|
58
|
-
|
|
103
|
+
### Fixed
|
|
59
104
|
|
|
60
|
-
|
|
61
|
-
* Drop certs
|
|
62
|
-
* Add action for trusted release
|
|
105
|
+
- Root `File` operations to prevent clashes with Rack
|
|
63
106
|
|
|
64
|
-
## 0.3.
|
|
107
|
+
## [0.3.0] - 2025-01-16
|
|
65
108
|
|
|
66
|
-
###
|
|
67
|
-
* Resolve all paths to prevent problems with relative paths
|
|
109
|
+
### Changed
|
|
68
110
|
|
|
69
|
-
|
|
111
|
+
- Converted `geoipget` from Bash to Ruby
|
|
70
112
|
|
|
71
|
-
|
|
72
|
-
* Root `File` operations to prevent clashes with Rack
|
|
113
|
+
## [0.2.4] - 2025-01-15
|
|
73
114
|
|
|
74
|
-
|
|
115
|
+
### Changed
|
|
75
116
|
|
|
76
|
-
|
|
77
|
-
* Convert `geoipget` from Bash to Ruby
|
|
117
|
+
- Use Bash for `geoipget` to prevent problems with `/bin/sh` diversity
|
|
78
118
|
|
|
79
|
-
## 0.2.
|
|
119
|
+
## [0.2.3] - 2025-01-15
|
|
80
120
|
|
|
81
|
-
###
|
|
82
|
-
* Use Bash for `geoipget` to prevent problems with `/bin/sh` diversity
|
|
121
|
+
### Added
|
|
83
122
|
|
|
84
|
-
|
|
123
|
+
- `geoipget` shell script
|
|
85
124
|
|
|
86
|
-
|
|
87
|
-
* `geoipget` shell script
|
|
125
|
+
## [0.2.2] - 2024-12-25
|
|
88
126
|
|
|
89
|
-
|
|
127
|
+
### Changed
|
|
90
128
|
|
|
91
|
-
|
|
92
|
-
* Update to Ruby 3.4
|
|
129
|
+
- Updated to Ruby 3.4
|
|
93
130
|
|
|
94
|
-
## 0.2.1
|
|
131
|
+
## [0.2.1] - 2024-11-20
|
|
95
132
|
|
|
96
|
-
###
|
|
133
|
+
### Fixed
|
|
97
134
|
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
- Fixed paths on conditional requires
|
|
136
|
+
- Renewed certificate
|
|
100
137
|
|
|
101
|
-
## 0.2.0
|
|
138
|
+
## [0.2.0] - 2023-05-16
|
|
102
139
|
|
|
103
|
-
###
|
|
140
|
+
### Changed
|
|
104
141
|
|
|
105
|
-
|
|
106
|
-
|
|
142
|
+
- Determine real client IP
|
|
143
|
+
- Dropped autoload and put filters in proper namespace
|
|
107
144
|
|
|
108
|
-
## 0.1.0
|
|
145
|
+
## [0.1.0] - 2023-02-03
|
|
109
146
|
|
|
110
|
-
###
|
|
147
|
+
### Added
|
|
111
148
|
|
|
112
|
-
|
|
113
|
-
|
|
149
|
+
- UserAgent filter
|
|
150
|
+
- Country filter
|
data/README.md
CHANGED
|
@@ -92,9 +92,20 @@ end
|
|
|
92
92
|
|
|
93
93
|
Given the drastic nature of the filters, you should use this middleware for production environments only and/or if an environment variable like `UNDER_ATTACK` is set to true.
|
|
94
94
|
|
|
95
|
+
### Real IP
|
|
96
|
+
|
|
97
|
+
By default, `request.ip` provided by Rack is used to figure out the IP of the connecting client. Depending on the web framework you use or reverse proxies such as Cloudflare, this value might not contain the correct IP address.
|
|
98
|
+
|
|
99
|
+
However, it is possible to override this default behavior. Rails' Action Dispatch for instance determines `remote_ip` using its own mechanism. You can use this value instead with:
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
use Rack::Dedos,
|
|
103
|
+
ip: ->(request) { request.env['action_dispatch.remote_ip'].to_s }
|
|
104
|
+
```
|
|
105
|
+
|
|
95
106
|
### Request
|
|
96
107
|
|
|
97
|
-
By default, filters are applied to all request paths. You can
|
|
108
|
+
By default, filters are applied to all request paths. You can narrow this to only certain matching request paths:
|
|
98
109
|
|
|
99
110
|
```ruby
|
|
100
111
|
use Rack::Dedos,
|
|
@@ -8,6 +8,7 @@ module Rack
|
|
|
8
8
|
class Base
|
|
9
9
|
|
|
10
10
|
DEFAULT_OPTIONS = {
|
|
11
|
+
ip: nil,
|
|
11
12
|
logger: nil,
|
|
12
13
|
cache_url: 'Hash',
|
|
13
14
|
cache_key_prefix: nil,
|
|
@@ -61,22 +62,11 @@ module Rack
|
|
|
61
62
|
|
|
62
63
|
# Get the real IP of the client
|
|
63
64
|
#
|
|
64
|
-
# If containers and/or proxies such as Cloudflare are in the mix, the
|
|
65
|
-
# client IP reported by Rack may be wrong. Therefore, we determine the
|
|
66
|
-
# real client IP using the following priorities:
|
|
67
|
-
#
|
|
68
|
-
# 1. Cf-Connecting-Ip header
|
|
69
|
-
# 2. X-Forwarded-For header (also remove port number)
|
|
70
|
-
# 3. IP reported by Rack
|
|
71
|
-
#
|
|
72
65
|
# @param request [Rack::Request]
|
|
73
|
-
# @return [String]
|
|
66
|
+
# @return [String] IP
|
|
74
67
|
def real_ip(request)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
ip
|
|
78
|
-
when forwarded_for = request.forwarded_for
|
|
79
|
-
forwarded_for.split(/\s*,\s*/).first&.sub(/:\d+$/, '')
|
|
68
|
+
if (callable = @options[:ip]).respond_to? :call
|
|
69
|
+
callable.call(request)
|
|
80
70
|
else
|
|
81
71
|
request.ip
|
|
82
72
|
end
|
data/lib/rack/dedos/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rack-dedos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sven Schwyn
|
|
@@ -43,14 +43,14 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
46
|
+
version: 2.5.0
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 2.5.0
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: rake
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
183
183
|
- !ruby/object:Gem::Version
|
|
184
184
|
version: '0'
|
|
185
185
|
requirements: []
|
|
186
|
-
rubygems_version: 4.0.
|
|
186
|
+
rubygems_version: 4.0.20
|
|
187
187
|
specification_version: 4
|
|
188
188
|
summary: Radical filters to block denial-of-service (DoS) requests.
|
|
189
189
|
test_files: []
|