[Openvas-commits] r11927 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Nov 1 20:40:11 CET 2011
Author: mattm
Date: 2011-11-01 20:40:09 +0100 (Tue, 01 Nov 2011)
New Revision: 11927
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage_sql.c
Log:
* src/manage_sql.c (print_report_xml): In the prognostic case, calculate
the filtered total from the other totals, to include the level filtering.
Only skip the host if result_hosts_only is set. Move the host buffering
out of the result loop, and add a result_hosts_only check there too. Add
missing iterator cleanup.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2011-11-01 18:20:25 UTC (rev 11926)
+++ trunk/openvas-manager/ChangeLog 2011-11-01 19:40:09 UTC (rev 11927)
@@ -1,5 +1,13 @@
2011-11-01 Matthew Mundell <matthew.mundell at greenbone.net>
+ * src/manage_sql.c (print_report_xml): In the prognostic case, calculate
+ the filtered total from the other totals, to include the level filtering.
+ Only skip the host if result_hosts_only is set. Move the host buffering
+ out of the result loop, and add a result_hosts_only check there too. Add
+ missing iterator cleanup.
+
+2011-11-01 Matthew Mundell <matthew.mundell at greenbone.net>
+
* src/manage_sql.c (print_report_xml): Buffer the host only if it has
results on the current page.
Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c 2011-11-01 18:20:25 UTC (rev 11926)
+++ trunk/openvas-manager/src/manage_sql.c 2011-11-01 19:40:09 UTC (rev 11927)
@@ -16387,9 +16387,13 @@
&filtered, &f_holes,
&f_infos, &f_logs,
&f_warnings);
+ filtered = (strchr (levels, 'h') ? f_holes : 0)
+ + (strchr (levels, 'l') ? f_infos : 0)
+ + (strchr (levels, 'g') ? f_logs : 0)
+ + (strchr (levels, 'm') ? f_warnings : 0);
if (filtered)
filtered_result_count += filtered;
- else
+ else if (result_hosts_only)
/* Skip this host. */
report_host = 0;
}
@@ -16427,51 +16431,52 @@
if (max_results == 0)
continue;
- if (buffered == 0 && report_host && max_results)
- {
- /* Buffer IP and report_host. */
- buffer_host_t *buffer_host;
- buffer_host = (buffer_host_t*) g_malloc (sizeof (buffer_host_t));
- buffer_host->report_host = report_host;
- buffer_host->ip = g_strdup (ip);
- array_add (buffer, buffer_host);
- buffered = 1;
- }
+ buffered = 1;
- PRINT (out,
- "<result>"
- "<subnet/>"
- "<host>%s</host>"
- "<port>0</port>"
- "<nvt oid=\"0\">"
- "<name/>"
- "</nvt>"
- "<threat>%s</threat>"
- "<description>"
- "The host carries the product: %s\n"
- "It is vulnerable according to: %s.\n"
- "\n"
- "%s"
- "</description>"
- "<cve id='%s'>"
- "<cvss_base>%s</cvss_base>"
- "<cpe id='%s'/>"
- "</cve>"
- "</result>",
- ip,
- threat,
- prognosis_iterator_cpe (&prognosis),
- prognosis_iterator_cve (&prognosis),
- prognosis_iterator_description
- (&prognosis),
- prognosis_iterator_cve (&prognosis),
- prognosis_iterator_cvss (&prognosis),
- prognosis_iterator_cpe (&prognosis));
+ PRINT (out,
+ "<result>"
+ "<subnet/>"
+ "<host>%s</host>"
+ "<port>0</port>"
+ "<nvt oid=\"0\">"
+ "<name/>"
+ "</nvt>"
+ "<threat>%s</threat>"
+ "<description>"
+ "The host carries the product: %s\n"
+ "It is vulnerable according to: %s.\n"
+ "\n"
+ "%s"
+ "</description>"
+ "<cve id='%s'>"
+ "<cvss_base>%s</cvss_base>"
+ "<cpe id='%s'/>"
+ "</cve>"
+ "</result>",
+ ip,
+ threat,
+ prognosis_iterator_cpe (&prognosis),
+ prognosis_iterator_cve (&prognosis),
+ prognosis_iterator_description
+ (&prognosis),
+ prognosis_iterator_cve (&prognosis),
+ prognosis_iterator_cvss (&prognosis),
+ prognosis_iterator_cpe (&prognosis));
max_results--;
- }
+ }
+ if (buffered || (result_hosts_only == 0))
+ {
+ /* Buffer IP and report_host. */
+ buffer_host_t *buffer_host;
+ buffer_host = (buffer_host_t*) g_malloc (sizeof (buffer_host_t));
+ buffer_host->report_host = report_host;
+ buffer_host->ip = g_strdup (ip);
+ array_add (buffer, buffer_host);
+ }
cleanup_iterator (&prognosis);
}
+ cleanup_iterator (&report_hosts);
}
if (host)
@@ -16502,6 +16507,7 @@
"<filtered>%i</filtered>"
"</host_count>",
host_count (),
+ // FIX just count in buffer
filtered_host_count (host_levels, host_search_phrase));
PRINT (out,
"<hosts start=\"%i\" max=\"%i\"/>",
More information about the Openvas-commits
mailing list