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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 16 22:50:08 CET 2009


Author: mattm
Date: 2009-12-16 22:50:05 +0100 (Wed, 16 Dec 2009)
New Revision: 6153

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.h
   trunk/openvas-manager/src/omp.c
   trunk/openvas-manager/src/tasks_sql.h
Log:
	Add message counts to GET_REPORT XML response.

	* src/tasks_sql.h (REPORT_COUNT): Take report arg instead of using
	report UUID variable.
	(report_counts_id): New function.
	(report_counts): Call through to report_counts_id.

	* src/manage.h: Add header.

	* src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_REPORT add message
	counts to XML format response.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-12-16 19:51:10 UTC (rev 6152)
+++ trunk/openvas-manager/ChangeLog	2009-12-16 21:50:05 UTC (rev 6153)
@@ -1,5 +1,19 @@
 2009-12-16  Matthew Mundell <matthew.mundell at intevation.de>
 
+	Add message counts to GET_REPORT XML response.
+
+	* src/tasks_sql.h (REPORT_COUNT): Take report arg instead of using
+	report UUID variable.
+	(report_counts_id): New function.
+	(report_counts): Call through to report_counts_id.
+
+	* src/manage.h: Add header.
+
+	* src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_REPORT add message
+	counts to XML format response.
+
+2009-12-16  Matthew Mundell <matthew.mundell at intevation.de>
+
 	Add filtered count to OMP GET_REPORT XML report.
 
 	* src/tasks_sql.h (where_levels): New function.

Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h	2009-12-16 19:51:10 UTC (rev 6152)
+++ trunk/openvas-manager/src/manage.h	2009-12-16 21:50:05 UTC (rev 6153)
@@ -446,6 +446,9 @@
 int
 report_counts (const char*, int*, int*, int*, int*, int*);
 
+int
+report_counts_id (report_t, int*, int*, int*, int*, int*);
+
 char*
 scan_start_time (report_t);
 

Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c	2009-12-16 19:51:10 UTC (rev 6152)
+++ trunk/openvas-manager/src/omp.c	2009-12-16 21:50:05 UTC (rev 6153)
@@ -3844,6 +3844,28 @@
                   cleanup_iterator (&results);
                 }
 
+                /* Threat counts. */
+
+                {
+                  int debugs, holes, infos, logs, warnings;
+
+                  report_counts_id (report, &debugs, &holes, &infos, &logs,
+                                    &warnings);
+
+                  SENDF_TO_CLIENT_OR_FAIL ("<messages>"
+                                           "<debug>%i</debug>"
+                                           "<hole>%i</hole>"
+                                           "<info>%i</info>"
+                                           "<log>%i</log>"
+                                           "<warning>%i</warning>"
+                                           "</messages>",
+                                           debugs,
+                                           holes,
+                                           infos,
+                                           logs,
+                                           warnings);
+                }
+
                 /* Results. */
 
                 init_result_iterator (&results, report, NULL,

Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h	2009-12-16 19:51:10 UTC (rev 6152)
+++ trunk/openvas-manager/src/tasks_sql.h	2009-12-16 21:50:05 UTC (rev 6153)
@@ -3939,17 +3939,16 @@
   return 0;
 }
 
-#define REPORT_COUNT(var, name) \
+#define REPORT_COUNT(report, var, name) \
   *var = sql_int (0, 0, \
                   "SELECT count(*) FROM results, report_results" \
                   " WHERE results.type = '" name "'" \
                   " AND results.ROWID = report_results.result" \
-                  " AND report_results.report" \
-                  " = (SELECT ROWID FROM reports WHERE uuid = '%s');", \
-                  report_id)
+                  " AND report_results.report = '%llu';", \
+                  report)
 
 /**
- * @brief Get the message counts for a report.
+ * @brief Get the message counts for a report given the UUID.
  *
  * @param[in]   report_id    ID of report.
  * @param[out]  debugs       Number of debug messages.
@@ -3964,11 +3963,32 @@
 report_counts (const char* report_id, int* debugs, int* holes, int* infos,
                int* logs, int* warnings)
 {
-  REPORT_COUNT (debugs,   "Debug Message");
-  REPORT_COUNT (holes,    "Security Hole");
-  REPORT_COUNT (infos,    "Security Note");
-  REPORT_COUNT (logs,     "Log Message");
-  REPORT_COUNT (warnings, "Security Warning");
+  report_t report;
+  if (find_report (report_id, &report)) return -1;
+  return report_counts_id (report, debugs, holes, infos, logs, warnings);
+}
+
+/**
+ * @brief Get the message counts for a report.
+ *
+ * @param[in]   report    Report.
+ * @param[out]  debugs    Number of debug messages.
+ * @param[out]  holes     Number of hole messages.
+ * @param[out]  infos     Number of info messages.
+ * @param[out]  logs      Number of log messages.
+ * @param[out]  warnings  Number of warning messages.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int
+report_counts_id (report_t report, int* debugs, int* holes, int* infos,
+                  int* logs, int* warnings)
+{
+  REPORT_COUNT (report, debugs,   "Debug Message");
+  REPORT_COUNT (report, holes,    "Security Hole");
+  REPORT_COUNT (report, infos,    "Security Note");
+  REPORT_COUNT (report, logs,     "Log Message");
+  REPORT_COUNT (report, warnings, "Security Warning");
   return 0;
 }
 



More information about the Openvas-commits mailing list