wafris 1.1.0 → 1.1.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: 919967ec8203e767f77202e17964dbcfd21f60422bb91bd61b806575886c5dbf
4
- data.tar.gz: ffe9b975f6613e1742c90b6335e85f53769d439d32f014517487142a97edb37e
3
+ metadata.gz: 73475a40b943b5e9fb0dbfd3800a1548f188e29403d86ba06a1beb5937b28a9b
4
+ data.tar.gz: 45c9fefafd42733d95bb370390096925c16ffdf1eb7dfe2bca660a2e0c068782
5
5
  SHA512:
6
- metadata.gz: 4efff1ae48ec5417bf9917c0a3b7f073064216ee718eed8246f0b993397454ab4296a2e27ac48a1289f31abe20ca277d32f4bc848978a7c4dd88d04ee08c4cdb
7
- data.tar.gz: 274d14a646e0e706a940d16c53adb050045df1593056f012ba47666af402c37e38a055038fa2074a73e32e73cc49bcf5f5d943c16e7bff71bd3d79d47e8aaadc
6
+ metadata.gz: '025458318f9afa210b624690dfa613e5a979045b8116010bbbec7b22048dd4a424e5e3d4ca51fb6473dd902ac13de7216ba48c49ecfffc2e61d8d82b886a9716'
7
+ data.tar.gz: 908c8e51856c7defcf8f033f5dbbe54a06018f0a3400c67aeca715a130e69e4a89d5be537edb545597a7fdf01802c04bccc7973f44bcc510fe8d30255e398fec
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wafris
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
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.0
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-07 00:00:00.000000000 Z
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