paraxial 1.0.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paraxial/cli.rb +65 -14
- data/lib/paraxial/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51fd89540b5bb3bea0b1487cc67e255c6b8597f87215ff70256370a1499b78c9
|
4
|
+
data.tar.gz: 863d248900cb324777b4bfe11dc7bd0dfffd9bc4766642c2d63502b2804fbfe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33df2b745e8cc43b41a4bb36cff045039fc8db0d807676d025d38553ecaf39a9f2fde3b26aafe11f12b9ddd1ff5560c18146b7d481a695c14184a6943bbf85cb
|
7
|
+
data.tar.gz: be45476d228f23b7dc49436a97802c284abcaa6561f76ab49b5bfa1a729ecdaefb3d8f84d043737920eb2b72411e40eb84e42eec8eba1e433a0b801dce7f7df9
|
data/lib/paraxial/cli.rb
CHANGED
@@ -20,13 +20,42 @@ module Paraxial
|
|
20
20
|
|
21
21
|
def scan
|
22
22
|
puts "[Paraxial] v#{Paraxial::VERSION} Scan starting..."
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
puts '[Paraxial] .rubocop.yml
|
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.'
|
40
|
+
end
|
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
|
30
59
|
end
|
31
60
|
|
32
61
|
if Paraxial::Helpers.get_api_key.nil?
|
@@ -40,22 +69,29 @@ module Paraxial
|
|
40
69
|
exit_code = options[:exit_code]
|
41
70
|
|
42
71
|
cops = 'Paraxial,Security/Eval,Security/IoMethods,Security/JSONLoad,Security/MarshalLoad,Security/Open,Security/YAMLLoad'
|
72
|
+
rubo_config = '--config .paraxial-rubocop.yml'
|
43
73
|
if options[:debug_rubocop]
|
44
74
|
puts '[Paraxial] rubocop debug enabled'
|
45
|
-
rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json 2>/dev/null`
|
46
|
-
debug_rubocop = `rubocop
|
75
|
+
rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json #{rubo_config} 2>/dev/null`
|
76
|
+
debug_rubocop = `rubocop --debug --require paraxial --only #{cops} --disable-pending-cops #{rubo_config} 2>&1`
|
47
77
|
puts debug_rubocop
|
48
78
|
else
|
49
|
-
rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json`
|
79
|
+
rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json #{rubo_config}`
|
50
80
|
end
|
51
81
|
lockfile = File.read('./Gemfile.lock')
|
52
82
|
api_key = ENV['PARAXIAL_API_KEY']
|
53
83
|
uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/ruby_scan')
|
54
84
|
headers = { 'Content-Type': 'application/json' }
|
55
85
|
|
56
|
-
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 }
|
57
87
|
response = Net::HTTP.post(uri, body.to_json, headers)
|
58
88
|
m = JSON.parse(response.body)
|
89
|
+
|
90
|
+
if m['ok'].nil?
|
91
|
+
puts "[Paraxial] Upload failed, check if PARAXIAL_API_KEY is valid"
|
92
|
+
exit(1)
|
93
|
+
end
|
94
|
+
|
59
95
|
findings = m['ok']['findings']
|
60
96
|
puts
|
61
97
|
puts "[Paraxial] Scan count: #{findings.length}"
|
@@ -113,18 +149,33 @@ module Paraxial
|
|
113
149
|
|
114
150
|
private
|
115
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
|
+
|
116
164
|
def check_rubocop_configuration
|
117
|
-
|
165
|
+
# return values:
|
166
|
+
# :does_not_exist, :found_no_erb, :found_with_erb
|
167
|
+
|
168
|
+
rubocop_file = File.join(Dir.pwd, '.paraxial-rubocop.yml')
|
118
169
|
|
119
|
-
return
|
170
|
+
return :does_not_exist unless File.exist?(rubocop_file)
|
120
171
|
|
121
172
|
config = YAML.load_file(rubocop_file)
|
122
173
|
required_key = 'require'
|
123
174
|
|
124
|
-
if config.is_a?(Hash) && config[required_key].is_a?(Array)
|
125
|
-
|
175
|
+
if config.is_a?(Hash) && config[required_key].is_a?(Array) && config[required_key].include?('rubocop-erb')
|
176
|
+
:found_with_erb
|
126
177
|
else
|
127
|
-
|
178
|
+
:found_no_erb
|
128
179
|
end
|
129
180
|
end
|
130
181
|
end
|
data/lib/paraxial/version.rb
CHANGED
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
|
4
|
+
version: 1.2.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-
|
11
|
+
date: 2024-11-07 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.
|
136
|
+
rubygems_version: 3.5.11
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Paraxial.io Ruby Agent
|