greenbone / gvmd

Greenbone Vulnerability Manager - The database backend for the Greenbone Community Edition
GNU Affero General Public License v3.0
272 stars 154 forks source link

--delete-scanner doesn't check if a scanner is used #2240

Open guedou opened 6 days ago

guedou commented 6 days ago

The --delete-scanner doesn't check if a scanner is used before deleting it. This causes GSA and the API to break.

Expected behavior

An error message is displayed if the scanner is assigned to a task.

Actual behavior

The scanner is deleted and GSA and the API breaks. The only fix that I found is to correct the task entry in PostgreSQL.

Steps to reproduce

1 . create a new scanner

  1. create a track using this scanner
  2. list tasks with GSA or the API

GVM versions

gsa:

docker compose -p openvas exec gsa gsad --version
Greenbone Security Assistant 22.08.0

gvm:

docker compose -p openvas exec gvmd gvmd --version
Greenbone Vulnerability Manager 23.6.2
Manager DB revision 255
Copyright (C) 2009-2021 Greenbone AG
License: AGPL-3.0-or-later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Environment

Linux Debian with a Docker Compose deployment.

cfi-gb commented 6 days ago

Seems to be another variant of #2067 (there the user suggested to delete the associated task if the scanner is getting deleted).