Fix faradaysec executive report template macro

Jinja was looking for the following tags: 'endmacro'.

Upon FaradaySEC v3.12 we upgraded our jinja templates libraries, this affected our macro. In our original template the macro contains a "-" which is now incompatible and requires template update.
The correct macro is:
  1. {% macro severity(name) %}{% if name == "critical" %}Critical{% elif name == "high" %}High{% elif name == "med" %}Medium{% elif name == "low" %}Low{% elif name == "info" %}Informational{% elif name == "unclassified" %}Unclassified{% endif %}{% endmacro %}


Usually the error asociated with this issue is the following:

  1. jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'elif'. Jinja was looking for the following tags: 'endmacro'. The innermost block that needs to be closed is 'macro'.
Full traceback

  1. 2020-08-11T12:39:58-0300 - faraday.faraday.reports.executive_reports - ERROR {ReportsThread} [executive_reports.py:288 - create_docx_report()]  Error creating report (another_workspace_symtai_webapp_dsadas): {Traceback (most recent call last):
  2.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/faraday/reports/executive_reports.py", line 279, in create_docx_report
  3.     docx = docx_report.create_document(report,
  4.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/faraday/reports/executive/group_by_name.py", line 443, in create_document
  5.     tpl.render(context, jinja_env)
  6.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/docxtpl/__init__.py", line 283, in render
  7.     xml_src = self.build_xml(context, jinja_env)
  8.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/docxtpl/__init__.py", line 242, in build_xml
  9.     xml = self.render_xml(xml, context, jinja_env)
  10.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/docxtpl/__init__.py", line 230, in render_xml
  11.     raise exc
  12.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/docxtpl/__init__.py", line 221, in render_xml
  13.     template = jinja_env.from_string(src_xml)
  14.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 896, in from_string
  15.     return cls.from_code(self, self.compile(source), globals, None)
  16.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 625, in compile
  17.     self.handle_exception(source=source_hint)
  18.   File "/Users/username/.pyenv/versions/faraday380/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 787, in handle_exception
  19.     raise rewrite_traceback_stack(source=source)
  20.   File "<unknown>", line 1, in template
  21. jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'elif'. Jinja was looking for the following tags: 'endmacro'. The innermost block that needs to be closed is 'macro'.
  22. }
  23. 2020-08-11T12:39:58-0300 - faraday.faraday.reports.executive_reports - ERROR {ReportsThread} [executive_reports.py:289 - create_docx_report()]  Please review your template

    Still looking for answers? You can try opening a ticket.
      • Related Articles

      • Faraday vulnerability search

        The vulnerability search allows you to build search queries to search for vulnerabilities. screenshot of vulnerability search Understanding search For using the search you need to know the vulnerability attributes and its relationships. Vulnerability ...
      • Executive Report jinja2 Template Context json

        These are examples of jinja2 static dataset usage. You can access this information from the docx template. Executive reports use jinja for rendering the report, check jinja documentation for more details. methodologies can be used from version 3.12 ...
      • Executive Report

        Intro No more 3AM reporting! The Executive Report feature lets you create (as the name implies) reports using the results obtained in each workspace. When an Executive Report is created, all the data from the Status Report is automatically processed ...
      • Debian/Ubuntu/Kali Installation

        Download Faraday's Installer from the Customer Portal . Install postgresql > 9.6 (locally or in a remote server). In order to install PostgreSQL, you can run the following command:  $ sudo apt install postgresql After the installation is completed, ...
      • CentOS7/RedHat7 Installation

        Before installation Please note that PostgreSQL YUM repository and Faraday, depend on EPEL repository for some packages. Users with RHEL, CentOS, etc. should install EPEL repo RPM along with PGDG repo RPMs to satisfy dependencies. In order to do ...