StamusNetworks/scirius

KeyError on Hunt whith latest django-webpack-loader (v1.0.0)

yodapotatofly opened this issue · 0 comments

When installing python requirements for Scirius from requirements.txt, latest version of django-webpack-loader gets installed.
This causes the following error :
image

Show Traceback
Environment:


Request Method: GET
Request URL: https://10.136.0.51/rules/hunt

Django Version: 2.2.24
Python Version: 3.8.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_tables2',
 'bootstrap3',
 'dbbackup',
 'viz',
 'rules',
 'suricata',
 'accounts',
 'rest_framework',
 'rest_framework.authtoken',
 'django_filters',
 'webpack_loader',
 'revproxy')
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'scirius.loginrequired.LoginRequiredMiddleware',
 'scirius.utils.TimezoneMiddleware',
 'csp.middleware.CSPMiddleware',
 'django_cprofile_middleware.middleware.ProfilerMiddleware']


Template error:
In template /opt/scirius/rules/templates/rules/hunt.html, error at line 15
   assets
   5 :   <head>
   6 :     <meta charset="UTF-8" />
   7 :     <meta name="viewport" content="width=device-width" />
   8 :     <link rel="shortcut icon" href="{% static 'rules/favicon.ico' %}" />
   9 :     <title>Scirius - Hunt</title>
   10 :   </head>
   11 :   <body class="cards-pf">
   12 :     <div id="root">
   13 :     </div>
   14 :     <script type="text/javascript" src="{{ current_user_url }}" nonce="{{ request.csp_nonce }}"></script>
   15 :       {% get_files 'main' 'css' as css_files %} 
   16 :      {% for css_file in css_files %}
   17 :        <link type="text/css" href="{{ css_file.url }}" rel="preload stylesheet" />
   18 :      {% endfor %}
   19 : 
   20 :      {% get_files 'main' 'js' as js_files %}
   21 :      {% for js_file in js_files %}
   22 :        <script type="text/javascript" src="{{ js_file.url }}" nonce="{{ request.csp_nonce }}"></script>
   23 :      {% endfor %}
   24 :      {% if settings.CUSTOM_CSS %}
   25 :        <link rel="stylesheet" type="text/css" href="{{ settings.CUSTOM_CSS }}" />


Traceback:

File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.8/site-packages/csp/decorators.py" in _wrapped
  49.             r = f(*a, **kw)

File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  21.                 return view_func(request, *args, **kwargs)

File "/opt/scirius/rules/views.py" in hunt
  2038.     return scirius_render(request, 'rules/hunt.html', context)

File "/opt/scirius/scirius/utils.py" in scirius_render
  141.     return render(request, template, context)

File "/usr/local/lib/python3.8/site-packages/django/shortcuts.py" in render
  36.     content = loader.render_to_string(template_name, context, request, using=using)

File "/usr/local/lib/python3.8/site-packages/django/template/loader.py" in render_to_string
  62.     return template.render(context, request)

File "/usr/local/lib/python3.8/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/usr/local/lib/python3.8/site-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/usr/local/lib/python3.8/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/usr/local/lib/python3.8/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.8/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/usr/local/lib/python3.8/site-packages/django/template/library.py" in render
  192.         output = self.func(*resolved_args, **resolved_kwargs)

File "/usr/local/lib/python3.8/site-packages/webpack_loader/templatetags/webpack_loader.py" in get_files
  36.     return utils.get_files(bundle_name, extension=extension, config=config)

File "/usr/local/lib/python3.8/site-packages/webpack_loader/utils.py" in get_files
  48.     return list(_get_bundle(bundle_name, extension, config))

File "/usr/local/lib/python3.8/site-packages/webpack_loader/utils.py" in _get_bundle
  40.     bundle = get_loader(config).get_bundle(bundle_name)

File "/usr/local/lib/python3.8/site-packages/webpack_loader/loader.py" in get_bundle
  90.                 asset = assets['assets'][chunk]

Exception Type: KeyError at /rules/hunt
Exception Value: 'assets'

Simplest workaround is to set django-webpack-loader==0.7 in requirements.txt

django-webpack-loader