brakeman 3.0.5 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +19 -0
- data/README.md +3 -13
- data/lib/brakeman.rb +3 -0
- data/lib/brakeman/checks/base_check.rb +19 -47
- data/lib/brakeman/checks/check_basic_auth.rb +3 -3
- data/lib/brakeman/checks/check_cross_site_scripting.rb +26 -12
- data/lib/brakeman/checks/check_default_routes.rb +1 -1
- data/lib/brakeman/checks/check_detailed_exceptions.rb +2 -2
- data/lib/brakeman/checks/check_evaluation.rb +3 -0
- data/lib/brakeman/checks/check_execute.rb +3 -3
- data/lib/brakeman/checks/check_file_disclosure.rb +2 -2
- data/lib/brakeman/checks/check_forgery_setting.rb +9 -12
- data/lib/brakeman/checks/check_header_dos.rb +1 -1
- data/lib/brakeman/checks/check_i18n_xss.rb +2 -2
- data/lib/brakeman/checks/check_jruby_xml.rb +1 -1
- data/lib/brakeman/checks/check_json_encoding.rb +1 -1
- data/lib/brakeman/checks/check_json_parsing.rb +3 -3
- data/lib/brakeman/checks/check_link_to.rb +1 -1
- data/lib/brakeman/checks/check_link_to_href.rb +9 -2
- data/lib/brakeman/checks/check_mass_assignment.rb +5 -2
- data/lib/brakeman/checks/check_model_attr_accessible.rb +4 -4
- data/lib/brakeman/checks/check_model_attributes.rb +7 -7
- data/lib/brakeman/checks/check_model_serialize.rb +6 -6
- data/lib/brakeman/checks/check_nested_attributes.rb +2 -2
- data/lib/brakeman/checks/check_number_to_currency.rb +2 -2
- data/lib/brakeman/checks/check_quote_table_name.rb +1 -1
- data/lib/brakeman/checks/check_redirect.rb +2 -10
- data/lib/brakeman/checks/check_render.rb +1 -1
- data/lib/brakeman/checks/check_render_dos.rb +1 -1
- data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +1 -1
- data/lib/brakeman/checks/check_sanitize_methods.rb +1 -1
- data/lib/brakeman/checks/check_select_tag.rb +1 -1
- data/lib/brakeman/checks/check_select_vulnerability.rb +2 -2
- data/lib/brakeman/checks/check_session_settings.rb +1 -2
- data/lib/brakeman/checks/check_simple_format.rb +2 -2
- data/lib/brakeman/checks/check_single_quotes.rb +3 -3
- data/lib/brakeman/checks/check_skip_before_filter.rb +5 -7
- data/lib/brakeman/checks/check_sql.rb +10 -14
- data/lib/brakeman/checks/check_sql_cves.rb +4 -4
- data/lib/brakeman/checks/check_ssl_verify.rb +27 -9
- data/lib/brakeman/checks/check_strip_tags.rb +5 -5
- data/lib/brakeman/checks/check_symbol_dos_cve.rb +1 -1
- data/lib/brakeman/checks/check_translate_bug.rb +3 -4
- data/lib/brakeman/checks/check_unscoped_find.rb +1 -1
- data/lib/brakeman/checks/check_validation_regex.rb +2 -2
- data/lib/brakeman/checks/check_xml_dos.rb +1 -1
- data/lib/brakeman/checks/check_yaml_parsing.rb +1 -1
- data/lib/brakeman/file_parser.rb +1 -0
- data/lib/brakeman/parsers/template_parser.rb +6 -5
- data/lib/brakeman/processor.rb +7 -7
- data/lib/brakeman/processors/alias_processor.rb +30 -12
- data/lib/brakeman/processors/base_processor.rb +4 -8
- data/lib/brakeman/processors/controller_alias_processor.rb +33 -132
- data/lib/brakeman/processors/controller_processor.rb +29 -53
- data/lib/brakeman/processors/erb_template_processor.rb +4 -6
- data/lib/brakeman/processors/erubis_template_processor.rb +8 -11
- data/lib/brakeman/processors/gem_processor.rb +19 -35
- data/lib/brakeman/processors/haml_template_processor.rb +10 -12
- data/lib/brakeman/processors/lib/find_all_calls.rb +3 -5
- data/lib/brakeman/processors/lib/find_call.rb +2 -2
- data/lib/brakeman/processors/lib/find_return_value.rb +1 -1
- data/lib/brakeman/processors/lib/rails2_config_processor.rb +7 -8
- data/lib/brakeman/processors/lib/rails3_config_processor.rb +6 -7
- data/lib/brakeman/processors/lib/render_helper.rb +15 -14
- data/lib/brakeman/processors/lib/render_path.rb +11 -5
- data/lib/brakeman/processors/library_processor.rb +13 -35
- data/lib/brakeman/processors/model_processor.rb +22 -64
- data/lib/brakeman/processors/output_processor.rb +1 -37
- data/lib/brakeman/processors/slim_template_processor.rb +6 -8
- data/lib/brakeman/processors/template_alias_processor.rb +9 -9
- data/lib/brakeman/processors/template_processor.rb +5 -9
- data/lib/brakeman/report/report_base.rb +7 -7
- data/lib/brakeman/report/report_html.rb +5 -7
- data/lib/brakeman/report/report_markdown.rb +4 -6
- data/lib/brakeman/report/report_table.rb +4 -6
- data/lib/brakeman/rescanner.rb +29 -31
- data/lib/brakeman/scanner.rb +17 -8
- data/lib/brakeman/tracker.rb +24 -34
- data/lib/brakeman/tracker/collection.rb +77 -0
- data/lib/brakeman/tracker/config.rb +93 -0
- data/lib/brakeman/tracker/controller.rb +161 -0
- data/lib/brakeman/tracker/library.rb +17 -0
- data/lib/brakeman/tracker/model.rb +90 -0
- data/lib/brakeman/tracker/template.rb +33 -0
- data/lib/brakeman/util.rb +17 -9
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning.rb +8 -9
- data/lib/ruby_parser/bm_sexp.rb +16 -16
- data/lib/ruby_parser/bm_sexp_processor.rb +1 -120
- metadata +42 -31
- checksums.yaml.gz.sig +0 -1
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -6,19 +6,25 @@ module Brakeman
|
|
6
6
|
@path = []
|
7
7
|
end
|
8
8
|
|
9
|
-
def add_controller_render controller_name, method_name
|
9
|
+
def add_controller_render controller_name, method_name, line, file
|
10
10
|
method_name ||= ""
|
11
11
|
|
12
12
|
@path << { :type => :controller,
|
13
13
|
:class => controller_name.to_sym,
|
14
|
-
:method => method_name.to_sym
|
14
|
+
:method => method_name.to_sym,
|
15
|
+
:line => line,
|
16
|
+
:file => file
|
17
|
+
}
|
15
18
|
|
16
19
|
self
|
17
20
|
end
|
18
21
|
|
19
|
-
def add_template_render template_name
|
22
|
+
def add_template_render template_name, line, file
|
20
23
|
@path << { :type => :template,
|
21
|
-
:name => template_name.to_sym
|
24
|
+
:name => template_name.to_sym,
|
25
|
+
:line => line,
|
26
|
+
:file => file
|
27
|
+
}
|
22
28
|
|
23
29
|
self
|
24
30
|
end
|
@@ -89,7 +95,7 @@ module Brakeman
|
|
89
95
|
end
|
90
96
|
|
91
97
|
def to_json *args
|
92
|
-
MultiJson.dump(
|
98
|
+
MultiJson.dump(@path)
|
93
99
|
end
|
94
100
|
|
95
101
|
def initialize_copy original
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'brakeman/processors/base_processor'
|
2
2
|
require 'brakeman/processors/alias_processor'
|
3
|
+
require 'brakeman/tracker/library'
|
3
4
|
|
4
5
|
#Process generic library and stores it in Tracker.libs
|
5
6
|
class Brakeman::LibraryProcessor < Brakeman::BaseProcessor
|
@@ -23,29 +24,18 @@ class Brakeman::LibraryProcessor < Brakeman::BaseProcessor
|
|
23
24
|
|
24
25
|
if @current_class
|
25
26
|
outer_class = @current_class
|
26
|
-
name = (outer_class
|
27
|
+
name = (outer_class.name.to_s + "::" + name.to_s).to_sym
|
27
28
|
end
|
28
29
|
|
29
30
|
if @current_module
|
30
|
-
name = (@current_module
|
31
|
+
name = (@current_module.name.to_s + "::" + name.to_s).to_sym
|
31
32
|
end
|
32
33
|
|
33
34
|
if @tracker.libs[name]
|
34
35
|
@current_class = @tracker.libs[name]
|
35
|
-
@current_class
|
36
|
-
@current_class[:src][@file_name] = exp
|
36
|
+
@current_class.add_file @file_name, exp
|
37
37
|
else
|
38
|
-
@current_class =
|
39
|
-
:name => name,
|
40
|
-
:parent => parent,
|
41
|
-
:includes => [],
|
42
|
-
:public => {},
|
43
|
-
:private => {},
|
44
|
-
:protected => {},
|
45
|
-
:src => { @file_name => exp },
|
46
|
-
:files => [ @file_name ]
|
47
|
-
}
|
48
|
-
|
38
|
+
@current_class = Brakeman::Library.new name, parent, @file_name, exp, @tracker
|
49
39
|
@tracker.libs[name] = @current_class
|
50
40
|
end
|
51
41
|
|
@@ -65,28 +55,18 @@ class Brakeman::LibraryProcessor < Brakeman::BaseProcessor
|
|
65
55
|
|
66
56
|
if @current_module
|
67
57
|
outer_module = @current_module
|
68
|
-
name = (outer_module
|
58
|
+
name = (outer_module.name.to_s + "::" + name.to_s).to_sym
|
69
59
|
end
|
70
60
|
|
71
61
|
if @current_class
|
72
|
-
name = (@current_class
|
62
|
+
name = (@current_class.name.to_s + "::" + name.to_s).to_sym
|
73
63
|
end
|
74
64
|
|
75
65
|
if @tracker.libs[name]
|
76
66
|
@current_module = @tracker.libs[name]
|
77
|
-
@current_module
|
78
|
-
@current_module[:src][@file_name] = exp
|
67
|
+
@current_module.add_file @file_name, exp
|
79
68
|
else
|
80
|
-
@current_module =
|
81
|
-
:name => name,
|
82
|
-
:includes => [],
|
83
|
-
:public => {},
|
84
|
-
:private => {},
|
85
|
-
:protected => {},
|
86
|
-
:src => { @file_name => exp },
|
87
|
-
:files => [ @file_name ]
|
88
|
-
}
|
89
|
-
|
69
|
+
@current_module = Brakeman::Library.new name, nil, @file_name, exp, @tracker
|
90
70
|
@tracker.libs[name] = @current_module
|
91
71
|
end
|
92
72
|
|
@@ -103,14 +83,13 @@ class Brakeman::LibraryProcessor < Brakeman::BaseProcessor
|
|
103
83
|
|
104
84
|
def process_defn exp
|
105
85
|
exp = @alias_processor.process exp
|
106
|
-
exp.node_type = :methdef
|
107
86
|
|
108
87
|
if @current_class
|
109
88
|
exp.body = process_all! exp.body
|
110
|
-
@current_class
|
89
|
+
@current_class.add_method :public, exp.method_name, exp, @file_name
|
111
90
|
elsif @current_module
|
112
91
|
exp.body = process_all! exp.body
|
113
|
-
@current_module
|
92
|
+
@current_module.add_method :public, exp.method_name, exp, @file_name
|
114
93
|
end
|
115
94
|
|
116
95
|
exp
|
@@ -118,14 +97,13 @@ class Brakeman::LibraryProcessor < Brakeman::BaseProcessor
|
|
118
97
|
|
119
98
|
def process_defs exp
|
120
99
|
exp = @alias_processor.process exp
|
121
|
-
exp.node_type = :selfdef
|
122
100
|
|
123
101
|
if @current_class
|
124
102
|
exp.body = process_all! exp.body
|
125
|
-
@current_class
|
103
|
+
@current_class.add_method :public, exp.method_name, exp, @file_name
|
126
104
|
elsif @current_module
|
127
105
|
exp.body = process_all! exp.body
|
128
|
-
@current_module
|
106
|
+
@current_module.add_method :public, exp.method_name, exp, @file_name
|
129
107
|
end
|
130
108
|
|
131
109
|
exp
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'brakeman/processors/base_processor'
|
2
|
+
require 'brakeman/tracker/model'
|
2
3
|
|
3
4
|
#Processes models. Puts results in tracker.models
|
4
5
|
class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
5
6
|
|
6
|
-
ASSOCIATIONS = Set[:belongs_to, :has_one, :has_many, :has_and_belongs_to_many]
|
7
|
-
|
8
7
|
def initialize tracker
|
9
8
|
super
|
10
9
|
@current_class = nil
|
@@ -34,31 +33,18 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
|
34
33
|
|
35
34
|
if @current_class
|
36
35
|
outer_class = @current_class
|
37
|
-
name = (outer_class
|
36
|
+
name = (outer_class.name.to_s + "::" + name.to_s).to_sym
|
38
37
|
end
|
39
38
|
|
40
39
|
if @current_module
|
41
|
-
name = (@current_module
|
40
|
+
name = (@current_module.name.to_s + "::" + name.to_s).to_sym
|
42
41
|
end
|
43
42
|
|
44
43
|
if @tracker.models[name]
|
45
44
|
@current_class = @tracker.models[name]
|
46
|
-
@current_class
|
47
|
-
@current_class[:src][@file_name] = exp
|
45
|
+
@current_class.add_file @file_name, exp
|
48
46
|
else
|
49
|
-
@current_class =
|
50
|
-
:name => name,
|
51
|
-
:parent => parent,
|
52
|
-
:includes => [],
|
53
|
-
:public => {},
|
54
|
-
:private => {},
|
55
|
-
:protected => {},
|
56
|
-
:options => {},
|
57
|
-
:src => { @file_name => exp },
|
58
|
-
:associations => {},
|
59
|
-
:files => [ @file_name ]
|
60
|
-
}
|
61
|
-
|
47
|
+
@current_class = Brakeman::Model.new name, parent, @file_name, exp, @tracker
|
62
48
|
@tracker.models[name] = @current_class
|
63
49
|
end
|
64
50
|
|
@@ -78,30 +64,18 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
|
78
64
|
|
79
65
|
if @current_module
|
80
66
|
outer_module = @current_module
|
81
|
-
name = (outer_module
|
67
|
+
name = (outer_module.name.to_s + "::" + name.to_s).to_sym
|
82
68
|
end
|
83
69
|
|
84
70
|
if @current_class
|
85
|
-
name = (@current_class
|
71
|
+
name = (@current_class.name.to_s + "::" + name.to_s).to_sym
|
86
72
|
end
|
87
73
|
|
88
74
|
if @tracker.libs[name]
|
89
75
|
@current_module = @tracker.libs[name]
|
90
|
-
@current_module
|
91
|
-
@current_module[:src][@file_name] = exp
|
76
|
+
@current_module.add_file @file_name, exp
|
92
77
|
else
|
93
|
-
@current_module =
|
94
|
-
:name => name,
|
95
|
-
:includes => [],
|
96
|
-
:public => {},
|
97
|
-
:private => {},
|
98
|
-
:protected => {},
|
99
|
-
:options => {},
|
100
|
-
:src => { @file_name => exp },
|
101
|
-
:associations => {},
|
102
|
-
:files => [ @file_name ]
|
103
|
-
}
|
104
|
-
|
78
|
+
@current_module = Brakeman::Model.new name, nil, @file_name, exp, @tracker
|
105
79
|
@tracker.libs[name] = @current_module
|
106
80
|
end
|
107
81
|
|
@@ -136,37 +110,21 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
|
136
110
|
when :private, :protected, :public
|
137
111
|
@visibility = method
|
138
112
|
when :attr_accessible
|
139
|
-
@current_class
|
113
|
+
@current_class.set_attr_accessible
|
140
114
|
else
|
141
115
|
#??
|
142
116
|
end
|
143
117
|
else
|
144
118
|
case method
|
145
119
|
when :include
|
146
|
-
@current_class
|
120
|
+
@current_class.add_include class_name(first_arg) if @current_class
|
147
121
|
when :attr_accessible
|
148
|
-
@current_class
|
149
|
-
|
150
|
-
|
151
|
-
exp.each_arg do |e|
|
152
|
-
if node_type? e, :lit
|
153
|
-
args << e.value
|
154
|
-
elsif hash? e
|
155
|
-
@current_class[:options][:role_accessible] ||= []
|
156
|
-
@current_class[:options][:role_accessible].concat args
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
@current_class[:attr_accessible].concat args
|
122
|
+
@current_class.set_attr_accessible exp
|
123
|
+
when :attr_protected
|
124
|
+
@current_class.set_attr_protected exp
|
161
125
|
else
|
162
126
|
if @current_class
|
163
|
-
|
164
|
-
@current_class[:associations][method] ||= []
|
165
|
-
@current_class[:associations][method].concat exp.args
|
166
|
-
else
|
167
|
-
@current_class[:options][method] ||= []
|
168
|
-
@current_class[:options][method] << exp.arglist.line(exp.line)
|
169
|
-
end
|
127
|
+
@current_class.add_option method, exp
|
170
128
|
end
|
171
129
|
end
|
172
130
|
end
|
@@ -185,14 +143,14 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
|
185
143
|
name = exp.method_name
|
186
144
|
|
187
145
|
@current_method = name
|
188
|
-
res = Sexp.new :
|
146
|
+
res = Sexp.new :defn, name, exp.formal_args, *process_all!(exp.body)
|
189
147
|
res.line(exp.line)
|
190
148
|
@current_method = nil
|
191
149
|
|
192
150
|
if @current_class
|
193
|
-
@current_class
|
151
|
+
@current_class.add_method @visibility, name, res, @file_name
|
194
152
|
elsif @current_module
|
195
|
-
@current_module
|
153
|
+
@current_module.add_method @visibility, name, res, @file_name
|
196
154
|
end
|
197
155
|
|
198
156
|
res
|
@@ -205,7 +163,7 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
|
205
163
|
|
206
164
|
if exp[1].node_type == :self
|
207
165
|
if @current_class
|
208
|
-
target = @current_class
|
166
|
+
target = @current_class.name
|
209
167
|
elsif @current_module
|
210
168
|
target = @current_module
|
211
169
|
else
|
@@ -216,14 +174,14 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
|
|
216
174
|
end
|
217
175
|
|
218
176
|
@current_method = name
|
219
|
-
res = Sexp.new :
|
177
|
+
res = Sexp.new :defs, target, name, exp.formal_args, *process_all!(exp.body)
|
220
178
|
res.line(exp.line)
|
221
179
|
@current_method = nil
|
222
180
|
|
223
181
|
if @current_class
|
224
|
-
@current_class
|
182
|
+
@current_class.add_method @visibility, name, res, @file_name
|
225
183
|
elsif @current_module
|
226
|
-
@current_module
|
184
|
+
@current_module.add_method @visibility, name, res, @file_name
|
227
185
|
end
|
228
186
|
res
|
229
187
|
end
|
@@ -43,9 +43,6 @@ class Brakeman::OutputProcessor < Ruby2Ruby
|
|
43
43
|
"cookies"
|
44
44
|
end
|
45
45
|
|
46
|
-
alias process_string_interp process_dstr
|
47
|
-
alias process_string_eval process_evstr
|
48
|
-
|
49
46
|
def process_rlist exp
|
50
47
|
out = exp.map do |e|
|
51
48
|
res = process e
|
@@ -80,9 +77,7 @@ class Brakeman::OutputProcessor < Ruby2Ruby
|
|
80
77
|
return "def #{name}#{args}\n#{body}\nend".gsub(/\n\s*\n+/, "\n")
|
81
78
|
end
|
82
79
|
|
83
|
-
|
84
|
-
|
85
|
-
def process_call_with_block exp
|
80
|
+
def process_iter exp
|
86
81
|
call = process exp[0]
|
87
82
|
block = process_rlist exp[2..-1]
|
88
83
|
out = "#{call} do\n #{block}\n end"
|
@@ -173,35 +168,4 @@ class Brakeman::OutputProcessor < Ruby2Ruby
|
|
173
168
|
exp.clear
|
174
169
|
out
|
175
170
|
end
|
176
|
-
|
177
|
-
#This is copied from Ruby2Ruby, except the :string_eval type has been added
|
178
|
-
def util_dthing(type, exp)
|
179
|
-
s = []
|
180
|
-
|
181
|
-
# first item in sexp is a string literal
|
182
|
-
s << dthing_escape(type, exp.shift)
|
183
|
-
|
184
|
-
until exp.empty?
|
185
|
-
pt = exp.shift
|
186
|
-
case pt
|
187
|
-
when Sexp then
|
188
|
-
case pt.first
|
189
|
-
when :str then
|
190
|
-
s << dthing_escape(type, pt.last)
|
191
|
-
when :evstr, :string_eval then
|
192
|
-
s << '#{' << process(pt) << '}' # do not use interpolation here
|
193
|
-
else
|
194
|
-
raise "unknown type: #{pt.inspect}"
|
195
|
-
end
|
196
|
-
when String then
|
197
|
-
s << pt
|
198
|
-
else
|
199
|
-
# HACK: raise "huh?: #{pt.inspect}" -- hitting # constants in regexps
|
200
|
-
# do nothing for now
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
s.join
|
205
|
-
end
|
206
|
-
|
207
171
|
end
|
@@ -25,7 +25,7 @@ class Brakeman::SlimTemplateProcessor < Brakeman::TemplateProcessor
|
|
25
25
|
ignore
|
26
26
|
elsif render? arg
|
27
27
|
make_output make_render_in_view arg
|
28
|
-
elsif
|
28
|
+
elsif string_interp? arg
|
29
29
|
process_inside_interp arg
|
30
30
|
elsif node_type? arg, :ignore
|
31
31
|
ignore
|
@@ -38,24 +38,22 @@ class Brakeman::SlimTemplateProcessor < Brakeman::TemplateProcessor
|
|
38
38
|
exp.arglist = process exp.arglist
|
39
39
|
make_render_in_view exp
|
40
40
|
else
|
41
|
-
|
42
|
-
|
43
|
-
call.line(exp.line)
|
44
|
-
call
|
41
|
+
exp.arglist = process exp.arglist
|
42
|
+
exp
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
46
|
def make_output exp
|
49
47
|
s = Sexp.new :output, exp
|
50
48
|
s.line(exp.line)
|
51
|
-
@current_template
|
49
|
+
@current_template.add_output s
|
52
50
|
s
|
53
51
|
end
|
54
52
|
|
55
53
|
def make_escaped_output exp
|
56
54
|
s = Sexp.new :escaped_output, exp.first_arg
|
57
55
|
s.line(exp.line)
|
58
|
-
@current_template
|
56
|
+
@current_template.add_output s
|
59
57
|
s
|
60
58
|
end
|
61
59
|
|
@@ -63,7 +61,7 @@ class Brakeman::SlimTemplateProcessor < Brakeman::TemplateProcessor
|
|
63
61
|
#Better to pull those values out directly.
|
64
62
|
def process_inside_interp exp
|
65
63
|
exp.map! do |e|
|
66
|
-
if node_type? e, :evstr
|
64
|
+
if node_type? e, :evstr
|
67
65
|
e.value = process_interp_output e.value
|
68
66
|
e
|
69
67
|
else
|
@@ -18,23 +18,25 @@ class Brakeman::TemplateAliasProcessor < Brakeman::AliasProcessor
|
|
18
18
|
end
|
19
19
|
|
20
20
|
#Process template
|
21
|
-
def process_template name, args
|
21
|
+
def process_template name, args, _, line = nil
|
22
|
+
file = relative_path(@template.file || @tracker.templates[@template.name])
|
23
|
+
|
22
24
|
if @called_from
|
23
25
|
if @called_from.include_template? name
|
24
|
-
Brakeman.debug "Skipping circular render from #{@template
|
26
|
+
Brakeman.debug "Skipping circular render from #{@template.name} to #{name}"
|
25
27
|
return
|
26
28
|
end
|
27
29
|
|
28
|
-
super name, args, @called_from.dup.add_template_render(@template
|
30
|
+
super name, args, @called_from.dup.add_template_render(@template.name, line, file)
|
29
31
|
else
|
30
|
-
super name, args, Brakeman::RenderPath.new.add_template_render(@template
|
32
|
+
super name, args, Brakeman::RenderPath.new.add_template_render(@template.name, line, file)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
#Determine template name
|
35
37
|
def template_name name
|
36
|
-
if !name.to_s.include?('/') && @template
|
37
|
-
name = "#{@template
|
38
|
+
if !name.to_s.include?('/') && @template.name.to_s.include?('/')
|
39
|
+
name = "#{@template.name.to_s.match(/^(.*\/).*$/)[1]}#{name}"
|
38
40
|
end
|
39
41
|
name
|
40
42
|
end
|
@@ -43,7 +45,7 @@ class Brakeman::TemplateAliasProcessor < Brakeman::AliasProcessor
|
|
43
45
|
FORM_BUILDER_CALL = Sexp.new(:call, Sexp.new(:const, :FormBuilder), :new)
|
44
46
|
|
45
47
|
#Looks for form methods and iterating over collections of Models
|
46
|
-
def
|
48
|
+
def process_iter exp
|
47
49
|
process_default exp
|
48
50
|
|
49
51
|
call = exp.block_call
|
@@ -77,8 +79,6 @@ class Brakeman::TemplateAliasProcessor < Brakeman::AliasProcessor
|
|
77
79
|
exp
|
78
80
|
end
|
79
81
|
|
80
|
-
alias process_iter process_call_with_block
|
81
|
-
|
82
82
|
#Checks if +exp+ is a call to Model.all or Model.find*
|
83
83
|
def get_model_target exp
|
84
84
|
if call? exp
|