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

ruby 3.1: undefined method `original_line' for nil:NilClass unless value.original_line #1700

Closed
jorgenschaefer opened this issue Apr 7, 2022 · 3 comments · Fixed by #1701

Comments

@jorgenschaefer
Copy link

We just upgraded to brakeman 5.2.2 and ruby 3.1.1. The command bundle exec brakeman results in the following output:

== Brakeman Report ==

Application Path: […]
Rails Version: 7.0.2.3
Brakeman Version: 5.2.2
Scan Date: 2022-04-07 10:29:53 +0200
Duration: 4.397862559 seconds
Checks Run: BasicAuth, BasicAuthTimingAttack, CSRFTokenForgeryCVE, ContentTag, CookieSerialization, CreateWith, CrossSiteScripting, DefaultRoutes, Deserialize, DetailedExceptions, DigestDoS, DivideByZero, DynamicFinders, EOLRails, EOLRuby, EscapeFunction, Evaluation, Execute, FileAccess, FileDisclosure, FilterSkipping, ForceSSL, ForgerySetting, HeaderDoS, I18nXSS, JRubyXML, JSONEncoding, JSONEntityEscape, JSONParsing, LinkTo, LinkToHref, MailTo, MassAssignment, MimeTypeDoS, ModelAttrAccessible, ModelAttributes, ModelSerialize, NestedAttributes, NestedAttributesBypass, NumberToCurrency, PageCachingCVE, PermitAttributes, QuoteTableName, Redirect, RegexDoS, Render, RenderDoS, RenderInline, ResponseSplitting, ReverseTabnabbing, RouteDoS, SQL, SQLCVEs, SSLVerify, SafeBufferManipulation, SanitizeMethods, Secrets, SelectTag, SelectVulnerability, Send, SendFile, SessionManipulation, SessionSettings, SimpleFormat, SingleQuotes, SkipBeforeFilter, SprocketsPathTraversal, StripTags, SymbolDoS, SymbolDoSCVE, TemplateInjection, TranslateBug, UnsafeReflection, UnsafeReflectionMethods, UnscopedFind, ValidationRegex, VerbConfusion, WeakHash, WithoutProtection, XMLDoS, YAMLParsing

== Overview ==

Controllers: 74
Models: 72
Templates: 69
Errors: 11
Security Warnings: 0
Ignored Warnings: 6

== Warning Types ==


== Errors ==

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

Error: undefined method `original_line' for nil:NilClass          unless value.original_line                     ^^^^^^^^^^^^^^
Location: /home/jorgen/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/brakeman-5.2.2/lib/brakeman/processors/lib/render_helper.rb:128:in `block in process_template'

No warnings found

Is there any way I can find out where this error is occurring, or provide more detail on why this is failing? :-)

@presidentbeef
Copy link
Owner

Hi @jorgenschaefer - yes, if you run with -d you will be able to get a full stack trace and it will be more apparent which file(s) are causing the issue.

@jorgenschaefer
Copy link
Author

Hah! That helped.

Ruby 3.1 allows a shorthand syntax for passing key-value-pairs with the same name, e.g. { account: account } can be written as { account: }. Rubocop even enforces this by default. That apparently triggers the bug.

Example code:

  def new
    account = Customer.find(params.fetch(:customer_id)).accounts.build
    render 'new', locals: { account: }
  end

presidentbeef added a commit that referenced this issue Apr 8, 2022
@presidentbeef
Copy link
Owner

Really helpful, thanks!

presidentbeef added a commit that referenced this issue Apr 8, 2022
Repository owner locked and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants