brakeman 3.0.5 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +19 -0
  3. data/README.md +3 -13
  4. data/lib/brakeman.rb +3 -0
  5. data/lib/brakeman/checks/base_check.rb +19 -47
  6. data/lib/brakeman/checks/check_basic_auth.rb +3 -3
  7. data/lib/brakeman/checks/check_cross_site_scripting.rb +26 -12
  8. data/lib/brakeman/checks/check_default_routes.rb +1 -1
  9. data/lib/brakeman/checks/check_detailed_exceptions.rb +2 -2
  10. data/lib/brakeman/checks/check_evaluation.rb +3 -0
  11. data/lib/brakeman/checks/check_execute.rb +3 -3
  12. data/lib/brakeman/checks/check_file_disclosure.rb +2 -2
  13. data/lib/brakeman/checks/check_forgery_setting.rb +9 -12
  14. data/lib/brakeman/checks/check_header_dos.rb +1 -1
  15. data/lib/brakeman/checks/check_i18n_xss.rb +2 -2
  16. data/lib/brakeman/checks/check_jruby_xml.rb +1 -1
  17. data/lib/brakeman/checks/check_json_encoding.rb +1 -1
  18. data/lib/brakeman/checks/check_json_parsing.rb +3 -3
  19. data/lib/brakeman/checks/check_link_to.rb +1 -1
  20. data/lib/brakeman/checks/check_link_to_href.rb +9 -2
  21. data/lib/brakeman/checks/check_mass_assignment.rb +5 -2
  22. data/lib/brakeman/checks/check_model_attr_accessible.rb +4 -4
  23. data/lib/brakeman/checks/check_model_attributes.rb +7 -7
  24. data/lib/brakeman/checks/check_model_serialize.rb +6 -6
  25. data/lib/brakeman/checks/check_nested_attributes.rb +2 -2
  26. data/lib/brakeman/checks/check_number_to_currency.rb +2 -2
  27. data/lib/brakeman/checks/check_quote_table_name.rb +1 -1
  28. data/lib/brakeman/checks/check_redirect.rb +2 -10
  29. data/lib/brakeman/checks/check_render.rb +1 -1
  30. data/lib/brakeman/checks/check_render_dos.rb +1 -1
  31. data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +1 -1
  32. data/lib/brakeman/checks/check_sanitize_methods.rb +1 -1
  33. data/lib/brakeman/checks/check_select_tag.rb +1 -1
  34. data/lib/brakeman/checks/check_select_vulnerability.rb +2 -2
  35. data/lib/brakeman/checks/check_session_settings.rb +1 -2
  36. data/lib/brakeman/checks/check_simple_format.rb +2 -2
  37. data/lib/brakeman/checks/check_single_quotes.rb +3 -3
  38. data/lib/brakeman/checks/check_skip_before_filter.rb +5 -7
  39. data/lib/brakeman/checks/check_sql.rb +10 -14
  40. data/lib/brakeman/checks/check_sql_cves.rb +4 -4
  41. data/lib/brakeman/checks/check_ssl_verify.rb +27 -9
  42. data/lib/brakeman/checks/check_strip_tags.rb +5 -5
  43. data/lib/brakeman/checks/check_symbol_dos_cve.rb +1 -1
  44. data/lib/brakeman/checks/check_translate_bug.rb +3 -4
  45. data/lib/brakeman/checks/check_unscoped_find.rb +1 -1
  46. data/lib/brakeman/checks/check_validation_regex.rb +2 -2
  47. data/lib/brakeman/checks/check_xml_dos.rb +1 -1
  48. data/lib/brakeman/checks/check_yaml_parsing.rb +1 -1
  49. data/lib/brakeman/file_parser.rb +1 -0
  50. data/lib/brakeman/parsers/template_parser.rb +6 -5
  51. data/lib/brakeman/processor.rb +7 -7
  52. data/lib/brakeman/processors/alias_processor.rb +30 -12
  53. data/lib/brakeman/processors/base_processor.rb +4 -8
  54. data/lib/brakeman/processors/controller_alias_processor.rb +33 -132
  55. data/lib/brakeman/processors/controller_processor.rb +29 -53
  56. data/lib/brakeman/processors/erb_template_processor.rb +4 -6
  57. data/lib/brakeman/processors/erubis_template_processor.rb +8 -11
  58. data/lib/brakeman/processors/gem_processor.rb +19 -35
  59. data/lib/brakeman/processors/haml_template_processor.rb +10 -12
  60. data/lib/brakeman/processors/lib/find_all_calls.rb +3 -5
  61. data/lib/brakeman/processors/lib/find_call.rb +2 -2
  62. data/lib/brakeman/processors/lib/find_return_value.rb +1 -1
  63. data/lib/brakeman/processors/lib/rails2_config_processor.rb +7 -8
  64. data/lib/brakeman/processors/lib/rails3_config_processor.rb +6 -7
  65. data/lib/brakeman/processors/lib/render_helper.rb +15 -14
  66. data/lib/brakeman/processors/lib/render_path.rb +11 -5
  67. data/lib/brakeman/processors/library_processor.rb +13 -35
  68. data/lib/brakeman/processors/model_processor.rb +22 -64
  69. data/lib/brakeman/processors/output_processor.rb +1 -37
  70. data/lib/brakeman/processors/slim_template_processor.rb +6 -8
  71. data/lib/brakeman/processors/template_alias_processor.rb +9 -9
  72. data/lib/brakeman/processors/template_processor.rb +5 -9
  73. data/lib/brakeman/report/report_base.rb +7 -7
  74. data/lib/brakeman/report/report_html.rb +5 -7
  75. data/lib/brakeman/report/report_markdown.rb +4 -6
  76. data/lib/brakeman/report/report_table.rb +4 -6
  77. data/lib/brakeman/rescanner.rb +29 -31
  78. data/lib/brakeman/scanner.rb +17 -8
  79. data/lib/brakeman/tracker.rb +24 -34
  80. data/lib/brakeman/tracker/collection.rb +77 -0
  81. data/lib/brakeman/tracker/config.rb +93 -0
  82. data/lib/brakeman/tracker/controller.rb +161 -0
  83. data/lib/brakeman/tracker/library.rb +17 -0
  84. data/lib/brakeman/tracker/model.rb +90 -0
  85. data/lib/brakeman/tracker/template.rb +33 -0
  86. data/lib/brakeman/util.rb +17 -9
  87. data/lib/brakeman/version.rb +1 -1
  88. data/lib/brakeman/warning.rb +8 -9
  89. data/lib/ruby_parser/bm_sexp.rb +16 -16
  90. data/lib/ruby_parser/bm_sexp_processor.rb +1 -120
  91. metadata +42 -31
  92. checksums.yaml.gz.sig +0 -1
  93. data.tar.gz.sig +0 -0
  94. metadata.gz.sig +0 -0
@@ -34,7 +34,7 @@ class Brakeman::ErbTemplateProcessor < Brakeman::TemplateProcessor
34
34
  else
35
35
  s = Sexp.new :output, arg
36
36
  s.line(exp.line)
37
- @current_template[:outputs] << s
37
+ @current_template.add_output s
38
38
  s
39
39
  end
40
40
  elsif method == :force_encoding
@@ -46,11 +46,9 @@ class Brakeman::ErbTemplateProcessor < Brakeman::TemplateProcessor
46
46
  exp.arglist = process(exp.arglist)
47
47
  make_render_in_view exp
48
48
  else
49
- #TODO: Is it really necessary to create a new Sexp here?
50
- call = make_call target, method, process_all!(exp.args)
51
- call.original_line = exp.original_line
52
- call.line(exp.line)
53
- call
49
+ exp.target = target
50
+ exp.arglist = process(exp.arglist)
51
+ exp
54
52
  end
55
53
  end
56
54
 
@@ -9,12 +9,14 @@ class Brakeman::ErubisTemplateProcessor < Brakeman::TemplateProcessor
9
9
  if sexp? target
10
10
  target = process target
11
11
  end
12
+
13
+ exp.target = target
14
+ exp.arglist = process exp.arglist
12
15
  method = exp.method
13
16
 
14
17
  #_buf is the default output variable for Erubis
15
18
  if node_type?(target, :lvar, :ivar) and (target.value == :_buf or target.value == :@output_buffer)
16
19
  if method == :<< or method == :safe_concat
17
- exp.arglist = process exp.arglist
18
20
 
19
21
  arg = exp.first_arg
20
22
 
@@ -28,12 +30,12 @@ class Brakeman::ErubisTemplateProcessor < Brakeman::TemplateProcessor
28
30
  elsif node_type? target, :ivar and target.value == :@output_buffer
29
31
  s = Sexp.new :escaped_output, arg
30
32
  s.line(exp.line)
31
- @current_template[:outputs] << s
33
+ @current_template.add_output s
32
34
  s
33
35
  else
34
36
  s = Sexp.new :output, arg
35
37
  s.line(exp.line)
36
- @current_template[:outputs] << s
38
+ @current_template.add_output s
37
39
  s
38
40
  end
39
41
  elsif method == :to_s
@@ -42,14 +44,9 @@ class Brakeman::ErubisTemplateProcessor < Brakeman::TemplateProcessor
42
44
  abort "Unrecognized action on buffer: #{method}"
43
45
  end
44
46
  elsif target == nil and method == :render
45
- exp.arglist = process exp.arglist
46
47
  make_render_in_view exp
47
48
  else
48
- #TODO: Is it really necessary to create a new Sexp here?
49
- call = make_call target, method, process_all!(exp.args)
50
- call.original_line = exp.original_line
51
- call.line(exp.line)
52
- call
49
+ exp
53
50
  end
54
51
  end
55
52
 
@@ -83,12 +80,12 @@ class Brakeman::ErubisTemplateProcessor < Brakeman::TemplateProcessor
83
80
  elsif exp.method == :safe_append=
84
81
  s = Sexp.new :output, arg
85
82
  s.line(exp.line)
86
- @current_template[:outputs] << s
83
+ @current_template.add_output s
87
84
  s
88
85
  else
89
86
  s = Sexp.new :escaped_output, arg
90
87
  s.line(exp.line)
91
- @current_template[:outputs] << s
88
+ @current_template.add_output s
92
89
  s
93
90
  end
94
91
  else
@@ -6,37 +6,18 @@ class Brakeman::GemProcessor < Brakeman::BasicProcessor
6
6
  def initialize *args
7
7
  super
8
8
  @gem_name_version = /^\s*([-_+.A-Za-z0-9]+) \((\w(\.\w+)*)\)/
9
- @tracker.config[:gems] ||= {}
10
9
  end
11
10
 
12
- def process_gems src, gem_lock = nil
13
- process src
11
+ def process_gems gem_files
12
+ @gem_files = gem_files
13
+ @gemfile = gem_files[:gemfile][:file]
14
+ process gem_files[:gemfile][:src]
14
15
 
15
- if gem_lock
16
- process_gem_lock gem_lock
17
- @tracker.config[:rails_version] = @tracker.config[:gems][:rails][:version] if @tracker.config[:gems][:rails]
18
- elsif @tracker.config[:gems] && @tracker.config[:gems][:rails] && @tracker.config[:gems][:rails][:version] =~ /(\d+.\d+.\d+)/
19
- @tracker.config[:rails_version] = $1
20
- else
21
- @tracker.config[:rails_version] = nil
16
+ if gem_files[:gemlock]
17
+ process_gem_lock
22
18
  end
23
19
 
24
- if @tracker.options[:rails3].nil? and @tracker.options[:rails4].nil? and @tracker.config[:rails_version]
25
- if @tracker.config[:rails_version].start_with? "3"
26
- @tracker.options[:rails3] = true
27
- Brakeman.notify "[Notice] Detected Rails 3 application"
28
- elsif @tracker.config[:rails_version].start_with? "4"
29
- @tracker.options[:rails3] = true
30
- @tracker.options[:rails4] = true
31
- Brakeman.notify "[Notice] Detected Rails 4 application"
32
- end
33
- end
34
-
35
- if @tracker.config[:gems][:rails_xss]
36
- @tracker.config[:escape_html] = true
37
-
38
- Brakeman.notify "[Notice] Escaping HTML by default"
39
- end
20
+ @tracker.config.set_rails_version
40
21
  end
41
22
 
42
23
  def process_call exp
@@ -46,20 +27,23 @@ class Brakeman::GemProcessor < Brakeman::BasicProcessor
46
27
 
47
28
  gem_version = exp.second_arg
48
29
 
49
- if string? gem_version
50
- @tracker.config[:gems][gem_name.value.to_sym] = { :version => gem_version.value.to_s, :file => 'Gemfile', :line => exp.line }
51
- else
52
- @tracker.config[:gems][gem_name.value.to_sym] = { :version => nil, :file => 'Gemfile' , :line => exp.line }
53
- end
30
+ version = if string? gem_version
31
+ gem_version.value
32
+ else
33
+ nil
34
+ end
35
+
36
+ @tracker.config.add_gem gem_name.value, version, @gemfile, exp.line
54
37
  end
55
38
 
56
39
  exp
57
40
  end
58
41
 
59
- def process_gem_lock gem_lock
42
+ def process_gem_lock
60
43
  line_num = 1
61
- gem_lock.each_line do |line|
62
- set_gem_version_and_file line, 'Gemfile.lock', line_num
44
+ file = @gem_files[:gemlock][:file]
45
+ @gem_files[:gemlock][:src].each_line do |line|
46
+ set_gem_version_and_file line, file, line_num
63
47
  line_num += 1
64
48
  end
65
49
  end
@@ -67,7 +51,7 @@ class Brakeman::GemProcessor < Brakeman::BasicProcessor
67
51
  # Supports .rc2 but not ~>, >=, or <=
68
52
  def set_gem_version_and_file line, file, line_num
69
53
  if line =~ @gem_name_version
70
- @tracker.config[:gems][$1.to_sym] = { :version => $2, :file => file, :line => line_num }
54
+ @tracker.config.add_gem $1, $2, file, line_num
71
55
  end
72
56
  end
73
57
  end
@@ -67,7 +67,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
67
67
  ignore
68
68
  else
69
69
  s = Sexp.new(:output, out)
70
- @current_template[:outputs] << s
70
+ @current_template.add_output s
71
71
  s.line(exp.line)
72
72
  s
73
73
  end
@@ -76,11 +76,9 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
76
76
  exp.arglist = process exp.arglist
77
77
  make_render_in_view exp
78
78
  else
79
- #TODO: Do we really need a new Sexp here?
80
- call = make_call target, method, process_all!(exp.args)
81
- call.original_line = exp.original_line
82
- call.line(exp.line)
83
- call
79
+ exp.target = target
80
+ exp.arglist = process exp.arglist
81
+ exp
84
82
  end
85
83
  end
86
84
 
@@ -120,10 +118,10 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
120
118
  #HAML likes to put interpolated values into _hamlout.push_text
121
119
  #but we want to handle those individually
122
120
  def build_output_from_push_text exp
123
- if node_type? exp, :string_interp, :dstr
121
+ if string_interp? exp
124
122
  exp.map! do |e|
125
123
  if sexp? e
126
- if node_type? e, :string_eval, :evstr
124
+ if node_type? e, :evstr
127
125
  e = e.value
128
126
  end
129
127
 
@@ -142,15 +140,15 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
142
140
  case exp.node_type
143
141
  when :format
144
142
  exp.node_type = :output
145
- @current_template[:outputs] << exp
143
+ @current_template.add_output exp
146
144
  exp
147
145
  when :format_escaped
148
146
  exp.node_type = :escaped_output
149
- @current_template[:outputs] << exp
147
+ @current_template.add_output exp
150
148
  exp
151
149
  when :str, :ignore, :output, :escaped_output
152
150
  exp
153
- when :block, :rlist, :string_interp, :dstr
151
+ when :block, :rlist, :dstr
154
152
  exp.map! { |e| get_pushed_value e }
155
153
  else
156
154
  if call? exp and exp.target == HAML_HELPERS and exp.method == :html_escape
@@ -160,7 +158,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
160
158
  end
161
159
 
162
160
  s.line(exp.line)
163
- @current_template[:outputs] << s
161
+ @current_template.add_output s
164
162
  s
165
163
  end
166
164
  end
@@ -23,12 +23,12 @@ class Brakeman::FindAllCalls < Brakeman::BasicProcessor
23
23
  end
24
24
 
25
25
  #Process body of method
26
- def process_methdef exp
26
+ def process_defn exp
27
27
  process_all exp.body
28
28
  end
29
29
 
30
30
  #Process body of method
31
- def process_selfdef exp
31
+ def process_defs exp
32
32
  process_all exp.body
33
33
  end
34
34
 
@@ -42,7 +42,7 @@ class Brakeman::FindAllCalls < Brakeman::BasicProcessor
42
42
  exp
43
43
  end
44
44
 
45
- def process_call_with_block exp
45
+ def process_iter exp
46
46
  call = exp.block_call
47
47
 
48
48
  if call.node_type == :call
@@ -63,8 +63,6 @@ class Brakeman::FindAllCalls < Brakeman::BasicProcessor
63
63
  exp
64
64
  end
65
65
 
66
- alias process_iter process_call_with_block
67
-
68
66
  #Calls to render() are converted to s(:render, ...) but we would
69
67
  #like them in the call cache still for speed
70
68
  def process_render exp
@@ -68,11 +68,11 @@ class Brakeman::FindCall < Brakeman::BasicProcessor
68
68
  end
69
69
 
70
70
  #Process body of method
71
- def process_methdef exp
71
+ def process_defn exp
72
72
  process_all exp.body
73
73
  end
74
74
 
75
- alias :process_selfdef :process_methdef
75
+ alias :process_defs :process_defn
76
76
 
77
77
  #Process body of block
78
78
  def process_rlist exp
@@ -38,7 +38,7 @@ class Brakeman::FindReturnValue
38
38
 
39
39
  find_explicit_return_values exp
40
40
 
41
- if node_type? exp, :methdef, :selfdef, :defn, :defs
41
+ if node_type? exp, :defn, :defs
42
42
  body = exp.body
43
43
 
44
44
  unless body.empty?
@@ -2,7 +2,7 @@ require 'brakeman/processors/lib/basic_processor'
2
2
 
3
3
  #Processes configuration. Results are put in tracker.config.
4
4
  #
5
- #Configuration of Rails via Rails::Initializer are stored in tracker.config[:rails].
5
+ #Configuration of Rails via Rails::Initializer are stored in tracker.config.rails.
6
6
  #For example:
7
7
  #
8
8
  # Rails::Initializer.run |config|
@@ -13,7 +13,7 @@ require 'brakeman/processors/lib/basic_processor'
13
13
  #
14
14
  # tracker.config[:rails][:action_controller][:session_store]
15
15
  #
16
- #Values for tracker.config[:rails] will still be Sexps.
16
+ #Values for tracker.config.rails will still be Sexps.
17
17
  class Brakeman::Rails2ConfigProcessor < Brakeman::BasicProcessor
18
18
  #Replace block variable in
19
19
  #
@@ -24,7 +24,6 @@ class Brakeman::Rails2ConfigProcessor < Brakeman::BasicProcessor
24
24
 
25
25
  def initialize *args
26
26
  super
27
- @tracker.config[:rails] ||= {}
28
27
  end
29
28
 
30
29
  #Use this method to process configuration file
@@ -40,7 +39,7 @@ class Brakeman::Rails2ConfigProcessor < Brakeman::BasicProcessor
40
39
 
41
40
  if exp.method == :gem and exp.first_arg.value == "erubis"
42
41
  Brakeman.notify "[Notice] Using Erubis for ERB templates"
43
- @tracker.config[:erubis] = true
42
+ @tracker.config.erubis = true
44
43
  end
45
44
 
46
45
  exp
@@ -53,13 +52,13 @@ class Brakeman::Rails2ConfigProcessor < Brakeman::BasicProcessor
53
52
  attribute = exp.method.to_s[0..-2].to_sym
54
53
  if exp.args.length > 1
55
54
  #Multiple arguments?...not sure if this will ever happen
56
- @tracker.config[:rails][attribute] = exp.args
55
+ @tracker.config.rails[attribute] = exp.args
57
56
  else
58
- @tracker.config[:rails][attribute] = exp.first_arg
57
+ @tracker.config.rails[attribute] = exp.first_arg
59
58
  end
60
59
  elsif include_rails_config? exp
61
60
  options = get_rails_config exp
62
- level = @tracker.config[:rails]
61
+ level = @tracker.config.rails
63
62
  options[0..-2].each do |o|
64
63
  level[o] ||= {}
65
64
  level = level[o]
@@ -75,7 +74,7 @@ class Brakeman::Rails2ConfigProcessor < Brakeman::BasicProcessor
75
74
  def process_cdecl exp
76
75
  #Set Rails version required
77
76
  if exp.lhs == :RAILS_GEM_VERSION
78
- @tracker.config[:rails_version] = exp.rhs.value
77
+ @tracker.config.rails_version = exp.rhs.value
79
78
  end
80
79
 
81
80
  exp
@@ -3,7 +3,7 @@ require 'brakeman/processors/lib/basic_processor'
3
3
 
4
4
  #Processes configuration. Results are put in tracker.config.
5
5
  #
6
- #Configuration of Rails via Rails::Initializer are stored in tracker.config[:rails].
6
+ #Configuration of Rails via Rails::Initializer are stored in tracker.config.rails.
7
7
  #For example:
8
8
  #
9
9
  # MyApp::Application.configure do
@@ -12,15 +12,14 @@ require 'brakeman/processors/lib/basic_processor'
12
12
  #
13
13
  #will be stored in
14
14
  #
15
- # tracker.config[:rails][:active_record][:whitelist_attributes]
15
+ # tracker.config.rails[:active_record][:whitelist_attributes]
16
16
  #
17
- #Values for tracker.config[:rails] will still be Sexps.
17
+ #Values for tracker.config.rails will still be Sexps.
18
18
  class Brakeman::Rails3ConfigProcessor < Brakeman::BasicProcessor
19
19
  RAILS_CONFIG = Sexp.new(:call, nil, :config)
20
20
 
21
21
  def initialize *args
22
22
  super
23
- @tracker.config[:rails] ||= {}
24
23
  @inside_config = false
25
24
  end
26
25
 
@@ -66,13 +65,13 @@ class Brakeman::Rails3ConfigProcessor < Brakeman::BasicProcessor
66
65
  attribute = exp.method.to_s[0..-2].to_sym
67
66
  if exp.args.length > 1
68
67
  #Multiple arguments?...not sure if this will ever happen
69
- @tracker.config[:rails][attribute] = exp.args
68
+ @tracker.config.rails[attribute] = exp.args
70
69
  else
71
- @tracker.config[:rails][attribute] = exp.first_arg
70
+ @tracker.config.rails[attribute] = exp.first_arg
72
71
  end
73
72
  elsif include_rails_config? exp
74
73
  options = get_rails_config exp
75
- level = @tracker.config[:rails]
74
+ level = @tracker.config.rails
76
75
  options[0..-2].each do |o|
77
76
  level[o] ||= {}
78
77
 
@@ -9,15 +9,15 @@ module Brakeman::RenderHelper
9
9
  @rendered = true
10
10
  case exp.render_type
11
11
  when :action, :template
12
- process_action exp[2][1], exp[3]
12
+ process_action exp[2][1], exp[3], exp.line
13
13
  when :default
14
14
  begin
15
- process_template template_name, exp[3]
15
+ process_template template_name, exp[3], nil, exp.line
16
16
  rescue ArgumentError
17
17
  Brakeman.debug "Problem processing render: #{exp}"
18
18
  end
19
19
  when :partial, :layout
20
- process_partial exp[2], exp[3]
20
+ process_partial exp[2], exp[3], exp.line
21
21
  when :nothing
22
22
  end
23
23
  exp
@@ -31,30 +31,31 @@ module Brakeman::RenderHelper
31
31
 
32
32
  return unless name
33
33
 
34
- process_template name, nil
34
+ process_template name, nil, nil, nil
35
35
  end
36
36
 
37
37
  #Determines file name for partial and then processes it
38
- def process_partial name, args
38
+ def process_partial name, args, line
39
39
  if name == "" or !(string? name or symbol? name)
40
40
  return
41
41
  end
42
42
 
43
43
  names = name.value.to_s.split("/")
44
44
  names[-1] = "_" + names[-1]
45
- process_template template_name(names.join("/")), args
45
+ process_template template_name(names.join("/")), args, nil, line
46
46
  end
47
47
 
48
48
  #Processes a given action
49
- def process_action name, args
49
+ def process_action name, args, line
50
50
  if name.is_a? String or name.is_a? Symbol
51
- process_template template_name(name), args
51
+ process_template template_name(name), args, nil, line
52
52
  end
53
53
  end
54
54
 
55
55
  #Processes a template, adding any instance variables
56
56
  #to its environment.
57
- def process_template name, args, called_from = nil
57
+ def process_template name, args, called_from = nil, *_
58
+
58
59
  Brakeman.debug "Rendering #{name} (#{called_from})"
59
60
  #Get scanned source for this template
60
61
  name = name.to_s.gsub(/^\//, "")
@@ -81,10 +82,10 @@ module Brakeman::RenderHelper
81
82
 
82
83
  #Process layout
83
84
  if string? options[:layout]
84
- process_template "layouts/#{options[:layout][1]}", nil
85
+ process_template "layouts/#{options[:layout][1]}", nil, nil, nil
85
86
  elsif node_type? options[:layout], :false
86
87
  #nothing
87
- elsif not template[:name].to_s.match(/[^\/_][^\/]+$/)
88
+ elsif not template.name.to_s.match(/[^\/_][^\/]+$/)
88
89
  #Don't do this for partials
89
90
 
90
91
  process_layout
@@ -100,7 +101,7 @@ module Brakeman::RenderHelper
100
101
 
101
102
  #The collection name is the name of the partial without the leading
102
103
  #underscore.
103
- variable = template[:name].to_s.match(/[^\/_][^\/]+$/)[0].to_sym
104
+ variable = template.name.to_s.match(/[^\/_][^\/]+$/)[0].to_sym
104
105
 
105
106
  #Unless the :as => :variable_name option is used
106
107
  if options[:as]
@@ -127,7 +128,7 @@ module Brakeman::RenderHelper
127
128
  #Run source through AliasProcessor with instance variables from the
128
129
  #current environment.
129
130
  #TODO: Add in :locals => { ... } to environment
130
- src = Brakeman::TemplateAliasProcessor.new(@tracker, template, called_from).process_safely(template[:src], template_env)
131
+ src = Brakeman::TemplateAliasProcessor.new(@tracker, template, called_from).process_safely(template.src, template_env)
131
132
 
132
133
  digest = Digest::SHA1.new.update(name + src.to_s).to_s.to_sym
133
134
 
@@ -142,7 +143,7 @@ module Brakeman::RenderHelper
142
143
  #This information will be stored in tracker.templates, but with a name
143
144
  #specifying this particular route. The original source should remain
144
145
  #pristine (so it can be processed within other environments).
145
- @tracker.processor.process_template name, src, template[:type], called_from
146
+ @tracker.processor.process_template name, src, template.type, called_from
146
147
  end
147
148
  end
148
149