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

Add test for SQL in self call

上级 ef3c6e8b
class User < ActiveRecord::Base
named_scope :dah, lambda {|*args| { :condition => "dah = '#{args[1]}'"}}
named_scope :dah, lambda {|*args| { :conditions => "dah = '#{args[1]}'"}}
named_scope :phooey, :condition => "phoeey = '#{User.phooey}'"
named_scope :phooey, :conditions => "phoeey = '#{User.phooey}'"
named_scope :with_state, lambda {|state| state.present? ? {:conditions => "state_name = '#{state}'"} : {}}
named_scope :safe_phooey, :condition => ["phoeey = ?", "#{User.phooey}"]
named_scope :safe_phooey, :conditions => ["phoeey = ?", "#{User.phooey}"]
named_scope :safe_dah, lambda {|*args| { :condition => ["dah = ?", "#{args[1]}"]}}
named_scope :safe_dah, lambda {|*args| { :conditions => ["dah = ?", "#{args[1]}"]}}
named_scope :with_state, lambda {|state| state.present? ? {:conditions => ["state_name = ?", "#{state}"]} : {}}
def get_something x
self.find(:all, :conditions => "where blah = #{x}")
end
end
......@@ -12,13 +12,13 @@ class Rails2Tests < Test::Unit::TestCase
:controller => 1,
:model => 2,
:template => 18,
:warning => 21 }
:warning => 22 }
else
@expected ||= {
:controller => 1,
:model => 2,
:template => 18,
:warning => 22 }
:warning => 23 }
end
end
......@@ -201,6 +201,15 @@ class Rails2Tests < Test::Unit::TestCase
:file => /user\.rb/
end
def test_sql_injection_in_self_call
assert_warning :type => :warning,
:warning_type => "SQL Injection",
:line => 15,
:message => /^Possible SQL injection near line 15: self\.find/,
:confidence => 1,
:file => /user\.rb/
end
def test_csrf_protection
assert_warning :type => :controller,
:warning_type => "Cross-Site Request Forgery",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册