-
Notifications
You must be signed in to change notification settings - Fork 732
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
Detect ActiveModel::ForbiddenAttributesProtection #88
Comments
Hi Joost, Thank you for bringing this up. It does not seem to be widely-used at the moment, but it does not look difficult to support. Also, Rails 4 support is not a top priority until there is at least a release candidate :) |
Agreed on low priority. I am working on an entirely new app which definitely will run Rails 4 most of its life. It seemed smart to implement the new way of protecting mass attributes. Now my brakeman scan is full of high priority warnings while it should be 100% clean. :) The gem is at 1.0.3 and does work with Rails 3.2+. I am not sure if it is widely used at this time though. Op 5 mei 2012 om 00:46 heeft Justin reply@reply.github.com het volgende geschreven:
|
This is the only thing in Rails 4 that I am relatively certain will affect Brakeman, so plan to get done before Brakeman 2.0 |
As a very early first cut of this, could we just skip In the time since it was released, that approach has become popular even in Rails 3 apps, anecdotally. |
Is that all we need to do? If someone is using the gem or Rails 4, do we just not warn on mass assignment issues? If not, what do we warn on? |
Okay, looks like if the app is using the gem, it needs to also include I'll see about getting to this today. |
Yes, that sounds like a good start for Rails 3. In Rails 4 I believe this will become a config setting (default to on). If someone flips that off (which may be especially likely during early Rails 3 -> 4 migrations), then we'll want the current/old behavior. Finally, looking at the strong_parameters gem, there seems to be a method |
Does that require each model include ActiveModel::ForbiddenAttributesProtection? The common/best way is to include it into AR::Base at boot time in an initializer. |
Yes, it does. Do you have example code for the initializer? I can add it. |
or
|
|
Eh, yeah. I actually often use |
Okay, updated. Just checking for |
Sounds good! |
I learned this one from Ryan Bates
|
Yes, we should catch that too. |
Using permit! is safe if you are protecting your code in other ways, such as requiring that the user be an admin, so all fields are permissible. Even then, it's dangerous as it also allows access to the user_id fields, for instance, which you likely don't want to grant. I'd make permit! a warning of some sort, but make it easy to turn it off for those who think they know better. |
@skandragon Can you open a separate issue for this, maybe with some more details or links about |
Forgive me for creating an issue and not a pull request (yet) but it seems Brakeman does not detect when the 'strong_parameters' gem is used and ActiveModel::ForbiddenAttributesProtection is included in a model. This will be the Rails 4-way of protecting mass assignment and I think Brakeman should see it, right?
The text was updated successfully, but these errors were encountered: