From eb6a5fd12d69d3e4dc567e8ff85571edfbfa06ca Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 15 Nov 2019 09:37:59 +0100 Subject: [PATCH 1/2] Add option to set finished hosts in OSP targets The function osp_target_set_finished_hosts has been added to set the new field finished_host of OSP targets. The version number has been increased to 11.0.1 for this. --- CMakeLists.txt | 2 +- osp/osp.c | 26 ++++++++++++++++++++++---- osp/osp.h | 3 +++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fe814f28..f0edad046 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 3.0) message ("-- Configuring the Greenbone Vulnerability Management Libraries...") project (gvm-libs - VERSION 11.0.0 + VERSION 11.0.1 LANGUAGES C) if (POLICY CMP0005) diff --git a/osp/osp.c b/osp/osp.c index 7a2fec4d2..5f5685f11 100644 --- a/osp/osp.c +++ b/osp/osp.c @@ -83,10 +83,11 @@ struct osp_credential */ struct osp_target { - GSList *credentials; /** Credentials to use in the scan */ - gchar *exclude_hosts; /** String defining one or many hosts to exclude */ - gchar *hosts; /** String defining one or many hosts to scan */ - gchar *ports; /** String defining the ports to scan */ + GSList *credentials; /** Credentials to use in the scan */ + gchar *exclude_hosts; /** String defining one or many hosts to exclude */ + gchar *hosts; /** String defining one or many hosts to scan */ + gchar *ports; /** String defining the ports to scan */ + gchar *finished_hosts; /** String defining hosts to exclude as finished */ }; /** @@ -858,9 +859,11 @@ target_append_as_xml (osp_target_t *target, GString *xml_string) "" "%s" "%s" + "%s" "%s", target->hosts ? target->hosts : "", target->exclude_hosts ? target->exclude_hosts : "", + target->finished_hosts ? target->finished_hosts : "", target->ports ? target->ports : ""); if (target->credentials) @@ -1399,10 +1402,25 @@ osp_target_new (const char *hosts, new_target->exclude_hosts = exclude_hosts ? g_strdup (exclude_hosts) : NULL; new_target->hosts = hosts ? g_strdup (hosts) : NULL; new_target->ports = ports ? g_strdup (ports) : NULL; + new_target->finished_hosts = NULL; return new_target; } +/** + * @brief Set the finished hosts of an OSP target. + * + * @param[in] target The OSP target to modify. + * @param[in] finished_hosts The hostnames to consider finished. + */ +void +osp_target_set_finished_hosts (osp_target_t *target, + const char *finished_hosts) +{ + g_free (target->finished_hosts); + target->finished_hosts = finished_hosts ? g_strdup (finished_hosts) : NULL; +} + /** * @brief Free an OSP target, including all added credentials. * diff --git a/osp/osp.h b/osp/osp.h index 8ef4f1706..7a0c80ab0 100644 --- a/osp/osp.h +++ b/osp/osp.h @@ -201,6 +201,9 @@ osp_credential_set_auth_data (osp_credential_t *, const char*, const char*); osp_target_t * osp_target_new (const char *, const char *, const char *); +void +osp_target_set_finished_hosts (osp_target_t *, const char *); + void osp_target_free (osp_target_t *); From 9a7178482efb4717f8c8d5175050b9067f681fcd Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 15 Nov 2019 09:43:35 +0100 Subject: [PATCH 2/2] Add new finished_hosts to CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b87f678f1..2fede718a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [11.0.1] (unreleased) +### Added +- Add option to set finished hosts in OSP targets [#298](https://github.com/greenbone/gvm-libs/pull/298) + ### Fixed - Fix sigsegv when no plugin_feed_info.inc file present. [#278](https://github.com/greenbone/gvm-libs/pull/278)