I am trying to delete existing reports using the python-gvm library but I keep getting a “404 Failed to find report …” error while am sure the report exists!
Am I doing something wrong ? I can’t seem to wrap my head around this.
This is the code am running:
...
# Fetching reports using gmp.get_reports() -> OK
...
for report in reports:
if report.get("id"):
print(report.get("id"))
print(gmp.get_report(report.get("id")))
gmp.delete_report(report.get("id"))
...
This is the output:
<Element get_reports_response at 0x7f9521bd6240>
6714a663-184a-4509-8e00-ad4446a63792
2022-08-11 08:15:38 WARNING Lost the connection to GVM. So, kill the container.
Traceback (most recent call last):
File "mapper.py", line 289, in fetch_reports
gmp.delete_report(report.get("id"))
File "/usr/local/lib/python3.8/dist-packages/gvm/protocols/gmpv208/entities/reports.py", line 45, in delete_report
return self._send_xml_command(cmd)
File "/usr/local/lib/python3.8/dist-packages/gvm/protocols/base.py", line 86, in _send_xml_command
return self.send_command(xmlcmd.to_string())
File "/usr/local/lib/python3.8/dist-packages/gvm/protocols/base.py", line 142, in send_command
return self._transform(response)
File "/usr/local/lib/python3.8/dist-packages/gvm/protocols/base.py", line 78, in _transform
return transform(data)
File "/usr/local/lib/python3.8/dist-packages/gvm/transforms.py", line 79, in __call__
check_command_status(root)
File "/usr/local/lib/python3.8/dist-packages/gvm/transforms.py", line 49, in check_command_status
raise GvmResponseError(status=status, message=root.get("status_text"))
gvm.errors.GvmResponseError: Response Error 404. Failed to find report '6714a663-184a-4509-8e00-ad4446a63792'
I checked in the output of the gvmd.log file but couldn’t find any indication on what happened.
In the meantime, I decided to delete the whole task once it’s done which also removes the linked reports.
I don’t need to remove individual reports anymore.