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

Return Struct for BaseCheck#has_user_input?

上级 7da75463
...@@ -12,6 +12,8 @@ class Brakeman::BaseCheck < SexpProcessor ...@@ -12,6 +12,8 @@ class Brakeman::BaseCheck < SexpProcessor
CONFIDENCE = { :high => 0, :med => 1, :low => 2 } CONFIDENCE = { :high => 0, :med => 1, :low => 2 }
Match = Struct.new(:type, :match)
#Initialize Check with Checks. #Initialize Check with Checks.
def initialize tracker def initialize tracker
super() super()
...@@ -66,13 +68,13 @@ class Brakeman::BaseCheck < SexpProcessor ...@@ -66,13 +68,13 @@ class Brakeman::BaseCheck < SexpProcessor
process exp[3] process exp[3]
if params? exp[1] if params? exp[1]
@has_user_input = :params @has_user_input = Match.new(:params, exp)
elsif cookies? exp[1] elsif cookies? exp[1]
@has_user_input = :cookies @has_user_input = Match.new(:cookies, exp)
elsif request_env? exp[1] elsif request_env? exp[1]
@has_user_input = :request @has_user_input = Match.new(:request, exp)
elsif sexp? exp[1] and model_name? exp[1][1] elsif sexp? exp[1] and model_name? exp[1][1]
@has_user_input = :model @has_user_input = Match.new(:model, exp)
end end
exp exp
...@@ -92,13 +94,13 @@ class Brakeman::BaseCheck < SexpProcessor ...@@ -92,13 +94,13 @@ class Brakeman::BaseCheck < SexpProcessor
#Note that params are included in current expression #Note that params are included in current expression
def process_params exp def process_params exp
@has_user_input = :params @has_user_input = Match.new(:params, exp)
exp exp
end end
#Note that cookies are included in current expression #Note that cookies are included in current expression
def process_cookies exp def process_cookies exp
@has_user_input = :cookies @has_user_input = Match.new(:cookies, exp)
exp exp
end end
......
...@@ -28,13 +28,14 @@ class Brakeman::CheckFileAccess < Brakeman::BaseCheck ...@@ -28,13 +28,14 @@ class Brakeman::CheckFileAccess < Brakeman::BaseCheck
file_name = call[3][1] file_name = call[3][1]
if check = include_user_input?(file_name) if input = include_user_input?(file_name)
unless duplicate? result unless duplicate? result
add_result result add_result result
if check == :params case input.type
when :params
message = "Parameter" message = "Parameter"
elsif check == :cookies when :cookies
message = "Cookie" message = "Cookie"
else else
message = "User input" message = "User input"
......
...@@ -36,7 +36,10 @@ class Brakeman::CheckRender < Brakeman::BaseCheck ...@@ -36,7 +36,10 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
if type if type
confidence = CONFIDENCE[:high] confidence = CONFIDENCE[:high]
elsif type = include_user_input?(view) elsif input = include_user_input?(view)
type = input.type
match = input.match
if node_type? view, :string_interp, :dstr if node_type? view, :string_interp, :dstr
confidence = CONFIDENCE[:med] confidence = CONFIDENCE[:med]
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册