paraxial 1.0.1 → 1.1.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 +33 -13
- data/lib/paraxial/version.rb +1 -1
- data/lib/rubocop/cop/paraxial/sql.rb +6 -0
- 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: 8fc606825a60ae6e756bf7fda0fb6d3434e88075e8afe0ba1be0ab64c62304af
|
4
|
+
data.tar.gz: 5e4daf86eb7f58a60abe6e3f3497381c9e4e4c70a289a230ec25a72a1427e7ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.'
|
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
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
147
|
+
:found_no_erb
|
128
148
|
end
|
129
149
|
end
|
130
150
|
end
|
data/lib/paraxial/version.rb
CHANGED
@@ -86,6 +86,10 @@ module RuboCop
|
|
86
86
|
where
|
87
87
|
].freeze
|
88
88
|
|
89
|
+
def_node_matcher :object_manipulation?, <<~'PATTERN'
|
90
|
+
(send _ _ (send ...)) # Matches object methods (send node within a send)
|
91
|
+
PATTERN
|
92
|
+
|
89
93
|
def_node_matcher :non_literal_condition?, <<~'PATTERN'
|
90
94
|
(
|
91
95
|
send _ _ # Match `where` and `Model.find_by`
|
@@ -100,6 +104,8 @@ module RuboCop
|
|
100
104
|
end
|
101
105
|
|
102
106
|
def on_send(node)
|
107
|
+
return if object_manipulation?(node)
|
108
|
+
|
103
109
|
return unless non_literal_condition?(node)
|
104
110
|
|
105
111
|
add_offense(node)
|
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.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-
|
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.
|
136
|
+
rubygems_version: 3.5.11
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Paraxial.io Ruby Agent
|