brakeman-lib 7.0.0 → 7.0.2
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 +4 -4
- data/CHANGES.md +13 -0
- data/README.md +1 -1
- data/lib/brakeman/app_tree.rb +6 -1
- data/lib/brakeman/checks/check_evaluation.rb +39 -20
- data/lib/brakeman/checks/check_weak_rsa_key.rb +1 -1
- data/lib/brakeman/options.rb +4 -0
- data/lib/brakeman/processors/alias_processor.rb +3 -2
- data/lib/brakeman/scanner.rb +22 -13
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman.rb +7 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6159d3bde042821529cf3e5200e88de8e8706879cf44fb273e3291bb68d4f2b7
|
4
|
+
data.tar.gz: bf06c105b4c21ca099b017f9407f582a7a47515bebe5a834c8fe8296382b9a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf1296b60acc90093aab77e65fbdc6d2f9ea4c60371b7bfd5d6301b3fd2e7195f46bec8b3d3811a011f144d22d597303a41bf517d4d257eec382d52de0d109f
|
7
|
+
data.tar.gz: f4770665453293c3b06b9bb3bdca5216eb81d8696e929fcc9d4dd2d416a017296664794134022a6812bda18fe16fffaedb17daa2ff93e049eb0ee760eb5e00fc
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 7.0.2 - 2025-04-04
|
2
|
+
|
3
|
+
* Fix error with empty `BUNDLE_GEMFILE` env variable
|
4
|
+
|
5
|
+
# 7.0.1 - 2025-04-03
|
6
|
+
|
7
|
+
* Avoid warning on evaluation of plain strings
|
8
|
+
* Enable use of custom/alternative Gemfiles
|
9
|
+
* Fix error on directory with `rb` extension (viralpraxis)
|
10
|
+
* Support `terminal-table` 4.0 (Chedli Bourguiba)
|
11
|
+
* Better support Prism 1.4.0
|
12
|
+
* Only output timing for each file when using `--debug`
|
13
|
+
|
1
14
|
# 7.0.0 - 2024-12-30
|
2
15
|
|
3
16
|
* Always warn about deserializing from Marshal
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ Outside of Rails root (note that the output file is relative to path/to/rails/ap
|
|
63
63
|
|
64
64
|
# Compatibility
|
65
65
|
|
66
|
-
Brakeman should work with any version of Rails from 2.3.x to
|
66
|
+
Brakeman should work with any version of Rails from 2.3.x to 8.x.
|
67
67
|
|
68
68
|
Brakeman can analyze code written with Ruby 2.0 syntax and newer, but requires at least Ruby 3.0.0 to run.
|
69
69
|
|
data/lib/brakeman/app_tree.rb
CHANGED
@@ -190,7 +190,12 @@ module Brakeman
|
|
190
190
|
paths = select_only_files(paths)
|
191
191
|
paths = reject_skipped_files(paths)
|
192
192
|
paths = convert_to_file_paths(paths)
|
193
|
-
reject_global_excludes(paths)
|
193
|
+
paths = reject_global_excludes(paths)
|
194
|
+
reject_directories(paths)
|
195
|
+
end
|
196
|
+
|
197
|
+
def reject_directories(paths)
|
198
|
+
paths.reject { |path| File.directory?(path) }
|
194
199
|
end
|
195
200
|
|
196
201
|
def select_only_files(paths)
|
@@ -22,27 +22,29 @@ class Brakeman::CheckEvaluation < Brakeman::BaseCheck
|
|
22
22
|
def process_result result
|
23
23
|
return unless original? result
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
first_arg = result[:call].first_arg
|
26
|
+
|
27
|
+
unless safe_value? first_arg
|
28
|
+
if input = include_user_input?(first_arg)
|
29
|
+
confidence = :high
|
30
|
+
message = msg(msg_input(input), " evaluated as code")
|
31
|
+
elsif string_evaluation? first_arg
|
32
|
+
confidence = :low
|
33
|
+
message = "Dynamic string evaluated as code"
|
34
|
+
elsif result[:call].method == :eval
|
35
|
+
confidence = :low
|
36
|
+
message = "Dynamic code evaluation"
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
if confidence
|
40
|
+
warn :result => result,
|
41
|
+
:warning_type => "Dangerous Eval",
|
42
|
+
:warning_code => :code_eval,
|
43
|
+
:message => message,
|
44
|
+
:user_input => input,
|
45
|
+
:confidence => confidence,
|
46
|
+
:cwe_id => [913, 95]
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -50,4 +52,21 @@ class Brakeman::CheckEvaluation < Brakeman::BaseCheck
|
|
50
52
|
string_interp? exp or
|
51
53
|
(call? exp and string? exp.target)
|
52
54
|
end
|
55
|
+
|
56
|
+
def safe_value? exp
|
57
|
+
return true unless sexp? exp
|
58
|
+
|
59
|
+
case exp.sexp_type
|
60
|
+
when :dstr
|
61
|
+
exp.all? { |e| safe_value? e}
|
62
|
+
when :evstr
|
63
|
+
safe_value? exp.value
|
64
|
+
when :str, :lit
|
65
|
+
true
|
66
|
+
when :call
|
67
|
+
always_safe_method? exp.method
|
68
|
+
else
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
53
72
|
end
|
data/lib/brakeman/options.rb
CHANGED
@@ -226,6 +226,10 @@ module Brakeman::Options
|
|
226
226
|
options[:follow_symlinks] = follow_symlinks
|
227
227
|
end
|
228
228
|
|
229
|
+
opts.on '--gemfile GEMFILE', 'Specify Gemfile to scan' do |gemfile|
|
230
|
+
options[:gemfile] = gemfile
|
231
|
+
end
|
232
|
+
|
229
233
|
opts.on "-E", "--enable Check1,Check2,etc", Array, "Enable the specified checks" do |checks|
|
230
234
|
checks.map! do |check|
|
231
235
|
if check.start_with? "Check"
|
@@ -270,7 +270,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
|
|
270
270
|
end
|
271
271
|
when :<<
|
272
272
|
if string? target and string? first_arg
|
273
|
-
target.value
|
273
|
+
target.value += first_arg.value
|
274
274
|
env[target_var] = target
|
275
275
|
return target
|
276
276
|
elsif string? target and string_interp? first_arg
|
@@ -278,8 +278,9 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
|
|
278
278
|
env[target_var] = exp
|
279
279
|
elsif string? first_arg and string_interp? target
|
280
280
|
if string? target.last
|
281
|
-
target.last.value
|
281
|
+
target.last.value += first_arg.value
|
282
282
|
elsif target.last.is_a? String
|
283
|
+
# TODO Use target.last += ?
|
283
284
|
target.last << first_arg.value
|
284
285
|
else
|
285
286
|
target << first_arg
|
data/lib/brakeman/scanner.rb
CHANGED
@@ -32,6 +32,7 @@ class Brakeman::Scanner
|
|
32
32
|
|
33
33
|
@processor = processor || Brakeman::Processor.new(@app_tree, options)
|
34
34
|
@show_timing = tracker.options[:debug] || tracker.options[:show_timing]
|
35
|
+
@per_file_timing = tracker.options[:debug] && tracker.options[:show_timing]
|
35
36
|
end
|
36
37
|
|
37
38
|
#Returns the Tracker generated from the scan
|
@@ -58,7 +59,7 @@ class Brakeman::Scanner
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def process_step_file description
|
61
|
-
if @
|
62
|
+
if @per_file_timing
|
62
63
|
Brakeman.notify "Processing #{description}"
|
63
64
|
|
64
65
|
start_t = Time.now
|
@@ -230,21 +231,29 @@ class Brakeman::Scanner
|
|
230
231
|
#Process Gemfile
|
231
232
|
def process_gems
|
232
233
|
gem_files = {}
|
234
|
+
gem_file_names = ['Gemfile', 'gems.rb']
|
235
|
+
lock_file_names = ['Gemfile.lock', 'gems.locked']
|
233
236
|
|
234
|
-
if
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
file = @app_tree.file_path("gems.rb")
|
239
|
-
gem_files[:gemfile] = { :src => parse_ruby_file(file), :file => file }
|
237
|
+
if tracker.options[:gemfile]
|
238
|
+
name = tracker.options[:gemfile]
|
239
|
+
gem_file_names.unshift name
|
240
|
+
lock_file_names.unshift "#{name}.lock"
|
240
241
|
end
|
241
242
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
243
|
+
gem_file_names.each do |name|
|
244
|
+
if @app_tree.exists? name
|
245
|
+
file = @app_tree.file_path(name)
|
246
|
+
gem_files[:gemfile] = { :src => parse_ruby_file(file), :file => file }
|
247
|
+
break
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
lock_file_names.each do |name|
|
252
|
+
if @app_tree.exists? name
|
253
|
+
file = @app_tree.file_path(name)
|
254
|
+
gem_files[:gemlock] = { :src => file.read, :file => file }
|
255
|
+
break
|
256
|
+
end
|
248
257
|
end
|
249
258
|
|
250
259
|
if @app_tree.gemspec
|
data/lib/brakeman/version.rb
CHANGED
data/lib/brakeman.rb
CHANGED
@@ -127,6 +127,13 @@ module Brakeman
|
|
127
127
|
options[:output_formats] = get_output_formats options
|
128
128
|
options[:github_url] = get_github_url options
|
129
129
|
|
130
|
+
|
131
|
+
# Use ENV value only if option was not already explicitly set
|
132
|
+
# (i.e. prefer commandline option over environment variable).
|
133
|
+
if options[:gemfile].nil? and ENV['BUNDLE_GEMFILE'] and not ENV['BUNDLE_GEMFILE'].empty?
|
134
|
+
options[:gemfile] = ENV['BUNDLE_GEMFILE']
|
135
|
+
end
|
136
|
+
|
130
137
|
options
|
131
138
|
end
|
132
139
|
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brakeman-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Collins
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: minitest
|
@@ -141,14 +142,14 @@ dependencies:
|
|
141
142
|
requirements:
|
142
143
|
- - "<"
|
143
144
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
145
|
+
version: '5.0'
|
145
146
|
type: :runtime
|
146
147
|
prerelease: false
|
147
148
|
version_requirements: !ruby/object:Gem::Requirement
|
148
149
|
requirements:
|
149
150
|
- - "<"
|
150
151
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
152
|
+
version: '5.0'
|
152
153
|
- !ruby/object:Gem::Dependency
|
153
154
|
name: highline
|
154
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -452,6 +453,7 @@ metadata:
|
|
452
453
|
mailing_list_uri: https://gitter.im/presidentbeef/brakeman
|
453
454
|
source_code_uri: https://github.com/presidentbeef/brakeman
|
454
455
|
wiki_uri: https://github.com/presidentbeef/brakeman/wiki
|
456
|
+
post_install_message:
|
455
457
|
rdoc_options: []
|
456
458
|
require_paths:
|
457
459
|
- lib
|
@@ -466,7 +468,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
466
468
|
- !ruby/object:Gem::Version
|
467
469
|
version: '0'
|
468
470
|
requirements: []
|
469
|
-
rubygems_version: 3.
|
471
|
+
rubygems_version: 3.3.27
|
472
|
+
signing_key:
|
470
473
|
specification_version: 4
|
471
474
|
summary: Security vulnerability scanner for Ruby on Rails.
|
472
475
|
test_files: []
|