paraxial 1.2.0 → 1.3.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: 51fd89540b5bb3bea0b1487cc67e255c6b8597f87215ff70256370a1499b78c9
4
- data.tar.gz: 863d248900cb324777b4bfe11dc7bd0dfffd9bc4766642c2d63502b2804fbfe2
3
+ metadata.gz: baa2ee1790a37ff9ba35dabce992774e0a7d1090e6b5ffd9fb24fcc3eefd037c
4
+ data.tar.gz: 8d454295bf64117f57e9df2c90a3cb6e888b291f0d40d101b3b264c02cbc7b8e
5
5
  SHA512:
6
- metadata.gz: 33df2b745e8cc43b41a4bb36cff045039fc8db0d807676d025d38553ecaf39a9f2fde3b26aafe11f12b9ddd1ff5560c18146b7d481a695c14184a6943bbf85cb
7
- data.tar.gz: be45476d228f23b7dc49436a97802c284abcaa6561f76ab49b5bfa1a729ecdaefb3d8f84d043737920eb2b72411e40eb84e42eec8eba1e433a0b801dce7f7df9
6
+ metadata.gz: 8406bf6da59a65c52c31b5dd2fa7c967924a4f6de9a6a6b1695877a01643ebc8e08d79e7f6cf53f5a95bf5af495dac550fdefbf6d28f98957afb8b1a34c46cac
7
+ data.tar.gz: f5327f15ba804a0a50fa3575fee33dd6db99cb99c0e1ab58aa22cd5248e9d169d3fe5c8c66e991d5dec18ca66640b1697e7ef86622381fbe0201a6c672aa862b
@@ -7,7 +7,7 @@ require_relative '../free_tier'
7
7
 
8
8
  Bundler.setup
9
9
 
10
- unless Rails.env.test? || File.basename($0) == 'rake' || defined?(Rails::Generators)
10
+ unless Rails.env.test? || File.basename($0) == 'rake' || Paraxial.do_not_start?
11
11
  Rails.application.config.to_prepare do
12
12
  puts "[Paraxial] v#{Paraxial::VERSION} Agent starting..."
13
13
  api_key = Paraxial::Helpers.get_api_key
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.1'
5
5
  end
data/lib/paraxial.rb CHANGED
@@ -21,17 +21,26 @@ module Paraxial
21
21
  class Error < StandardError; end
22
22
  # Your code goes here...
23
23
 
24
- class Defense
25
- def initialize(app)
24
+ class PHPAttackMiddleware
25
+ VALID_LENGTHS = [:hour, :day, :week, :infinity]
26
+
27
+ def initialize(app, length: :hour)
26
28
  @app = app
29
+ if VALID_LENGTHS.include?(length)
30
+ @ban_length = length
31
+ else
32
+ puts "[Paraxial] PHPAttackMiddleware invalid ban length: #{length}, using hour"
33
+ @ban_length = :hour
34
+ end
27
35
  end
28
36
 
29
37
  def call(env)
30
- request_path = env['PATH_INFO']
38
+ request = ActionDispatch::Request.new(env)
31
39
 
32
- if request_path.end_with?('.php')
40
+ if request.path.downcase.end_with?('.php')
41
+ Paraxial.ban_ip_msg(request.remote_ip, @ban_length, "Sent request ending in .php")
33
42
  # Return a 404 response if the request path ends with '.php'
34
- [404, { 'Content-Type' => 'text/plain' }, ['Not Found from Paraxial.io']]
43
+ [404, { 'Content-Type' => 'text/plain' }, ['Not Found']]
35
44
  else
36
45
  # Pass the request to the next middleware or the application
37
46
  @app.call(env)
@@ -167,7 +176,7 @@ module Paraxial
167
176
 
168
177
  def self.check_exploit_guard
169
178
  if configuration.nil?
170
- puts "[Paraxial] Exploit Guard, no configuration exists, will not run"
179
+ # puts "[Paraxial] Exploit Guard, no configuration exists, will not run"
171
180
  return
172
181
  end
173
182
 
@@ -190,4 +199,21 @@ module Paraxial
190
199
  @exploit_guard = nil
191
200
  end
192
201
  end
202
+
203
+ def self.do_not_start?
204
+ defined?(Rails::Command::CredentialsCommand) ||
205
+ defined?(Rails::Command::Db::System::ChangeCommand) ||
206
+ defined?(Rails::Command::DbConsoleCommand) ||
207
+ defined?(Rails::Command::DestroyCommand) ||
208
+ defined?(Rails::Command::DevCommand) ||
209
+ defined?(Rails::Command::EncryptedCommand) ||
210
+ defined?(Rails::Command::GenerateCommand) ||
211
+ defined?(Rails::Command::InitializersCommand) ||
212
+ defined?(Rails::Command::NotesCommand) ||
213
+ defined?(Rails::Command::RoutesCommand) ||
214
+ defined?(Rails::Command::RunnerCommand) ||
215
+ defined?(Rails::Command::SecretsCommand) ||
216
+ defined?(Rails::Command::AboutCommand) ||
217
+ defined?(Rails::Command::DbconsoleCommand)
218
+ end
193
219
  end
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.2.0
4
+ version: 1.3.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-07 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.5.11
136
+ rubygems_version: 3.5.23
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Paraxial.io Ruby Agent