paraxial 1.3.1 → 1.4.1

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: baa2ee1790a37ff9ba35dabce992774e0a7d1090e6b5ffd9fb24fcc3eefd037c
4
- data.tar.gz: 8d454295bf64117f57e9df2c90a3cb6e888b291f0d40d101b3b264c02cbc7b8e
3
+ metadata.gz: a049e14f86235b3984d52cb9d0401e42ec85deb103ae479df22ee73f52020f76
4
+ data.tar.gz: a05102fc73df7dc030be7a009de6a77be503aab05722dc7ff23fc8db10246f05
5
5
  SHA512:
6
- metadata.gz: 8406bf6da59a65c52c31b5dd2fa7c967924a4f6de9a6a6b1695877a01643ebc8e08d79e7f6cf53f5a95bf5af495dac550fdefbf6d28f98957afb8b1a34c46cac
7
- data.tar.gz: f5327f15ba804a0a50fa3575fee33dd6db99cb99c0e1ab58aa22cd5248e9d169d3fe5c8c66e991d5dec18ca66640b1697e7ef86622381fbe0201a6c672aa862b
6
+ metadata.gz: 2f3af29e03215f6315ada3200487edadbd4c8bce1dba0c2ef1ff7dc73af72a1fb870a6474b40276e8a43e89baf94aedd286118bbc052216605bb39226ba67df8
7
+ data.tar.gz: 10ab830e631b9fa6b550b74a9c88ce87ed4917014574ecd8cbd25acee4fc76401bcc73994e83f73c5b0018641e6ab43f40d700737dbcbe58a2833799eaa8edb3
@@ -7,7 +7,7 @@ module Paraxial
7
7
  @mutex = Mutex.new
8
8
  @headers = { 'Content-Type': 'application/json' }
9
9
 
10
- if Paraxial::Helpers.get_api_key
10
+ if Paraxial::Helpers.get_api_key and !Paraxial.configuration&.disable_http_tick
11
11
  @thread = Thread.new do
12
12
  loop do
13
13
  get_abr
@@ -130,7 +130,11 @@ module Paraxial
130
130
  end
131
131
 
132
132
  def self.ban_ip_msg(ip, length, msg)
133
- if allow_ip?(ip) == true
133
+ if whitelist_ip?(ip)
134
+ :on_whitelist
135
+ elsif blacklist_ip?(ip)
136
+ :already_banned
137
+ else
134
138
  local_ban(ip)
135
139
 
136
140
  uri = URI.parse(Paraxial::Helpers.get_ruby_ban_url)
@@ -147,8 +151,6 @@ module Paraxial
147
151
  else
148
152
  :error
149
153
  end
150
- else
151
- :already_banned
152
154
  end
153
155
  end
154
156
 
@@ -166,19 +168,6 @@ module Paraxial
166
168
  end
167
169
  end
168
170
 
169
- def self.ban_ip(ip)
170
- local_ban(ip)
171
- uri = URI.parse(Paraxial::Helpers.get_ban_url)
172
-
173
- body = { api_key: Paraxial::Helpers.get_api_key, ip_address: ip }
174
- r = Net::HTTP.post(uri, body.to_json, @headers)
175
- if r.code == '200'
176
- :ok
177
- else
178
- :error
179
- end
180
- end
181
-
182
171
  def self.local_ban(ip)
183
172
  if ip.include?('.')
184
173
  # IPv4
@@ -193,21 +182,19 @@ module Paraxial
193
182
  end
194
183
  end
195
184
 
196
- def self.allow_ip?(ip)
185
+ def self.whitelist_ip?(ip)
197
186
  if ip.include?('.')
198
- if !@allows['v4'].search_best(ip).nil? # v4 on allow list
199
- true
200
- elsif !@bans['v4'].search_best(ip).nil? # v4 on ban list
201
- false
202
- else # v4 on no list
203
- true
204
- end
205
- elsif !@allows['v6'].search_best(ip).nil? # v6 on allow list
206
- true
207
- elsif !@bans['v6'].search_best(ip).nil? # v6 on ban list
208
- false
209
- else # v6 on no list
210
- true
187
+ !@allows['v4'].search_best(ip).nil? # v4 on allow list
188
+ else
189
+ !@allows['v6'].search_best(ip).nil? # v6 on allow list
190
+ end
191
+ end
192
+
193
+ def self.blacklist_ip?(ip)
194
+ if ip.include?('.')
195
+ !@bans['v4'].search_best(ip).nil? # v4 on allow list
196
+ else
197
+ !@bans['v6'].search_best(ip).nil? # v6 on allow list
211
198
  end
212
199
  end
213
200
  end
@@ -1,7 +1,7 @@
1
1
  module Paraxial
2
2
  module Helpers
3
3
  def self.get_paraxial_url
4
- @paraxial_url ||= ENV['PARAXIAL_URL'] || 'https://app.paraxial.io/'
4
+ @paraxial_url ||= ENV['PARAXIAL_URL'] || 'https://app.paraxial.io'
5
5
  end
6
6
 
7
7
  def self.get_ban_url
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '1.3.1'
4
+ VERSION = '1.4.1'
5
5
  end
data/lib/paraxial.rb CHANGED
@@ -98,14 +98,16 @@ module Paraxial
98
98
  def self.req_allowed?(request)
99
99
  return if Paraxial::Helpers.get_api_key.nil?
100
100
 
101
- if request.env['paraxial.deny'] == true
102
- false
103
- elsif Paraxial::Checker.allow_ip?(request.remote_ip) == true
101
+ if Paraxial::Checker.whitelist_ip?(request.remote_ip)
104
102
  request.env['paraxial.deny'] = false
105
103
  true
106
- else
104
+ elsif Paraxial::Checker.blacklist_ip?(request.remote_ip)
107
105
  request.env['paraxial.deny'] = true
108
106
  false
107
+ elsif request.env['paraxial.deny']
108
+ false
109
+ else
110
+ true
109
111
  end
110
112
  end
111
113
 
@@ -129,12 +131,6 @@ module Paraxial
129
131
  end
130
132
  end
131
133
 
132
- def self.ban_ip(ip)
133
- return if Paraxial::Helpers.get_api_key.nil?
134
-
135
- Paraxial::Checker.ban_ip(ip)
136
- end
137
-
138
134
  def self.ban_ip_msg(ip, length, msg)
139
135
  return if Paraxial::Helpers.get_api_key.nil?
140
136
 
@@ -147,12 +143,6 @@ module Paraxial
147
143
  Paraxial::Checker.honeypot_ban(ip, length)
148
144
  end
149
145
 
150
- def self.allow_ip?(ip)
151
- return if Paraxial::Helpers.get_api_key.nil?
152
-
153
- Paraxial::Checker.allow_ip?(ip)
154
- end
155
-
156
146
  def self.trim_dep(input)
157
147
  if input.nil?
158
148
  nil
@@ -194,9 +184,11 @@ module Paraxial
194
184
 
195
185
  class Configuration
196
186
  attr_accessor :exploit_guard
187
+ attr_accessor :disable_http_tick
197
188
 
198
189
  def initialize
199
190
  @exploit_guard = nil
191
+ @disable_http_tick = nil
200
192
  end
201
193
  end
202
194
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paraxial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lubas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec