paraxial 0.9.1 → 1.0.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: be68560342effbc4099f126d85e25acf0400e0b27dc636f4173192a9a634d3da
4
- data.tar.gz: 489450bae67581a1738754843a8ce3b6128ad098aa88228d1823bf41ce0ebada
3
+ metadata.gz: a679f1421bdbb16b511672a5f45ada85ac38811d657a4eebe3c2f25805fa7bc9
4
+ data.tar.gz: 24fc51622351b5fee13c9108bea3f4276857a73bd87f4ea0f6ca33dcccc4474d
5
5
  SHA512:
6
- metadata.gz: edd5307bcc69fcff116b2873d5571b035808f76bf508447403da5a1064d7faea2d230ceb12f0e6318469815b18d23254a6b4adf914b6c0bca009ac807f35d8fd
7
- data.tar.gz: f473320f53f772245dad48f68edeb47271ebe22e921b73b6cfe74506b6e5ccc8925ebf6621f2a4a46f0b6f9c2282c9580f498572f85dc6214fe21359d59dcc52
6
+ metadata.gz: fffaca550500aa79a5df9761f87a493eb94d35461c1e3cdb0d4b03fbfac00bc8289948a051adcab4237a5088f82c34e93b6be5178622096c2378d73773b15fd5
7
+ data.tar.gz: 1f8b328b62b810db88d7d1f496325d98f4f8fe05a627cf6f371d52ffb6aed5cedb13905b4fa0567014bf36d5a530977e5b2bfccaab5380157acf8b46c551cec5
@@ -130,21 +130,25 @@ module Paraxial
130
130
  end
131
131
 
132
132
  def self.ban_ip_msg(ip, length, msg)
133
- local_ban(ip)
134
-
135
- uri = URI.parse(Paraxial::Helpers.get_ruby_ban_url)
136
- body =
137
- {
138
- bad_ip: ip,
139
- ban_length: length,
140
- msg: msg,
141
- api_key: Paraxial::Helpers.get_api_key
142
- }
143
- r = Net::HTTP.post(uri, body.to_json, @headers)
144
- if r.code == '200'
145
- :ok
133
+ if allow_ip?(ip) == true
134
+ local_ban(ip)
135
+
136
+ uri = URI.parse(Paraxial::Helpers.get_ruby_ban_url)
137
+ body =
138
+ {
139
+ bad_ip: ip,
140
+ ban_length: length,
141
+ msg: msg,
142
+ api_key: Paraxial::Helpers.get_api_key
143
+ }
144
+ r = Net::HTTP.post(uri, body.to_json, @headers)
145
+ if r.code == '200'
146
+ :ok
147
+ else
148
+ :error
149
+ end
146
150
  else
147
- :error
151
+ :already_banned
148
152
  end
149
153
  end
150
154
 
data/lib/paraxial/cli.rb CHANGED
@@ -15,9 +15,11 @@ module Paraxial
15
15
  option :repo_owner, type: :string, desc: 'Repository owner'
16
16
  option :repo_name, type: :string, desc: 'Repository name'
17
17
  option :pr_number, type: :numeric, desc: 'Pull request number'
18
+ option :exit_code, type: :boolean, default: false, desc: 'Non-zero exit code if findings > 0'
19
+ option :debug_rubocop, type: :boolean, default: false, desc: "Run rubocop in debug mode"
18
20
 
19
21
  def scan
20
- puts '[Paraxial] Scan starting...'
22
+ puts "[Paraxial] v#{Paraxial::VERSION} Scan starting..."
21
23
  if check_rubocop_configuration
22
24
  puts '[Paraxial] .rubocop.yml is valid.'
23
25
  else
@@ -27,7 +29,6 @@ module Paraxial
27
29
  puts '- rubocop-erb'
28
30
  end
29
31
 
30
-
31
32
  if Paraxial::Helpers.get_api_key.nil?
32
33
  puts '[Paraxial] Environment variable PARAXIAL_API_KEY not found'
33
34
  else
@@ -36,9 +37,17 @@ module Paraxial
36
37
  repo_owner = options[:repo_owner]
37
38
  repo_name = options[:repo_name]
38
39
  pr_number = options[:pr_number]
40
+ exit_code = options[:exit_code]
39
41
 
40
42
  cops = 'Paraxial,Security/Eval,Security/IoMethods,Security/JSONLoad,Security/MarshalLoad,Security/Open,Security/YAMLLoad'
41
- rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json`
43
+ if options[:debug_rubocop]
44
+ puts '[Paraxial] rubocop debug enabled'
45
+ rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json 2>/dev/null`
46
+ debug_rubocop = `rubocop -d --require paraxial --only #{cops} --disable-pending-cops 2>&1`
47
+ puts debug_rubocop
48
+ else
49
+ rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json`
50
+ end
42
51
  lockfile = File.read('./Gemfile.lock')
43
52
  api_key = ENV['PARAXIAL_API_KEY']
44
53
  uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/ruby_scan')
@@ -95,6 +104,10 @@ module Paraxial
95
104
  else
96
105
  :ok
97
106
  end
107
+
108
+ if exit_code and (findings.length > 0)
109
+ exit(1)
110
+ end
98
111
  end
99
112
  end
100
113
 
@@ -9,7 +9,7 @@ Bundler.setup
9
9
 
10
10
  unless Rails.env.test? || File.basename($0) == 'rake' || defined?(Rails::Generators)
11
11
  Rails.application.config.to_prepare do
12
- puts '[Paraxial] Agent starting...'
12
+ puts "[Paraxial] v#{Paraxial::VERSION} Agent starting..."
13
13
  api_key = Paraxial::Helpers.get_api_key
14
14
 
15
15
  if api_key.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '0.9.1'
4
+ VERSION = '1.0.1'
5
5
  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: 0.9.1
4
+ version: 1.0.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-09-24 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec