提交 ef83e361 编写于 作者: J Justin Collins

Update some documentation

上级 a0e5f7e1
require 'set'
#Stores call sites to look up later.
class Brakeman::CallIndex
#Initialize index with calls from FindAllCalls
def initialize calls
@calls_by_method = Hash.new { |h,k| h[k] = [] }
@calls_by_target = Hash.new { |h,k| h[k] = [] }
......@@ -10,6 +13,14 @@ class Brakeman::CallIndex
index_calls calls
end
#Find calls matching specified option hash.
#
#Options:
#
# * :target - symbol, array of symbols, or regular expression to match target(s)
# * :method - symbol, array of symbols, or regular expression to match method(s)
# * :chained - boolean, whether or not to match against a whole method chain (false by default)
# * :nested - boolean, whether or not to match against a method call that is a target itself (false by default)
def find_calls options
target = options[:target] || options[:targets]
method = options[:method] || options[:methods]
......
......@@ -25,7 +25,7 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
end
end
#Processes results from FindCall.
#Processes results from Tracker#find_call.
def process_result result
call = result[:call]
......
......@@ -37,7 +37,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
end
end
#Process result from FindCall.
#Process result from Tracker#find_call.
def process_result result
call = result[:call]
......
......@@ -97,6 +97,26 @@ class Brakeman::Tracker
end
#Find a method call.
#
#Options:
# * :target => target name(s)
# * :method => method name(s)
# * :chained => search in method chains
#
#If :target => false or :target => nil, searches for methods without a target.
#Targets and methods can be specified as a symbol, an array of symbols,
#or a regular expression.
#
#If :chained => true, matches target at head of method chain and method at end.
#
#For example:
#
# find_call :target => User, :method => :all, :chained => true
#
#could match
#
# User.human.active.all(...)
#
def find_call options
index_calls unless @call_index
@call_index.find_calls options
......
......@@ -5,7 +5,7 @@ class Brakeman::Warning
attr_accessor :code, :context, :file, :message
#+options[:result]+ can be a result Sexp from FindCall. Otherwise, it can be +nil+.
#+options[:result]+ can be a result from Tracker#find_call. Otherwise, it can be +nil+.
def initialize options = {}
@view_name = nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册