Author: mattm
Date: 2016-10-17 15:57:14 +0200 (Mon, 17 Oct 2016)
New Revision: 26417

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage_config_discovery.c
   trunk/openvas-manager/src/manage_config_system_discovery.c
   trunk/openvas-manager/src/manage_sql.c
Log:
        Ensure Discovery has "Report about unrechable Hosts" "no" and System
        Discovery includes "Traceroute".

        * src/manage_sql.c (check_db_configs): Call Discovery and System
        Discovery checkers.

        * src/manage_config_discovery.c (make_config_discovery): Default "Report
        about unrechable Hosts" to "No".
        (check_config_discovery): New function.

        * src/manage_config_system_discovery.c
        (make_config_system_discovery): Add NVT "Traceroute".
        (check_config_system_discovery): New function.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog     2016-10-17 13:21:27 UTC (rev 26416)
+++ trunk/openvas-manager/ChangeLog     2016-10-17 13:57:14 UTC (rev 26417)
@@ -1,3 +1,19 @@
+2016-10-17  Matthew Mundell <matthew.mund...@greenbone.net>
+
+       Ensure Discovery has "Report about unrechable Hosts" "no" and System
+       Discovery includes "Traceroute".
+
+       * src/manage_sql.c (check_db_configs): Call Discovery and System
+       Discovery checkers.
+
+       * src/manage_config_discovery.c (make_config_discovery): Default "Report
+       about unrechable Hosts" to "No".
+       (check_config_discovery): New function.
+
+       * src/manage_config_system_discovery.c
+       (make_config_system_discovery): Add NVT "Traceroute".
+       (check_config_system_discovery): New function.
+
 2016-10-14  Matthew Mundell <matthew.mund...@greenbone.net>
 
        * src/manage_sql.c (check_db_configs): Recover lost Service Detection

Modified: trunk/openvas-manager/src/manage_config_discovery.c
===================================================================
--- trunk/openvas-manager/src/manage_config_discovery.c 2016-10-17 13:21:27 UTC 
(rev 26416)
+++ trunk/openvas-manager/src/manage_config_discovery.c 2016-10-17 13:57:14 UTC 
(rev 26417)
@@ -949,7 +949,7 @@
        " VALUES ((SELECT id FROM configs WHERE uuid = '%s'),"
        "         'PLUGINS_PREFS',"
        "         'Ping Host[checkbox]:Report about unrechable Hosts',"
-       "         'yes');",
+       "         'no');",
        uuid);
 
   /* Add preferences for "Services" nvt in Discovery Scan Config. */
@@ -960,3 +960,25 @@
        "         'All;Known SSL ports;None');",
        uuid);
 }
+
+/**
+ * @brief Ensure the Discovery config is up to date.
+ *
+ * @param[in]  uuid  UUID of config.
+ *
+ * @return 0 success, -1 error.
+ */
+int
+check_config_discovery (const char *uuid)
+{
+  /* Check new preference. */
+
+  sql ("UPDATE config_preferences SET value = 'no'"
+       " WHERE config = (SELECT id FROM configs WHERE uuid = '%s')"
+       " AND type = 'PLUGINS_PREFS'"
+       " AND name = 'Ping Host[checkbox]:Report about unrechable Hosts'"
+       " AND value = 'yes';",
+       uuid);
+
+  return 0;
+}

Modified: trunk/openvas-manager/src/manage_config_system_discovery.c
===================================================================
--- trunk/openvas-manager/src/manage_config_system_discovery.c  2016-10-17 
13:21:27 UTC (rev 26416)
+++ trunk/openvas-manager/src/manage_config_system_discovery.c  2016-10-17 
13:57:14 UTC (rev 26417)
@@ -77,6 +77,10 @@
        selector_name);
   sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
        " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
+       "         '1.3.6.1.4.1.25623.1.0.51662', 'General');",
+       selector_name);
+  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
+       " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
        "         '1.3.6.1.4.1.25623.1.0.96207', 'Windows');",
        selector_name);
   sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
@@ -186,3 +190,38 @@
        nvt_selector_nvt_count (selector_name, NULL, 0),
        config);
 }
+
+/**
+ * @brief Ensure the Discovery config is up to date.
+ *
+ * @param[in]  uuid  UUID of config.
+ *
+ * @return 0 success, -1 error.
+ */
+int
+check_config_system_discovery (const char *uuid)
+{
+  int update;
+
+  /* Check new NVT. */
+
+  if (sql_int ("SELECT count (*) FROM nvt_selectors"
+               " WHERE name = (SELECT nvt_selector FROM configs"
+               "               WHERE uuid = '%s')"
+               "       AND family_or_nvt = '1.3.6.1.4.1.25623.1.0.51662';",
+               uuid)
+      == 0)
+    {
+      sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, 
family)"
+           " VALUES ((SELECT nvt_selector FROM configs WHERE uuid = '%s'), 0,"
+           "         " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
+           "         '1.3.6.1.4.1.25623.1.0.51662', 'General');",
+           uuid);
+      update = 1;
+    }
+
+  if (update)
+    update_config_cache_init (uuid);
+
+  return 0;
+}

Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c      2016-10-17 13:21:27 UTC (rev 
26416)
+++ trunk/openvas-manager/src/manage_sql.c      2016-10-17 13:57:14 UTC (rev 
26417)
@@ -174,9 +174,15 @@
 void
 make_config_system_discovery (char *const, const char * const);
 
+int
+check_config_discovery (const char *);
+
 void
 check_config_host_discovery (const char *);
 
+int
+check_config_system_discovery (const char *);
+
 
 /* Static headers. */
 
@@ -14778,6 +14784,8 @@
          " AND NOT EXISTS (SELECT * FROM nvts"
          "                 WHERE oid = nvt_selectors.family_or_nvt);");
 
+  check_config_discovery (CONFIG_UUID_DISCOVERY);
+
   if (sql_int ("SELECT count(*) FROM configs"
                " WHERE uuid = '%s';",
                CONFIG_UUID_HOST_DISCOVERY)
@@ -14793,6 +14801,8 @@
       == 0)
     make_config_system_discovery (CONFIG_UUID_SYSTEM_DISCOVERY,
                                   MANAGE_NVT_SELECTOR_UUID_SYSTEM_DISCOVERY);
+
+  check_config_system_discovery (CONFIG_UUID_SYSTEM_DISCOVERY);
 }
 
 /**

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to