Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

User actual class name when rending collections

  • Loading branch information...
commit 277106c3024afafc5b3f1da75e62095662eafb78 1 parent da420b6
@presidentbeef authored
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/brakeman/processors/lib/render_helper.rb
View
16 lib/brakeman/processors/lib/render_helper.rb
@@ -109,7 +109,9 @@ def process_template name, args, called_from = nil
end
end
- template_env[Sexp.new(:call, nil, variable, Sexp.new(:arglist))] = Sexp.new(:call, Sexp.new(:const, Brakeman::Tracker::UNKNOWN_MODEL), :new, Sexp.new(:arglist))
+ collection = get_class_target(options[:collection]) || Brakeman::Tracker::UNKNOWN_MODEL
+
+ template_env[Sexp.new(:call, nil, variable, Sexp.new(:arglist))] = Sexp.new(:call, Sexp.new(:const, collection), :new, Sexp.new(:arglist))
end
#Set original_line for values so it is clear
@@ -154,4 +156,16 @@ def get_options args
options
end
+
+ def get_class_target sexp
+ if call? sexp
+ get_class_target sexp.target
+ else
+ begin
+ class_name sexp
+ rescue
+ nil
+ end
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.