📌

【Rails】brakeman gemでSexpTypeError

2021/12/28に公開

brakemanでSexpTypeError

問題が発生した環境

brakeman version: 4.9.1
ruby version: 3.0.1

解決法

brakemanのバージョンを 4.10.0以上にする(最新版は5.2.0)

出たエラー

/usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:82:in `process': Result must be a Sexp, was Array:[:arglist, s(:str, "App")] (SexpTypeError)
ログ全文
root@db97bb2a3968:/app# brakeman
Loading scanner...
Processing application in /app
Processing gems...
[Notice] Detected Rails 6 application
Processing configuration...
[Notice] Error while processing /app/config/application.rb
[Notice] Escaping HTML by default
Parsing files...
Processing initializers...
/usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:82:in `process': Result must be a Sexp, was Array:[:arglist, s(:str, "App")] (SexpTypeError)
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/processors/base_processor.rb:175:in `process_attrasgn'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:76:in `block in process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:113:in `in_context'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:72:in `process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/processors/base_processor.rb:111:in `block in process_block'
	from (eval):3:in `map!'
	from (eval):3:in `map!'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/processors/base_processor.rb:110:in `process_block'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:76:in `block in process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:113:in `in_context'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:72:in `process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/processors/base_processor.rb:74:in `process_iter'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:76:in `block in process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:113:in `in_context'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/ruby_parser/bm_sexp_processor.rb:72:in `process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/processors/base_processor.rb:24:in `process_file'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/processor.rb:91:in `process_initializer'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:197:in `process_initializer'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:191:in `block in process_initializers'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:314:in `block in track_progress'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:311:in `each'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:311:in `track_progress'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:189:in `process_initializers'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/scanner.rb:47:in `process'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman.rb:369:in `scan'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman.rb:84:in `run'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/commandline.rb:157:in `run_brakeman'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/commandline.rb:125:in `regular_report'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/commandline.rb:166:in `run_report'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/commandline.rb:35:in `run'
	from /usr/local/bundle/gems/brakeman-4.9.1/lib/brakeman/commandline.rb:20:in `start'
	from /usr/local/bundle/gems/brakeman-4.9.1/bin/brakeman:10:in `<top (required)>'
	from /usr/local/bundle/bin/brakeman:23:in `load'
	from /usr/local/bundle/bin/brakeman:23:in `<main>'

参考

  • brakeman バージョン5.2.0のリリース

https://github.com/presidentbeef/brakeman/discussions/1661

Discussion