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 for protect_from_forgery when defaults for rails 7 are used #1784

Closed
Pritilender opened this issue Jul 7, 2023 · 1 comment · Fixed by #1785
Closed

False positive for protect_from_forgery when defaults for rails 7 are used #1784

Pritilender opened this issue Jul 7, 2023 · 1 comment · Fixed by #1785

Comments

@Pritilender
Copy link

Background

Brakeman version: 6.0.0
Rails version: 7.0.6
Ruby version: 3.2.2

False Positive

Full warning from Brakeman:

Confidence: High
Category: Cross-Site Request Forgery
Check: ForgerySetting
Message: `protect_from_forgery` should be called in `ApplicationController`
File: app/controllers/application_controller.rb
Line: 6

Relevant code:

# in config/application.rb
config.load_defaults "7.0"

This looks like a false positive because load_defaults always loads the defaults for the given version and the previous versions.
And the value for default_protect_from_forgery is by default true since rails version 5.2, so load_defaults "7.0" should be enough.

I've also inspected the ApplicationController.default_protect_from_forgery from the rails console and it returns true.

presidentbeef added a commit that referenced this issue Jul 8, 2023
@presidentbeef
Copy link
Owner

Yes, this is the same as #1783

It's interesting that Rails itself generates number literals for the version and that's what's in all the documentation, but then the actual code uses strings. 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants