Author: mattm Date: 2016-10-14 15:19:06 +0200 (Fri, 14 Oct 2016) New Revision: 26411
Modified: branches/openvas-manager-6.0/ChangeLog branches/openvas-manager-6.0/src/manage_config_discovery.c branches/openvas-manager-6.0/src/manage_sql.c Log: Backport r26409. * src/manage_sql.c (check_db_configs): Recover lost Service Detection NVTs. * src/manage_config_discovery.c (make_config_discovery_service_detection): New function. (make_config_discovery): Use new function. Modified: branches/openvas-manager-6.0/ChangeLog =================================================================== --- branches/openvas-manager-6.0/ChangeLog 2016-10-14 13:01:06 UTC (rev 26410) +++ branches/openvas-manager-6.0/ChangeLog 2016-10-14 13:19:06 UTC (rev 26411) @@ -1,5 +1,16 @@ 2016-10-14 Matthew Mundell <matthew.mund...@greenbone.net> + Backport r26409. + + * src/manage_sql.c (check_db_configs): Recover lost Service Detection + NVTs. + + * src/manage_config_discovery.c + (make_config_discovery_service_detection): New function. + (make_config_discovery): Use new function. + +2016-10-14 Matthew Mundell <matthew.mund...@greenbone.net> + Backport r26406. * src/manage_sql.c (check_db_configs): Only check for removed Service Modified: branches/openvas-manager-6.0/src/manage_config_discovery.c =================================================================== --- branches/openvas-manager-6.0/src/manage_config_discovery.c 2016-10-14 13:01:06 UTC (rev 26410) +++ branches/openvas-manager-6.0/src/manage_config_discovery.c 2016-10-14 13:19:06 UTC (rev 26411) @@ -45,21 +45,8 @@ * @param[in] selector_name Name of NVT selector to use. */ void -make_config_discovery (char *const uuid, char *const selector_name) +make_config_discovery_service_detection (char *const selector_name) { - sql_begin_exclusive (); - - /* First, create the Discovery config. */ - sql ("INSERT into configs (uuid, name, owner, nvt_selector, comment," - " family_count, nvt_count, nvts_growing, families_growing," - " type, creation_time, modification_time)" - " VALUES ('%s', 'Discovery', NULL," - " '%s', 'Network Discovery scan configuration.'," - " 0, 0, 0, 0, 0, m_now (), m_now ());", - uuid, - selector_name); - - /* Setup the appropriate NVTs for the config. */ NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11929", "Service detection"); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900534", "Service detection"); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902019", "Service detection"); @@ -576,6 +563,33 @@ NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900371", "Service detection"); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900374", "Service detection"); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900376", "Service detection"); +} + +/** + * @brief Make Discovery Scan Config. + * + * Caller must lock the db. + * + * @param[in] uuid UUID for new scan config. + * @param[in] selector_name Name of NVT selector to use. + */ +void +make_config_discovery (char *const uuid, char *const selector_name) +{ + sql_begin_exclusive (); + + /* First, create the Discovery config. */ + sql ("INSERT into configs (uuid, name, owner, nvt_selector, comment," + " family_count, nvt_count, nvts_growing, families_growing," + " type, creation_time, modification_time)" + " VALUES ('%s', 'Discovery', NULL," + " '%s', 'Network Discovery scan configuration.'," + " 0, 0, 0, 0, 0, m_now (), m_now ());", + uuid, + selector_name); + + /* Setup the appropriate NVTs for the config. */ + make_config_discovery_service_detection (selector_name); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17586", "Brute force attacks"); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17584", "Brute force attacks"); NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17368", "Brute force attacks"); Modified: branches/openvas-manager-6.0/src/manage_sql.c =================================================================== --- branches/openvas-manager-6.0/src/manage_sql.c 2016-10-14 13:01:06 UTC (rev 26410) +++ branches/openvas-manager-6.0/src/manage_sql.c 2016-10-14 13:19:06 UTC (rev 26411) @@ -135,6 +135,9 @@ make_config_discovery (char *const, const char * const); void +make_config_discovery_service_detection (char * const); + +void make_config_host_discovery (char *const, const char * const); void @@ -13054,6 +13057,16 @@ make_config_discovery (CONFIG_UUID_DISCOVERY, MANAGE_NVT_SELECTOR_UUID_DISCOVERY); + /* Service Detection NVTs were all being accidentally removed by the + * checks below. Recover them. */ + + if (sql_int ("SELECT count (*) FROM nvt_selectors" + " WHERE name = '" MANAGE_NVT_SELECTOR_UUID_DISCOVERY "'" + " AND family = 'Service detection'") + == 0) + make_config_discovery_service_detection + (MANAGE_NVT_SELECTOR_UUID_DISCOVERY); + /* In the Service Detection family, NVTs sometimes move to Product * Detection, and once an NVT was removed. So remove those NVTs * from Service Detection in the NVT selector. */ _______________________________________________ Openvas-commits mailing list Openvas-commits@wald.intevation.org https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits