wafris 1.1.2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7590310d437ae2574c37907b8c285e236b3e22686769cb2a5043a1e8a4c6171b
4
- data.tar.gz: 4bbc22d46692a7505b37845a5c39d8b5197441c6dc8b8bf61b12622fa690d9b6
3
+ metadata.gz: 6600b4667202df4429e13018d9eb1bdc0473029ad20dd5052e993f8390f06330
4
+ data.tar.gz: a4cf7a7781a19b03aa2c6389e24093b69f8b448c49beff1ddf798de9e9c97ef0
5
5
  SHA512:
6
- metadata.gz: 89063fcce8dcd2f35c10651bccc9de6b517f2925194493673fa6e2fa672eba4a6c3bfc1444624c957a70cd3d3b401cbc743ad13a0d8981fd5f18bcbba8eb02c8
7
- data.tar.gz: 61b32244a41efdca5cffa93f753e8bed5fdbf23849fb4f0f8773083493c3bb26e0a9cc23480584d41e674a1cb0fa749faafa428af2c741ee9d12c5fb8078c1d4
6
+ metadata.gz: 8eef758330be30b532d5b069df5db72d7bbbf8e98d277fe3cacc6842e8d01c997fcb1532810467497a2c87864f809b9fd83a0f13bfeef91a0503bfceace2f893
7
+ data.tar.gz: 0da7423796d0eb18d0d21d6ccda75555fe7042e1d5d999b539bfb13bde301d17b581b2b399faa122afc4e3acb32c567d5426cb04326dff34a81271319e341fd2
@@ -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
- 'redis-host', 'heroku')
33
- puts "[Wafris] firewall enabled. Connected to Redis. Ready to process requests. Set rules at: https://wafris.org/hub" unless LogSuppressor.suppress_logs?
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
@@ -2,6 +2,10 @@
2
2
 
3
3
  module Wafris
4
4
  class LogSuppressor
5
+ def self.puts_log(message)
6
+ message unless suppress_logs?
7
+ end
8
+
5
9
  def self.suppress_logs?
6
10
  suppressed_environments.include?(current_environment)
7
11
  end
@@ -33,7 +33,9 @@ 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." unless LogSuppressor.suppress_logs?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wafris
4
- VERSION = "1.1.2"
4
+ VERSION = "1.1.4"
5
5
  end
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
- def configure
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 configuration
24
- @configuration ||= Wafris::Configuration.new
25
- end
17
+ def configure
18
+ raise ArgumentError, "[Wafris] block is required to configure Wafris" unless block_given?
26
19
 
27
- def reset
28
- @configuration = Wafris::Configuration.new
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.2
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-13 00:00:00.000000000 Z
12
+ date: 2023-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: connection_pool
@@ -49,9 +49,6 @@ dependencies:
49
49
  name: redis
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '4.8'
55
52
  - - ">="
56
53
  - !ruby/object:Gem::Version
57
54
  version: 4.8.0
@@ -59,9 +56,6 @@ dependencies:
59
56
  prerelease: false
60
57
  version_requirements: !ruby/object:Gem::Requirement
61
58
  requirements:
62
- - - "~>"
63
- - !ruby/object:Gem::Version
64
- version: '4.8'
65
59
  - - ">="
66
60
  - !ruby/object:Gem::Version
67
61
  version: 4.8.0
@@ -103,82 +97,58 @@ dependencies:
103
97
  name: rack-test
104
98
  requirement: !ruby/object:Gem::Requirement
105
99
  requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '2.0'
109
100
  - - ">="
110
101
  - !ruby/object:Gem::Version
111
- version: 2.0.2
102
+ version: '0.6'
112
103
  type: :development
113
104
  prerelease: false
114
105
  version_requirements: !ruby/object:Gem::Requirement
115
106
  requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: '2.0'
119
107
  - - ">="
120
108
  - !ruby/object:Gem::Version
121
- version: 2.0.2
109
+ version: '0.6'
122
110
  - !ruby/object:Gem::Dependency
123
111
  name: rails
124
112
  requirement: !ruby/object:Gem::Requirement
125
113
  requirements:
126
- - - "~>"
127
- - !ruby/object:Gem::Version
128
- version: '7.0'
129
114
  - - ">="
130
115
  - !ruby/object:Gem::Version
131
- version: 7.0.4
116
+ version: '5.0'
132
117
  type: :development
133
118
  prerelease: false
134
119
  version_requirements: !ruby/object:Gem::Requirement
135
120
  requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '7.0'
139
121
  - - ">="
140
122
  - !ruby/object:Gem::Version
141
- version: 7.0.4
123
+ version: '5.0'
142
124
  - !ruby/object:Gem::Dependency
143
125
  name: railties
144
126
  requirement: !ruby/object:Gem::Requirement
145
127
  requirements:
146
- - - "~>"
147
- - !ruby/object:Gem::Version
148
- version: '7.0'
149
128
  - - ">="
150
129
  - !ruby/object:Gem::Version
151
- version: 7.0.4
130
+ version: '5.0'
152
131
  type: :development
153
132
  prerelease: false
154
133
  version_requirements: !ruby/object:Gem::Requirement
155
134
  requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '7.0'
159
135
  - - ">="
160
136
  - !ruby/object:Gem::Version
161
- version: 7.0.4
137
+ version: '5.0'
162
138
  - !ruby/object:Gem::Dependency
163
139
  name: rake
164
140
  requirement: !ruby/object:Gem::Requirement
165
141
  requirements:
166
- - - "~>"
167
- - !ruby/object:Gem::Version
168
- version: '13.0'
169
142
  - - ">="
170
143
  - !ruby/object:Gem::Version
171
- version: 13.0.6
144
+ version: '12.0'
172
145
  type: :development
173
146
  prerelease: false
174
147
  version_requirements: !ruby/object:Gem::Requirement
175
148
  requirements:
176
- - - "~>"
177
- - !ruby/object:Gem::Version
178
- version: '13.0'
179
149
  - - ">="
180
150
  - !ruby/object:Gem::Version
181
- version: 13.0.6
151
+ version: '12.0'
182
152
  description:
183
153
  email:
184
154
  executables: []
@@ -196,8 +166,13 @@ homepage:
196
166
  licenses:
197
167
  - Elastic-2.0
198
168
  metadata: {}
199
- post_install_message: " Thank you for installing the wafris gem. \n \n If
200
- you haven't already, please sign up for Wafris Hub at:\n\n https://wafris.org\n\n"
169
+ post_install_message: |2+
170
+ Thank you for installing the wafris gem.
171
+
172
+ If you haven't already, please sign up for Wafris Hub at:
173
+
174
+ https://wafris.org
175
+
201
176
  rdoc_options: []
202
177
  require_paths:
203
178
  - lib