[BUG] ERROR at Generate Report
Describe the bug Using the default investigation template (https://docs.dfir-iris.org/operations/example_reports/iris_report_template.docx) or custom template get ERROR
iriswebapp_app | 2025-04-26 08:40:53 :: ERROR :: app :: log_exception :: Exception on /case/report/generate-investigation/1 [GET] iriswebapp_app | Traceback (most recent call last): iriswebapp_app | File "/opt/venv/lib/python3.12/site-packages/flask/app.py", line 1511, in wsgi_app iriswebapp_app | response = self.full_dispatch_request() iriswebapp_app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/opt/venv/lib/python3.12/site-packages/flask/app.py", line 919, in full_dispatch_request iriswebapp_nginx | 192.168.84.1 - - [26/Apr/2025:08:40:53 +0000] "GET /case/report/generate-investigation/1?cid=2&safe=true HTTP/1.1" 500 265 "https://192.168.84.130/case?cid=2" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0" "-" iriswebapp_app | rv = self.handle_user_exception(e) iriswebapp_app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/opt/venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request iriswebapp_app | rv = self.dispatch_request() iriswebapp_app | ^^^^^^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/opt/venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request iriswebapp_app | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] iriswebapp_app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/iriswebapp/app/blueprints/access_controls.py", line 335, in wrap iriswebapp_app | return f(*args, **kwargs) iriswebapp_app | ^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/iriswebapp/app/blueprints/access_controls.py", line 244, in wrap iriswebapp_app | return f(*args, **kwargs) iriswebapp_app | ^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/iriswebapp/app/blueprints/rest/reports_route.py", line 116, in generate_report iriswebapp_app | fpath, logs = mreport.generate_doc_report(doc_type="Investigation") iriswebapp_app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/iriswebapp/app/iris_engine/reporter/reporter.py", line 311, in generate_doc_report iriswebapp_app | image_handler = ImageHandler(template=None, base_path='/') iriswebapp_app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ iriswebapp_app | File "/iriswebapp/app/iris_engine/reporter/ImageHandler.py", line 36, in init iriswebapp_app | PictureGlobals.init(self, template, base_path) iriswebapp_app | File "/opt/venv/lib/python3.12/site-packages/docx_generator/globals/picture_globals.py", line 44, in init iriswebapp_app | self._available_alignment_values.append(member.name) iriswebapp_app | ^^^^^^^^^^^ iriswebapp_app | AttributeError: 'str' object has no attribute 'name'
To Reproduce Steps to reproduce the behavior:
Go to Case > Generate Report See Internal Server Error
Expected behavior No Internal Server Error
Desktop (please complete the following information):
- OS: Ubuntu Docker
- Version v2.5.0-beta.1
Got the same bug. Tried with the investigation report template offered in the documentation. Also, tried safe mode and still got it.
I’ve reproduced the bug described in this issue and identified the root cause in the docx_generator package, specifically in /opt/venv/lib/python3.12/site-packages/docx_generator/globals/picture_globals.py. The error occurs because the code attempts to access the name attribute of a string object in the PictureGlobals.init method, which is not valid.
Temporary Workaround
As a temporary fix, I modified the Dockerfile to patch the problematic line during the image build process. Here’s the change I added to the Dockerfile in the compile-image stage:
COPY source/dependencies /dependencies
COPY source/requirements.txt /
RUN pip3 install -r requirements.txt
#Fix report generate
RUN sed -i 's/self._available_alignment_values.append(member.name)/self._available_alignment_values.append(member)/' /opt/venv/lib/python3.12/site-packages/docx_generator/globals/picture_globals.py
###############
# BUILD IMAGE #
###############
FROM python:3.12 AS iriswebapp
ENV PYTHONUNBUFFERED=1 DOCKERIZED=1
COPY --from=compile-image /opt/venv /opt/venv
This change replaces member.name with member, ensuring the alignment values are appended correctly. After rebuilding the Docker image with this modification, the report generation worked without the AttributeError.
This is also fixed by https://github.com/dfir-iris/docx-generator/pull/4 from the dependency, but this hasn't been folded into IRIS proper yet.