brad-sp / cuckoo-modified

Modified edition of cuckoo
271 stars 100 forks source link

TemplateSyntaxError Invaild Filter: stats_total #208

Closed housemusic42 closed 9 years ago

housemusic42 commented 9 years ago

howdy.

i'm updated to the latest commit and I'm getting a django error when trying to pull up an analysis. I'm front ending cuckoo with apache so perhaps i'm missing another directive in my wsgi.py?

Environment:

Request Method: GET
Request URL: http://cuckoo.test/analysis/1159/

Django Version: 1.6.1
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'analysis',
 'compare',
 'api',
 'ratelimit')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'web.headers.CuckooHeaders',
 'ratelimit.middleware.RatelimitMiddleware')

Template error:
In template /opt/cuckoo-modified/web/templates/analysis/statistics/index.html, error at line 5
   Invalid filter: 'stats_total'
   1 : {% if analysis.statistics %}

   2 : {% load analysis_tags %}

   3 :     <div class="row">

   4 :     <div class="well well-small col-md-6">

   5 :       <h4>Processing&emsp;(  {{ analysis.statistics.processing|stats_total }}  seconds )</h4>

   6 :         <ul class="list-group">

   7 :             {% for stat in analysis.statistics.processing|dictsortreversed:"time" %}

   8 :             {% if stat.time %}

   9 :             <li class="list-group-item">

   10 :                 <span class="badge">{{stat.time}}</span>

   11 :                 {{stat.name}}

   12 :             </li>

   13 :             {% endif %}

   14 :             {% endfor %}

   15 :         </ul>

Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/http.py" in inner
  41.             return func(request, *args, **kwargs)
File "/opt/cuckoo-modified/web/analysis/views.py" in report
  381.                     chunks.append(data)
File "/usr/lib/python2.7/dist-packages/django/shortcuts/__init__.py" in render_to_response
  29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
  162.         t = get_template(template_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in get_template
  138.     template, origin = find_template(template_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in find_template
  127.             source, display_name = loader(name, dirs)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in __call__
  43.         return self.load_template(template_name, template_dirs)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in load_template
  49.             template = get_template_from_string(source, origin, template_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in get_template_from_string
  149.     return Template(source, origin, name)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in __init__
  125.         self.nodelist = compile_string(template_string, origin)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in compile_string
  153.     return parser.parse()
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in parse
  278.                     compiled_result = compile_func(self, token)
File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py" in do_extends
  215.     nodelist = parser.parse()
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in parse
  278.                     compiled_result = compile_func(self, token)
File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py" in do_block
  190.     nodelist = parser.parse(('endblock',))
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in parse
  278.                     compiled_result = compile_func(self, token)
File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py" in do_include
  263.                                    isolated_context=isolated_context)
File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py" in __init__
  145.             t = get_template(template_path)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in get_template
  138.     template, origin = find_template(template_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in find_template
  127.             source, display_name = loader(name, dirs)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in __call__
  43.         return self.load_template(template_name, template_dirs)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in load_template
  49.             template = get_template_from_string(source, origin, template_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py" in get_template_from_string
  149.     return Template(source, origin, name)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in __init__
  125.         self.nodelist = compile_string(template_string, origin)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in compile_string
  153.     return parser.parse()
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in parse
  278.                     compiled_result = compile_func(self, token)
File "/usr/lib/python2.7/dist-packages/django/template/defaulttags.py" in do_if
  942.     nodelist = parser.parse(('elif', 'else', 'endif'))
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in parse
  254.                     filter_expression = self.compile_filter(token.contents)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in compile_filter
  360.         return FilterExpression(token, self)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in __init__
  571.                 filter_func = parser.find_filter(filter_name)
File "/usr/lib/python2.7/dist-packages/django/template/base.py" in find_filter
  366.             raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name)

Exception Type: TemplateSyntaxError at /analysis/1159/
Exception Value: Invalid filter: 'stats_total'

wsgi.py

import os, sys

sys.path.append('/opt/cuckoo-modified/')
sys.path.append('/opt/cuckoo-modified/web')
os.chdir('/opt/cuckoo-modified/web/')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
KillerInstinct commented 9 years ago

Apache config looks fine.

https://github.com/brad-accuvant/cuckoo-modified/blob/master/web/analysis/templatetags/analysis_tags.py

Can you make sure you have the stats_total definition in there?

If so, did you restart apache after the git pull?

housemusic42 commented 9 years ago

Yup. Apache restart. I am the dumb. Thanks!