-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Fix AC::Parameters not being sanitized for query methods. #21539
Conversation
(@rails-bot has picked a reviewer for you, use r? to override) |
e32fddd
to
5bcde95
Compare
@@ -42,6 +42,7 @@ def initialize(scope) | |||
# User.where.not(name: "Jon", role: "admin") | |||
# # SELECT * FROM users WHERE name != 'Jon' AND role != 'admin' | |||
def not(opts, *rest) | |||
opts = @scope.send(:sanitize_opts, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need to do it on where!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm we can't. where!
is not called if it is called the following way: where.not(params)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where.not
don't need to be sanitized, only where
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does where.not
need not be sanitized? 💭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the arguments passed to where.not
are not used to initialize the object when you do where.not(admin: true).first_or_create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it 😄 Thanks!
r+ @rails-bot |
r+ @schneems. This pull request was approved by one of the reviewers and it is waiting your decision |
Ah I forgot about this. Let me get it sorted by this weekend. @rafaelfranca |
5bcde95
to
7d0b1e4
Compare
@rafaelfranca Updated |
Fix AC::Parameters not being sanitized for query methods.
❤️ 💚 💙 💛 💜 |
Actually do we need to sanitize inputs for query methods?