"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/omp.c" between
openvas-manager-7.0.2.tar.gz and openvas-manager-7.0.3.tar.gz

About: OpenVAS Manager is a layer between OpenVAS-Scanner and various client applications such as OpenVAS-Client or Greenbone Security Assistant. Among other features, it adds server-side storage of scan results and it makes it unnecessary for scan clients to keep connection until a scan finishes. OpenVAS-9.

omp.c  (openvas-manager-7.0.2):omp.c  (openvas-manager-7.0.3)
skipping to change at line 2853 skipping to change at line 2853
/** /**
* @brief Command data for the get_results command. * @brief Command data for the get_results command.
*/ */
typedef struct typedef struct
{ {
get_data_t get; ///< Get args. get_data_t get; ///< Get args.
char *task_id; ///< Task associated with results. char *task_id; ///< Task associated with results.
int notes_details; ///< Boolean. Whether to include details of above. int notes_details; ///< Boolean. Whether to include details of above.
int overrides_details; ///< Boolean. Whether to include details of above. int overrides_details; ///< Boolean. Whether to include details of above.
int get_counts; ///< Boolean. Whether to include result counts.
} get_results_data_t; } get_results_data_t;
/** /**
* @brief Reset command data. * @brief Reset command data.
* *
* @param[in] data Command data. * @param[in] data Command data.
*/ */
static void static void
get_results_data_reset (get_results_data_t *data) get_results_data_reset (get_results_data_t *data)
{ {
skipping to change at line 6179 skipping to change at line 6180
"</keywords>" "</keywords>"
"</filters>"); "</filters>");
return 0; return 0;
} }
/** /**
* @brief Send end of GET response. * @brief Send end of GET response.
* *
* @param[in] type Type. * @param[in] type Type.
* @param[in] get GET data. * @param[in] get GET data.
* @param[in] get_counts Include counts.
* @param[in] count Page count. * @param[in] count Page count.
* @param[in] filtered Filtered count. * @param[in] filtered Filtered count.
* @param[in] full Full count. * @param[in] full Full count.
* @param[in] write_to_client Function that sends to clients. * @param[in] write_to_client Function that sends to clients.
* @param[in] write_to_client_data Data for write_to_client. * @param[in] write_to_client_data Data for write_to_client.
*/ */
int int
send_get_end (const char *type, get_data_t *get, int count, int filtered, send_get_end_internal (const char *type, get_data_t *get, int get_counts,
int full, int (*write_to_client) (const char *, void*), int count, int filtered, int full,
void* write_to_client_data) int (*write_to_client) (const char *, void*),
void* write_to_client_data)
{ {
gchar *sort_field, *filter; gchar *sort_field, *filter;
int first, max, sort_order; int first, max, sort_order;
GString *type_many, *msg; GString *type_many, *msg;
if (get->filt_id && strcmp (get->filt_id, "0")) if (get->filt_id && strcmp (get->filt_id, "0"))
{ {
if (get->filter_replacement) if (get->filter_replacement)
filter = g_strdup (get->filter_replacement); filter = g_strdup (get->filter_replacement);
else else
skipping to change at line 6279 skipping to change at line 6282
g_string_append (type_many, "s"); g_string_append (type_many, "s");
msg = g_string_new (""); msg = g_string_new ("");
buffer_get_filter_xml (msg, type, get, filter, NULL); buffer_get_filter_xml (msg, type, get, filter, NULL);
buffer_xml_append_printf (msg, buffer_xml_append_printf (msg,
"<sort>" "<sort>"
"<field>%s<order>%s</order></field>" "<field>%s<order>%s</order></field>"
"</sort>" "</sort>"
"<%s start=\"%i\" max=\"%i\"/>" "<%s start=\"%i\" max=\"%i\"/>",
"<%s_count>"
"%i"
"<filtered>%i</filtered>"
"<page>%i</page>"
"</%s_count>"
"</get_%s_response>",
sort_field, sort_field,
sort_order ? "ascending" : "descending", sort_order ? "ascending" : "descending",
type_many->str, type_many->str,
first, first,
max, max);
type, if (get_counts)
full, buffer_xml_append_printf (msg,
filtered, "<%s_count>"
count, "%i"
type, "<filtered>%i</filtered>"
"<page>%i</page>"
"</%s_count>",
type,
full,
filtered,
count,
type);
buffer_xml_append_printf (msg,
"</get_%s_response>",
type_many->str); type_many->str);
g_string_free (type_many, TRUE); g_string_free (type_many, TRUE);
g_free (sort_field); g_free (sort_field);
g_free (filter); g_free (filter);
if (send_to_client (msg->str, write_to_client, write_to_client_data)) if (send_to_client (msg->str, write_to_client, write_to_client_data))
{ {
g_string_free (msg, TRUE); g_string_free (msg, TRUE);
return 1; return 1;
} }
g_string_free (msg, TRUE); g_string_free (msg, TRUE);
return 0; return 0;
} }
/** /**
* @brief Send end of GET response.
*
* @param[in] type Type.
* @param[in] get GET data.
* @param[in] count Page count.
* @param[in] filtered Filtered count.
* @param[in] full Full count.
* @param[in] write_to_client Function that sends to clients.
* @param[in] write_to_client_data Data for write_to_client.
*/
int
send_get_end (const char *type, get_data_t *get, int count, int filtered,
int full, int (*write_to_client) (const char *, void*),
void* write_to_client_data)
{
return send_get_end_internal (type, get, 1, count, filtered, full,
write_to_client, write_to_client_data);
}
/**
* @brief Send end of GET response, skipping result counts.
*
* @param[in] type Type.
* @param[in] get GET data.
* @param[in] count Page count.
* @param[in] filtered Filtered count.
* @param[in] full Full count.
* @param[in] write_to_client Function that sends to clients.
* @param[in] write_to_client_data Data for write_to_client.
*/
int
send_get_end_no_counts (const char *type, get_data_t *get,
int (*write_to_client) (const char *, void*),
void* write_to_client_data)
{
return send_get_end_internal (type, get, 0, 0, 0, 0, write_to_client,
write_to_client_data);
}
/**
* @brief Send start of GET response to client, returning on fail. * @brief Send start of GET response to client, returning on fail.
* *
* @param[in] type Type of resource. * @param[in] type Type of resource.
* @param[in] get GET data. * @param[in] get GET data.
*/ */
#define SEND_GET_START(type) \ #define SEND_GET_START(type) \
do \ do \
{ \ { \
if (send_get_start (type, omp_parser->client_writer, \ if (send_get_start (type, omp_parser->client_writer, \
omp_parser->client_writer_data)) \ omp_parser->client_writer_data)) \
skipping to change at line 7514 skipping to change at line 7560
get_results_data->notes_details = strcmp (attribute, "0"); get_results_data->notes_details = strcmp (attribute, "0");
else else
get_results_data->notes_details = 0; get_results_data->notes_details = 0;
if (find_attribute (attribute_names, attribute_values, if (find_attribute (attribute_names, attribute_values,
"overrides_details", &attribute)) "overrides_details", &attribute))
get_results_data->overrides_details = strcmp (attribute, "0"); get_results_data->overrides_details = strcmp (attribute, "0");
else else
get_results_data->overrides_details = 0; get_results_data->overrides_details = 0;
if (find_attribute (attribute_names, attribute_values,
"get_counts", &attribute))
get_results_data->get_counts = strcmp (attribute, "0");
else
get_results_data->get_counts = 1;
set_client_state (CLIENT_GET_RESULTS); set_client_state (CLIENT_GET_RESULTS);
} }
else if (strcasecmp ("GET_ROLES", element_name) == 0) else if (strcasecmp ("GET_ROLES", element_name) == 0)
{ {
get_data_parse_attributes (&get_roles_data->get, "role", get_data_parse_attributes (&get_roles_data->get, "role",
attribute_names, attribute_names,
attribute_values); attribute_values);
set_client_state (CLIENT_GET_ROLES); set_client_state (CLIENT_GET_ROLES);
} }
else if (strcasecmp ("GET_SCANNERS", element_name) == 0) else if (strcasecmp ("GET_SCANNERS", element_name) == 0)
skipping to change at line 11573 skipping to change at line 11625
{ {
char *result_report_id, *result_task_id, *result_task_name; char *result_report_id, *result_task_id, *result_task_name;
if (task == 0) if (task == 0)
selected_task = result_iterator_task (results); selected_task = result_iterator_task (results);
task_uuid (selected_task, &result_task_id); task_uuid (selected_task, &result_task_id);
result_task_name = task_name (result_iterator_task (results)); result_task_name = task_name (result_iterator_task (results));
result_report_id = report_uuid (result_iterator_report (results)); result_report_id = report_uuid (result_iterator_report (results));
g_string_append_printf (buffer, buffer_xml_append_printf (buffer,
"<report id=\"%s\"/>" "<report id=\"%s\"/>"
"<task id=\"%s\"><name>%s</name></task>", "<task id=\"%s\"><name>%s</name></task>",
result_report_id, result_report_id,
result_task_id, result_task_id,
result_task_name); result_task_name);
free (result_report_id); free (result_report_id);
free (result_task_id); free (result_task_id);
free (result_task_name); free (result_task_name);
} }
if (include_tags) if (include_tags)
{ {
buffer_xml_append_printf (buffer, buffer_xml_append_printf (buffer,
"<user_tags>" "<user_tags>"
skipping to change at line 16490 skipping to change at line 16542
omp_parser)) omp_parser))
{ {
error_send_to_client (error); error_send_to_client (error);
return; return;
} }
get_reports_data_reset (get_reports_data); get_reports_data_reset (get_reports_data);
set_client_state (CLIENT_AUTHENTIC); set_client_state (CLIENT_AUTHENTIC);
return; return;
} }
if (get_reports_data->get.filt_id
&& strcmp (get_reports_data->get.filt_id, "0")
&& strcmp (get_reports_data->get.filt_id, "-2"))
{
filter_t filter;
if (find_filter_with_permission (get_reports_data->get.filt_id,
&filter,
"get_filters"))
{
get_reports_data_reset (get_reports_data);
SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("get_reports"));
set_client_state (CLIENT_AUTHENTIC);
return;
}
if (filter == 0)
{
if (send_find_error_to_client ("get_reports", "filter",
get_reports_data->get.filt_id,
omp_parser))
{
error_send_to_client (error);
return;
}
get_reports_data_reset (get_reports_data);
set_client_state (CLIENT_AUTHENTIC);
return;
}
}
if ((strcmp (get_reports_data->type, "scan") == 0) if ((strcmp (get_reports_data->type, "scan") == 0)
&& get_reports_data->report_id && get_reports_data->report_id
&& request_report == 0) && request_report == 0)
{ {
if (send_find_error_to_client ("get_reports", "report", if (send_find_error_to_client ("get_reports", "report",
get_reports_data->report_id, get_reports_data->report_id,
omp_parser)) omp_parser))
{ {
error_send_to_client (error); error_send_to_client (error);
return; return;
skipping to change at line 17458 skipping to change at line 17540
{ {
error_send_to_client (error); error_send_to_client (error);
return; return;
} }
} }
else else
{ {
const char* filter; const char* filter;
iterator_t results; iterator_t results;
int notes, overrides; int notes, overrides;
int count, filtered, ret, first; int count, ret, first;
if (get_results_data->get.filt_id if (get_results_data->get.filt_id
&& strcmp (get_results_data->get.filt_id, "0")) && strcmp (get_results_data->get.filt_id, "0"))
{ {
filter = filter_term (get_results_data->get.filt_id); filter = filter_term (get_results_data->get.filt_id);
} }
else else
filter = get_results_data->get.filter; filter = get_results_data->get.filter;
SEND_TO_CLIENT_OR_FAIL ("<get_results_response" SEND_TO_CLIENT_OR_FAIL ("<get_results_response"
skipping to change at line 17543 skipping to change at line 17625
g_string_free (buffer, TRUE); g_string_free (buffer, TRUE);
count ++; count ++;
} }
while (next (&results)); while (next (&results));
} }
cleanup_iterator (&results); cleanup_iterator (&results);
manage_filter_controls (get_results_data->get.filter, manage_filter_controls (get_results_data->get.filter,
&first, NULL, NULL, NULL); &first, NULL, NULL, NULL);
filtered = get_results_data->get.id if (get_results_data->get_counts)
? 1 : result_count (&get_results_data->get, {
0 /* No report */, int filtered;
NULL /* No host */);
filtered = get_results_data->get.id
? 1 : result_count (&get_results_data->get,
0 /* No report */,
NULL /* No host */);
SEND_GET_END ("result", &get_results_data->get, count, filtered); if (send_get_end ("result", &get_results_data->get, count, filtered,
resource_count ("result", &get_results_data->get),
omp_parser->client_writer,
omp_parser->client_writer_data))
{
error_send_to_client (error);
return;
}
}
else if (send_get_end_no_counts ("result",
&get_results_data->get,
omp_parser->client_writer,
omp_parser->client_writer_data))
{
error_send_to_client (error);
return;
}
} }
get_results_data_reset (get_results_data); get_results_data_reset (get_results_data);
set_client_state (CLIENT_AUTHENTIC); set_client_state (CLIENT_AUTHENTIC);
} }
/** /**
* @brief Handle end of GET_ROLES element. * @brief Handle end of GET_ROLES element.
* *
* @param[in] omp_parser OMP parser. * @param[in] omp_parser OMP parser.
skipping to change at line 18255 skipping to change at line 18357
break; break;
case 2: case 2:
if (send_find_error_to_client if (send_find_error_to_client
("get_system_reports", "slave", ("get_system_reports", "slave",
get_system_reports_data->slave_id, omp_parser)) get_system_reports_data->slave_id, omp_parser))
{ {
error_send_to_client (error); error_send_to_client (error);
return; return;
} }
break; break;
case 4:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_UNAVAILABLE ("get_system_reports",
"Could not connect to slave"));
break;
case 5:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_UNAVAILABLE ("get_system_reports",
"Authentication to slave failed"));
break;
case 6:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_UNAVAILABLE ("get_system_reports",
"Failed to get system report from slave"));
break;
case 99: case 99:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("get_system_reports", (XML_ERROR_SYNTAX ("get_system_reports",
"Permission denied")); "Permission denied"));
break; break;
default: default:
assert (0); assert (0);
/* fallthrough */ /* fallthrough */
case -1: case -1:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
skipping to change at line 18666 skipping to change at line 18783
&found, &found,
"get_port_lists")) "get_port_lists"))
abort (); abort ();
port_list_available = (found > 0); port_list_available = (found > 0);
} }
SEND_GET_COMMON (target, &get_targets_data->get, &targets); SEND_GET_COMMON (target, &get_targets_data->get, &targets);
hosts = target_iterator_hosts (&targets); hosts = target_iterator_hosts (&targets);
exclude_hosts = target_iterator_exclude_hosts (&targets); exclude_hosts = target_iterator_exclude_hosts (&targets);
max_hosts = manage_count_hosts (hosts, exclude_hosts); max_hosts = manage_count_hosts_max (hosts, exclude_hosts, 0);
reverse_lookup_only = target_iterator_reverse_lookup_only reverse_lookup_only = target_iterator_reverse_lookup_only
(&targets); (&targets);
reverse_lookup_unify = target_iterator_reverse_lookup_unify reverse_lookup_unify = target_iterator_reverse_lookup_unify
(&targets); (&targets);
SENDF_TO_CLIENT_OR_FAIL ("<hosts>%s</hosts>" SENDF_TO_CLIENT_OR_FAIL ("<hosts>%s</hosts>"
"<exclude_hosts>%s</exclude_hosts>" "<exclude_hosts>%s</exclude_hosts>"
"<max_hosts>%i</max_hosts>" "<max_hosts>%i</max_hosts>"
"<port_list id=\"%s\">" "<port_list id=\"%s\">"
"<name>%s</name>" "<name>%s</name>"
skipping to change at line 18900 skipping to change at line 19017
apply_overrides); apply_overrides);
while (1) while (1)
{ {
task_t index; task_t index;
gchar *progress_xml; gchar *progress_xml;
target_t target; target_t target;
scanner_t scanner; scanner_t scanner;
const char *first_report_id, *last_report_id; const char *first_report_id, *last_report_id;
char *config_name, *config_uuid; char *config_name, *config_uuid;
gchar *config_name_escaped;
char *task_target_uuid, *task_target_name; char *task_target_uuid, *task_target_name;
gchar *task_target_name_escaped;
char *task_schedule_uuid, *task_schedule_name; char *task_schedule_uuid, *task_schedule_name;
gchar *task_schedule_name_escaped;
char *task_scanner_uuid, *task_scanner_name; char *task_scanner_uuid, *task_scanner_name;
gchar *task_scanner_name_escaped;
gchar *first_report, *last_report; gchar *first_report, *last_report;
gchar *second_last_report_id, *second_last_report; gchar *second_last_report_id, *second_last_report;
gchar *current_report; gchar *current_report;
report_t running_report; report_t running_report;
schedule_t schedule; schedule_t schedule;
time_t next_time; time_t next_time;
char *owner, *observers; char *owner, *observers;
int target_in_trash, schedule_in_trash, scanner_in_trash; int target_in_trash, schedule_in_trash, scanner_in_trash;
int debugs, holes = 0, infos = 0, logs, warnings = 0; int debugs, holes = 0, infos = 0, logs, warnings = 0;
int holes_2 = 0, infos_2 = 0, warnings_2 = 0; int holes_2 = 0, infos_2 = 0, warnings_2 = 0;
skipping to change at line 19411 skipping to change at line 19532
} }
else else
{ {
/* Container tasks have no associated scanner. */ /* Container tasks have no associated scanner. */
task_scanner_uuid = g_strdup (""); task_scanner_uuid = g_strdup ("");
task_scanner_name = g_strdup (""); task_scanner_name = g_strdup ("");
task_scanner_type = 0; task_scanner_type = 0;
scanner_in_trash = 0; scanner_in_trash = 0;
} }
next_time = task_schedule_next_time (index); next_time = task_schedule_next_time (index);
config_name_escaped
= config_name
? g_markup_escape_text (config_name, -1)
: NULL;
task_target_name_escaped
= task_target_name
? g_markup_escape_text (task_target_name, -1)
: NULL;
task_scanner_name_escaped
= task_scanner_name
? g_markup_escape_text (task_scanner_name, -1)
: NULL;
task_schedule_name_escaped
= task_schedule_name
? g_markup_escape_text (task_schedule_name, -1)
: NULL;
response = g_strdup_printf response = g_strdup_printf
("<alterable>%i</alterable>" ("<alterable>%i</alterable>"
"<config id=\"%s\">" "<config id=\"%s\">"
"<name>%s</name>" "<name>%s</name>"
"<type>%i</type>" "<type>%i</type>"
"<trash>%i</trash>" "<trash>%i</trash>"
"%s" "%s"
"</config>" "</config>"
"<target id=\"%s\">" "<target id=\"%s\">"
"<name>%s</name>" "<name>%s</name>"
skipping to change at line 19449 skipping to change at line 19586
"<next_time>%s</next_time>" "<next_time>%s</next_time>"
"<trash>%i</trash>" "<trash>%i</trash>"
"%s" "%s"
"</schedule>" "</schedule>"
"<schedule_periods>%i</schedule_periods>" "<schedule_periods>%i</schedule_periods>"
"%s%s%s%s", "%s%s%s%s",
get_tasks_data->get.trash get_tasks_data->get.trash
? 0 ? 0
: task_alterable (index), : task_alterable (index),
config_uuid ?: "", config_uuid ?: "",
config_name ?: "", config_name_escaped ?: "",
config_type (task_config (index)), config_type (task_config (index)),
task_config_in_trash (index), task_config_in_trash (index),
config_available ? "" : "<permissions/>", config_available ? "" : "<permissions/>",
task_target_uuid ?: "", task_target_uuid ?: "",
task_target_name ?: "", task_target_name_escaped ?: "",
target_in_trash, target_in_trash,
target_available ? "" : "<permissions/>", target_available ? "" : "<permissions/>",
task_iterator_hosts_ordering (&tasks), task_iterator_hosts_ordering (&tasks),
task_scanner_uuid, task_scanner_uuid,
task_scanner_name, task_scanner_name_escaped,
task_scanner_type, task_scanner_type,
scanner_in_trash, scanner_in_trash,
scanner_available ? "" : "<permissions/>", scanner_available ? "" : "<permissions/>",
task_iterator_run_status_name (&tasks), task_iterator_run_status_name (&tasks),
progress_xml, progress_xml,
task_iterator_total_reports (&tasks), task_iterator_total_reports (&tasks),
task_iterator_finished_reports (&tasks), task_iterator_finished_reports (&tasks),
task_iterator_trend_counts task_iterator_trend_counts
(&tasks, holes, warnings, infos, severity, (&tasks, holes, warnings, infos, severity,
holes_2, warnings_2, infos_2, severity_2), holes_2, warnings_2, infos_2, severity_2),
task_schedule_uuid, task_schedule_uuid,
task_schedule_name, task_schedule_name_escaped,
(next_time == 0 ? "over" : iso_time (&next_time)), (next_time == 0 ? "over" : iso_time (&next_time)),
schedule_in_trash, schedule_in_trash,
schedule_available ? "" : "<permissions/>", schedule_available ? "" : "<permissions/>",
task_schedule_periods (index), task_schedule_periods (index),
current_report, current_report,
first_report, first_report,
last_report, last_report,
second_last_report); second_last_report);
g_free (config_name); g_free (config_name);
g_free (config_uuid); g_free (config_uuid);
g_free (config_name_escaped);
free (task_target_name); free (task_target_name);
free (task_target_uuid); free (task_target_uuid);
g_free (task_target_name_escaped);
g_free (progress_xml); g_free (progress_xml);
g_free (current_report); g_free (current_report);
g_free (first_report); g_free (first_report);
g_free (last_report); g_free (last_report);
g_free (second_last_report); g_free (second_last_report);
g_free (task_schedule_uuid); g_free (task_schedule_uuid);
g_free (task_schedule_name); g_free (task_schedule_name);
g_free (task_schedule_name_escaped);
g_free (task_scanner_uuid); g_free (task_scanner_uuid);
g_free (task_scanner_name); g_free (task_scanner_name);
g_free (task_scanner_name_escaped);
if (send_to_client (response, if (send_to_client (response,
omp_parser->client_writer, omp_parser->client_writer,
omp_parser->client_writer_data)) omp_parser->client_writer_data))
{ {
g_free (response); g_free (response);
cleanup_iterator (&tasks); cleanup_iterator (&tasks);
error_send_to_client (error); error_send_to_client (error);
cleanup_iterator (&tasks); cleanup_iterator (&tasks);
return; return;
} }
skipping to change at line 20738 skipping to change at line 20879
case 4: case 4:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("delete_user", (XML_ERROR_SYNTAX ("delete_user",
"User has an active task")); "User has an active task"));
break; break;
case 5: case 5:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("delete_user", (XML_ERROR_SYNTAX ("delete_user",
"Attempt to delete current user")); "Attempt to delete current user"));
break; break;
case 6:
if (send_find_error_to_client ("delete_user", "inheriting user",
delete_user_data->inheritor_id,
omp_parser))
{
error_send_to_client (error);
return;
}
break;
case 7:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("delete_user",
"Inheritor is the same as the deleted"
" user."));
break;
case 8:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("delete_user",
"Invalid inheritor."));
break;
case 9:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("delete_user",
"Resources owned by the user are still"
" in use by others."));
break;
case 99: case 99:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("delete_user", (XML_ERROR_SYNTAX ("delete_user",
"Permission denied")); "Permission denied"));
log_event_fail ("user", "User", delete_user_data->user_id, log_event_fail ("user", "User", delete_user_data->user_id,
"deleted"); "deleted");
break; break;
default: default:
SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("delete_user")); SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("delete_user"));
log_event_fail ("user", "User", delete_user_data->user_id, log_event_fail ("user", "User", delete_user_data->user_id,
skipping to change at line 21947 skipping to change at line 22114
(XML_ERROR_SYNTAX ("create_alert", (XML_ERROR_SYNTAX ("create_alert",
"Method does not match event type")); "Method does not match event type"));
log_event_fail ("alert", "Alert", NULL, "created"); log_event_fail ("alert", "Alert", NULL, "created");
break; break;
case 21: case 21:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert", (XML_ERROR_SYNTAX ("create_alert",
"Condition does not match event type")); "Condition does not match event type"));
log_event_fail ("alert", "Alert", NULL, "created"); log_event_fail ("alert", "Alert", NULL, "created");
break; break;
case 31:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Unexpected event data name"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 32:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Syntax error in event data"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 40:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in SMB credential"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 41:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in SMB share path"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 42:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in SMB file path"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 50:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in TippingPoint credential"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 51:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in TippingPoint hostname"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 52:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in TippingPoint TLS"
" certificate"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 53:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"TippingPoint TLS workaround must be"
" set to 0 or 1"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 99: case 99:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert", (XML_ERROR_SYNTAX ("create_alert",
"Permission denied")); "Permission denied"));
log_event_fail ("alert", "Alert", NULL, "created"); log_event_fail ("alert", "Alert", NULL, "created");
break; break;
default: default:
assert (0); assert (0);
case -1: case -1:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
skipping to change at line 25616 skipping to change at line 25839
(XML_ERROR_SYNTAX ("modify_alert", (XML_ERROR_SYNTAX ("modify_alert",
"Method does not match event type")); "Method does not match event type"));
log_event_fail ("alert", "Alert", NULL, "modify"); log_event_fail ("alert", "Alert", NULL, "modify");
break; break;
case 21: case 21:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert", (XML_ERROR_SYNTAX ("modify_alert",
"Condition does not match event type")); "Condition does not match event type"));
log_event_fail ("alert", "Alert", NULL, "modify"); log_event_fail ("alert", "Alert", NULL, "modify");
break; break;
case 31:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert",
"Unexpected event data name"));
log_event_fail ("alert", "Alert", NULL, "modified");
break;
case 32:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert",
"Syntax error in event data"));
log_event_fail ("alert", "Alert", NULL, "modified");
break;
case 40:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert",
"Error in SMB credential"));
log_event_fail ("alert", "Alert", NULL, "modified");
break;
case 41:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert",
"Error in SMB share path"));
log_event_fail ("alert", "Alert", NULL, "modified");
break;
case 42:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert",
"Error in SMB file path"));
log_event_fail ("alert", "Alert", NULL, "modified");
break;
case 50:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in TippingPoint credential"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 51:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in TippingPoint hostname"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 52:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"Error in TippingPoint TLS"
" certificate"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 53:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_alert",
"TippingPoint TLS workaround must be"
" set to 0 or 1"));
log_event_fail ("alert", "Alert", NULL, "created");
break;
case 99: case 99:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_alert", (XML_ERROR_SYNTAX ("modify_alert",
"Permission denied")); "Permission denied"));
log_event_fail ("alert", "Alert", modify_alert_data->alert_id, log_event_fail ("alert", "Alert", modify_alert_data->alert_id,
"modified"); "modified");
break; break;
default: default:
case -1: case -1:
SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("modify_alert")); SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("modify_alert"));
skipping to change at line 26095 skipping to change at line 26374
(XML_ERROR_SYNTAX ("modify_credential", (XML_ERROR_SYNTAX ("modify_credential",
"MODIFY_credential requires a" "MODIFY_credential requires a"
" credential_id")); " credential_id"));
log_event_fail ("credential", "Credential", log_event_fail ("credential", "Credential",
modify_credential_data->credential_id, modify_credential_data->credential_id,
"modified"); "modified");
break; break;
case 4: case 4:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_credential", (XML_ERROR_SYNTAX ("modify_credential",
"Attempt to change login or password of" "Login name must not be empty and contain"
" packaged credential")); " only alphanumeric characters"));
log_event_fail ("credential", "Credential",
modify_credential_data->credential_id,
"modified");
break;
case 5:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_credential",
"Invalid or empty certificate"));
log_event_fail ("credential", "Credential",
modify_credential_data->credential_id,
"modified");
break;
case 6:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_credential",
"Invalid or empty auth_algorithm"));
log_event_fail ("credential", "Credential",
modify_credential_data->credential_id,
"modified");
break;
case 7:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_credential",
"Invalid or empty privacy_algorithm"));
log_event_fail ("credential", "Credential",
modify_credential_data->credential_id,
"modified");
break;
case 8:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_credential",
"Invalid or empty private key"));
log_event_fail ("credential", "Credential", log_event_fail ("credential", "Credential",
modify_credential_data->credential_id, modify_credential_data->credential_id,
"modified"); "modified");
break; break;
case 99: case 99:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_credential", (XML_ERROR_SYNTAX ("modify_credential",
"Permission denied")); "Permission denied"));
log_event_fail ("credential", "Credential", log_event_fail ("credential", "Credential",
modify_credential_data->credential_id, modify_credential_data->credential_id,
skipping to change at line 28347 skipping to change at line 28658
assert (0); assert (0);
break; break;
} }
move_task_data_reset (move_task_data); move_task_data_reset (move_task_data);
set_client_state (CLIENT_AUTHENTIC); set_client_state (CLIENT_AUTHENTIC);
break; break;
case CLIENT_TEST_ALERT: case CLIENT_TEST_ALERT:
if (test_alert_data->alert_id) if (test_alert_data->alert_id)
{ {
switch (manage_test_alert (test_alert_data->alert_id)) gchar *script_message = NULL;
switch (manage_test_alert (test_alert_data->alert_id,
&script_message))
{ {
case 0: case 0:
SEND_TO_CLIENT_OR_FAIL (XML_OK ("test_alert")); SEND_TO_CLIENT_OR_FAIL (XML_OK ("test_alert"));
break; break;
case 1: case 1:
if (send_find_error_to_client if (send_find_error_to_client
("test_alert", "alert", test_alert_data->alert_id, ("test_alert", "alert", test_alert_data->alert_id,
omp_parser)) omp_parser))
{ {
error_send_to_client (error); error_send_to_client (error);
skipping to change at line 28387 skipping to change at line 28700
case -3: case -3:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("test_alert", (XML_ERROR_SYNTAX ("test_alert",
"Failed to find filter for alert")); "Failed to find filter for alert"));
break; break;
case -4: case -4:
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("test_alert", (XML_ERROR_SYNTAX ("test_alert",
"Failed to find credential for alert")); "Failed to find credential for alert"));
break; break;
case -5:
if (script_message)
{
gchar *msg;
msg = g_markup_printf_escaped
("<test_alert_response status=\"400\""
" status_text=\"Alert script failed\">"
"<status_details>%s</status_details>"
"</test_alert_response>",
script_message);
if (send_to_client (msg, omp_parser->client_writer,
omp_parser->client_writer_data))
{
error_send_to_client (error);
g_free (msg);
return;
}
}
else
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("test_alert",
"Alert script failed"));
}
break;
default: /* Programming error. */ default: /* Programming error. */
assert (0); assert (0);
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_INTERNAL_ERROR ("test_alert")); (XML_INTERNAL_ERROR ("test_alert"));
break; break;
} }
} }
else else
SEND_TO_CLIENT_OR_FAIL SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("test_alert", (XML_ERROR_SYNTAX ("test_alert",
skipping to change at line 30386 skipping to change at line 30725
/** /**
* @brief Initialise OMP library. * @brief Initialise OMP library.
* *
* @param[in] log_config Logging configuration list. * @param[in] log_config Logging configuration list.
* @param[in] nvt_cache_mode True when running in NVT caching mode. * @param[in] nvt_cache_mode True when running in NVT caching mode.
* @param[in] database Location of manage database. * @param[in] database Location of manage database.
* @param[in] max_ips_per_target Max number of IPs per target. * @param[in] max_ips_per_target Max number of IPs per target.
* @param[in] max_email_attachment_size Max size of email attachments. * @param[in] max_email_attachment_size Max size of email attachments.
* @param[in] max_email_include_size Max size of email inclusions. * @param[in] max_email_include_size Max size of email inclusions.
* @param[in] max_email_message_size Max size of email user message text.
* @param[in] progress Function to update progress, or NULL. * @param[in] progress Function to update progress, or NULL.
* @param[in] fork_connection Function to fork a connection to the OMP * @param[in] fork_connection Function to fork a connection to the OMP
* daemon layer, or NULL. * daemon layer, or NULL.
* @param[in] skip_db_check Skip DB check. * @param[in] skip_db_check Skip DB check.
* *
* @return 0 success, -1 error, -2 database is wrong version, -3 database * @return 0 success, -1 error, -2 database is wrong version, -3 database
* needs to be initialized from server, -4 max_ips_per_target out of * needs to be initialized from server, -4 max_ips_per_target out of
* range. * range.
*/ */
int int
init_omp (GSList *log_config, int nvt_cache_mode, const gchar *database, init_omp (GSList *log_config, int nvt_cache_mode, const gchar *database,
int max_ips_per_target, int max_email_attachment_size, int max_ips_per_target, int max_email_attachment_size,
int max_email_include_size, void (*progress) (), int max_email_include_size, int max_email_message_size,
void (*progress) (),
int (*fork_connection) (openvas_connection_t *, gchar*), int (*fork_connection) (openvas_connection_t *, gchar*),
int skip_db_check) int skip_db_check)
{ {
g_log_set_handler (G_LOG_DOMAIN, g_log_set_handler (G_LOG_DOMAIN,
ALL_LOG_LEVELS, ALL_LOG_LEVELS,
(GLogFunc) openvas_log_func, (GLogFunc) openvas_log_func,
log_config); log_config);
command_data_init (&command_data); command_data_init (&command_data);
return init_manage (log_config, nvt_cache_mode, database, max_ips_per_target, return init_manage (log_config, nvt_cache_mode, database, max_ips_per_target,
max_email_attachment_size, max_email_include_size, max_email_attachment_size, max_email_include_size,
max_email_message_size,
progress, fork_connection, skip_db_check); progress, fork_connection, skip_db_check);
} }
/** /**
* @brief Initialise OMP library data for a process. * @brief Initialise OMP library data for a process.
* *
* @param[in] update_nvt_cache 0 operate normally, -1 just update NVT cache, * @param[in] update_nvt_cache 0 operate normally, -1 just update NVT cache,
* -2 just rebuild NVT cache. * -2 just rebuild NVT cache.
* @param[in] database Location of manage database. * @param[in] database Location of manage database.
* @param[in] write_to_client Function to write to client. * @param[in] write_to_client Function to write to client.
 End of changes. 36 change blocks. 
37 lines changed or deleted 379 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)