wafris 1.1.3 → 1.1.4
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/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: 6600b4667202df4429e13018d9eb1bdc0473029ad20dd5052e993f8390f06330
|
4
|
+
data.tar.gz: a4cf7a7781a19b03aa2c6389e24093b69f8b448c49beff1ddf798de9e9c97ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eef758330be30b532d5b069df5db72d7bbbf8e98d277fe3cacc6842e8d01c997fcb1532810467497a2c87864f809b9fd83a0f13bfeef91a0503bfceace2f893
|
7
|
+
data.tar.gz: 0da7423796d0eb18d0d21d6ccda75555fe7042e1d5d999b539bfb13bde301d17b581b2b399faa122afc4e3acb32c567d5426cb04326dff34a81271319e341fd2
|
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.4
|
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
|