On Mon, Mar 5, 2012 at 8:48 PM, Justin Collins
<[email protected] <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
<[email protected] <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