提交 9f449fb5 编写于 作者: G Gabriel Sobrinho

Ignore quoted_table_name in SQL

上级 16fd2dd9
......@@ -547,7 +547,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
string_building? exp.first_arg
end
IGNORE_METHODS_IN_SQL = Set[:id, :merge_conditions, :table_name, :to_i, :to_f,
IGNORE_METHODS_IN_SQL = Set[:id, :merge_conditions, :table_name, :quoted_table_name, :to_i, :to_f,
:sanitize_sql, :sanitize_sql_array, :sanitize_sql_for_assignment,
:sanitize_sql_for_conditions, :sanitize_sql_hash,
:sanitize_sql_hash_for_assignment, :sanitize_sql_hash_for_conditions,
......
......@@ -43,6 +43,10 @@ class User < ActiveRecord::Base
stuff, stuff, user.id, user.id)
end
def self.safe_sql_using_quoted_table_name
where("#{User.quoted_table_name}.id = ?", 1)
end
def self.more_safe_stuff
where("#{User.primary_key} = #{table_name_prefix}a.thing")
end
......
......@@ -1018,6 +1018,18 @@ class Rails31Tests < Test::Unit::TestCase
:user_input => s(:call, s(:const, :User), :primary_key)
end
def test_sql_injection_quoted_table_name
assert_no_warning :type => :warning,
:warning_code => 0,
:fingerprint => "d62a8796ff7e8f7547cea5352112294354b0400b01ab55388fa802a655751ed3",
:warning_type => "SQL Injection",
:line => 47,
:message => /^Possible\ SQL\ injection/,
:confidence => 0,
:relative_path => "app/models/user.rb",
:user_input => s(:call, s(:const, :User), :quoted_table_name)
end
def test_sql_injection_table_name_prefix
assert_no_warning :type => :warning,
:warning_code => 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册