From 0750e9fbcfbca97f5f1e78bc491263d0c114270c Mon Sep 17 00:00:00 2001 From: Justin Collins Date: Wed, 19 Sep 2012 14:05:18 -0700 Subject: [PATCH 1/3] No special Sexps for options/buffer calls in HAML Brakeman was generating invalid call Sexps with `:_hamlout` as the target for `_hamlout.options` and `hamlout.buffer`. However, these special Sexps were not really be handled in Brakeman anywhere, and there was no real reason to make special Sexps for them. --- lib/brakeman/processors/haml_template_processor.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/brakeman/processors/haml_template_processor.rb b/lib/brakeman/processors/haml_template_processor.rb index 375ff17d26..7c4c1441a5 100644 --- a/lib/brakeman/processors/haml_template_processor.rb +++ b/lib/brakeman/processors/haml_template_processor.rb @@ -29,14 +29,12 @@ def process_call exp method = exp.method - if (call? target and target.method == :_hamlout) or target == :_hamlout + if (call? target and target.method == :_hamlout) res = case method when :adjust_tabs, :rstrip!, :attributes #Check attributes, maybe? ignore - when :options - Sexp.new :call, :_hamlout, :options, exp.arglist - when :buffer - Sexp.new :call, :_hamlout, :buffer, exp.arglist + when :options, :buffer + exp when :open_tag Sexp.new(:tag, process(exp.arglist)) else From ef8ea3ffedf151ca3ada4ff4cfc73c9055ff104b Mon Sep 17 00:00:00 2001 From: Justin Collins Date: Wed, 19 Sep 2012 14:12:22 -0700 Subject: [PATCH 2/3] Remove unsupported :tag node type Surprised this never caused any errors --- lib/brakeman/processors/haml_template_processor.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/brakeman/processors/haml_template_processor.rb b/lib/brakeman/processors/haml_template_processor.rb index 7c4c1441a5..64d142df1b 100644 --- a/lib/brakeman/processors/haml_template_processor.rb +++ b/lib/brakeman/processors/haml_template_processor.rb @@ -36,7 +36,8 @@ def process_call exp when :options, :buffer exp when :open_tag - Sexp.new(:tag, process(exp.arglist)) + process(exp.arglist) + exp else arg = exp.first_arg From c0cedbd129776157a20cd8b78a08e28b94a1cb3f Mon Sep 17 00:00:00 2001 From: Justin Collins Date: Wed, 19 Sep 2012 18:05:06 -0700 Subject: [PATCH 3/3] Remove special cased OutputProcessor#process_call There should never be the case where the target of a :call Sexp is a symbol, it should always be either `nil` or a Sexp. Brakeman should not be building invalid Sexps. --- lib/brakeman/processors/output_processor.rb | 30 --------------------- 1 file changed, 30 deletions(-) diff --git a/lib/brakeman/processors/output_processor.rb b/lib/brakeman/processors/output_processor.rb index ab9b74a8a5..708f8b50f2 100644 --- a/lib/brakeman/processors/output_processor.rb +++ b/lib/brakeman/processors/output_processor.rb @@ -23,36 +23,6 @@ def process exp end end - def process_call exp - if exp[0].is_a? Symbol - target = exp[0] - - method = exp[1] - - args = process exp[2] - - out = nil - - if method == :[] - if target - out = "#{target}[#{args}]" - else - raise Exception.new("Not sure what to do with access and no target: #{exp}") - end - else - if target - out = "#{target}.#{method}(#{args})" - else - out = "#{method}(#{args})" - end - end - exp.clear - out - else - super exp - end - end - def process_lvar exp out = "(local #{exp[0]})" exp.clear