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
Brakeman 4.7.0 fails processing routes.rb #1410
Comments
This is because of a change in ruby_parser 3.14.0. As a temporary fix, you could use Somewhere in your routes you are using a |
Thanks! I inherited this project and haven't had to poke around much in the routes, but there is this portion that is probably the culprit: # Monkey patch discover_path and discover_url to support passing type value of 'discover' and 'things_to_do'
#
# ref: https://github.com/rails/rails/blob/v5.2.2/actionpack/lib/action_dispatch/routing/route_set.rb#L321-L334
#
%i(path url).each do |helper_type|
mod = Rails.application.routes.named_routes.public_send "#{helper_type}_helpers_module"
method_name = "discover_#{helper_type}"
original_helper = mod.instance_method method_name
extract_option = ->(args) {
case args.last
when Hash then args.pop
when ActionController::Parameters then args.pop.to_h
else {}
end
}
translate = ->(discover_type) {
case discover_type
when 'discover' then 'all'
when 'things_to_do' then 'tours-and-activities'
else discover_type || 'all'
end
} |
we use stabby lambdas for constraints. There's an example in the rails guide: https://guides.rubyonrails.org/routing.html#advanced-constraints Brakeman didn't crash hard but we got a similar error on this is the line: config.middleware.use Flipper::Middleware::SetupEnv, -> { FeatureFlag.flipper } |
Is it caused by this issue? seattlerb/ruby_parser#300 |
@lucascaton No, I don't think so. The issue is that ruby_parser changed how it handles |
Background
Brakeman version: 4.7.0
Rails version: 5.2.2
Ruby version: 2.6.3
Issue
Since upgrading Brakeman to 4.7.0 it fails both locally and on CircleCI while processing config/routes.rb. My application's routes are working just fine, so I think it could be a Brakeman bug.
Other Error
Stack trace:
The text was updated successfully, but these errors were encountered: