提交 6e567540 编写于 作者: J Justin Collins

Store call chain in CallIndex

上级 14ebf8a6
......@@ -108,15 +108,14 @@ class Brakeman::CallIndex
elsif methods.length > 1
calls_by_methods methods
else
@calls_by_method[methods.first.to_sym]
calls_by_method[methods.first]
end
else
@calls_by_method[method.to_sym]
@calls_by_method[method]
end
end
def calls_by_methods methods
methods = methods.map { |m| m.to_sym }
calls = []
methods.each do |method|
......
......@@ -51,13 +51,17 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor
method = exp[2]
process exp[3]
call = { :target => target, :method => method, :call => exp, :nested => @in_target, :chain => get_chain(exp) }
if @current_template
@calls << { :target => target, :method => method, :call => exp, :nested => @in_target, :location => [:template, @current_template]}
call[:location] = [:template, @current_template]
else
@calls << { :target => target, :method => method, :call => exp, :nested => @in_target, :location => [:class, @current_class, @current_method] }
call[:location] = [:class, @current_class, @current_method]
end
@calls << call
exp
end
......@@ -88,4 +92,14 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor
exp
end
end
#Returns method chain as an array
#For example, User.human.alive.all would return [:User, :human, :alive, :all]
def get_chain call
if call? call
get_chain(call[1]) + [call[2]]
else
[get_target(call)]
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册