Couldn't find the report format when using get_report

Hello everyone!

I have a problem getting the report. I need to export a report, and I use the following options:

report = gmp.get_report(report_id=“my_report_id”, filter_string=“apply_overrides=1 min_qod=0 rows=-1 created>-1d sort=created”, report_format_id=‘f67e70f0-4571-4aeb-ac6a-4e0846995228’, ignore_pagination=True, details=True).

But when I start the program, I see this message in the output xml file:

<get_reports_response status="404" status_text="Failed to find report format 'f67e70f0-4571-4aeb-ac6a-4e0846995228'"/>

Here is the whole code:

from gvm.connections import UnixSocketConnection
from gvm.protocols.gmp import GMP
from gvm.transforms import EtreeTransform
from gvm.xml import pretty_print

connection = UnixSocketConnection(path=‘my_path’)
transform = EtreeTransform()

with GMP(connection, transform=transform) as gmp:
gmp.authenticate(‘admin’, ‘password’)
report = gmp.get_report(report_id=“my_rep_id”, filter_string=“apply_overrides=1 min_qod=0 rows=-1 created>-1d sort=created”, report_format_id='f67e70f0-4571-4aeb-ac6a-4e0846995228’, ignore_pagination=True, details=True)>
pretty_print(report)

Can you tell me what the problem might be?

And please can you tell me where I can get a file to add reports to my greenbone? in the documentation here: https://docs.greenbone.net/GSM-Manual/gos-24.10/en/reports.html#managing-report-formats In paragraph 10.1.3, the developers add a report file called CSV_Results_report_1.0.0.xml . Can I get it?

Thank you!

@kama_trick well. reason to fail is probably that this report id is not in system?

Link that you use is greenbone enterprise appliance, not the opensource version and there a bit differences between opensouce and commercial edition.

Eero

Hello Eero!

Thank you for your reply, it helped me. We were able to import the required report formats. Anonymous xml, xml, pdf, txt, and csv are now available to me. But another problem has arisen. This is my python script:

from gvm.connections import UnixSocketConnection
from gvm.protocols.gmp import GMP
from gvm.transforms import EtreeTransform
from gvm.xml import pretty_print

connection = UnixSocketConnection(path=‘my_path’)
transform = EtreeTransform()

with GMP(connection, transform=transform) as gmp:
gmp.authenticate(‘admin’, ‘admin’)

report = gmp.get_report(report_id=“my_rep_id”, filter_string=“apply_overrides=1 min_qod=0 rows=-1 created>-1d”, report_format_id=“c402cc3e-b531-11e1-9163-406186ea4fc5”, ignore_pagination=True, details=True)

pretty_print(report)

In the linux console, I run it this way: python3 script.py > test1.pdf. But after the script is running, the pdf file does not open. I can’t figure out why the script isn’t working.

#my main task is to programmatically export the report

Thanks a lot!

@kama_trick make sure that pdf export from gui works fine?

Eero

Please check out scripts gvm-tools/scripts at main · greenbone/gvm-tools · GitHub

you need at least base64decode the content

Eero

@kama_trick example: gvm-tools/scripts/export-pdf-report.gmp.py at main · greenbone/gvm-tools · GitHub

Eero

Thank you so much Eero! It works right now

This topic was automatically closed after 90 days. New replies are no longer allowed.