Skip to content

Error: undefined method 'first_param' for an instance of Array with Ruby 3.4.1 #1909

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

Open
greendrop opened this issue Jan 7, 2025 · 5 comments

Comments

@greendrop
Copy link

Background

Brakeman version: 7.0.0
Rails version: 8.0.1
Ruby version: 3.4.1

Link to Rails application code: https://github.com/greendrop/ruby_3_4_1_rails_8_0_1_brakeman_7_0_0

Issue

Using it in an erb file causes an error with Ruby 3.4.1.
If I didn't use it or set it to --no-prism, no error occurred.

Error: undefined method 'first_param' for an instance of Array
Location: /home/runner/work/ruby_3_4_1_rails_8_0_1_brakeman_7_0_0/ruby_3_4_1_rails_8_0_1_brakeman_7_0_0/vendor/bundle/ruby/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/template_alias_processor.rb:88:in 'Brakeman::TemplateAliasProcessor#process_iter'

Other Error

Run Brakeman with --debug to see the full stack trace.

Stack trace:

== Errors ==

Error: undefined method 'first_param' for an instance of Array
Location: /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/template_alias_processor.rb:88:in 'Brakeman::TemplateAliasProcessor#process_iter'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:76:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:184:in 'Brakeman::AliasProcessor#process_call'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:76:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:78:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:78:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/template_alias_processor.rb:81:in 'Brakeman::TemplateAliasProcessor#process_iter'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:76:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:78:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:78:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:63:in 'block in Brakeman::AliasProcessor#process_default'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Array#map!'
(eval at /Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp.rb:628):3:in 'Sexp#map!'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:61:in 'Brakeman::AliasProcessor#process_default'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/template_alias_processor.rb:81:in 'Brakeman::TemplateAliasProcessor#process_iter'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:76:in 'block in Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:113:in 'Brakeman::SexpProcessor#in_context'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/ruby_parser/bm_sexp_processor.rb:72:in 'Brakeman::SexpProcessor#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processors/alias_processor.rb:51:in 'Brakeman::AliasProcessor#process_safely'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/processor.rb:86:in 'Brakeman::Processor#process_template_alias'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:395:in 'block (2 levels) in Brakeman::Scanner#process_template_data_flows'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:65:in 'Brakeman::Scanner#process_step_file'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:394:in 'block in Brakeman::Scanner#process_template_data_flows'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:423:in 'block in Brakeman::Scanner#track_progress'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:420:in 'Array#each'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:420:in 'Brakeman::Scanner#track_progress'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:393:in 'Brakeman::Scanner#process_template_data_flows'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:126:in 'block in Brakeman::Scanner#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:51:in 'Brakeman::Scanner#process_step'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/scanner.rb:125:in 'Brakeman::Scanner#process'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman.rb:403:in 'Brakeman.scan'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman.rb:96:in 'Brakeman.run'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/commandline.rb:157:in 'Brakeman::Commandline.run_brakeman'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/commandline.rb:125:in 'Brakeman::Commandline.regular_report'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/commandline.rb:166:in 'Brakeman::Commandline.run_report'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/commandline.rb:35:in 'Brakeman::Commandline.run'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/lib/brakeman/commandline.rb:20:in 'Brakeman::Commandline.start'
/Users/greendrop/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/brakeman-7.0.0/bin/brakeman:10:in '<top (required)>'
bin/brakeman:7:in 'Kernel#load'
bin/brakeman:7:in '<main>'
@presidentbeef
Copy link
Owner

ruby/prism#3409

@abratashov
Copy link

Yeah, the same issue for Rails 7.2:

bundle exec brakeman --rails7

Error: undefined method 'first_param' for an instance of Array
Location: /home/alex/.rvm/gems/ruby-3.4.1@autumn-leaves-v2/gems/brakeman-7.0.0/lib/brakeman/processors/template_alias_processor.rb:88:in 'Brakeman::TemplateAliasProcessor#process_iter'

Ruby 3.4.1
Rails Version: 7.2.2.1
Brakeman Version: 7.0.0

@presidentbeef
Copy link
Owner

As linked above, this is a Prism issue, is fixed in Prism, and I assume will be part of the next Prism release.

@Merovex
Copy link

Merovex commented Mar 15, 2025

So this is an it problem. I just started using it and now getting errors for the three places I'm usin git. Well, dang it :-)

@mattbrictson
Copy link

I've upgraded to the latest version of ruby (3.4.3), prism (1.4.0) and brakeman (7.0.2) and this issue persists.

Error: undefined method 'first_param' for an instance of Array
Location: /Users/mbrictson/.local/share/mise/installs/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/brakeman-7.0.2/lib/brakeman/processors/template_alias_processor.rb:88:in 'Brakeman::TemplateAliasProcessor#process_iter'
  • ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [arm64-darwin24]
  • brakeman (7.0.2)
  • prism (1.4.0)
  • bundler (2.6.8)

The workaround, as others have mentioned, is to run brakeman with the --no-prism flag.

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

No branches or pull requests

5 participants