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

False positive: Mass assignment when using a filtered hash #203

Closed
brynary opened this issue Dec 11, 2012 · 3 comments · Fixed by #303
Closed

False positive: Mass assignment when using a filtered hash #203

brynary opened this issue Dec 11, 2012 · 3 comments · Fixed by #303
Milestone

Comments

@brynary
Copy link
Contributor

brynary commented Dec 11, 2012

You all asked for false positive reports so here we go. :wink: Here's a Mass Assignment false positive I found today:

Bill.find(params[:id]).update_attributes(bill_params.only("content", "amount_cents"))

In this case, the developer is using Hash#only to filter params (even though strong_parameters is not in use in this repo).

On the plus side, this was flagged as "Weak" confidence.

@presidentbeef
Copy link
Owner

My guess is Brakeman doesn't know what bill_params is, and is warning because the code is doing a mass assignment, period. Otherwise, you would be getting a high confidence warning and probably be more disappointed. I suppose Brakeman could check for only or slice, since those signal intent.

@brynary
Copy link
Contributor Author

brynary commented Dec 11, 2012

Yeah, agreed checking for only or slice would be the way to improve this. I'm not quite sure it's worth it in the wake of strong_parameters, but wanted to report nonetheless.

@presidentbeef
Copy link
Owner

I appreciate it!

Repository owner locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants