TheGroundZero / openvasreporting

OpenVAS Reporting: Convert OpenVAS XML report files to reports
Other
127 stars 44 forks source link

NotImplementedError("Use of template is not supported in XSLX-output.") even though --template is not provided #2

Closed moxli closed 5 years ago

moxli commented 5 years ago

Hello,

I am encountering the following problem.

Command: python3 -m openvasreporting --input *.xml --format xlsx --output report.xlsx

Error: Traceback (most recent call last): File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/mdorner/.local/lib/python3.7/site-packages/openvasreporting/__main__.py", line 17, in <module> main() File "/home/mdorner/.local/lib/python3.7/site-packages/openvasreporting/openvasreporting.py", line 32, in main convert(config) File "/home/mdorner/.local/lib/python3.7/site-packages/openvasreporting/openvasreporting.py", line 88, in convert exporters()[config.filetype](openvas_info, config.template, config.output_file) File "/home/mdorner/.local/lib/python3.7/site-packages/openvasreporting/libs/export.py", line 60, in export_to_excel raise NotImplementedError("Use of template is not supported in XSLX-output.") NotImplementedError: Use of template is not supported in XSLX-output.

Replacing the following line with print("1") or sleep 1 is my current workaround ^^ https://github.com/TheGroundZero/openvasreporting/blob/fb4b32f62d1ebdd8ae1a81fd4b375f8bd613dcd3/openvasreporting/libs/export.py#L86

This check should clearly not result in 'True' because neither '-t' or '--template' are passed to openvasreporting. https://github.com/TheGroundZero/openvasreporting/blob/fb4b32f62d1ebdd8ae1a81fd4b375f8bd613dcd3/openvasreporting/libs/export.py#L85

I have installed openvasreporting via pip: pip3 install OpenVAS-Reporting

My current version is 1.4.3: pip3 freeze | grep OpenVAS OpenVAS-Reporting==1.4.3

Am I doing something wrong, because looking at the code 'template' is set to 'None' per default everywhere?

TheGroundZero commented 5 years ago

Very weird indeed. If you don't pass a template param you shouldn't be receiving this error.

I'll try to free up some time to look into this

moxli commented 5 years ago

Thanks!

FYI my Python version is: Python 3.7.3

TheGroundZero commented 5 years ago

What's weird is that I'm not getting this error.
I'm on Linux, running Python 3.7.3 as well.

Are you running on Windows or on Linux?
Not sure there is/would be logical difference causing this issue between OSes.

I could follow the suggestion in #3 and remove the check resulting in this error. However, I'd like to keep it for the sake of informing a user that might incorrectly assume that a template features is available in each of the export formats.

moxli commented 5 years ago

I am running on Linux. I will try to reproduce it on a different machine.

moxli commented 5 years ago

So I was able to reproduce this behavior in a Debian 10 Buster container.

moxli commented 5 years ago

A colleague of mine was able to reproduce it with the pip package & python 3.7.3 on MacOS.

TheGroundZero commented 5 years ago

Thanks you for verifying this odd behaviour.

Sadly enough, I haven't had the time to dig deeper into this.

The code sets default to Null and check for the param not being Null, so it doesn't make sense that this is triggering.
The current workaround would be to remove the check completely, which I may do until I find a working solution.

TheGroundZero commented 5 years ago

Can you test with the last commit?

Testing on a recent Ubuntu install:

$ python3 --version
Python 3.7.3

$ pip3 freeze | grep -i openvas
OpenVAS-Reporting==1.4.4

$ python3 -m openvasreporting -i test/report.xml -o test/report -f xlsx

$ ls test
report.xml
report.xlsx
moxli commented 5 years ago

Ok for testing purposes I am using a Docker container with the official Python image (latest).

I am getting the following error on all systems (local, kubernetes docker with debian 10, python official image):

root@880549ee3d81:/# python3 -m openvasreporting -i *.xml -o report.xlsx -f xlsx Traceback (most recent call last): File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.7/site-packages/openvasreporting/__main__.py", line 6, in <module> from openvasreporting.openvasreporting import main File "/usr/local/lib/python3.7/site-packages/openvasreporting/openvasreporting.py", line 9, in <module> from .libs.config import Config ModuleNotFoundError: No module named 'openvasreporting.libs'

root@880549ee3d81:/# pip freeze | grep OpenVAS OpenVAS-Reporting==1.4.4

TheGroundZero commented 5 years ago

That's weird.
I had similar errors when running from the pip install (running openvasreporting instead of python3 -m openvasreporting). See #4 for a similar issue.

On the template error:
I don't appear to get that error when running from the openvasreporting folder.
If I run python3 -m openvasreporting -i *.xml -o report from the repo base folder, it works fine. Running it from any other folder (e.g. home) results in the error NotImplementedError: Use of template is not supported in XSLX-output.
Which makes this all even more confusing.