[Openvas-commits] r11378 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Aug 1 18:51:42 CEST 2011
Author: mattm
Date: 2011-08-01 18:51:39 +0200 (Mon, 01 Aug 2011)
New Revision: 11378
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.c
trunk/openvas-manager/src/manage.h
trunk/openvas-manager/src/manage_sql.c
trunk/openvas-manager/src/omp.c
Log:
Add a basic host inventory, as a new type of GET_REPORT report.
* src/manage_sql.c (report_host_t): Remove. To manage.h.
(init_host_iterator): Add report_host arg, to iterate over single
report_host. Update callers.
(host_iterator_report, host_iterator_report_uuid, init_inventory_iterator)
(inventory_iterator_ip, host_last_report_host, host_report_count): New
functions.
(print_report_xml): Add type arg for type of report. Include entire host
inventory when type is inventory, using existing OMP entities.
(manage_report, manage_send_report): Add type arg.
* src/manage.h: Update headers accordingly.
(report_host_t): New type. From manage_sql.c.
* src/manage.c (send_user_rules): Update init_host_iterator callers.
* src/omp.c (get_reports_data_t, get_reports_data_reset): Add type.
(omp_xml_handle_start_element, omp_xml_handle_end_element): Add type to
GET_REPORT. Add case for "inventory" type.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2011-08-01 12:44:47 UTC (rev 11377)
+++ trunk/openvas-manager/ChangeLog 2011-08-01 16:51:39 UTC (rev 11378)
@@ -1,3 +1,26 @@
+2011-08-01 Matthew Mundell <matthew.mundell at greenbone.net>
+
+ Add a basic host inventory, as a new type of GET_REPORT report.
+
+ * src/manage_sql.c (report_host_t): Remove. To manage.h.
+ (init_host_iterator): Add report_host arg, to iterate over single
+ report_host. Update callers.
+ (host_iterator_report, host_iterator_report_uuid, init_inventory_iterator)
+ (inventory_iterator_ip, host_last_report_host, host_report_count): New
+ functions.
+ (print_report_xml): Add type arg for type of report. Include entire host
+ inventory when type is inventory, using existing OMP entities.
+ (manage_report, manage_send_report): Add type arg.
+
+ * src/manage.h: Update headers accordingly.
+ (report_host_t): New type. From manage_sql.c.
+
+ * src/manage.c (send_user_rules): Update init_host_iterator callers.
+
+ * src/omp.c (get_reports_data_t, get_reports_data_reset): Add type.
+ (omp_xml_handle_start_element, omp_xml_handle_end_element): Add type to
+ GET_REPORT. Add case for "inventory" type.
+
2011-07-21 Michael Wiegand <michael.wiegand at greenbone.net>
Post release version bump.
Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c 2011-08-01 12:44:47 UTC (rev 11377)
+++ trunk/openvas-manager/src/manage.c 2011-08-01 16:51:39 UTC (rev 11378)
@@ -845,7 +845,7 @@
/* Empty rules file. Send rules to deny all finished hosts. */
- init_host_iterator (&hosts, stopped_report, NULL);
+ init_host_iterator (&hosts, stopped_report, NULL, 0);
while (next (&hosts))
if (host_iterator_end_time (&hosts)
&& strlen (host_iterator_end_time (&hosts))
@@ -886,7 +886,7 @@
if (strncmp (*rule, "default accept", strlen ("default accept")) == 0)
{
- init_host_iterator (&hosts, stopped_report, NULL);
+ init_host_iterator (&hosts, stopped_report, NULL, 0);
while (next (&hosts))
if (host_iterator_end_time (&hosts)
&& strlen (host_iterator_end_time (&hosts))
@@ -903,7 +903,7 @@
{
/* Prevent allow rules for finished hosts. */
- init_host_iterator (&hosts, stopped_report, NULL);
+ init_host_iterator (&hosts, stopped_report, NULL, 0);
while (next (&hosts))
if (host_iterator_end_time (&hosts)
&& strlen (host_iterator_end_time (&hosts)))
Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h 2011-08-01 12:44:47 UTC (rev 11377)
+++ trunk/openvas-manager/src/manage.h 2011-08-01 16:51:39 UTC (rev 11378)
@@ -164,6 +164,7 @@
typedef long long int task_t;
typedef long long int result_t;
typedef long long int report_t;
+typedef long long int report_host_t;
typedef long long int report_format_t;
typedef long long int report_format_param_t;
typedef long long int note_t;
@@ -770,7 +771,7 @@
result_iterator_descr (iterator_t*);
void
-init_host_iterator (iterator_t*, report_t, const char *);
+init_host_iterator (iterator_t*, report_t, const char *, report_host_t);
const char*
host_iterator_host (iterator_t*);
@@ -802,14 +803,14 @@
gchar *
manage_report (report_t, report_format_t, int, const char*, int, const char *,
const char *, int, const char *, int, int, int, int, int, int,
- gsize *, gchar **, gchar **);
+ const char *, gsize *, gchar **, gchar **);
int
manage_send_report (report_t, report_t, report_format_t, int, const char*, int,
const char *, const char *, const char *, int,
const char *, int, int, int, int, int, int, int,
gboolean (*) (const char *, int (*) (void*), void*),
- int (*) (void*), void *, const char *);
+ int (*) (void*), void *, const char *, const char *);
/* RC's. */
Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c 2011-08-01 12:44:47 UTC (rev 11377)
+++ trunk/openvas-manager/src/manage_sql.c 2011-08-01 16:51:39 UTC (rev 11378)
@@ -71,11 +71,6 @@
typedef long long int resource_t;
/**
- * @brief A report host.
- */
-typedef long long int report_host_t;
-
-/**
* @brief Database ROWID of 'Full and fast' config.
*/
#define CONFIG_ID_FULL_AND_FAST 1
@@ -6549,6 +6544,7 @@
notes_details, overrides,
overrides_details,
first_result, max_results,
+ NULL, /* Type. */
&content_length,
NULL, /* Extension. */
NULL); /* Content type. */
@@ -6653,6 +6649,7 @@
notes_details, overrides,
overrides_details,
first_result, max_results,
+ NULL, /* Type. */
&content_length,
&extension,
&type);
@@ -6821,6 +6818,7 @@
notes_details, overrides,
overrides_details,
first_result, max_results,
+ NULL, /* Type. */
&content_length,
NULL, /* Extension. */
NULL); /* Content type. */
@@ -10977,27 +10975,68 @@
*
* @param[in] iterator Iterator.
* @param[in] report Report whose hosts the iterator loops over.
- * All hosts if NULL.
* @param[in] host Single host to iterate over. All hosts if NULL.
+ * @param[in] report_host Single report host to iterate over. All if 0.
*/
void
-init_host_iterator (iterator_t* iterator, report_t report, const char *host)
+init_host_iterator (iterator_t* iterator, report_t report, const char *host,
+ report_host_t report_host)
{
- gchar* sql;
-
- assert (report);
-
- sql = g_strdup_printf ("SELECT ROWID, host, start_time, end_time,"
- " attack_state, current_port, max_port"
- " FROM report_hosts WHERE report = %llu"
- "%s%s%s"
- " ORDER BY host COLLATE collate_ip;",
- report,
- host ? " AND host = '" : "",
- host ? host : "",
- host ? "'" : "");
- init_iterator (iterator, sql);
- g_free (sql);
+ if (report)
+ {
+ if (report_host)
+ init_iterator (iterator,
+ "SELECT ROWID, host, start_time, end_time,"
+ " attack_state, current_port, max_port, report,"
+ " (SELECT uuid FROM reports WHERE ROWID = report)"
+ " FROM report_hosts WHERE ROWID = %llu"
+ " AND report = %llu"
+ "%s%s%s"
+ " ORDER BY host COLLATE collate_ip;",
+ report_host,
+ report,
+ host ? " AND host = '" : "",
+ host ? host : "",
+ host ? "'" : "");
+ else
+ init_iterator (iterator,
+ "SELECT ROWID, host, start_time, end_time,"
+ " attack_state, current_port, max_port, report,"
+ " (SELECT uuid FROM reports WHERE ROWID = report)"
+ " FROM report_hosts WHERE report = %llu"
+ "%s%s%s"
+ " ORDER BY host COLLATE collate_ip;",
+ report,
+ host ? " AND host = '" : "",
+ host ? host : "",
+ host ? "'" : "");
+ }
+ else
+ {
+ if (report_host)
+ init_iterator (iterator,
+ "SELECT ROWID, host, start_time, end_time,"
+ " attack_state, current_port, max_port, report,"
+ " (SELECT uuid FROM reports WHERE ROWID = report)"
+ " FROM report_hosts WHERE ROWID = %llu"
+ "%s%s%s"
+ " ORDER BY host COLLATE collate_ip;",
+ report_host,
+ host ? " AND host = '" : "",
+ host ? host : "",
+ host ? "'" : "");
+ else
+ init_iterator (iterator,
+ "SELECT ROWID, host, start_time, end_time,"
+ " attack_state, current_port, max_port, report,"
+ " (SELECT uuid FROM reports WHERE ROWID = report)"
+ " FROM report_hosts"
+ "%s%s%s"
+ " ORDER BY host COLLATE collate_ip;",
+ host ? " WHERE host = '" : "",
+ host ? host : "",
+ host ? "'" : "");
+ }
}
#define DEF_ACCESS(name, col) \
@@ -11097,6 +11136,30 @@
}
/**
+ * @brief Get the report from a host iterator.
+ *
+ * @param[in] iterator Iterator.
+ *
+ * @return The report of the host.
+ */
+static report_host_t
+host_iterator_report (iterator_t* iterator)
+{
+ if (iterator->done) return 0;
+ return (report_host_t) sqlite3_column_int64 (iterator->stmt, 7);
+}
+
+/**
+ * @brief Get the report UUID from a host iterator.
+ *
+ * @param[in] iterator Iterator.
+ *
+ * @return The UUID of the report of the host. Caller must use only before
+ * calling cleanup_iterator.
+ */
+DEF_ACCESS (host_iterator_report_uuid, 8);
+
+/**
* @brief Return whether a host has results on a report.
*
* @param[in] report Report.
@@ -11188,6 +11251,28 @@
DEF_ACCESS (report_host_details_iterator_source_desc, 5);
/**
+ * @brief Initialise a host inventory iterator.
+ *
+ * @param[in] iterator Iterator.
+ */
+static void
+init_inventory_iterator (iterator_t* iterator)
+{
+ init_iterator (iterator,
+ "SELECT DISTINCT host FROM report_hosts"
+ " ORDER BY host COLLATE collate_ip;");
+}
+
+/**
+ * @brief Get the IP from a inventory iterator.
+ *
+ * @param[in] iterator Iterator.
+ *
+ * @return Host IP.
+ */
+DEF_ACCESS (inventory_iterator_ip, 0);
+
+/**
* @brief Set the end time of a task.
*
* @param[in] task Task.
@@ -13879,6 +13964,58 @@
}
/**
+ * @brief Free delta host ports.
+ *
+ * @param[in] host Host.
+ * @param[in] report_host Report host.
+ */
+static gboolean
+host_last_report_host (const char *host, report_host_t *report_host)
+{
+ gchar *quoted_host;
+ quoted_host = sql_quote (host);
+ switch (sql_int64 (report_host, 0, 0,
+ "SELECT ROWID FROM report_hosts WHERE host = '%s'"
+ " ORDER BY ROWID DESC LIMIT 1;",
+ host))
+ {
+ case 0:
+ break;
+ case 1: /* Too few rows in result of query. */
+ *report_host = 0;
+ break;
+ default: /* Programming error. */
+ assert (0);
+ case -1:
+ return TRUE;
+ break;
+ }
+
+ g_free (quoted_host);
+ return FALSE;
+}
+
+/**
+ * @brief Count host reports.
+ *
+ * @param[in] host Host.
+ *
+ * @return Report count.
+ */
+static int
+host_report_count (const char *host)
+{
+ int count;
+ gchar *quoted_host;
+ quoted_host = sql_quote (host);
+ count = sql_int (0, 0,
+ "SELECT count (*) FROM report_hosts WHERE host = '%s';",
+ quoted_host);
+ g_free (quoted_host);
+ return count;
+}
+
+/**
* @brief Print the XML for a report to a file.
*
* @param[in] report The report.
@@ -13908,6 +14045,7 @@
* @param[in] first_result The result to start from. The results are 0
* indexed.
* @param[in] max_results The maximum number of results returned.
+ * @param[in] type Type of report, NULL or "inventory".
*
* @return 0 on success, -1 error.
*/
@@ -13918,7 +14056,7 @@
const char *levels, const char *delta_states,
int apply_overrides, const char *search_phrase, int notes,
int notes_details, int overrides, int overrides_details,
- int first_result, int max_results)
+ int first_result, int max_results, const char *type)
{
FILE *out;
char *uuid, *tsk_uuid = NULL, *start_time, *end_time;
@@ -13930,6 +14068,16 @@
/** @todo Leaks on error in PRINT. The process normally exits then anyway. */
+ if (strcmp (type, "scan") == 0)
+ {
+ type = NULL;
+ if (report == 0)
+ {
+ assert (0);
+ return -1;
+ }
+ }
+
out = fopen (xml_file, "w");
if (out == NULL)
@@ -13948,9 +14096,14 @@
return -1;
}
- uuid = report_uuid (report);
- PRINT (out, "<report id=\"%s\">", uuid);
- free (uuid);
+ if (report)
+ {
+ uuid = report_uuid (report);
+ PRINT (out, "<report id=\"%s\">", uuid);
+ free (uuid);
+ }
+ else
+ PRINT (out, "<report>");
if (delta)
{
@@ -13994,19 +14147,22 @@
cleanup_iterator (¶ms);
PRINT (out, "</report_format>");
- if (delta == 0)
+ if (report)
{
- report_scan_result_count (report, NULL, NULL, NULL,
+ if (delta == 0)
+ {
+ report_scan_result_count (report, NULL, NULL, NULL,
+ apply_overrides,
+ &result_count);
+ }
+ report_scan_result_count (report,
+ levels,
+ search_phrase,
+ min_cvss_base,
apply_overrides,
- &result_count);
+ &filtered_result_count);
+ report_scan_run_status (report, &run_status);
}
- report_scan_result_count (report,
- levels,
- search_phrase,
- min_cvss_base,
- apply_overrides,
- &filtered_result_count);
- report_scan_run_status (report, &run_status);
PRINT
(out,
"<sort><field>%s<order>%s</order></field></sort>"
@@ -14058,14 +14214,16 @@
strchr (delta_states, 's') != NULL);
}
- PRINT
- (out,
- "</filters>"
- "<scan_run_status>%s</scan_run_status>",
- run_status_name (run_status
- ? run_status
- : TASK_STATUS_INTERNAL_ERROR));
+ PRINT (out, "</filters>");
+ if (report)
+ PRINT
+ (out,
+ "<scan_run_status>%s</scan_run_status>",
+ run_status_name (run_status
+ ? run_status
+ : TASK_STATUS_INTERNAL_ERROR));
+
if (task && tsk_uuid)
{
char *tsk_name, *task_target_uuid;
@@ -14094,6 +14252,148 @@
free (tsk_uuid);
}
+ if (type && (strcmp (type, "inventory") == 0))
+ {
+ iterator_t hosts;
+ init_inventory_iterator (&hosts);
+ while (next (&hosts))
+ {
+ iterator_t report_hosts;
+ report_host_t report_host;
+ const char *ip;
+
+ ip = inventory_iterator_ip (&hosts);
+
+ if (host_last_report_host (ip, &report_host))
+ {
+ cleanup_iterator (&hosts);
+ return -1;
+ }
+
+ if (report_host)
+ {
+ init_host_iterator (&report_hosts, 0, NULL, report_host);
+ if (next (&report_hosts))
+ {
+ iterator_t details;
+ report_t report;
+ int holes, infos, logs, warnings, false_positives;
+
+ PRINT (out,
+ "<host>"
+ "<ip>%s</ip>"
+ "<start>%s</start>"
+ "<end>%s</end>",
+ ip,
+ host_iterator_start_time (&report_hosts),
+ host_iterator_end_time (&report_hosts));
+
+ PRINT (out,
+ "<detail>"
+ "<name>report/@id</name>"
+ "<value>%s</value>"
+ "<source>"
+ "<type></type>"
+ "<name>openvasmd</name>"
+ "<description>UUID of latest report</description>"
+ "</source>"
+ "</detail>",
+ host_iterator_report_uuid (&report_hosts));
+
+ PRINT (out,
+ "<detail>"
+ "<name>report_count</name>"
+ "<value>%i</value>"
+ "<source>"
+ "<type></type>"
+ "<name>openvasmd</name>"
+ "<description>Number of reports</description>"
+ "</source>"
+ "</detail>",
+ host_report_count (ip));
+
+ report = host_iterator_report (&report_hosts);
+
+ report_counts_id (report, NULL, &holes, &infos, &logs,
+ &warnings, &false_positives, 0,
+ NULL);
+
+ PRINT (out,
+ "<detail>"
+ "<name>report/result_count/high</name>"
+ "<value>%i</value>"
+ "<source>"
+ "<type></type>"
+ "<name>openvasmd</name>"
+ "<description>Number of highs</description>"
+ "</source>"
+ "</detail>",
+ holes);
+
+ PRINT (out,
+ "<detail>"
+ "<name>report/result_count/medium</name>"
+ "<value>%i</value>"
+ "<source>"
+ "<type></type>"
+ "<name>openvasmd</name>"
+ "<description>Number of highs</description>"
+ "</source>"
+ "</detail>",
+ warnings);
+
+ PRINT (out,
+ "<detail>"
+ "<name>report/result_count/low</name>"
+ "<value>%i</value>"
+ "<source>"
+ "<type></type>"
+ "<name>openvasmd</name>"
+ "<description>Number of highs</description>"
+ "</source>"
+ "</detail>",
+ infos);
+
+ init_report_host_details_iterator
+ (&details, report_host);
+ while (next (&details))
+ PRINT (out,
+ "<detail>"
+ "<name>%s</name>"
+ "<value>%s</value>"
+ "<source>"
+ "<type>%s</type>"
+ "<name>%s</name>"
+ "<description>%s</description>"
+ "</source>"
+ "</detail>",
+ report_host_details_iterator_name (&details),
+ report_host_details_iterator_value (&details),
+ report_host_details_iterator_source_type (&details),
+ report_host_details_iterator_source_name (&details),
+ report_host_details_iterator_source_desc (&details));
+ cleanup_iterator (&details);
+ }
+ }
+
+ PRINT (out,
+ "</host>");
+ }
+ cleanup_iterator (&hosts);
+
+ PRINT (out, "</report>");
+
+ if (fclose (out))
+ {
+ g_warning ("%s: fclose failed: %s\n",
+ __FUNCTION__,
+ strerror (errno));
+ return -1;
+ }
+
+ return 0;
+ }
+
start_time = scan_start_time (report);
PRINT (out,
"<scan_start>%s</scan_start>",
@@ -14924,12 +15224,12 @@
{
gboolean present;
iterator_t hosts;
- init_host_iterator (&hosts, report, host);
+ init_host_iterator (&hosts, report, host, 0);
present = next (&hosts);
if (delta && (present == FALSE))
{
cleanup_iterator (&hosts);
- init_host_iterator (&hosts, delta, host);
+ init_host_iterator (&hosts, delta, host, 0);
present = next (&hosts);
}
if (present)
@@ -14992,7 +15292,7 @@
else
{
iterator_t hosts;
- init_host_iterator (&hosts, report, NULL);
+ init_host_iterator (&hosts, report, NULL, 0);
while (next (&hosts))
{
iterator_t details;
@@ -15038,7 +15338,7 @@
}
cleanup_iterator (&hosts);
- init_host_iterator (&hosts, report, NULL);
+ init_host_iterator (&hosts, report, NULL, 0);
while (next (&hosts))
PRINT (out,
"<host_end><host>%s</host>%s</host_end>",
@@ -15091,6 +15391,7 @@
* @param[in] first_result The result to start from. The results are 0
* indexed.
* @param[in] max_results The maximum number of results returned.
+ * @param[in] type Type of report: NULL or "inventory".
* @param[out] output_length NULL or location for length of return.
* @param[out] extension NULL or location for report format extension.
* @param[out] content_type NULL or location for report format content
@@ -15104,8 +15405,8 @@
const char *min_cvss_base, const char *levels,
int apply_overrides, const char *search_phrase, int notes,
int notes_details, int overrides, int overrides_details,
- int first_result, int max_results, gsize *output_length,
- gchar **extension, gchar **content_type)
+ int first_result, int max_results, const char *type,
+ gsize *output_length, gchar **extension, gchar **content_type)
{
task_t task;
gchar *xml_file;
@@ -15131,7 +15432,7 @@
result_hosts_only, min_cvss_base, report_format,
levels, NULL, apply_overrides, search_phrase, notes,
notes_details, overrides, overrides_details,
- first_result, max_results))
+ first_result, max_results, type))
{
g_free (xml_file);
return NULL;
@@ -15537,6 +15838,7 @@
* @param[in] escalator_id ID of escalator to escalate report with,
* instead of getting report. NULL to get
* report.
+ * @param[in] type Type of report: NULL or "inventory".
*
* @return 0 success, -1 error, 1 failed to find escalator.
*/
@@ -15552,13 +15854,17 @@
int base64,
gboolean (*send) (const char *, int (*) (void*), void*),
int (*send_data_1) (void*), void *send_data_2,
- const char *escalator_id)
+ const char *escalator_id, const char *type)
{
task_t task;
gchar *xml_file;
char xml_dir[] = "/tmp/openvasmd_XXXXXX";
- if (report_task (report, &task))
+ // FIX same changes in manage_send?
+
+ if (type && (strcmp (type, "inventory") == 0))
+ task = 0;
+ else if (report_task (report, &task))
return -1;
/* Escalate instead, if requested. */
@@ -15604,7 +15910,7 @@
sort_field, result_hosts_only, min_cvss_base,
report_format, levels, delta_states, apply_overrides,
search_phrase, notes, notes_details, overrides,
- overrides_details, first_result, max_results))
+ overrides_details, first_result, max_results, type))
{
g_free (xml_file);
return -1;
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2011-08-01 12:44:47 UTC (rev 11377)
+++ trunk/openvas-manager/src/omp.c 2011-08-01 16:51:39 UTC (rev 11378)
@@ -1792,6 +1792,7 @@
int overrides; ///< Boolean. Whether to include associated overrides.
int overrides_details; ///< Boolean. Whether to include details of above.
int result_hosts_only; ///< Boolean. Whether to include only resulted hosts.
+ char *type; ///< Type of report.
} get_reports_data_t;
/**
@@ -1811,6 +1812,7 @@
free (data->levels);
free (data->search_phrase);
free (data->min_cvss_base);
+ free (data->type);
memset (data, 0, sizeof (get_reports_data_t));
}
@@ -4287,9 +4289,11 @@
else
get_reports_data->result_hosts_only = 1;
- append_attribute (attribute_names, attribute_values,
- "min_cvss_base",
- &get_reports_data->min_cvss_base);
+ if (find_attribute (attribute_names, attribute_values,
+ "type", &attribute))
+ openvas_append_string (&get_reports_data->type, attribute);
+ else
+ get_reports_data->type = g_strdup ("scan");
set_client_state (CLIENT_GET_REPORTS);
}
@@ -9676,7 +9680,10 @@
float min_cvss_base;
iterator_t reports;
- if (get_reports_data->report_id
+ // FIX check if report only when type is "scan"
+
+ if ((strcmp (get_reports_data->type, "scan") == 0)
+ && get_reports_data->report_id
&& find_report (get_reports_data->report_id, &request_report))
{
get_reports_data_reset (get_reports_data);
@@ -9723,7 +9730,9 @@
break;
}
- if (get_reports_data->report_id && request_report == 0)
+ if ((strcmp (get_reports_data->type, "scan") == 0)
+ && get_reports_data->report_id
+ && request_report == 0)
{
if (send_find_error_to_client ("get_reports",
"report",
@@ -9739,7 +9748,8 @@
break;
}
- if (get_reports_data->delta_report_id
+ if ((strcmp (get_reports_data->type, "scan") == 0)
+ && get_reports_data->delta_report_id
&& strcmp (get_reports_data->delta_report_id, "0")
&& delta_report == 0)
{
@@ -9757,7 +9767,8 @@
break;
}
- if (get_reports_data->min_cvss_base
+ if ((strcmp (get_reports_data->type, "scan") == 0)
+ && get_reports_data->min_cvss_base
&& strlen (get_reports_data->min_cvss_base)
&& (sscanf (get_reports_data->min_cvss_base,
"%f",
@@ -9801,6 +9812,75 @@
" status=\"" STATUS_OK "\""
" status_text=\"" STATUS_OK_TEXT "\">");
+ if (strcmp (get_reports_data->type, "inventory") == 0)
+ {
+ gchar *extension, *content_type;
+ int ret;
+
+ /* A host inventory report. */
+
+ content_type = report_format_content_type (report_format);
+ extension = report_format_extension (report_format);
+
+ SENDF_TO_CLIENT_OR_FAIL
+ ("<report"
+ " type=\"inventory\""
+ " format_id=\"%s\""
+ " extension=\"%s\""
+ " content_type=\"%s\">",
+ get_reports_data->format_id,
+ extension,
+ content_type);
+
+ g_free (extension);
+ g_free (content_type);
+
+ ret = manage_send_report (0,
+ 0,
+ report_format,
+ get_reports_data->sort_order,
+ get_reports_data->sort_field,
+ get_reports_data->result_hosts_only,
+ NULL,
+ get_reports_data->levels,
+ get_reports_data->delta_states,
+ get_reports_data->apply_overrides,
+ get_reports_data->search_phrase,
+ get_reports_data->notes,
+ get_reports_data->notes_details,
+ get_reports_data->overrides,
+ get_reports_data->overrides_details,
+ get_reports_data->first_result,
+ get_reports_data->max_results,
+ /* Special case the XML report, bah. */
+ strcmp
+ (get_reports_data->format_id,
+ "d5da9f67-8551-4e51-807b-b6a873d70e34"),
+ send_to_client,
+ write_to_client,
+ write_to_client_data,
+ get_reports_data->escalator_id,
+ "inventory");
+
+ if (ret)
+ {
+ internal_error_send_to_client (error);
+ cleanup_iterator (&reports);
+ get_reports_data_reset (get_reports_data);
+ set_client_state (CLIENT_AUTHENTIC);
+ return;
+ }
+
+ SEND_TO_CLIENT_OR_FAIL ("</report>"
+ "</get_reports_response>");
+
+ get_reports_data_reset (get_reports_data);
+ set_client_state (CLIENT_AUTHENTIC);
+ break;
+ }
+
+ /* The usual scan report. */
+
init_report_iterator (&reports, 0, request_report);
while (next_report (&reports, &report))
{
@@ -9813,6 +9893,7 @@
if (get_reports_data->escalator_id == NULL)
SENDF_TO_CLIENT_OR_FAIL
("<report"
+ " type=\"scan\""
" id=\"%s\""
" format_id=\"%s\""
" extension=\"%s\""
@@ -9849,7 +9930,8 @@
send_to_client,
write_to_client,
write_to_client_data,
- get_reports_data->escalator_id);
+ get_reports_data->escalator_id,
+ get_reports_data->type);
if (ret)
{
if (get_reports_data->escalator_id)
@@ -16167,7 +16249,7 @@
iterator_t hosts;
GString *string = g_string_new ("");
- init_host_iterator (&hosts, running_report, NULL);
+ init_host_iterator (&hosts, running_report, NULL, 0);
while (next (&hosts))
{
unsigned int max_port, current_port;
@@ -16617,7 +16699,7 @@
iterator_t hosts;
GString *string = g_string_new ("");
- init_host_iterator (&hosts, running_report, NULL);
+ init_host_iterator (&hosts, running_report, NULL, 0);
while (next (&hosts))
{
unsigned int max_port, current_port;
More information about the Openvas-commits
mailing list