paraxial 1.1.0 → 1.3.0

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: 8fc606825a60ae6e756bf7fda0fb6d3434e88075e8afe0ba1be0ab64c62304af
4
- data.tar.gz: 5e4daf86eb7f58a60abe6e3f3497381c9e4e4c70a289a230ec25a72a1427e7ad
3
+ metadata.gz: 0b27974dfe877ee32f7c49718c18916c39c6d13dff2b1fd0087b8da359207713
4
+ data.tar.gz: d93d8ab5654d522f8093f998afa5f65fc77c7abc363bd89c377dccca8b140bb3
5
5
  SHA512:
6
- metadata.gz: a8e809b4362e4182f23c1a997fb20dd3c05ec6dea16ae6e41d6f6b276a82334543abb223f5634bb5560dcc725059d7306f50a153ea373368f8be9cdab18eb521
7
- data.tar.gz: 1228d5f5ada089b496fe408fb6f4725733966adeb700948947195942ef7a13da8adda0c39e32575ac1d08632f594d72ac6fe374f6d88cca7a3cfd8d6338cb6d1
6
+ metadata.gz: 0e0e45aece62762e91542544721c3ff73ee9c0de01ee0215793ae2f4120cd9b21de34a392c0ab805805720e7955befb8a99d9a6ffa9a57571d95c73d5ebed34c
7
+ data.tar.gz: 242039eabbd12a31d0c5e48f0c7b63a18b559ec5f49d867ff7dabcd6fe81398ba8fb8e47f08cb6c1c43f3beecd94e71e62eff014acc83afb2ae718ce1864b2b3
data/lib/paraxial/cli.rb CHANGED
@@ -39,6 +39,25 @@ module Paraxial
39
39
  puts '[Paraxial] .paraxial-rubocop.yml is valid, .erb files will be scanned.'
40
40
  end
41
41
 
42
+ paraxial_config = get_paraxial_configuration
43
+
44
+ if paraxial_config && paraxial_config["ignore-gems"]
45
+ puts '[Paraxial] .paraxial.yml configuration file found.'
46
+ puts '[Paraxial] Gems ignored by dependency scan:'
47
+ puts paraxial_config["ignore-gems"]
48
+ elsif paraxial_config == :error
49
+ puts '[Paraxial] .paraxial.yml file is not well formed and is being ignored.'
50
+ paraxial_config = false
51
+ elsif paraxial_config
52
+ puts '[Paraxial] .paraxial.yml does not define a valid configuration. Using default configuration.'
53
+ paraxial_config = false
54
+ elsif paraxial_config == false
55
+ puts '[Paraxial] .paraxial.yml configuration file was not found. Using default configuration.'
56
+ else
57
+ puts '[Paraxial] .paraxial.yml configuration is empty. Using default configuration.'
58
+ paraxial_config = false
59
+ end
60
+
42
61
  if Paraxial::Helpers.get_api_key.nil?
43
62
  puts '[Paraxial] Environment variable PARAXIAL_API_KEY not found'
44
63
  else
@@ -64,7 +83,7 @@ module Paraxial
64
83
  uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/ruby_scan')
65
84
  headers = { 'Content-Type': 'application/json' }
66
85
 
67
- body = { rubocop: rubocop, lockfile: lockfile, api_key: api_key, timestamp: Paraxial.get_timestamp }
86
+ body = { rubocop: rubocop, lockfile: lockfile, api_key: api_key, paraxial_config: paraxial_config, timestamp: Paraxial.get_timestamp }
68
87
  response = Net::HTTP.post(uri, body.to_json, headers)
69
88
  m = JSON.parse(response.body)
70
89
 
@@ -130,6 +149,18 @@ module Paraxial
130
149
 
131
150
  private
132
151
 
152
+ def get_paraxial_configuration
153
+ config_file = File.join(Dir.pwd, '.paraxial.yml')
154
+
155
+ return false unless File.exist?(config_file)
156
+
157
+ begin
158
+ YAML.load_file(config_file)
159
+ rescue
160
+ :error
161
+ end
162
+ end
163
+
133
164
  def check_rubocop_configuration
134
165
  # return values:
135
166
  # :does_not_exist, :found_no_erb, :found_with_erb
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '1.1.0'
4
+ VERSION = '1.3.0'
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)
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.1.0
4
+ version: 1.3.0
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-10-30 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec