From eb9622cf1968a042d44529459c5292c0f430f288 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 27 Sep 2019 14:50:54 +0200 Subject: [PATCH 1/3] Allow "0" or empty credential_id in create_scanner Previously the command only accepted the attribute missing completely to set no credential. --- src/manage_sql.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 57a62340e..b4bc666f4 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -42639,7 +42639,11 @@ create_scanner (const char* name, const char *comment, const char *host, return 1; } - if (!unix_socket && itype == SCANNER_TYPE_GMP && credential_id == NULL) + if (!unix_socket + && itype == SCANNER_TYPE_GMP + && (credential_id == NULL + || strcmp (credential_id, "") == 0 + || strcmp (credential_id, "0") == 0)) { sql_rollback (); return 6; @@ -42649,7 +42653,9 @@ create_scanner (const char* name, const char *comment, const char *host, else { credential = 0; - if (credential_id) + if (credential_id + && strcmp (credential_id, "") + && strcmp (credential_id, "0")) { if (find_credential_with_permission (credential_id, &credential, "get_credentials")) From 1b8f7193fd49a2fd407b505e9493d8c664a57392 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 27 Sep 2019 14:54:13 +0200 Subject: [PATCH 2/3] Add CHANGELOG for credential_id in create_scanner --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 492f72206..fe0959514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Command cleanup-report-formats for --optimize option [#652](https://github.com/greenbone/gvmd/pull/652) - Document container tasks in GMP doc [#688](https://github.com/greenbone/gvmd/pull/688) - Add lean option to GET_REPORTS [#745](https://github.com/greenbone/gvmd/pull/745) -- Add scanner relays and OSP sensor scanner type [#756](https://github.com/greenbone/gvmd/pull/756) +- Add scanner relays and OSP sensor scanner type [#756](https://github.com/greenbone/gvmd/pull/756) [#759](https://github.com/greenbone/gvmd/pull/759) ### Changed - Check if NVT preferences exist before inserting. [#406](https://github.com/greenbone/gvmd/pull/406) From 416e5935960f51ec29894e1a311d55585ab76604 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 27 Sep 2019 15:41:57 +0200 Subject: [PATCH 3/3] Add SCANNER_TYPE_OSP_SENSOR to task config checks The functions create_task_check_config_scanner and modify_task_check_config_scannerfunction were missing cases for the new scanner type. --- src/manage_sql_configs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/manage_sql_configs.c b/src/manage_sql_configs.c index 6c6a65cf8..d667fb758 100644 --- a/src/manage_sql_configs.c +++ b/src/manage_sql_configs.c @@ -2538,6 +2538,8 @@ create_task_check_config_scanner (config_t config, scanner_t scanner) return 1; if (ctype == 0 && stype == SCANNER_TYPE_GMP) return 1; + if (ctype == 0 && stype == SCANNER_TYPE_OSP_SENSOR) + return 1; if (ctype == 1 && stype == SCANNER_TYPE_OSP) return 1; @@ -2615,6 +2617,10 @@ modify_task_check_config_scanner (task_t task, const char *config_id, if (stype == SCANNER_TYPE_GMP && ctype == 0) return 0; + /* OSP Sensor with OpenVAS config. */ + if (stype == SCANNER_TYPE_OSP_SENSOR && ctype == 0) + return 0; + /* Default Scanner with OpenVAS Config. */ if (scanner == 0 && ctype == 0) return 0;