TheGroundZero / openvasreporting

OpenVAS Reporting: Convert OpenVAS XML report files to reports
Other
131 stars 45 forks source link

Cannot Generate XLSX reports #16

Closed rockabillycat666 closed 4 years ago

rockabillycat666 commented 4 years ago

Hi I read that the pip version was not working so I cloned the git repo. I am using Greenbone Security Manager - Greenbone OS 6.0.7

When trying to generate the report for the multiple XML files (generated them as XML not Anonymous XML). I get the following:

└──╼ $sudo python3 -m openvasreporting XML-Files/* -f xlsx
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/marduk/openvasreporting/openvasreporting/__main__.py", line 6, in <module>
    from openvasreporting.openvasreporting import main
  File "/home/marduk/openvasreporting/openvasreporting/openvasreporting.py", line 10, in <module>
    from .libs.parser import openvas_parser
  File "/home/marduk/openvasreporting/openvasreporting/libs/parser.py", line 164
    else:
        ^
IndentationError: unindent does not match any outer indentation level

Same thing happens if I run it without sudo. I am not sure how to fix it.

TheGroundZero commented 4 years ago

I edited parser.py on the Github website (see the latest commit). This may have caused an issue with intendation.

I'm not on a system with the source code right now, so can quickly push a fix.
I suggest you open parser.py in your favorite code editor and check the intendation on the lines I edited online.

This is a quick fix, so I should be able to update the repo somewhere this week.

I updated your post to use code tags to improve readability.

rockabillycat666 commented 4 years ago

Thank you I will try that! I appreciate it.

rockabillycat666 commented 4 years ago

I edited the file and was able to generate the report. I am not sure if the following is related to the same issue or it is on my own distro: ... ... ...

020-06-01 12:34:40 | DEBUG | root | * vuln_threat:  low
2020-06-01 12:34:40 | DEBUG | root | * vuln_family: General
2020-06-01 12:34:40 | DEBUG | root | * vuln_cves:   []
2020-06-01 12:34:40 | DEBUG | root | * vuln_references: []
2020-06-01 12:34:40 | DEBUG | root | * vuln_result: It was detected that the host implements RFC1323.

The following timestamps were retrieved with a delay of 1 seconds in-between:
Packet 1: 2221025497
Packet 2: 2221025605

/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:358: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if token is '':
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:2437: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if options['min_type'] is 'min' and options['min_value'] == 0:
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:2440: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if options['max_type'] is 'max' and options['max_value'] == 0:
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:4999: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if props[i]['type'] is 'number':
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:6827: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if data_bar['bar_axis_position'] is not 'none':
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:6862: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if data_bar['bar_direction'] is 'left':
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:6865: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if data_bar['bar_direction'] is 'right':
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:6875: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if data_bar['bar_axis_position'] is 'middle':
/usr/lib/python3/dist-packages/xlsxwriter/worksheet.py:6878: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if data_bar['bar_axis_position'] is 'none':
/usr/lib/python3/dist-packages/xlsxwriter/chart.py:2497: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if val is 'right':
/usr/lib/python3/dist-packages/xlsxwriter/chart.py:2500: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if val is 'left':
TheGroundZero commented 4 years ago

Glad it got fixed so quickly :)
Feel free to send a pull request with the fix, if you want.

Python 3.8+ added a SyntaxWarning (see https://adamj.eu/tech/2020/01/21/why-does-python-3-8-syntaxwarning-for-is-literal/).
Looks like the XLSXWriter package is throwing these warnings.
In some cases the use of is where a == is more appropriate this might cause an issue.
However, I don't expect this to be an issue here.