Probable bug: reports_trash does not exist

Part 1

I upgraded today to using OpenVAS 10 (gvmd 8.0.0), using postgresql, and I’m getting this error repeatedly in gvmd.log when I try to delete a report:

sql_exec_internal: PQexec failed: ERROR: relation “reports_trash” does not exist

When I look in the database, lo and behold, it truly isn’t there. Looking into the source code, I find:

  • There is no CREATE TABLE line for reports_trash
  • find_trash_report_with_permission is called at gvmd-8.0.0/src/manage_sql.c #26907, which (if I’m reading it correctly), eventually queries the reports_trash table, which doesn’t exist and so throws an error.

Part 2

So, being a tinkerer, I went ahead and created a reports_trash table defined the same as the reports table (including constraints, indexes, foreign keys, etc., but without adding references from other tables). Now, the first error disappears, but this one is in its place:

Report {name} - {timestamp} ({uuid}) could not be deleted by {user}

I’m pretty sure all the user permissions are correct, and that it’s not simply a privilege issue. I started trying to look through the source code for ideas as to what was causing this error, but I think I’m getting a little in over my head, without having any prior familiarity with the source.

One thing to note, in case it means anything to anyone, is that the kludged reports_trash table is always empty, and the original reports table truly does still contain the reports I’m trying to delete.

Does anyone have any insight into this issue, or debugging advice?

Thanks!

There shouldn’t be a reports_trash table, because there’s no trashcan for reports.

The find_trash_report_with_permission call shouldn’t be there, but I don’t see why
it is leading to an SQL error for you. I can delete my own reports and shared reports
just fine in GSA.

Are you deleting the report in GSA or with GMP? Is there anything unusual in your
situation, like is your task in the trashcan or is the task/report shared with you in
an unusual way?

No, it’s a pretty standard setup. I’m using the XML API directly to the listening socket.

The SQL error is a result of find_trash_report_with_permission calling find_resource_with_permission, which tries to do a query on reports_trash, which doesn’t exist. So you may be getting an error but not seeing it. Haven’t totally tracked down how it all works yet.

Still, that call obviously needs to be removed - not sure yet whether or not that will solve the whole problem though.

Actually the find_trash_report_with_permission is correct but there is an error in find_resource_with_permission for reports. Should be solved for gvmd 10 with

I reproduced by deleting a report of a trashcan task. Not very easy to do in GSA,
which is why nobody noticed.

Thanks for the report.

2 Likes