提交 11588e80 编写于 作者: J Justin Collins

CheckSQL: Test for params in method arguments

上级 30c10bc2
......@@ -100,6 +100,13 @@ class Product < ActiveRecord::Base
#Should not warn
Product.last("blah = '#{params[:blah] ? 1 : 0}'")
end
def test_params_in_args
#Should warn
Product.last("blah = '#{something(params[:blah])}'")
end
def test_more_if_statements
if some_condition
x = params[:x]
......@@ -121,4 +128,5 @@ class Product < ActiveRecord::Base
#Should not warn
Product.last("blah = '#{y}'")
Product.where("blah = 1").group(y)
end
end
......@@ -288,6 +288,15 @@ class Rails31Tests < Test::Unit::TestCase
:file => /product\.rb/
end
def test_sql_injection_in_method_args
assert_warning :type => :warning,
:warning_type => "SQL Injection",
:line => 106,
:message => /^Possible\ SQL\ injection/,
:confidence => 0,
:file => /product\.rb/
end
def test_sql_injection_with_if_statements
assert_warning :type => :warning,
:warning_type => "SQL Injection",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册