wafris 1.1.3 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wafris/configuration.rb +6 -11
- data/lib/wafris/log_suppressor.rb +4 -0
- data/lib/wafris/middleware.rb +3 -1
- data/lib/wafris/version.rb +1 -1
- data/lib/wafris.rb +13 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41a7301f46edd2db86921b04d380bae6be50bf420a7dce0d2253bfc9c357cbe3
|
4
|
+
data.tar.gz: 65210ab5daf81400a59e28423420aad4bc727f47f6cf71ff76111435fe685caa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73b821f4b6f72ca1a54ff457660fcdd4ca40c02a129df69bfb3ada73d189c0ece8b5bd147a937a1abd3347a8eea540c9674e5b36efa54857346128d44622a46e
|
7
|
+
data.tar.gz: cb866469bfe08d891202c77758a8408541f993ed784f405609340f0b02313ab2221c4b2166fc1f984194dc21bf4f631e4272c55322ee87eeb7d33998e580be32
|
data/lib/wafris/configuration.rb
CHANGED
@@ -6,18 +6,11 @@ module Wafris
|
|
6
6
|
class Configuration
|
7
7
|
attr_accessor :redis
|
8
8
|
attr_accessor :redis_pool_size
|
9
|
+
attr_accessor :maxmemory
|
9
10
|
|
10
11
|
def initialize
|
11
|
-
@redis = Redis.new(
|
12
|
-
url: ENV['REDIS_URL'],
|
13
|
-
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
14
|
-
)
|
15
12
|
@redis_pool_size = 20
|
16
|
-
|
17
|
-
puts "[Wafris] attempting firewall connection via REDIS_URL." unless LogSuppressor.suppress_logs?
|
18
|
-
create_settings
|
19
|
-
rescue Redis::CannotConnectError
|
20
|
-
puts "[Wafris] firewall disabled. Cannot connect to REDIS_URL. Will attempt Wafris.configure if it exists." unless LogSuppressor.suppress_logs?
|
13
|
+
@maxmemory = 25
|
21
14
|
end
|
22
15
|
|
23
16
|
def connection_pool
|
@@ -29,8 +22,10 @@ module Wafris
|
|
29
22
|
redis.hset('waf-settings',
|
30
23
|
'version', Wafris::VERSION,
|
31
24
|
'client', 'ruby',
|
32
|
-
'
|
33
|
-
|
25
|
+
'maxmemory', @maxmemory)
|
26
|
+
LogSuppressor.puts_log(
|
27
|
+
"[Wafris] firewall enabled. Connected to Redis. Ready to process requests. Set rules at: https://wafris.org/hub"
|
28
|
+
)
|
34
29
|
end
|
35
30
|
|
36
31
|
def core_sha
|
data/lib/wafris/middleware.rb
CHANGED
@@ -33,7 +33,9 @@ module Wafris
|
|
33
33
|
[403, {}, ['Blocked']]
|
34
34
|
end
|
35
35
|
rescue StandardError => e
|
36
|
-
|
36
|
+
LogSuppressor.puts_log(
|
37
|
+
"[Wafris] Redis connection error: #{e.message}. Request passed without rules check."
|
38
|
+
)
|
37
39
|
@app.call(env)
|
38
40
|
end
|
39
41
|
end
|
data/lib/wafris/version.rb
CHANGED
data/lib/wafris.rb
CHANGED
@@ -12,20 +12,21 @@ require 'wafris/railtie' if defined?(Rails::Railtie)
|
|
12
12
|
|
13
13
|
module Wafris
|
14
14
|
class << self
|
15
|
-
|
16
|
-
yield configuration
|
17
|
-
puts "[Wafris] attempting firewall connection via Wafris.configure initializer." unless LogSuppressor.suppress_logs?
|
18
|
-
configuration.create_settings
|
19
|
-
rescue Redis::CannotConnectError
|
20
|
-
puts "[Wafris] firewall disabled. Cannot connect via Wafris.configure. Please check your configuration settings." unless LogSuppressor.suppress_logs?
|
21
|
-
end
|
15
|
+
attr_accessor :configuration
|
22
16
|
|
23
|
-
def
|
24
|
-
|
25
|
-
end
|
17
|
+
def configure
|
18
|
+
raise ArgumentError, "[Wafris] block is required to configure Wafris" unless block_given?
|
26
19
|
|
27
|
-
|
28
|
-
|
20
|
+
self.configuration ||= Wafris::Configuration.new
|
21
|
+
yield(configuration)
|
22
|
+
LogSuppressor.puts_log(
|
23
|
+
"[Wafris] attempting firewall connection via Wafris.configure initializer."
|
24
|
+
)
|
25
|
+
configuration.create_settings
|
26
|
+
rescue Redis::CannotConnectError, ArgumentError
|
27
|
+
LogSuppressor.puts_log(
|
28
|
+
"[Wafris] firewall disabled. Cannot connect via Wafris.configure. Please check your configuration settings."
|
29
|
+
)
|
29
30
|
end
|
30
31
|
|
31
32
|
def allow_request?(request)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wafris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micahel Buckbee
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-09-
|
12
|
+
date: 2023-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: connection_pool
|