Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String interpolation on execute sql #119

Merged
merged 2 commits into from
Aug 14, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/scanny/checks/sql_injection/find_method_with_params_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ def pattern_find_by_sql_and_execute_on_models_with_params
SendWithArguments<
name = :[],
receiver = Send<name = :params>
>
|
DynamicString<
array = [
any*,
ToString<
value = SendWithArguments<
name = :[],
receiver = Send<name = :params>
>
>,
any*
]
>,
any*
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,20 @@ module Scanny::Checks::Sql
it "reports \"paginate\" calls on class with params correctly" do
@runner.should check('User.paginate params[:password]').with_issue(@issue_high)
end

it "reports \"execute\" calls on class with string interpolation correctly" do
@runner.should check('User.execute "#{params[:password]}"').
with_issue(@issue_high)
end

it "reports \"find_by_sql\" calls on class with string interpolation correctly" do
@runner.should check('User.find_by_sql "#{params[:password]}"').
with_issue(@issue_high)
end

it "reports \"paginate\" calls on class with string interpolation correctly" do
@runner.should check('User.paginate "#{params[:password]}"').
with_issue(@issue_high)
end
end
end