wafris 1.1.0 → 1.1.1
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 +3 -3
- data/lib/wafris/log_suppressor.rb +21 -0
- data/lib/wafris/middleware.rb +1 -1
- data/lib/wafris/version.rb +1 -1
- data/lib/wafris.rb +3 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73475a40b943b5e9fb0dbfd3800a1548f188e29403d86ba06a1beb5937b28a9b
|
4
|
+
data.tar.gz: 45c9fefafd42733d95bb370390096925c16ffdf1eb7dfe2bca660a2e0c068782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '025458318f9afa210b624690dfa613e5a979045b8116010bbbec7b22048dd4a424e5e3d4ca51fb6473dd902ac13de7216ba48c49ecfffc2e61d8d82b886a9716'
|
7
|
+
data.tar.gz: 908c8e51856c7defcf8f033f5dbbe54a06018f0a3400c67aeca715a130e69e4a89d5be537edb545597a7fdf01802c04bccc7973f44bcc510fe8d30255e398fec
|
data/lib/wafris/configuration.rb
CHANGED
@@ -14,10 +14,10 @@ module Wafris
|
|
14
14
|
)
|
15
15
|
@redis_pool_size = 20
|
16
16
|
|
17
|
-
puts "[Wafris] attempting firewall connection via REDIS_URL."
|
17
|
+
puts "[Wafris] attempting firewall connection via REDIS_URL." unless LogSuppressor.suppress_logs?
|
18
18
|
create_settings
|
19
19
|
rescue Redis::CannotConnectError
|
20
|
-
puts "[Wafris] firewall disabled. Cannot connect to REDIS_URL. Will attempt Wafris.configure if it exists."
|
20
|
+
puts "[Wafris] firewall disabled. Cannot connect to REDIS_URL. Will attempt Wafris.configure if it exists." unless LogSuppressor.suppress_logs?
|
21
21
|
end
|
22
22
|
|
23
23
|
def connection_pool
|
@@ -30,7 +30,7 @@ module Wafris
|
|
30
30
|
'version', Wafris::VERSION,
|
31
31
|
'client', 'ruby',
|
32
32
|
'redis-host', 'heroku')
|
33
|
-
puts "[Wafris] firewall enabled. Connected to Redis. Ready to process requests. Set rules at: https://wafris.org/hub"
|
33
|
+
puts "[Wafris] firewall enabled. Connected to Redis. Ready to process requests. Set rules at: https://wafris.org/hub" unless LogSuppressor.suppress_logs?
|
34
34
|
end
|
35
35
|
|
36
36
|
def core_sha
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Wafris
|
4
|
+
class LogSuppressor
|
5
|
+
def self.suppress_logs?
|
6
|
+
suppressed_environments.include?(current_environment)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.suppressed_environments
|
10
|
+
['development', 'test'] + (ENV['CI'] ? ['CI'] : [])
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.current_environment
|
14
|
+
if defined?(Rails)
|
15
|
+
Rails.env
|
16
|
+
else
|
17
|
+
ENV['RACK_ENV'] || 'development'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/wafris/middleware.rb
CHANGED
@@ -33,7 +33,7 @@ module Wafris
|
|
33
33
|
[403, {}, ['Blocked']]
|
34
34
|
end
|
35
35
|
rescue StandardError => e
|
36
|
-
puts "[Wafris] Redis connection error: #{e.message}. Request passed without rules check."
|
36
|
+
puts "[Wafris] Redis connection error: #{e.message}. Request passed without rules check." unless LogSuppressor.suppress_logs?
|
37
37
|
@app.call(env)
|
38
38
|
end
|
39
39
|
end
|
data/lib/wafris/version.rb
CHANGED
data/lib/wafris.rb
CHANGED
@@ -6,6 +6,7 @@ require 'redis'
|
|
6
6
|
|
7
7
|
require 'wafris/configuration'
|
8
8
|
require 'wafris/middleware'
|
9
|
+
require 'wafris/log_suppressor'
|
9
10
|
|
10
11
|
require 'wafris/railtie' if defined?(Rails::Railtie)
|
11
12
|
|
@@ -13,10 +14,10 @@ module Wafris
|
|
13
14
|
class << self
|
14
15
|
def configure
|
15
16
|
yield configuration
|
16
|
-
puts "[Wafris] attempting firewall connection via Wafris.configure initializer."
|
17
|
+
puts "[Wafris] attempting firewall connection via Wafris.configure initializer." unless LogSuppressor.suppress_logs?
|
17
18
|
configuration.create_settings
|
18
19
|
rescue Redis::CannotConnectError
|
19
|
-
puts "[Wafris] firewall disabled. Cannot connect via Wafris.configure. Please check your configuration settings."
|
20
|
+
puts "[Wafris] firewall disabled. Cannot connect via Wafris.configure. Please check your configuration settings." unless LogSuppressor.suppress_logs?
|
20
21
|
end
|
21
22
|
|
22
23
|
def configuration
|
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.1
|
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-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: connection_pool
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/lua/dist/wafris_core.lua
|
189
189
|
- lib/wafris.rb
|
190
190
|
- lib/wafris/configuration.rb
|
191
|
+
- lib/wafris/log_suppressor.rb
|
191
192
|
- lib/wafris/middleware.rb
|
192
193
|
- lib/wafris/railtie.rb
|
193
194
|
- lib/wafris/version.rb
|