SECURITY: SQL Injection in Admin List Active Users

This commit is contained in:
Robin Ward
2016-07-28 11:42:06 -04:00
parent 2f8ab8cd30
commit dc1a830d3d
2 changed files with 23 additions and 1 deletions

View File

@ -18,8 +18,20 @@ class AdminUserIndexQuery
find_users_query.count
end
def self.orderable_columns
%w(created_at days_visited posts_read_count topics_entered post_count trust_level)
end
def initialize_query_with_order(klass)
order = [params[:order]]
order = []
custom_order = params[:order]
if custom_order.present? &&
without_dir = custom_order.downcase.sub(/ (asc|desc)$/, '')
if AdminUserIndexQuery.orderable_columns.include?(without_dir)
order << custom_order
end
end
if params[:query] == "active"
order << "COALESCE(last_seen_at, to_date('1970-01-01', 'YYYY-MM-DD')) DESC"