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

Error: undefined method `line=' for nil:NilClass #1155

Closed
jesseproudman opened this Issue Jan 26, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@jesseproudman

jesseproudman commented Jan 26, 2018

Background

Brakeman version: 4.1.1
Rails version: 5.1.4
Ruby version: 2.3.6p384

Link to Rails application code: Private codebase

Issue

Scan of repository is showing a single error linking to the Brakeman code base. Attempting to track down what's causing it, but the error notice isn't providing us enough background to look into the code.

== Brakeman Report ==

Application Path: xxx
Rails Version: 5.1.4
Brakeman Version: 4.1.1
Scan Date: 2018-01-23 15:02:47 -0800
Duration: 1.386945 seconds
Checks Run: BasicAuth, BasicAuthTimingAttack, ContentTag, CreateWith, CrossSiteScripting, DefaultRoutes, Deserialize, DetailedExceptions, DigestDoS, DynamicFinders, EscapeFunction, Evaluation, Execute, FileAccess, FileDisclosure, FilterSkipping, ForgerySetting, HeaderDoS, I18nXSS, JRubyXML, JSONEncoding, JSONParsing, LinkTo, LinkToHref, MailTo, MassAssignment, MimeTypeDoS, ModelAttrAccessible, ModelAttributes, ModelSerialize, NestedAttributes, NestedAttributesBypass, NumberToCurrency, PermitAttributes, QuoteTableName, Redirect, RegexDoS, Render, RenderDoS, RenderInline, ResponseSplitting, RouteDoS, SQL, SQLCVEs, SSLVerify, SafeBufferManipulation, SanitizeMethods, SelectTag, SelectVulnerability, Send, SendFile, SessionManipulation, SessionSettings, SimpleFormat, SingleQuotes, SkipBeforeFilter, StripTags, SymbolDoSCVE, TranslateBug, UnsafeReflection, ValidationRegex, WithoutProtection, XMLDoS, YAMLParsing

== Overview ==

Controllers: 6
Models: 8
Templates: 1
Errors: 1
Security Warnings: 0

== Warning Types ==


== Errors ==

Error: undefined method `line=' for nil:NilClass
Location: /Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:434:in `process_gasgn'

No warnings found

Running with debug just repeats this over and over and over:

== Errors ==

Error: undefined method `line=' for nil:NilClass
Location: /Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:434:in `process_gasgn'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:75:in `block in process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:112:in `in_context'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:71:in `process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:61:in `block in process_default'
(eval):3:in `map!'
(eval):3:in `map!'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:59:in `process_default'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:77:in `block in process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:112:in `in_context'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:71:in `process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:61:in `block in process_default'
(eval):3:in `map!'
(eval):3:in `map!'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:59:in `process_default'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:503:in `process_masgn'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:75:in `block in process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:112:in `in_context'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:71:in `process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/lib/processor_helper.rb:13:in `block in process_all!'
(eval):3:in `map!'
(eval):3:in `map!'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/lib/processor_helper.rb:11:in `process_all!'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:354:in `block in process_defn'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:364:in `block in meth_env'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/bundle/ruby/2.3.0/gems/sexp_processor-4.10.0/lib/sexp_processor.rb:452:in `scope'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:361:in `meth_env'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:353:in `process_defn'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:75:in `block in process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:112:in `in_context'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:71:in `process'

Thanks!

@presidentbeef

This comment has been minimized.

Owner

presidentbeef commented Jan 26, 2018

Hi Jesse,

In the debug output you should be able to see what file Brakeman is processing when the error occurs. That file should contain some assignments to globals like $X = ....

If you could share what those assignments look like, that would be helpful.

I can/will change the code to be more defensive but I'd like to understand how this is happening in the first place.

@jesseproudman

This comment has been minimized.

jesseproudman commented Jan 26, 2018

Ahha!

Found it up above:

Processing /Users/jproudman/Source/octopus/lib/octopus/balances.rb
undefined method `line=' for nil:NilClass
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/brakeman/processors/alias_processor.rb:434:in `process_gasgn'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:75:in `block in process'
/Users/jproudman/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/brakeman-4.1.1/lib/ruby_parser/bm_sexp_processor.rb:112:in `in_context'

I can send you the globals assignments in balances.rb but would prefer to do so privately. What's the best way to do that?

@presidentbeef

This comment has been minimized.

Owner

presidentbeef commented Jan 27, 2018

DM me on Twitter or send a private message on Gitter.

@jesseproudman

This comment has been minimized.

jesseproudman commented Jan 27, 2018

Perfect. Thanks. Just sent you the file over a DM on twitter.

presidentbeef added a commit that referenced this issue Feb 4, 2018

@jesseproudman

This comment has been minimized.

jesseproudman commented Feb 6, 2018

Thanks!

Repository owner locked and limited conversation to collaborators May 9, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.