提交 20ac9c44 编写于 作者: J Justin Collins

Track calls with blocks in CallIndex

上级 9814b329
...@@ -37,28 +37,33 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor ...@@ -37,28 +37,33 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor
end end
def process_call exp def process_call exp
target = get_target exp.target @calls << create_call_hash(exp)
exp
if call? target end
already_in_target = @in_target
@in_target = true
process target
@in_target = already_in_target
end
method = exp.method def process_call_with_block exp
process_call_args exp call = exp.block_call
@calls << { :target => target, if call.node_type == :call
:method => method, call_hash = create_call_hash(call)
:call => exp,
:nested => @in_target, call_hash[:block] = exp.block
:chain => get_chain(exp), call_hash[:block_args] = exp.block_args
:location => make_location }
@calls << call_hash
process exp.block
else
#Probably a :render call with block
process call
process exp.block
end
exp exp
end end
alias process_iter process_call_with_block
#Calls to render() are converted to s(:render, ...) but we would #Calls to render() are converted to s(:render, ...) but we would
#like them in the call cache still for speed #like them in the call cache still for speed
def process_render exp def process_render exp
...@@ -155,4 +160,26 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor ...@@ -155,4 +160,26 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor
end end
end end
#Return info hash for a call Sexp
def create_call_hash exp
target = get_target exp.target
if call? target
already_in_target = @in_target
@in_target = true
process target
@in_target = already_in_target
end
method = exp.method
process_call_args exp
{ :target => target,
:method => method,
:call => exp,
:nested => @in_target,
:chain => get_chain(exp),
:location => make_location }
end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册