提交 89b67145 编写于 作者: J Justin Collins

Move more Sexp#[] calls to regular method calls

上级 9f5e7b16
...@@ -115,7 +115,11 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck ...@@ -115,7 +115,11 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
:confidence => CONFIDENCE[:high] :confidence => CONFIDENCE[:high]
elsif not tracker.options[:ignore_model_output] and match = has_immediate_model?(out) elsif not tracker.options[:ignore_model_output] and match = has_immediate_model?(out)
method = match[2] method = if call? match
match.method
else
nil
end
unless IGNORE_MODEL_METHODS.include? method unless IGNORE_MODEL_METHODS.include? method
add_result out add_result out
......
...@@ -73,12 +73,12 @@ class Brakeman::CheckRedirect < Brakeman::BaseCheck ...@@ -73,12 +73,12 @@ class Brakeman::CheckRedirect < Brakeman::BaseCheck
elsif call? arg elsif call? arg
if request_value? arg if request_value? arg
return Match.new(immediate, arg) return Match.new(immediate, arg)
elsif request_value? arg[1] elsif request_value? arg.target
return Match.new(immediate, arg[1]) return Match.new(immediate, arg.target)
elsif arg[2] == :url_for and include_user_input? arg elsif arg.method == :url_for and include_user_input? arg
return Match.new(immediate, arg) return Match.new(immediate, arg)
#Ignore helpers like some_model_url? #Ignore helpers like some_model_url?
elsif arg[2].to_s =~ /_(url|path)\z/ elsif arg.method.to_s =~ /_(url|path)\z/
return false return false
end end
elsif request_value? arg elsif request_value? arg
......
...@@ -261,23 +261,25 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck ...@@ -261,23 +261,25 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
def check_scope_arguments args def check_scope_arguments args
return unless node_type? args, :arglist return unless node_type? args, :arglist
scope_arg = args[2] #first arg is name of scope
if node_type? args[2], :iter if node_type? scope_arg, :iter
unsafe_sql? args[2].block unsafe_sql? scope_arg.block
else else
unsafe_sql? args[2] unsafe_sql? scope_arg
end end
end end
def check_query_arguments arg def check_query_arguments arg
return unless sexp? arg return unless sexp? arg
first_arg = arg[1]
if node_type? arg, :arglist if node_type? arg, :arglist
if arg.length > 2 and node_type? arg[1], :string_interp, :dstr if arg.length > 2 and node_type? first_arg, :string_interp, :dstr
# Model.where("blah = ?", blah) # Model.where("blah = ?", blah)
return check_string_interp arg[1] return check_string_interp first_arg
else else
arg = arg[1] arg = first_arg
end end
end end
...@@ -319,7 +321,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck ...@@ -319,7 +321,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
def check_by_sql_arguments arg def check_by_sql_arguments arg
return unless sexp? arg return unless sexp? arg
#This is kind of necessary, because unsafe_sql? will handle an array #This is kind of unnecessary, because unsafe_sql? will handle an array
#correctly, but might be better to be explicit. #correctly, but might be better to be explicit.
if array? arg if array? arg
unsafe_sql? arg[1] unsafe_sql? arg[1]
......
...@@ -477,8 +477,9 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor ...@@ -477,8 +477,9 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
#Join two string literals into one. #Join two string literals into one.
def join_strings string1, string2 def join_strings string1, string2
result = Sexp.new(:str) result = Sexp.new(:str)
result[1] = string1[1] + string2[1] result.value = string1.value + string2.value
if result[1].length > 50
if result.value.length > 50
string1 string1
else else
result result
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册