1modm / petereport

PeTeReport is an open-source application vulnerability reporting tool.
https://1modm.github.io/petereport/
BSD 3-Clause "New" or "Revised" License
449 stars 131 forks source link

Insert table in PDF report #66

Closed def-q closed 1 year ago

def-q commented 1 year ago

Hi, I'm trying to add a table in my report template so that i can put all the findings characteristics inside. But once i try to generate the report in PDF format, I receive an error saying Pandoc died. I've tried to debug it a bit but cannot understand why it does that only to the tables. The markdown code used is the following:


Test Nr. | Position | Radius | Rot | Grün | Blau | beste Fitness | Abweichung |
|---|---|---|---|---|---|---|---|
1 |  20 % |  20 % |  20 % |  20 % |  20 % |  7,5219 |  0,9115 |

image

Environment:

Request Method: GET
Request URL: http://localhost/report/download/pdf/1

Django Version: 3.2.15
Python Version: 3.8.10
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'martor',
 'django_bleach',
 'preport']
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']

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/opt/petereport/app/preport/views.py", line 985, in reportdownloadpdf
    output_pypandoc = pypandoc.convert_text(final_markdown_output, to='pdf', outputfile=pdf_file_output, format='md', extra_args=['-H', PDF_HEADER_FILE, '--from', 'markdown+yaml_metadata_block+raw_html', '--template', PETEREPORT_LATEX_FILE, '--table-of-contents', '--toc-depth', '4', '--number-sections', '--highlight-style', 'breezedark', '--filter', 'pandoc-latex-environment', '--listings', '--no-check-certificate'])
  File "/usr/local/lib/python3.8/dist-packages/pypandoc/__init__.py", line 93, in convert_text
    return _convert_input(source, format, 'string', to, extra_args=extra_args,
  File "/usr/local/lib/python3.8/dist-packages/pypandoc/__init__.py", line 420, in _convert_input
    raise RuntimeError(

Exception Type: RuntimeError at /report/download/pdf/1
Exception Value: Pandoc died with exitcode "43" during conversion: Error producing PDF.
! Missing number, treated as zero.
<to be read again> 
                   (
l.668 \begin
1modm commented 1 year ago

Hi @def-q, I have investigate and it seems that happens when the size the table is bigger than the width of the column. The next couple of lines appear in the latex output once the above condition is triggered. The application used to generate the PDF has still an opened issue about that: https://github.com/jgm/pandoc/issues/1023

If you remove 1 column appears to work:

Test Nr. | Position | Radius | Rot | Grün | Blau | beste Fitness |
|---|---|---|---|---|---|---|
1 |  20 % |  20 % |  20 % |  20 % |  20 % |  7,5219 |