rack-dedos 0.4.2 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13b363d6e2ef672affc0c451da8b7209cba8dcf99922ecf4ee852df9f72f2427
4
- data.tar.gz: ccd78d96fd078ecb549778809abc85cc8063d0ec0018fa111484e4571158751b
3
+ metadata.gz: 7345523b97820b5bae83175067c3f76b69a4c9f7f57d3bb5faa5175f5fbcdbe4
4
+ data.tar.gz: 241fc35b7c5c8df31468186079dc1ba27039481437cb249ae8884cee76c94f68
5
5
  SHA512:
6
- metadata.gz: 21cc53bde60003177c38cf0db3ea19b83a6cd47ca4b23cc0d3b40fac43e13b141b8d4186eef7fc6feecde39a9733fa5af621ba4cad1521d381c25166d2dc251d
7
- data.tar.gz: 1976ab0c669f8e222759251a45e502b2e7e62419bdfef21e7f184bb58dd7d23088a03e9ea3ab4fde20b70b1d651161923e448d9ed98ae14f1edb702098ebd5aa
6
+ metadata.gz: 7daa7932e86cea82bf48f6b26e14c70e3b8732b59d6b8495531795f60c79449fe7c25f40f213bfd22098dfe5565b20e34200e5b3a035840171286b93c569deb6
7
+ data.tar.gz: 94f5e9db12c676fb325624679b3105bdcdf1c107e552725cc56fc8ff77d3c84b9e617c30ccc183866c5ce7b36942843b1385befc0ec29c229807a2fa15a5f973
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  Nothing so far
4
4
 
5
+ ## 0.5.1
6
+
7
+ ### Fixes
8
+ * Fix getcwd errors due to unlinked tmpdir
9
+
10
+ ## 0.5.0
11
+
12
+ ### Changes
13
+ * Update to Ruby 4.0
14
+ * Require Minitest >= 6
15
+
5
16
  ## 0.4.2
6
17
 
7
18
  ### Changes
data/README.md CHANGED
@@ -94,11 +94,11 @@ Given the drastic nature of the filters, you should use this middleware for prod
94
94
 
95
95
  ### Request
96
96
 
97
- By default, filters are applied to all request paths. You can norrow this to only certain request paths:
97
+ By default, filters are applied to all request paths. You can norrow this to only certain matching request paths:
98
98
 
99
99
  ```ruby
100
100
  use Rack::Dedos,
101
- only_paths: [%r(^/search), %r(%r(\.xml)$)]
101
+ only_paths: [%r(^/search), %r(\.xml$)]
102
102
 
103
103
  use Rack::Dedos,
104
104
  except_paths: [%r(^/$)]
@@ -3,6 +3,7 @@
3
3
  require 'optparse'
4
4
  require 'tmpdir'
5
5
  require 'open-uri'
6
+ require 'zlib'
6
7
  require 'json'
7
8
  require 'rubygems/package'
8
9
 
@@ -58,7 +59,7 @@ module Rack
58
59
  private
59
60
 
60
61
  def latest_version
61
- URI("https://api.github.com/repos/#{REPO}/releases/latest")
62
+ @latest_version ||= URI("https://api.github.com/repos/#{REPO}/releases/latest")
62
63
  .read
63
64
  .then { JSON.parse(_1) }
64
65
  .fetch('tag_name')
@@ -68,20 +69,21 @@ module Rack
68
69
  def prepare(version)
69
70
  uri = URI("https://github.com/#{REPO}/releases/download/v#{version}/geoipupdate_#{version}_#{arch}.tar.gz")
70
71
  Dir.mktmpdir do |tmp|
71
- Dir.chdir tmp
72
- uri.open do |file|
73
- Zlib::GzipReader.wrap(file) do |gz|
74
- Gem::Package::TarReader.new(gz) do |tar|
75
- tar.each do |entry|
76
- if entry.full_name.match? %r(/geoipupdate$)
77
- ::File.write('geoipupdate', entry.read)
72
+ Dir.chdir(tmp) do
73
+ uri.open do |file|
74
+ Zlib::GzipReader.wrap(file) do |gz|
75
+ Gem::Package::TarReader.new(gz) do |tar|
76
+ tar.each do |entry|
77
+ if entry.full_name.match? %r(/geoipupdate$)
78
+ ::File.write('geoipupdate', entry.read)
79
+ end
78
80
  end
79
81
  end
80
82
  end
81
83
  end
84
+ ::File.chmod(0755, 'geoipupdate')
85
+ yield
82
86
  end
83
- ::File.chmod(0755, 'geoipupdate')
84
- yield
85
87
  end
86
88
  ensure
87
89
  lockfile = "#{dir}/.geoipupdate.lock"
@@ -30,7 +30,7 @@ module Rack
30
30
  if !apply?(request) || allowed?(request, ip)
31
31
  app.call(env)
32
32
  else
33
- message = "rack-dedos: request #{request.path} from #{ip} blocked by #{self.class}"
33
+ message = "rack-dedos: request #{request.path} from #{ip} blocked by #{name}"
34
34
  warn([message, details].compact.join(": "))
35
35
  [options[:status], { 'Content-Type' => 'text/plain' }, [options[:text]]]
36
36
  end
@@ -7,6 +7,10 @@ module Rack
7
7
  module Filters
8
8
  class Country < Base
9
9
 
10
+ def name
11
+ :country
12
+ end
13
+
10
14
  # @option options [String] :maxmind_db_file MaxMind database file
11
15
  # @option options [Symbol, Array<Symbol>] :allowed_countries ISO 3166-1 alpha 2
12
16
  # @option options [Symbol, Array<Symbol>] :denied_countries ISO 3166-1 alpha 2
@@ -5,6 +5,10 @@ module Rack
5
5
  module Filters
6
6
  class UserAgent < Base
7
7
 
8
+ def name
9
+ :user_agent
10
+ end
11
+
8
12
  # @option options [String] :cache_url URL of the cache backend
9
13
  # @option options [Integer] :cache_period how long to retain cached IP
10
14
  # addresses in seconds (default: 900)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  module Dedos
5
- VERSION = "0.4.2"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
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.2
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
@@ -85,16 +85,16 @@ dependencies:
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '0'
88
+ version: 6.0.0
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
95
+ version: 6.0.0
96
96
  - !ruby/object:Gem::Dependency
97
- name: minitest-flash
97
+ name: minitest-mock
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
@@ -108,7 +108,7 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
- name: minitest-focus
111
+ name: minitest-flash
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
@@ -204,7 +204,7 @@ metadata:
204
204
  bug_tracker_uri: https://github.com/svoop/rack-dedos/issues
205
205
  rdoc_options:
206
206
  - "--title"
207
- - AIXM/OFMX Builder
207
+ - Rack::Dedos
208
208
  - "--main"
209
209
  - README.md
210
210
  - "--line-numbers"
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.6.9
226
+ rubygems_version: 4.0.3
227
227
  specification_version: 4
228
228
  summary: Radical filters to block denial-of-service (DoS) requests.
229
229
  test_files: []