brakeman-lib 4.8.1 → 4.10.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 +4 -4
- data/CHANGES.md +39 -0
- data/README.md +5 -3
- data/lib/brakeman.rb +20 -0
- data/lib/brakeman/checks/base_check.rb +1 -1
- data/lib/brakeman/checks/check_basic_auth.rb +2 -0
- data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +28 -0
- data/lib/brakeman/checks/check_deserialize.rb +21 -1
- data/lib/brakeman/checks/check_execute.rb +1 -1
- data/lib/brakeman/checks/check_json_entity_escape.rb +38 -0
- data/lib/brakeman/checks/check_mass_assignment.rb +19 -4
- data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -1
- data/lib/brakeman/checks/check_model_attributes.rb +1 -1
- data/lib/brakeman/checks/check_page_caching_cve.rb +37 -0
- data/lib/brakeman/checks/check_permit_attributes.rb +1 -1
- data/lib/brakeman/checks/check_regex_dos.rb +1 -1
- data/lib/brakeman/checks/check_skip_before_filter.rb +4 -4
- data/lib/brakeman/checks/check_sql.rb +1 -1
- data/lib/brakeman/checks/check_template_injection.rb +32 -0
- data/lib/brakeman/commandline.rb +25 -1
- data/lib/brakeman/file_parser.rb +5 -0
- data/lib/brakeman/options.rb +21 -1
- data/lib/brakeman/processors/alias_processor.rb +4 -5
- data/lib/brakeman/processors/controller_processor.rb +1 -1
- data/lib/brakeman/processors/haml_template_processor.rb +8 -1
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +1 -1
- data/lib/brakeman/processors/lib/find_all_calls.rb +27 -12
- data/lib/brakeman/processors/output_processor.rb +1 -1
- data/lib/brakeman/processors/template_alias_processor.rb +5 -0
- data/lib/brakeman/report.rb +7 -0
- data/lib/brakeman/report/ignore/config.rb +4 -0
- data/lib/brakeman/report/report_sarif.rb +114 -0
- data/lib/brakeman/report/report_text.rb +37 -16
- data/lib/brakeman/scanner.rb +4 -1
- data/lib/brakeman/tracker.rb +3 -1
- data/lib/brakeman/tracker/config.rb +6 -4
- data/lib/brakeman/tracker/constants.rb +8 -7
- data/lib/brakeman/tracker/controller.rb +1 -1
- data/lib/brakeman/util.rb +18 -2
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning_codes.rb +6 -0
- data/lib/ruby_parser/bm_sexp.rb +9 -9
- metadata +38 -5
data/lib/brakeman/scanner.rb
CHANGED
@@ -94,11 +94,14 @@ class Brakeman::Scanner
|
|
94
94
|
#
|
95
95
|
#Stores parsed information in tracker.config
|
96
96
|
def process_config
|
97
|
+
# Sometimes folks like to put constants in environment.rb
|
98
|
+
# so let's always process it even for newer Rails versions
|
99
|
+
process_config_file "environment.rb"
|
100
|
+
|
97
101
|
if options[:rails3] or options[:rails4] or options[:rails5] or options[:rails6]
|
98
102
|
process_config_file "application.rb"
|
99
103
|
process_config_file "environments/production.rb"
|
100
104
|
else
|
101
|
-
process_config_file "environment.rb"
|
102
105
|
process_config_file "gems.rb"
|
103
106
|
end
|
104
107
|
|
data/lib/brakeman/tracker.rb
CHANGED
@@ -198,8 +198,10 @@ class Brakeman::Tracker
|
|
198
198
|
@constants.add name, value, context unless @options[:disable_constant_tracking]
|
199
199
|
end
|
200
200
|
|
201
|
+
# This method does not return all constants at this time,
|
202
|
+
# just ones with "simple" values.
|
201
203
|
def constant_lookup name
|
202
|
-
@constants.
|
204
|
+
@constants.get_simple_value name unless @options[:disable_constant_tracking]
|
203
205
|
end
|
204
206
|
|
205
207
|
def find_class name
|
@@ -54,7 +54,7 @@ module Brakeman
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def gem_version name
|
57
|
-
extract_version @gems.dig(name, :version)
|
57
|
+
extract_version @gems.dig(name.to_sym, :version)
|
58
58
|
end
|
59
59
|
|
60
60
|
def add_gem name, version, file, line
|
@@ -67,11 +67,11 @@ module Brakeman
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def has_gem? name
|
70
|
-
!!@gems[name]
|
70
|
+
!!@gems[name.to_sym]
|
71
71
|
end
|
72
72
|
|
73
73
|
def get_gem name
|
74
|
-
@gems[name]
|
74
|
+
@gems[name.to_sym]
|
75
75
|
end
|
76
76
|
|
77
77
|
def set_rails_version version = nil
|
@@ -79,7 +79,9 @@ module Brakeman
|
|
79
79
|
# Only used by Rails2ConfigProcessor right now
|
80
80
|
extract_version(version)
|
81
81
|
else
|
82
|
-
gem_version(:rails) ||
|
82
|
+
gem_version(:rails) ||
|
83
|
+
gem_version(:railties) ||
|
84
|
+
gem_version(:activerecord)
|
83
85
|
end
|
84
86
|
|
85
87
|
if version
|
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'brakeman/processors/output_processor'
|
2
|
+
require 'brakeman/util'
|
2
3
|
|
3
4
|
module Brakeman
|
4
5
|
class Constant
|
6
|
+
include Brakeman::Util
|
7
|
+
|
5
8
|
attr_reader :name, :name_array, :file, :value, :context
|
6
9
|
|
7
10
|
def initialize name, value, context = {}
|
@@ -107,13 +110,11 @@ module Brakeman
|
|
107
110
|
@constants[base_name] << Constant.new(name, value, context)
|
108
111
|
end
|
109
112
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
def get_literal name
|
116
|
-
if x = self[name] and literal? x
|
113
|
+
# Returns constant values that are not too complicated.
|
114
|
+
# Right now that means literal values (string, array, etc.)
|
115
|
+
# or calls on Dir.glob(..).whatever.
|
116
|
+
def get_simple_value name
|
117
|
+
if x = self[name] and (literal? x or dir_glob? x)
|
117
118
|
x
|
118
119
|
else
|
119
120
|
nil
|
data/lib/brakeman/util.rb
CHANGED
@@ -293,6 +293,22 @@ module Brakeman::Util
|
|
293
293
|
exp.is_a? Sexp and types.include? exp.node_type
|
294
294
|
end
|
295
295
|
|
296
|
+
LITERALS = [:lit, :false, :str, :true, :array, :hash]
|
297
|
+
|
298
|
+
def literal? exp
|
299
|
+
exp.is_a? Sexp and LITERALS.include? exp.node_type
|
300
|
+
end
|
301
|
+
|
302
|
+
DIR_CONST = s(:const, :Dir)
|
303
|
+
|
304
|
+
# Dir.glob(...).whatever
|
305
|
+
def dir_glob? exp
|
306
|
+
exp = exp.block_call if node_type? exp, :iter
|
307
|
+
return unless call? exp
|
308
|
+
|
309
|
+
(exp.target == DIR_CONST and exp.method == :glob) or dir_glob? exp.target
|
310
|
+
end
|
311
|
+
|
296
312
|
#Returns true if the given _exp_ contains a :class node.
|
297
313
|
#
|
298
314
|
#Useful for checking if a module is just a module or if it is a namespace.
|
@@ -305,7 +321,7 @@ module Brakeman::Util
|
|
305
321
|
if node_type? current, :class
|
306
322
|
return true
|
307
323
|
elsif sexp? current
|
308
|
-
todo = current
|
324
|
+
todo = current.sexp_body.concat todo
|
309
325
|
end
|
310
326
|
end
|
311
327
|
|
@@ -318,7 +334,7 @@ module Brakeman::Util
|
|
318
334
|
if args.empty? or args.first.empty?
|
319
335
|
#nothing to do
|
320
336
|
elsif node_type? args.first, :arglist
|
321
|
-
call.concat args.first
|
337
|
+
call.concat args.first.sexp_body
|
322
338
|
elsif args.first.node_type.is_a? Sexp #just a list of args
|
323
339
|
call.concat args.first
|
324
340
|
else
|
data/lib/brakeman/version.rb
CHANGED
@@ -114,6 +114,12 @@ module Brakeman::WarningCodes
|
|
114
114
|
:unsafe_cookie_serialization => 110,
|
115
115
|
:reverse_tabnabbing => 111,
|
116
116
|
:mass_assign_permit_all => 112,
|
117
|
+
:json_html_escape_config => 113,
|
118
|
+
:json_html_escape_module => 114,
|
119
|
+
:CVE_2020_8159 => 115,
|
120
|
+
:CVE_2020_8166 => 116,
|
121
|
+
:erb_template_injection => 117,
|
122
|
+
|
117
123
|
:custom_check => 9090,
|
118
124
|
}
|
119
125
|
|
data/lib/ruby_parser/bm_sexp.rb
CHANGED
@@ -175,7 +175,7 @@ class Sexp
|
|
175
175
|
start_index = 3
|
176
176
|
|
177
177
|
if exp.is_a? Sexp and exp.node_type == :arglist
|
178
|
-
exp = exp
|
178
|
+
exp = exp.sexp_body
|
179
179
|
end
|
180
180
|
|
181
181
|
exp.each_with_index do |e, i|
|
@@ -198,10 +198,10 @@ class Sexp
|
|
198
198
|
|
199
199
|
case self.node_type
|
200
200
|
when :call, :attrasgn, :safe_call, :safe_attrasgn
|
201
|
-
self
|
201
|
+
self.sexp_body(3).unshift :arglist
|
202
202
|
when :super, :zsuper
|
203
203
|
if self[1]
|
204
|
-
self
|
204
|
+
self.sexp_body.unshift :arglist
|
205
205
|
else
|
206
206
|
Sexp.new(:arglist)
|
207
207
|
end
|
@@ -218,13 +218,13 @@ class Sexp
|
|
218
218
|
case self.node_type
|
219
219
|
when :call, :attrasgn, :safe_call, :safe_attrasgn
|
220
220
|
if self[3]
|
221
|
-
self
|
221
|
+
self.sexp_body(3)
|
222
222
|
else
|
223
223
|
Sexp.new
|
224
224
|
end
|
225
225
|
when :super, :zsuper
|
226
226
|
if self[1]
|
227
|
-
self
|
227
|
+
self.sexp_body
|
228
228
|
else
|
229
229
|
Sexp.new
|
230
230
|
end
|
@@ -512,7 +512,7 @@ class Sexp
|
|
512
512
|
self.slice!(index..-1) #Remove old body
|
513
513
|
|
514
514
|
if exp.first == :rlist
|
515
|
-
exp = exp
|
515
|
+
exp = exp.sexp_body
|
516
516
|
end
|
517
517
|
|
518
518
|
#Insert new body
|
@@ -529,11 +529,11 @@ class Sexp
|
|
529
529
|
|
530
530
|
case self.node_type
|
531
531
|
when :defn, :class
|
532
|
-
self
|
532
|
+
self.sexp_body(3)
|
533
533
|
when :defs
|
534
|
-
self
|
534
|
+
self.sexp_body(4)
|
535
535
|
when :module
|
536
|
-
self
|
536
|
+
self.sexp_body(2)
|
537
537
|
end
|
538
538
|
end
|
539
539
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brakeman-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Collins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov-html
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.2
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: ruby_parser
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,7 +201,7 @@ dependencies:
|
|
187
201
|
version: 1.3.6
|
188
202
|
- - "<="
|
189
203
|
- !ruby/object:Gem::Version
|
190
|
-
version: 4.
|
204
|
+
version: '4.1'
|
191
205
|
type: :runtime
|
192
206
|
prerelease: false
|
193
207
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -197,7 +211,21 @@ dependencies:
|
|
197
211
|
version: 1.3.6
|
198
212
|
- - "<="
|
199
213
|
- !ruby/object:Gem::Version
|
200
|
-
version: 4.
|
214
|
+
version: '4.1'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: rexml
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - "~>"
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '3.0'
|
222
|
+
type: :runtime
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - "~>"
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '3.0'
|
201
229
|
description: Brakeman detects security vulnerabilities in Ruby on Rails applications
|
202
230
|
via static analysis. This package declares gem dependencies instead of bundling
|
203
231
|
them.
|
@@ -222,6 +250,7 @@ files:
|
|
222
250
|
- lib/brakeman/checks/check_cookie_serialization.rb
|
223
251
|
- lib/brakeman/checks/check_create_with.rb
|
224
252
|
- lib/brakeman/checks/check_cross_site_scripting.rb
|
253
|
+
- lib/brakeman/checks/check_csrf_token_forgery_cve.rb
|
225
254
|
- lib/brakeman/checks/check_default_routes.rb
|
226
255
|
- lib/brakeman/checks/check_deserialize.rb
|
227
256
|
- lib/brakeman/checks/check_detailed_exceptions.rb
|
@@ -240,6 +269,7 @@ files:
|
|
240
269
|
- lib/brakeman/checks/check_i18n_xss.rb
|
241
270
|
- lib/brakeman/checks/check_jruby_xml.rb
|
242
271
|
- lib/brakeman/checks/check_json_encoding.rb
|
272
|
+
- lib/brakeman/checks/check_json_entity_escape.rb
|
243
273
|
- lib/brakeman/checks/check_json_parsing.rb
|
244
274
|
- lib/brakeman/checks/check_link_to.rb
|
245
275
|
- lib/brakeman/checks/check_link_to_href.rb
|
@@ -252,6 +282,7 @@ files:
|
|
252
282
|
- lib/brakeman/checks/check_nested_attributes.rb
|
253
283
|
- lib/brakeman/checks/check_nested_attributes_bypass.rb
|
254
284
|
- lib/brakeman/checks/check_number_to_currency.rb
|
285
|
+
- lib/brakeman/checks/check_page_caching_cve.rb
|
255
286
|
- lib/brakeman/checks/check_permit_attributes.rb
|
256
287
|
- lib/brakeman/checks/check_quote_table_name.rb
|
257
288
|
- lib/brakeman/checks/check_redirect.rb
|
@@ -281,6 +312,7 @@ files:
|
|
281
312
|
- lib/brakeman/checks/check_strip_tags.rb
|
282
313
|
- lib/brakeman/checks/check_symbol_dos.rb
|
283
314
|
- lib/brakeman/checks/check_symbol_dos_cve.rb
|
315
|
+
- lib/brakeman/checks/check_template_injection.rb
|
284
316
|
- lib/brakeman/checks/check_translate_bug.rb
|
285
317
|
- lib/brakeman/checks/check_unsafe_reflection.rb
|
286
318
|
- lib/brakeman/checks/check_unscoped_find.rb
|
@@ -350,6 +382,7 @@ files:
|
|
350
382
|
- lib/brakeman/report/report_json.rb
|
351
383
|
- lib/brakeman/report/report_junit.rb
|
352
384
|
- lib/brakeman/report/report_markdown.rb
|
385
|
+
- lib/brakeman/report/report_sarif.rb
|
353
386
|
- lib/brakeman/report/report_table.rb
|
354
387
|
- lib/brakeman/report/report_tabs.rb
|
355
388
|
- lib/brakeman/report/report_text.rb
|
@@ -406,7 +439,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
406
439
|
- !ruby/object:Gem::Version
|
407
440
|
version: '0'
|
408
441
|
requirements: []
|
409
|
-
rubygems_version: 3.
|
442
|
+
rubygems_version: 3.2.2
|
410
443
|
signing_key:
|
411
444
|
specification_version: 4
|
412
445
|
summary: Security vulnerability scanner for Ruby on Rails.
|