Skip to content

Commit

Permalink
Add count_by_sql() to SQL injection checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Collins committed Mar 21, 2011
1 parent 3fe15ac commit 6b5ba72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/checks/check_sql.rb
Expand Up @@ -16,7 +16,7 @@ def run_check
@rails_version = tracker.config[:rails_version]
calls = tracker.find_model_find tracker.models.keys

calls.concat tracker.find_call([], /^(find.*|last|first|all|count|sum|average|minumum|maximum)$/)
calls.concat tracker.find_call([], /^(find.*|last|first|all|count|sum|average|minumum|maximum|count_by_sql)$/)

calls.concat tracker.find_model_find(nil).select { |result| constantize_call? result }

Expand All @@ -31,7 +31,7 @@ def process_result exp

args = process call[3]

if call[2] == :find_by_sql
if call[2] == :find_by_sql or call[2] == :count_by_sql
failed = check_arguments args[1]
elsif call[2].to_s =~ /^find/
failed = (args.length > 2 and check_arguments args[-1])
Expand Down
2 changes: 1 addition & 1 deletion lib/processors/lib/find_model_call.rb
Expand Up @@ -6,7 +6,7 @@ class FindModelCall < FindCall

#Passes +targets+ to FindCall
def initialize targets
super(targets, /^(find.*|first|last|all)$/)
super(targets, /^(find.*|first|last|all|count|sum|average|minumum|maximum|count_by_sql)$/)
end

#Matches entire method chain as a target. This differs from
Expand Down

0 comments on commit 6b5ba72

Please sign in to comment.