[Openvas-commits] r5802 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Nov 5 16:14:53 CET 2009
Author: mattm
Date: 2009-11-05 16:14:52 +0100 (Thu, 05 Nov 2009)
New Revision: 5802
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/omp.c
trunk/openvas-manager/src/tasks_sql.h
Log:
* src/omp.c (init_result_iterator): Include all levels if levels is NULL.
Add level 'd' for type "Debug Message". Simplify the SQL if all levels are
requested.
* src/tasks_sql.h (omp_xml_handle_end_element): Ensure globals used for
sort_field and levels attributes are cleared after commands. In
CLIENT_GET_REPORT correct attribute name in error response, set levels
to all levels if the attribute is NULL, add a 'd' entry in FILTERS and
add a NULL check on current_name.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2009-11-05 12:28:03 UTC (rev 5801)
+++ trunk/openvas-manager/ChangeLog 2009-11-05 15:14:52 UTC (rev 5802)
@@ -1,5 +1,17 @@
2009-11-05 Matthew Mundell <matthew.mundell at intevation.de>
+ * src/omp.c (init_result_iterator): Include all levels if levels is NULL.
+ Add level 'd' for type "Debug Message". Simplify the SQL if all levels are
+ requested.
+
+ * src/tasks_sql.h (omp_xml_handle_end_element): Ensure globals used for
+ sort_field and levels attributes are cleared after commands. In
+ CLIENT_GET_REPORT correct attribute name in error response, set levels
+ to all levels if the attribute is NULL, add a 'd' entry in FILTERS and
+ add a NULL check on current_name.
+
+2009-11-05 Matthew Mundell <matthew.mundell at intevation.de>
+
* src/omp.c (latex_severity_colour): Replace openvas_text with
openvas_report.
(latex_header): Remove openvas_text. Match threat colours to GSA.
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2009-11-05 12:28:03 UTC (rev 5801)
+++ trunk/openvas-manager/src/omp.c 2009-11-05 15:14:52 UTC (rev 5802)
@@ -3023,6 +3023,7 @@
SEND_TO_CLIENT_OR_FAIL (XML_SERVICE_DOWN ("get_nvt_details"));
}
openvas_free_string_var (¤t_uuid);
+ openvas_free_string_var (&modify_task_value);
set_client_state (CLIENT_AUTHENTIC);
break;
@@ -3083,10 +3084,10 @@
break;
}
- if (current_uuid == NULL)
+ if (current_uuid == NULL) /* Attribute report_id. */
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("get_report",
- "GET_REPORT must have a current_uuid attribute"));
+ "GET_REPORT must have a report_id attribute"));
else
{
report_t report;
@@ -3115,7 +3116,7 @@
const char *levels;
/* Attribute levels. */
- levels = modify_task_value ? modify_task_value : "hm";
+ levels = modify_task_value ? modify_task_value : "hmlgd";
if (report_task (report, &task))
{
@@ -3158,6 +3159,8 @@
SEND_TO_CLIENT_OR_FAIL ("<filter>Low</filter>");
if (strchr (levels, 'g'))
SEND_TO_CLIENT_OR_FAIL ("<filter>Log</filter>");
+ if (strchr (levels, 'd'))
+ SEND_TO_CLIENT_OR_FAIL ("<filter>Debug</filter>");
SENDF_TO_CLIENT_OR_FAIL
("</filters>"
@@ -3245,8 +3248,9 @@
/* Ensure the buffered results are sorted. */
- if (strcmp (current_name, /* Attribute sort_field. */
- "port"))
+ if (current_name
+ && strcmp (current_name, /* Attribute sort_field. */
+ "port"))
{
/* Sort by threat. */
if (current_int_3) /* Attribute sort_order. */
@@ -3888,6 +3892,8 @@
}
openvas_free_string_var (¤t_uuid);
openvas_free_string_var (¤t_format);
+ openvas_free_string_var (&modify_task_value);
+ openvas_free_string_var (¤t_name);
set_client_state (CLIENT_AUTHENTIC);
break;
@@ -5475,6 +5481,7 @@
cleanup_task_iterator (&iterator);
SEND_TO_CLIENT_OR_FAIL ("</get_status_response>");
}
+ openvas_free_string_var (¤t_format);
set_client_state (CLIENT_AUTHENTIC);
break;
@@ -5654,6 +5661,7 @@
SENDF_TO_CLIENT_OR_FAIL ("</config>");
}
openvas_free_string_var (¤t_name);
+ openvas_free_string_var (¤t_format);
cleanup_iterator (&configs);
SEND_TO_CLIENT_OR_FAIL ("</get_configs_response>");
set_client_state (CLIENT_AUTHENTIC);
@@ -5765,6 +5773,7 @@
cleanup_iterator (&targets);
SEND_TO_CLIENT_OR_FAIL ("</get_lsc_credentials_response>");
}
+ openvas_free_string_var (¤t_name);
set_client_state (CLIENT_AUTHENTIC);
break;
}
@@ -5797,6 +5806,7 @@
(target_iterator_name (&targets)));
cleanup_iterator (&targets);
SEND_TO_CLIENT_OR_FAIL ("</get_targets_response>");
+ openvas_free_string_var (¤t_format);
set_client_state (CLIENT_AUTHENTIC);
break;
}
Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h 2009-11-05 12:28:03 UTC (rev 5801)
+++ trunk/openvas-manager/src/tasks_sql.h 2009-11-05 15:14:52 UTC (rev 5802)
@@ -2996,8 +2996,9 @@
* @param[in] ascending Whether to sort ascending or descending.
* @param[in] sort_field Field to sort on, or NULL for "type".
* @param[in] levels String describing threat levels (message types)
- * to include in report (for example, "hmlg" for
- * High, Medium, Low and loG).
+ * to include in report (for example, "hmlgd" for
+ * High, Medium, Low, loG and Debug). All levels if
+ * NULL.
*/
void
init_result_iterator (iterator_t* iterator, report_t report, const char* host,
@@ -3006,7 +3007,7 @@
{
gchar* sql;
if (sort_field == NULL) sort_field = "type";
- if (levels == NULL) levels = "hm";
+ if (levels == NULL) levels = "hmlgd";
if (report)
{
GString *levels_sql = NULL;
@@ -3015,52 +3016,67 @@
if (strlen (levels))
{
- int first = 1;
+ int count = 0;
/* High. */
if (strchr (levels, 'h'))
{
- first = 0;
+ count = 1;
levels_sql = g_string_new (" AND (type = 'Security Hole'");
}
/* Medium. */
if (strchr (levels, 'm'))
{
- if (first)
- {
- levels_sql = g_string_new (" AND (type = 'Security Warning'");
- first = 0;
- }
+ if (count == 0)
+ levels_sql = g_string_new (" AND (type = 'Security Warning'");
else
levels_sql = g_string_append (levels_sql,
" OR type = 'Security Warning'");
+ count++;
}
/* Low. */
if (strchr (levels, 'l'))
{
- if (first)
- {
- levels_sql = g_string_new (" AND (type = 'Security Note'");
- first = 0;
- }
+ if (count == 0)
+ levels_sql = g_string_new (" AND (type = 'Security Note'");
else
levels_sql = g_string_append (levels_sql,
" OR type = 'Security Note'");
+ count++;
}
/* loG. */
if (strchr (levels, 'g'))
{
- if (first)
- levels_sql = g_string_new (" AND (type = 'Log Message')");
+ if (count == 0)
+ levels_sql = g_string_new (" AND (type = 'Log Message'");
else
levels_sql = g_string_append (levels_sql,
- " OR type = 'Log Message')");
+ " OR type = 'Log Message'");
+ count++;
}
- else if (first == 0)
+
+ /* Debug. */
+ if (strchr (levels, 'd'))
+ {
+ if (count == 0)
+ levels_sql = g_string_new (" AND (type = 'Debug Message')");
+ else
+ levels_sql = g_string_append (levels_sql,
+ " OR type = 'Debug Message')");
+ count++;
+ }
+ else if (count)
levels_sql = g_string_append (levels_sql, ")");
+
+ if (count == 5)
+ {
+ /* All levels. */
+ g_string_free (levels_sql, TRUE);
+ levels_sql = NULL;
+ }
}
/* Allocate the query. */
More information about the Openvas-commits
mailing list