[Openvas-commits] r6254 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Dec 25 15:31:17 CET 2009


Author: mattm
Date: 2009-12-25 15:31:15 +0100 (Fri, 25 Dec 2009)
New Revision: 6254

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.c
   trunk/openvas-manager/src/manage.h
   trunk/openvas-manager/src/tasks_sql.h
Log:
	* src/manage.c (event_description): New function.

	* src/manage.h: Add header.

	* src/tasks_sql.h (escalate): Flesh out email.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-12-24 19:16:41 UTC (rev 6253)
+++ trunk/openvas-manager/ChangeLog	2009-12-25 14:31:15 UTC (rev 6254)
@@ -1,5 +1,13 @@
 2009-12-24  Matthew Mundell <matthew.mundell at intevation.de>
 
+	* src/manage.c (event_description): New function.
+
+	* src/manage.h: Add header.
+
+	* src/tasks_sql.h (escalate): Flesh out email.
+
+2009-12-24  Matthew Mundell <matthew.mundell at intevation.de>
+
 	Add escalator support, including OMP commands CREATE_ESCALATOR,
 	DELETE_ESCALATOR and GET_ESCALATORS, and CREATE_TASK element ESCALATOR.
 

Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c	2009-12-24 19:16:41 UTC (rev 6253)
+++ trunk/openvas-manager/src/manage.c	2009-12-25 14:31:15 UTC (rev 6254)
@@ -278,6 +278,28 @@
 }
 
 /**
+ * @brief Get a description of an escalator event.
+ *
+ * @param[in]  event       Event.
+ * @param[in]  event_data  Event data.
+ *
+ * @return Freshly allocated description of event.
+ */
+gchar*
+event_description (event_t event, const void *event_data)
+{
+  switch (event)
+    {
+      case EVENT_TASK_RUN_STATUS_CHANGED:
+        return g_strdup_printf ("Task run status changed to '%s'",
+                                run_status_name ((task_status_t) event_data));
+        break;
+      default:
+        return g_strdup ("Internal Error");
+    }
+}
+
+/**
  * @brief Get the name of an escalator method.
  *
  * @param[in]  method  Method.

Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h	2009-12-24 19:16:41 UTC (rev 6253)
+++ trunk/openvas-manager/src/manage.h	2009-12-25 14:31:15 UTC (rev 6254)
@@ -263,6 +263,9 @@
 const char*
 event_name (event_t);
 
+gchar*
+event_description (event_t, const void *);
+
 const char*
 escalator_method_name (escalator_method_t);
 

Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h	2009-12-24 19:16:41 UTC (rev 6253)
+++ trunk/openvas-manager/src/tasks_sql.h	2009-12-25 14:31:15 UTC (rev 6254)
@@ -2339,12 +2339,49 @@
 
           if (address)
             {
-              gchar *subject;
-              subject = g_strdup_printf ("[OpenVAS-Manager] Task FIX subject");
-              ret = email (address, subject, "FIX body");
+              gchar *body, *subject;
+              char *name, *notice;
+
+              notice = escalator_data (escalator, "method", "notice");
+              name = task_name (task);
+              if (notice && strcmp (notice, "0") == 0)
+                {
+                  gchar *event_desc;
+
+                  /* Summary message. */
+                  event_desc = event_description (event, event_data);
+                  subject = g_strdup_printf ("[OpenVAS-Manager] Task '%s': %s",
+                                             name ? name : "Internal Error",
+                                             event_desc);
+                  body = g_strdup_printf ("Task: %s\n"
+                                          "Event: %s\n"
+                                          "Condition: %s\n"
+                                          "\n"
+                                          "The event occurred and matched the"
+                                          " task and condition.",
+                                          name ? name : "Internal Error",
+                                          event_desc,
+                                          escalator_condition_name (condition));
+                  g_free (event_desc);
+                }
+              else
+                {
+                  /* Notice message. */
+                  subject = g_strdup_printf ("[OpenVAS-Manager] Task '%s':"
+                                             " An event occurred",
+                                             name);
+                  body = g_strdup_printf ("Task: %s\n"
+                                          "\n"
+                                          "An event occurred on the task.",
+                                          name);
+                }
+              free (name);
+              free (notice);
+              ret = email (address, subject, body);
+              free (address);
               g_free (subject);
+              g_free (body);
             }
-          free (address);
           return ret;
           break;
         }



More information about the Openvas-commits mailing list