Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Justin Collins


On Mon, Mar 5, 2012 at 8:48 PM, Justin Collins 
mailto:[email protected]>> wrote:


On 03/05/2012 09:45 AM, Justin Collins wrote:

On 03/05/2012 09:07 AM, Justin Collins wrote:

On 03/05/2012 06:15 AM, Marten Veldthuis wrote:

On Mon, Mar 5, 2012 at 12:44 PM, Justin Collins
mailto:[email protected]>> wrote:

I'm really sorry you have run into this problem, especially
when first
trying Brakeman. I have not actually had anyone report
issues with
Brakeman "hanging" at this particular point, so this is
interesting.


No problems. It runs great on our other projects!

Can you pull the latest code from
https://github.com/presidentbeef/brakeman and try again?
(You can run
Brakeman directly from `bin/brakeman` if you don't want to
rebuild/install the gem). I've added more debugging output
so you can
see which template is being processed and you should get a
stack trace
when interrupting the process.

Okay, with the extended debug output I can now see that the
last one it's processing is this file:
https://gist.github.com/e8f702be18e2cb3ab0e5

The stacktrace is here:
https://gist.github.com/aaa45bf99c7f2a460607

This is with --no-branching and --debug.

- Marten



Perfect. I'm looking into this now.

-Justin

In the meantime, you can use `--skip-files` to skip that template
and hopefully get at least a partial report.
No pun intended.

-Justin


Hi Marten,

I'm guessing this is also related to the other partial being
rendered from that template. In fact, it looks like it's caught in
a loop of templates.

I've pushed one more debug output to show which template is being
rendered, which should confirm this. Would you mind trying it out?

Is there any chance you have code in one of the views that looks like

   render 'blah'

i.e., with no ":partial => ..." ?

-Justin




On 03/05/2012 12:18 PM, Marten Veldthuis wrote:

Yep, that's probably it.

Processing test/questionnaires/_check_box_test
Rendering test/questionnaires/_questions 
(Template:test/questionnaires/_check_box_test)
Rendering test/questionnaires/_radio_test 
(Template:test/questionnaires/_questions)
Rendering test/questionnaires/_questions 
(Template:test/questionnaires/_radio_test)
Rendering test/questionnaires/_radio_test 
(Template:test/questionnaires/_questions)
Rendering test/questionnaires/_questions 
(Template:test/questionnaires/_radio_test)

...

If I skip those two files it works like a charm. And indeed they do

radio_test:
  = render :partial => "questions", :object => {:quests => 
(option.questions||[]), :parent_question => "#{question.title} 
#{question.description}"}

questions:
  = render :partial => "radio_test", :object => {:question => 
question}


In actual usage this works fine, because there's a surrounding 
if-statement that will at some point become false. Basically, we're 
rendering a tree of questions of some type, and questions can have 
subquestions so we recurse until we reach a leaf node. I can see how 
that would make the life of a static analysis tool difficult :)


For now I'll just skip these two files. Thanks for all your help!

- Marten


At some point should probably add something to detect this scenario. 
It's not just the recursive rendering, because Brakeman will skip 
rendering if a template with the same environment has already been 
rendered. I noticed this breaks the loop when I was trying to test the 
mutual recursive rendering. In your situation, however, there was an 
instance variable that was being modified each time the template was 
rendering, and thus the loop.


Thanks so much for reporting this!

-Justin


Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Marten Veldthuis
Yep, that's probably it.

Processing test/questionnaires/_check_box_test
Rendering test/questionnaires/_questions
(Template:test/questionnaires/_check_box_test)
Rendering test/questionnaires/_radio_test
(Template:test/questionnaires/_questions)
Rendering test/questionnaires/_questions
(Template:test/questionnaires/_radio_test)
Rendering test/questionnaires/_radio_test
(Template:test/questionnaires/_questions)
Rendering test/questionnaires/_questions
(Template:test/questionnaires/_radio_test)
...

If I skip those two files it works like a charm. And indeed they do

radio_test:
  = render :partial => "questions", :object => {:quests =>
(option.questions||[]), :parent_question => "#{question.title}
#{question.description}"}
questions:
  = render :partial => "radio_test", :object => {:question => question}

In actual usage this works fine, because there's a surrounding if-statement
that will at some point become false. Basically, we're rendering a tree of
questions of some type, and questions can have subquestions so we recurse
until we reach a leaf node. I can see how that would make the life of a
static analysis tool difficult :)

For now I'll just skip these two files. Thanks for all your help!

- Marten

On Mon, Mar 5, 2012 at 8:48 PM, Justin Collins wrote:

> **
> On 03/05/2012 09:45 AM, Justin Collins wrote:
>
> On 03/05/2012 09:07 AM, Justin Collins wrote:
>
> On 03/05/2012 06:15 AM, Marten Veldthuis wrote:
>
> On Mon, Mar 5, 2012 at 12:44 PM, Justin Collins 
> wrote:
>
>> I'm really sorry you have run into this problem, especially when first
>> trying Brakeman. I have not actually had anyone report issues with
>> Brakeman "hanging" at this particular point, so this is interesting.
>>
>
>  No problems. It runs great on our other projects!
>
>  Can you pull the latest code from
>> https://github.com/presidentbeef/brakeman and try again? (You can run
>> Brakeman directly from `bin/brakeman` if you don't want to
>> rebuild/install the gem). I've added more debugging output so you can
>> see which template is being processed and you should get a stack trace
>> when interrupting the process.
>>
>
>  Okay, with the extended debug output I can now see that the last one
> it's processing is this file: https://gist.github.com/e8f702be18e2cb3ab0e5
>
>  The stacktrace is here: https://gist.github.com/aaa45bf99c7f2a460607
>
>  This is with --no-branching and --debug.
>
>  - Marten
>
>
> Perfect. I'm looking into this now.
>
> -Justin
>
> In the meantime, you can use `--skip-files` to skip that template and
> hopefully get at least a partial report.
> No pun intended.
>
> -Justin
>
>
> Hi Marten,
>
> I'm guessing this is also related to the other partial being rendered from
> that template. In fact, it looks like it's caught in a loop of templates.
>
> I've pushed one more debug output to show which template is being
> rendered, which should confirm this. Would you mind trying it out?
>
> Is there any chance you have code in one of the views that looks like
>
>render 'blah'
>
> i.e., with no ":partial => ..." ?
>
> -Justin
>


Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Justin Collins

On 03/05/2012 09:45 AM, Justin Collins wrote:

On 03/05/2012 09:07 AM, Justin Collins wrote:

On 03/05/2012 06:15 AM, Marten Veldthuis wrote:
On Mon, Mar 5, 2012 at 12:44 PM, Justin Collins 
mailto:[email protected]>> wrote:


I'm really sorry you have run into this problem, especially when
first
trying Brakeman. I have not actually had anyone report issues with
Brakeman "hanging" at this particular point, so this is interesting.


No problems. It runs great on our other projects!

Can you pull the latest code from
https://github.com/presidentbeef/brakeman and try again? (You
can run
Brakeman directly from `bin/brakeman` if you don't want to
rebuild/install the gem). I've added more debugging output so
you can
see which template is being processed and you should get a stack
trace
when interrupting the process.

Okay, with the extended debug output I can now see that the last one 
it's processing is this file: 
https://gist.github.com/e8f702be18e2cb3ab0e5


The stacktrace is here: https://gist.github.com/aaa45bf99c7f2a460607

This is with --no-branching and --debug.

- Marten



Perfect. I'm looking into this now.

-Justin
In the meantime, you can use `--skip-files` to skip that template and 
hopefully get at least a partial report.

No pun intended.

-Justin


Hi Marten,

I'm guessing this is also related to the other partial being rendered 
from that template. In fact, it looks like it's caught in a loop of 
templates.


I've pushed one more debug output to show which template is being 
rendered, which should confirm this. Would you mind trying it out?


Is there any chance you have code in one of the views that looks like

   render 'blah'

i.e., with no ":partial => ..." ?

-Justin


Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Justin Collins

On 03/05/2012 09:07 AM, Justin Collins wrote:

On 03/05/2012 06:15 AM, Marten Veldthuis wrote:
On Mon, Mar 5, 2012 at 12:44 PM, Justin Collins 
mailto:[email protected]>> wrote:


I'm really sorry you have run into this problem, especially when
first
trying Brakeman. I have not actually had anyone report issues with
Brakeman "hanging" at this particular point, so this is interesting.


No problems. It runs great on our other projects!

Can you pull the latest code from
https://github.com/presidentbeef/brakeman and try again? (You can run
Brakeman directly from `bin/brakeman` if you don't want to
rebuild/install the gem). I've added more debugging output so you can
see which template is being processed and you should get a stack
trace
when interrupting the process.

Okay, with the extended debug output I can now see that the last one 
it's processing is this file: 
https://gist.github.com/e8f702be18e2cb3ab0e5


The stacktrace is here: https://gist.github.com/aaa45bf99c7f2a460607

This is with --no-branching and --debug.

- Marten



Perfect. I'm looking into this now.

-Justin
In the meantime, you can use `--skip-files` to skip that template and 
hopefully get at least a partial report.

No pun intended.

-Justin


Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Justin Collins

On 03/05/2012 06:15 AM, Marten Veldthuis wrote:
On Mon, Mar 5, 2012 at 12:44 PM, Justin Collins 
mailto:[email protected]>> wrote:


I'm really sorry you have run into this problem, especially when first
trying Brakeman. I have not actually had anyone report issues with
Brakeman "hanging" at this particular point, so this is interesting.


No problems. It runs great on our other projects!

Can you pull the latest code from
https://github.com/presidentbeef/brakeman and try again? (You can run
Brakeman directly from `bin/brakeman` if you don't want to
rebuild/install the gem). I've added more debugging output so you can
see which template is being processed and you should get a stack trace
when interrupting the process.

Okay, with the extended debug output I can now see that the last one 
it's processing is this file: https://gist.github.com/e8f702be18e2cb3ab0e5


The stacktrace is here: https://gist.github.com/aaa45bf99c7f2a460607

This is with --no-branching and --debug.

- Marten



Perfect. I'm looking into this now.

-Justin


Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Marten Veldthuis
On Mon, Mar 5, 2012 at 12:44 PM, Justin Collins wrote:

> I'm really sorry you have run into this problem, especially when first
> trying Brakeman. I have not actually had anyone report issues with
> Brakeman "hanging" at this particular point, so this is interesting.
>

No problems. It runs great on our other projects!

Can you pull the latest code from
> https://github.com/presidentbeef/brakeman and try again? (You can run
> Brakeman directly from `bin/brakeman` if you don't want to
> rebuild/install the gem). I've added more debugging output so you can
> see which template is being processed and you should get a stack trace
> when interrupting the process.
>

Okay, with the extended debug output I can now see that the last one it's
processing is this file: https://gist.github.com/e8f702be18e2cb3ab0e5

The stacktrace is here: https://gist.github.com/aaa45bf99c7f2a460607

This is with --no-branching and --debug.

- Marten


Re: [brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Justin Collins
On 03/05/2012 03:23 AM, Marten Veldthuis wrote:
> Hi,
>
> I'm trying to run Brakeman on our application, but it seems to just 
> end up in an infinite loop (using 100% of one cpu core). I'm running 
> brakeman in debug-mode to see what's going on, but that doesn't give 
> enough information to track down what's happening. Anyone with ideas 
> of how to begin debugging (this is the first time I'm trying brakeman)?
>


Hi Marten,

I'm really sorry you have run into this problem, especially when first 
trying Brakeman. I have not actually had anyone report issues with 
Brakeman "hanging" at this particular point, so this is interesting.

Can you pull the latest code from 
https://github.com/presidentbeef/brakeman and try again? (You can run 
Brakeman directly from `bin/brakeman` if you don't want to 
rebuild/install the gem). I've added more debugging output so you can 
see which template is being processed and you should get a stack trace 
when interrupting the process.

If it's still hanging, also try the `--no-branching` option.

-Justin


[brakeman] Hanging at 146/162 templates processed

2012-03-05 Thread Marten Veldthuis
Hi,

I'm trying to run Brakeman on our application, but it seems to just end up
in an infinite loop (using 100% of one cpu core). I'm running brakeman in
debug-mode to see what's going on, but that doesn't give enough information
to track down what's happening. Anyone with ideas of how to begin debugging
(this is the first time I'm trying brakeman)?

Output of brakeman -n -d:

[Notice] Detected Rails 3 application
Loading scanner...
[Notice] Using Ruby 1.9.2. Please make sure this matches the one used to
run your Rails application.
Processing application in /home/marten/rgoc/roqua
Processing configuration...
[Notice] Escaping HTML by default
Processing gems...
Processing initializers...
Processing libs...
Processing /home/marten/rgoc/roqua/lib/active_resource_monkeypatch.rb
Processing /home/marten/rgoc/roqua/lib/builders.rb
Processing /home/marten/rgoc/roqua/lib/builders/measurement_builder.rb
Processing /home/marten/rgoc/roqua/lib/builders/protocol_builder.rb
Processing /home/marten/rgoc/roqua/lib/epd/epd_coupling.rb
Processing /home/marten/rgoc/roqua/lib/epd/token_url.rb
Processing /home/marten/rgoc/roqua/lib/extensions/action_view_extensions.rb
Processing
/home/marten/rgoc/roqua/lib/extensions/active_record_extensions.rb
Processing
/home/marten/rgoc/roqua/lib/extensions/active_support_extensions.rb
Processing /home/marten/rgoc/roqua/lib/extensions/array_extensions.rb
Processing /home/marten/rgoc/roqua/lib/extensions/enumerable_extensions.rb
Processing /home/marten/rgoc/roqua/lib/extensions/fabrication_extensions.rb
Processing /home/marten/rgoc/roqua/lib/extensions/fixnum_extensions.rb
Processing /home/marten/rgoc/roqua/lib/extensions/hash_extensions.rb
Processing /home/marten/rgoc/roqua/lib/extensions/string_extensions.rb
Processing /home/marten/rgoc/roqua/lib/migration_helper.rb
Processing /home/marten/rgoc/roqua/lib/will_paginate_bootstrap.rb
Processing routes...
Processing templates...
Processing data flow in templates...
[Notice] No such template: epd/new_outcomes/_chart_settings.js
[Notice] No such template: epd/new_outcomes/_chart_settings.js
[Notice] No such template: system/_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_extra_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_extra_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_extra_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_extra_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_notice
[Notice] No such template: system/_notice
 146/162 templates processed