paraxial 1.0.2 → 1.1.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: 3849213ba15a24d63699e026fbf59c0c3633d66c2f9c3a20a787ecbb43d6a727
4
- data.tar.gz: ea7d9cf3fcd4909b51c98c0922b83e834c7d04a5df204cfc64e44b2701e0eb09
3
+ metadata.gz: 8fc606825a60ae6e756bf7fda0fb6d3434e88075e8afe0ba1be0ab64c62304af
4
+ data.tar.gz: 5e4daf86eb7f58a60abe6e3f3497381c9e4e4c70a289a230ec25a72a1427e7ad
5
5
  SHA512:
6
- metadata.gz: 860660578753aa78749fbadedcf1fc5789bc41ad1d89d1afbf17b60c10dfc6ddc8f6900a082d99b4e915db65e3e99c9c36ee490c05e49853dd681071865546a7
7
- data.tar.gz: fb5bfb5f315482914d0fad182489180558be34975f8e1224ce07f906b29ca59c7642d153505b0ec6cb5903e8c7b24e492ca301e91a2015c64b0379ae93d01e8d
6
+ metadata.gz: a8e809b4362e4182f23c1a997fb20dd3c05ec6dea16ae6e41d6f6b276a82334543abb223f5634bb5560dcc725059d7306f50a153ea373368f8be9cdab18eb521
7
+ data.tar.gz: 1228d5f5ada089b496fe408fb6f4725733966adeb700948947195942ef7a13da8adda0c39e32575ac1d08632f594d72ac6fe374f6d88cca7a3cfd8d6338cb6d1
data/lib/paraxial/cli.rb CHANGED
@@ -20,13 +20,23 @@ module Paraxial
20
20
 
21
21
  def scan
22
22
  puts "[Paraxial] v#{Paraxial::VERSION} Scan starting..."
23
- if check_rubocop_configuration
24
- puts '[Paraxial] .rubocop.yml is valid.'
25
- else
26
- puts '[Paraxial] .rubocop.yml is missing rubocop-erb. To scan embedded Ruby files for security problems, add:'
27
- puts '.rubocop.yml'
23
+
24
+ case check_rubocop_configuration
25
+ when :does_not_exist
26
+ puts '[Paraxial] .paraxial-rubocop.yml does not exist. This file is required for the scan to run, add:'
27
+ puts '.paraxial-rubocop.yml'
28
28
  puts 'require:'
29
29
  puts '- rubocop-erb'
30
+ puts ''
31
+ exit(1)
32
+ when :found_no_erb
33
+ puts '[Paraxial] .paraxial-rubocop.yml is missing rubocop-erb. To scan embedded Ruby files for security problems, add:'
34
+ puts '.paraxial-rubocop.yml'
35
+ puts 'require:'
36
+ puts '- rubocop-erb'
37
+ puts ''
38
+ when :found_with_erb
39
+ puts '[Paraxial] .paraxial-rubocop.yml is valid, .erb files will be scanned.'
30
40
  end
31
41
 
32
42
  if Paraxial::Helpers.get_api_key.nil?
@@ -40,13 +50,14 @@ module Paraxial
40
50
  exit_code = options[:exit_code]
41
51
 
42
52
  cops = 'Paraxial,Security/Eval,Security/IoMethods,Security/JSONLoad,Security/MarshalLoad,Security/Open,Security/YAMLLoad'
53
+ rubo_config = '--config .paraxial-rubocop.yml'
43
54
  if options[:debug_rubocop]
44
55
  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`
56
+ rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json #{rubo_config} 2>/dev/null`
57
+ debug_rubocop = `rubocop --debug --require paraxial --only #{cops} --disable-pending-cops #{rubo_config} 2>&1`
47
58
  puts debug_rubocop
48
59
  else
49
- rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json`
60
+ rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json #{rubo_config}`
50
61
  end
51
62
  lockfile = File.read('./Gemfile.lock')
52
63
  api_key = ENV['PARAXIAL_API_KEY']
@@ -56,6 +67,12 @@ module Paraxial
56
67
  body = { rubocop: rubocop, lockfile: lockfile, api_key: api_key, timestamp: Paraxial.get_timestamp }
57
68
  response = Net::HTTP.post(uri, body.to_json, headers)
58
69
  m = JSON.parse(response.body)
70
+
71
+ if m['ok'].nil?
72
+ puts "[Paraxial] Upload failed, check if PARAXIAL_API_KEY is valid"
73
+ exit(1)
74
+ end
75
+
59
76
  findings = m['ok']['findings']
60
77
  puts
61
78
  puts "[Paraxial] Scan count: #{findings.length}"
@@ -114,17 +131,20 @@ module Paraxial
114
131
  private
115
132
 
116
133
  def check_rubocop_configuration
117
- rubocop_file = File.join(Dir.pwd, '.rubocop.yml')
134
+ # return values:
135
+ # :does_not_exist, :found_no_erb, :found_with_erb
136
+
137
+ rubocop_file = File.join(Dir.pwd, '.paraxial-rubocop.yml')
118
138
 
119
- return false unless File.exist?(rubocop_file)
139
+ return :does_not_exist unless File.exist?(rubocop_file)
120
140
 
121
141
  config = YAML.load_file(rubocop_file)
122
142
  required_key = 'require'
123
143
 
124
- if config.is_a?(Hash) && config[required_key].is_a?(Array)
125
- config[required_key].include?('rubocop-erb')
144
+ if config.is_a?(Hash) && config[required_key].is_a?(Array) && config[required_key].include?('rubocop-erb')
145
+ :found_with_erb
126
146
  else
127
- false
147
+ :found_no_erb
128
148
  end
129
149
  end
130
150
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '1.0.2'
4
+ VERSION = '1.1.0'
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: 1.0.2
4
+ version: 1.1.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-16 00:00:00.000000000 Z
11
+ date: 2024-10-30 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.3.7
136
+ rubygems_version: 3.5.11
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Paraxial.io Ruby Agent