41 #include <netinet/in.h> 43 #include <sys/socket.h> 46 #include <arpa/inet.h> 53 #include <microhttpd.h> 59 #include <openvas/misc/openvas_server.h> 60 #include <openvas/base/openvas_file.h> 61 #include <openvas/base/cvss.h> 62 #include <openvas/omp/omp.h> 63 #include <openvas/omp/xml.h> 68 #include <libxml2/libxml/xmlmemory.h> 69 #include <libxml2/libxml/HTMLtree.h> 70 #include <libxml2/libxml/xmlIO.h> 71 #include <libxml2/libxml/xinclude.h> 72 #include <libxslt/xslt.h> 73 #include <libxslt/xsltInternals.h> 74 #include <libxslt/transform.h> 75 #include <libxslt/xsltutils.h> 81 #define G_LOG_DOMAIN "gsad omp" 86 #define OPENVASMD_ADDRESS "127.0.0.1" 107 omp (openvas_connection_t *,
credentials_t *, gchar **, entity_t *,
111 ompf (openvas_connection_t *,
credentials_t *, gchar **, entity_t *,
138 static char *get_assets_chart (openvas_connection_t *,
credentials_t *,
148 static char *get_tasks_chart (openvas_connection_t *,
credentials_t *,
154 static char *get_config_family (openvas_connection_t *,
credentials_t *,
175 static char *get_credential (openvas_connection_t *,
credentials_t *,
178 static char *get_credentials (openvas_connection_t *,
credentials_t *,
187 static char *get_nvts (openvas_connection_t *,
credentials_t *credentials,
188 params_t *,
const char *,
const char *,
197 static char *get_permission (openvas_connection_t *,
credentials_t *,
200 static char *get_permissions (openvas_connection_t *,
credentials_t *,
206 static char *get_port_lists (openvas_connection_t *,
credentials_t *,
209 static char *edit_port_list (openvas_connection_t *,
credentials_t *,
225 const char *, gsize *, gchar **,
char **,
const char *,
228 static char *get_report_format (openvas_connection_t *,
credentials_t *,
231 static char *get_report_formats (openvas_connection_t *,
credentials_t *,
235 static char *get_report_section (openvas_connection_t *,
credentials_t *,
242 static char *get_result_page (openvas_connection_t *,
credentials_t *,
280 static int omp_success (entity_t entity);
283 const char *,
const char *,
const char *,
286 static gchar *action_result_page (openvas_connection_t *,
credentials_t *,
288 const char*,
const char*,
const char*,
289 const char*,
const char*);
291 static gchar* response_from_entity (openvas_connection_t *,
credentials_t*,
292 params_t *, entity_t,
int,
const char*,
293 const char *,
const char*,
const char*,
308 return strstr (credentials->
capabilities, name) ? 1 : 0;
319 omp_init (
const gchar *manager_address_unix,
const gchar *manager_address_tls,
322 if (manager_address_unix)
327 else if (manager_address_tls)
375 print_chart_pref (gchar *
id, gchar *
value, GString* buffer)
377 g_string_append_printf (buffer,
378 "<chart_preference id=\"%s\">" 380 "</chart_preference>",
405 g_list_free (find->
keys);
423 g_debug (
"%s found key %s for value %s\n",
424 __FUNCTION__, key,
value);
425 data->
keys = g_list_append (data->
keys, key);
440 filter_exists (openvas_connection_t *connection,
const char *filt_id)
445 || strcmp (filt_id,
"0")
446 || strcmp (filt_id,
"-2"))
450 if (openvas_connection_sendf (connection,
"<get_filters filter_id='%s'/>",
456 if (read_entity_c (connection, &entity))
461 return omp_success (entity);
475 xsl_transform_omp (openvas_connection_t *connection,
486 const char *refresh_interval, *xml_flag;
489 assert (credentials);
494 string = g_string_new (
"");
496 gettimeofday (&tv, NULL);
497 res = g_markup_printf_escaped (
"<envelope>" 498 "<version>%s</version>" 499 "<vendor_version>%s</vendor_version>" 501 "<caller>%s</caller>" 502 "<current_page>%s</current_page>" 504 "<timezone>%s</timezone>" 507 "<severity>%s</severity>" 509 "<charts>%d</charts>" 511 "<client_address>%s</client_address>" 512 "<backend_operation>%.2f</backend_operation>",
538 g_string_append (
string, res);
541 g_string_append (
string,
"<chart_preferences>");
543 (GTraverseFunc)print_chart_pref,
545 g_string_append (
string,
"</chart_preferences>");
550 warning_elem = g_markup_printf_escaped (
"<password_warning>" 552 "</password_warning>",
554 g_string_append (
string, warning_elem);
555 g_free (warning_elem);
559 if ((refresh_interval == NULL) || (strcmp (refresh_interval,
"") == 0))
560 g_string_append_printf (
string,
561 "<autorefresh interval=\"%s\"/>",
566 gchar *interval_64, *response;
569 interval_64 = (refresh_interval
570 ? g_base64_encode ((guchar*) refresh_interval,
571 strlen (refresh_interval))
573 ret = ompf (connection, credentials, &response, &entity, response_data,
575 " setting_id=\"578a1c14-e2dc-45ef-a591-89d31391d007\">" 579 g_free (interval_64);
588 "Internal error", __FUNCTION__, __LINE__,
589 "An internal error occurred while modifying the" 590 " autorefresh setting for the settings. " 591 "Diagnostics: Failure to send command to" 593 "/omp?cmd=get_my_settings", response_data);
597 "Internal error", __FUNCTION__, __LINE__,
598 "An internal error occurred while modifying the" 599 " autorefresh setting for the settings. " 600 "Diagnostics: Failure to receive response from" 602 "/omp?cmd=get_my_settings", response_data);
606 "Internal error", __FUNCTION__, __LINE__,
607 "An internal error occurred while modifying the" 608 " autorefresh setting for the settings. " 609 "Diagnostics: Internal Error.",
610 "/omp?cmd=get_my_settings", response_data);
613 free_entity (entity);
615 credentials->
autorefresh = g_strdup (refresh_interval);
618 g_string_append_printf (
string,
619 "<autorefresh interval=\"%s\"/>",
623 g_string_append (
string,
"<params>");
627 if (name && strcmp (name,
""))
629 if ((name[strlen (name) - 1] ==
':') &&
param->
values)
638 if (child_param->
value 639 && child_param->
valid 641 xml_string_append (
string,
643 "<name>%s%s</name><value>%s</value>" 645 name, child_name, child_param->
value);
649 && strcmp (name,
"xml_file") && strcmp (name,
"installer"))
650 xml_string_append (
string,
"<%s>%s</%s>", name,
param->
value, name);
653 g_warning (
"%s: Param without name found", __FUNCTION__);
655 g_string_append (
string,
"</params>");
657 g_string_append_printf (
string,
658 "<capabilities>%s</capabilities>" 666 if (xml_flag && strcmp (xml_flag,
"0"))
667 return g_string_free (
string, FALSE);
670 g_string_free (
string, TRUE);
674 res = g_strdup_printf (
"<gsad_response>" 675 "<title>Internal Error</title>" 677 "An internal server error has occurred during XSL" 680 "<backurl>/omp?cmd=get_tasks</backurl>" 684 html = g_strdup (
"<html>" 686 "An internal server error has occurred during XSL" 704 member (
params_t *params,
const char *
string)
712 if (strcmp (name,
string) == 0)
return 1;
735 && strcmp (name,
string) == 0)
755 openvas_connection_t *connection,
params_t *params,
756 const char* next,
const char* fail_next,
int* success,
761 const char *no_redirect, *status_text;
772 if (read_entity_c (connection, &entity))
776 "Internal error", __FUNCTION__, __LINE__,
777 "An internal error occurred while saving a config. " 778 "It is unclear whether the entire config has been saved. " 779 "Diagnostics: Failure to read command to manager daemon.",
780 "/omp?cmd=get_configs", response_data);
785 status_text = entity_attribute (entity,
"status_text");
786 if (status_text == NULL)
788 free_entity (entity);
791 "Internal error", __FUNCTION__, __LINE__,
792 "An internal error occurred while saving a config. " 793 "It is unclear whether the entire config has been saved. " 794 "Diagnostics: Failure to parse status_text from response.",
795 "/omp?cmd=get_configs", response_data);
798 if (strcmp (status_text,
"Config is in use") == 0)
800 const char* message =
"The config is now in use by a task," 801 " so only name and comment can be modified.";
802 gchar *next_url = next_page_url (credentials, params,
805 entity_attribute (entity,
"status"),
810 = action_result_page (connection, credentials, params, response_data,
812 entity_attribute (entity,
"status"),
813 message, NULL, next_url);
816 free_entity (entity);
819 else if (strcmp (status_text,
"MODIFY_CONFIG name must be unique") == 0)
821 const char* message =
"A config with the given name exists already.";
822 gchar *next_url = next_page_url (credentials, params,
825 entity_attribute (entity,
"status"),
830 = action_result_page (connection, credentials, params, response_data,
832 entity_attribute (entity,
"status"),
833 message, NULL, next_url);
836 free_entity (entity);
839 else if (success && omp_success (entity))
845 = response_from_entity (connection, credentials, params, entity,
846 (no_redirect && strcmp (no_redirect,
"0")),
849 "Save Config", response_data);
850 free_entity (entity);
863 omp_success (entity_t entity)
870 status = entity_attribute (entity,
"status");
872 || (strlen (status) == 0))
875 return status[0] ==
'2';
890 else if (strcmp (entity_attribute (entity,
"status_text"),
894 else if (strcmp (entity_attribute (entity,
"status"),
"404") == 0)
914 omp (openvas_connection_t *connection,
credentials_t *credentials,
915 gchar **response, entity_t *entity_return,
922 *entity_return = NULL;
924 ret = openvas_connection_sendf (connection,
"%s", command);
931 if (read_entity_and_text_c (connection, &entity, response))
936 *entity_return = entity;
938 free_entity (entity);
957 simple_ompf (openvas_connection_t *connection,
const gchar *message_operation,
966 va_start (args, format);
967 command = g_markup_vprintf_escaped (format, args);
970 ret = omp (connection, credentials, response, &entity, response_data,
986 message = g_strdup_printf
987 (
"An internal error occurred while %s. " 988 " The operation was not started." 989 " Diagnostics: Failure to send command to manager" 993 :
"performing an operation");
994 *response =
gsad_message (credentials,
"Internal error",
995 __FUNCTION__, __LINE__,
996 message,
"/omp?cmd=get_tasks",
1007 message = g_strdup_printf
1008 (
"An internal error occurred while %s." 1009 " It is unclear whether the operation succeeded." 1010 " Diagnostics: Failure to receive response from manager" 1014 :
"performing an operation");
1015 *response =
gsad_message (credentials,
"Internal error",
1016 __FUNCTION__, __LINE__,
1017 message,
"/omp?cmd=get_tasks",
1028 message = g_strdup_printf
1029 (
"An internal error occurred while %s." 1030 " It is unclear whether the operation succeeded." 1031 " Diagnostics: Internal Error.",
1034 :
"performing an operation");
1035 *response =
gsad_message (credentials,
"Internal error",
1036 __FUNCTION__, __LINE__,
1037 message,
"/omp?cmd=get_tasks",
1044 switch (omp_success (entity))
1057 free_entity (entity);
1076 ompf (openvas_connection_t* connection,
credentials_t *credentials,
1077 gchar **response, entity_t *entity_return,
1084 va_start (args, format);
1085 command = g_markup_vprintf_escaped (format, args);
1088 ret = omp (connection, credentials, response, entity_return, response_data,
1105 setting_get_value (openvas_connection_t *connection,
const char *setting_id,
1115 ret = openvas_connection_sendf (connection,
1116 "<get_settings setting_id=\"%s\"/>",
1122 if (read_entity_and_text_c (connection, &entity, &response))
1125 status = entity_attribute (entity,
"status");
1127 || strlen (status) == 0)
1130 free_entity (entity);
1134 if (status[0] ==
'2')
1137 setting = entity_child (entity,
"setting");
1138 if (setting == NULL)
1140 free_entity (entity);
1144 setting = entity_child (setting,
"value");
1145 if (setting == NULL)
1147 free_entity (entity);
1151 *value = g_strdup (entity_text (setting));
1153 free_entity (entity);
1159 free_entity (entity);
1174 #define CHECK_PARAM(name, op_name, ret_func) \ 1177 gchar *msg, *ret_html; \ 1178 msg = g_strdup_printf (GSAD_MESSAGE_INVALID, \ 1179 "Given " G_STRINGIFY (name) " was invalid", \ 1181 ret_html = ret_func (connection, credentials, params, msg, \ 1184 response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \ 1195 #define CHECK_PARAM_INVALID(name, op_name, next_cmd) \ 1198 return message_invalid (connection, credentials, params, response_data, \ 1199 "Given " G_STRINGIFY (name) " was invalid", \ 1200 G_STRINGIFY (MHD_HTTP_BAD_REQUEST), \ 1201 op_name, next_cmd); \ 1219 url = g_string_new (
"");
1221 if (credentials->
caller && strlen (credentials->
caller))
1223 gchar **split_question, *page, *params;
1225 split_question = g_strsplit (credentials->
caller,
"?", 2);
1227 page = *split_question;
1231 g_string_append_printf (url,
"%s?cmd=%s", page, cmd);
1232 params = split_question[1];
1236 g_string_append_printf (url,
"cmd=%s", cmd);
1237 params = credentials->
caller;
1241 gchar **split_amp, **point;
1243 point = split_amp = g_strsplit (params,
"&", 0);
1258 g_string_append_printf (url,
"&%s",
param);
1262 g_strfreev (split_amp);
1264 g_strfreev (split_question);
1267 g_string_append_printf (url,
"?cmd=%s", cmd);
1269 return g_string_free (url, FALSE);
1280 capitalize (
const char* input)
1287 int first_letter = 1;
1289 output = g_strdup (input);
1293 if (g_ascii_isalpha (output[pos]) && first_letter)
1295 output[pos] = g_ascii_toupper (output[pos]);
1298 else if (output[pos] ==
'_')
1327 const char* override_next,
const char *default_next,
1328 const char* prev_action,
const char* action_status,
1329 const char* action_message)
1332 const char *next_cmd, *xml_param, *next_xml_param;
1337 if (action_status && strcmp (action_status,
"") && action_status[0] !=
'2')
1342 url = g_string_new (
"/omp?cmd=");
1345 next_cmd = override_next;
1350 else if (default_next)
1351 next_cmd = default_next;
1353 next_cmd =
"get_tasks";
1358 g_string_append (url, next_cmd);
1363 if (strcmp (param_name,
"asset_type") == 0
1364 || strcmp (param_name,
"filter") == 0
1365 || strcmp (param_name,
"filt_id") == 0
1366 || (strstr (param_name,
"_id")
1367 == param_name + strlen (param_name) - strlen (
"_id"))
1368 || (strcmp (param_name,
"name") == 0
1369 && strcasecmp (prev_action,
"Run Wizard") == 0)
1370 || (strcmp (param_name,
"get_name") == 0
1371 && strcasecmp (next_cmd,
"wizard_get") == 0))
1373 g_string_append_printf (url,
"&%s=%s",
1375 current_param->
value 1376 ? current_param->
value 1383 g_string_append_printf (url,
"&xml=%s", next_xml_param);
1387 g_string_append_printf (url,
"&xml=%s", xml_param);
1392 gchar *escaped = g_uri_escape_string (action_status, NULL, FALSE);
1393 g_string_append_printf (url,
"&action_status=%s", escaped);
1399 gchar *escaped = g_uri_escape_string (action_message, NULL, FALSE);
1400 g_string_append_printf (url,
"&action_message=%s", escaped);
1406 gchar *escaped = g_uri_escape_string (prev_action, NULL, FALSE);
1407 g_string_append_printf (url,
"&prev_action=%s", escaped);
1412 g_string_append_printf (url,
"&token=%s", credentials->
token);
1414 return g_string_free (url, FALSE);
1433 action_result_page (openvas_connection_t *connection,
1436 const char* action,
const char* status,
1437 const char* message,
const char* details,
1438 const char* next_url)
1441 xml = g_markup_printf_escaped (
"<action_result>" 1442 "<action>%s</action>" 1443 "<status>%s</status>" 1444 "<message>%s</message>" 1445 "<details>%s</details>" 1448 action ? action :
"",
1449 status ? status :
"",
1450 message ? message :
"",
1451 details ? details :
"",
1452 next_url ? next_url :
"");
1453 return xsl_transform_omp (connection, credentials, params, xml,
1474 const char *message,
const char *status,
1475 const char *op_name,
const char *next_cmd)
1480 next_url = next_page_url (credentials, params, next_cmd, NULL, op_name,
1482 ret = action_result_page (connection, credentials, params, response_data,
1483 op_name, G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
1497 response_from_entity (openvas_connection_t *connection,
1499 entity_t entity,
int no_redirect,
1500 const char* override_next,
const char *default_next,
1501 const char* override_fail_next,
1502 const char* default_fail_next,
1505 gchar *res, *next_url;
1506 entity_t status_details_entity;
1507 const char *status_details;
1509 success = omp_success (entity);
1513 next_url = next_page_url (credentials, params,
1514 override_next, default_next,
1516 entity_attribute (entity,
"status"),
1517 entity_attribute (entity,
"status_text"));
1522 next_url = next_page_url (credentials, params,
1523 override_fail_next, default_fail_next,
1525 entity_attribute (entity,
"status"),
1526 entity_attribute (entity,
"status_text"));
1529 status_details_entity = entity_child (entity,
"status_details");
1530 if (status_details_entity)
1532 status_details = status_details_entity->text;
1536 status_details = NULL;
1539 if (no_redirect || success == 0)
1541 res = action_result_page (connection, credentials, params, response_data,
1542 action, entity_attribute (entity,
"status"),
1543 entity_attribute (entity,
"status_text"),
1544 status_details, next_url);
1550 response_data->
redirect = next_url;
1568 generate_page (openvas_connection_t *connection,
credentials_t *credentials,
1569 params_t *params, gchar *response,
const gchar *next,
1572 credentials->
current_page = page_url (credentials, next);
1573 if (g_utf8_validate (credentials->
current_page, -1, NULL) == FALSE)
1576 g_warning (
"%s - current_page is not valid UTF-8", __FUNCTION__);
1580 if (strcmp (next,
"edit_role") == 0)
1581 return edit_role (connection, credentials, params, response, response_data);
1583 if (strcmp (next,
"edit_task") == 0)
1584 return edit_task (connection, credentials, params, response, response_data);
1586 if (strcmp (next,
"get_alerts") == 0)
1587 return get_alerts (connection, credentials, params, response,
1590 if (strcmp (next,
"get_alert") == 0)
1591 return get_alert (connection, credentials, params, response, response_data);
1593 if (strcmp (next,
"edit_port_list") == 0)
1594 return edit_port_list (connection, credentials, params, response,
1597 if (strcmp (next,
"get_agents") == 0)
1598 return get_agents (connection, credentials, params, response,
1601 if (strcmp (next,
"get_agent") == 0)
1602 return get_agent (connection, credentials, params, response, response_data);
1604 if (strcmp (next,
"get_asset") == 0)
1605 return get_asset (connection, credentials, params, response, response_data);
1607 if (strcmp (next,
"get_assets") == 0)
1608 return get_assets (connection, credentials, params, response,
1611 if (strcmp (next,
"get_assets_chart") == 0)
1612 return get_assets_chart (connection, credentials, params, response,
1615 if (strcmp (next,
"get_config") == 0)
1616 return get_config (connection, credentials, params, response, 0,
1619 if (strcmp (next,
"get_configs") == 0)
1620 return get_configs (connection, credentials, params, response,
1623 if (strcmp (next,
"get_filter") == 0)
1624 return get_filter (connection, credentials, params, response,
1627 if (strcmp (next,
"get_filters") == 0)
1628 return get_filters (connection, credentials, params, response,
1631 if (strcmp (next,
"get_group") == 0)
1632 return get_group (connection, credentials, params, response, response_data);
1634 if (strcmp (next,
"get_groups") == 0)
1635 return get_groups (connection, credentials, params, response,
1638 if (strcmp (next,
"get_credential") == 0)
1639 return get_credential (connection, credentials, params, response,
1642 if (strcmp (next,
"get_credentials") == 0)
1643 return get_credentials (connection, credentials, params, response,
1646 if (strcmp (next,
"get_note") == 0)
1647 return get_note (connection, credentials, params, response, response_data);
1649 if (strcmp (next,
"get_notes") == 0)
1650 return get_notes (connection, credentials, params, response, response_data);
1652 if (strcmp (next,
"get_nvts") == 0)
1653 return get_nvts (connection, credentials, params, NULL, response,
1656 if (strcmp (next,
"get_override") == 0)
1657 return get_override (connection, credentials, params, response,
1660 if (strcmp (next,
"get_overrides") == 0)
1661 return get_overrides (connection, credentials, params, response,
1664 if (strcmp (next,
"get_permission") == 0)
1665 return get_permission (connection, credentials, params, response,
1668 if (strcmp (next,
"get_permissions") == 0)
1669 return get_permissions (connection, credentials, params, response,
1672 if (strcmp (next,
"get_port_list") == 0)
1673 return get_port_list (connection, credentials, params, response,
1676 if (strcmp (next,
"get_port_lists") == 0)
1677 return get_port_lists (connection, credentials, params, response,
1680 if (strcmp (next,
"get_tag") == 0)
1681 return get_tag (connection, credentials, params, response, response_data);
1683 if (strcmp (next,
"get_tags") == 0)
1684 return get_tags (connection, credentials, params, response, response_data);
1686 if (strcmp (next,
"get_target") == 0)
1687 return get_target (connection, credentials, params, response,
1690 if (strcmp (next,
"get_targets") == 0)
1691 return get_targets (connection, credentials, params, response,
1694 if (strcmp (next,
"get_task") == 0)
1695 return get_task (connection, credentials, params, response, response_data);
1697 if (strcmp (next,
"get_tasks") == 0)
1698 return get_tasks (connection, credentials, params, response,
1701 if (strcmp (next,
"get_tasks_chart") == 0)
1702 return get_tasks_chart (connection, credentials, params, response,
1705 if (strcmp (next,
"get_report") == 0)
1710 result = get_report (connection, credentials, params, NULL, NULL, NULL,
1711 NULL, response, &error, response_data);
1713 return error ? result : xsl_transform_omp (connection, credentials,
1718 if (strcmp (next,
"get_report_format") == 0)
1719 return get_report_format (connection, credentials, params, response,
1722 if (strcmp (next,
"get_report_formats") == 0)
1723 return get_report_formats (connection, credentials, params, response,
1726 if (strcmp (next,
"get_report_section") == 0)
1727 return get_report_section (connection, credentials, params, response,
1730 if (strcmp (next,
"get_reports") == 0)
1731 return get_reports (connection, credentials, params, response,
1734 if (strcmp (next,
"get_results") == 0)
1735 return get_results (connection, credentials, params, response,
1738 if (strcmp (next,
"get_result") == 0)
1739 return get_result_page (connection, credentials, params, response,
1742 if (strcmp (next,
"get_role") == 0)
1743 return get_role (connection, credentials, params, response, response_data);
1745 if (strcmp (next,
"get_roles") == 0)
1746 return get_roles (connection, credentials, params, response, response_data);
1748 if (strcmp (next,
"get_scanner") == 0)
1749 return get_scanner (connection, credentials, params, response,
1752 if (strcmp (next,
"get_scanners") == 0)
1753 return get_scanners (connection, credentials, params, response,
1756 if (strcmp (next,
"get_schedule") == 0)
1757 return get_schedule (connection, credentials, params, response,
1760 if (strcmp (next,
"get_schedules") == 0)
1761 return get_schedules (connection, credentials, params, response,
1764 if (strcmp (next,
"get_user") == 0)
1765 return get_user (connection, credentials, params, response, response_data);
1767 if (strcmp (next,
"get_users") == 0)
1768 return get_users (connection, credentials, params, response, response_data);
1770 if (strcmp (next,
"get_info") == 0)
1771 return get_info (connection, credentials, params, response, response_data);
1773 if (strcmp (next,
"wizard") == 0)
1774 return wizard (connection, credentials, params, response, response_data);
1776 if (strcmp (next,
"wizard_get") == 0)
1777 return wizard_get (connection, credentials, params, response,
1795 next_page (openvas_connection_t *connection,
credentials_t *credentials,
1805 return generate_page (connection, credentials, params, response, next,
1823 get_one (openvas_connection_t *connection,
const char *type,
1825 const char *extra_xml,
const char *extra_attribs,
1830 gchar *end, *id_name;
1831 const char *id, *sort_field, *sort_order, *filter, *first, *max;
1833 id_name = g_strdup_printf (
"%s_id", type);
1843 "Internal error", __FUNCTION__, __LINE__,
1844 "An internal error occurred while getting a resource. " 1845 "Diagnostics: missing ID.",
1846 "/omp?cmd=get_tasks", response_data);
1849 xml = g_string_new (
"");
1850 g_string_append_printf (xml,
"<get_%s>", type);
1852 if (strcmp (type,
"role") == 0
1861 switch (ompf (connection, credentials, &response, &entity, response_data,
1863 " filter=\"rows=-1 subject_type=role and subject_uuid=%s\"/>",
1872 "Internal error", __FUNCTION__, __LINE__,
1873 "An internal error occurred getting permissions. " 1874 "Diagnostics: Failure to send command to manager daemon.",
1875 "/omp?cmd=get_roles", response_data);
1879 "Internal error", __FUNCTION__, __LINE__,
1880 "An internal error occurred getting permissions. " 1881 "Diagnostics: Failure to receive response from manager daemon.",
1882 "/omp?cmd=get_roles", response_data);
1886 "Internal error", __FUNCTION__, __LINE__,
1887 "An internal error occurred getting permissins. " 1888 "Diagnostics: Internal Error.",
1889 "/omp?cmd=get_roles", response_data);
1892 g_string_append (xml, response);
1894 if (!omp_success (entity))
1897 free_entity (entity);
1905 end = g_markup_printf_escaped (
"<filters><term>%s</term></filters>" 1906 "<%ss start=\"%s\" max=\"%s\"/>",
1907 filter ? filter :
"",
1911 g_string_append (xml, end);
1915 g_string_append (xml, extra_xml);
1919 if (openvas_connection_sendf (connection,
1922 " sort_field=\"%s\"" 1923 " sort_order=\"%s\"" 1929 sort_field ? sort_field :
"name",
1930 sort_order ? sort_order :
"ascending",
1931 extra_attribs ? extra_attribs :
"")
1934 g_string_free (xml, TRUE);
1937 "Internal error", __FUNCTION__, __LINE__,
1938 "An internal error occurred while getting resources list. " 1939 "The current list of resources is not available. " 1940 "Diagnostics: Failure to send command to manager daemon.",
1941 "/omp?cmd=get_resources", response_data);
1944 if (read_string_c (connection, &xml))
1946 g_string_free (xml, TRUE);
1949 "Internal error", __FUNCTION__, __LINE__,
1950 "An internal error occurred while getting resources list. " 1951 "The current list of resources is not available. " 1952 "Diagnostics: Failure to receive response from manager daemon.",
1953 "/omp?cmd=get_resources", response_data);
1958 if (openvas_connection_sendf (connection,
1960 " filter=\"resource_type=%s" 1968 g_string_free (xml, TRUE);
1971 "Internal error", __FUNCTION__, __LINE__,
1972 "An internal error occurred while getting tag names list. " 1973 "The current list of resources is not available. " 1974 "Diagnostics: Failure to send command to manager daemon.",
1975 "/omp?cmd=get_resources", response_data);
1978 if (read_string_c (connection, &xml))
1980 g_string_free (xml, TRUE);
1983 "Internal error", __FUNCTION__, __LINE__,
1984 "An internal error occurred while getting tag names list. " 1985 "The current list of resources is not available. " 1986 "Diagnostics: Failure to receive response from manager daemon.",
1987 "/omp?cmd=get_resources", response_data);
1992 g_string_append (xml,
"<permissions>");
1994 if ((strcmp (type,
"user") == 0)
1995 || (strcmp (type,
"group") == 0)
1996 || (strcmp (type,
"role") == 0))
1997 ret = openvas_connection_sendf (connection,
1999 " filter=\"subject_uuid=%s" 2000 " and not resource_uuid=""" 2001 " or resource_uuid=%s" 2002 " first=1 rows=-1\"/>",
2006 ret = openvas_connection_sendf (connection,
2008 " filter=\"resource_uuid=%s" 2009 " first=1 rows=-1\"/>",
2013 g_string_free (xml, TRUE);
2016 "Internal error", __FUNCTION__, __LINE__,
2017 "An internal error occurred while getting permissions list. " 2018 "The current list of resources is not available. " 2019 "Diagnostics: Failure to send command to manager daemon.",
2020 "/omp?cmd=get_resources", response_data);
2023 if (read_string_c (connection, &xml))
2025 g_string_free (xml, TRUE);
2028 "Internal error", __FUNCTION__, __LINE__,
2029 "An internal error occurred while getting permissions list. " 2030 "The current list of resources is not available. " 2031 "Diagnostics: Failure to receive response from manager daemon.",
2032 "/omp?cmd=get_resources", response_data);
2035 g_string_append (xml,
"</permissions>");
2039 g_string_append_printf (xml,
"</get_%s>", type);
2040 return xsl_transform_omp (connection, credentials, params,
2041 g_string_free (xml, FALSE), response_data);
2058 get_many (openvas_connection_t *connection,
const char *type,
2060 const char *extra_xml,
const char *extra_attribs,
2065 gchar *filter_type, *request, *built_filter;
2066 int no_filter_history;
2067 const char *build_filter, *given_filt_id, *filt_id, *filter, *filter_extra;
2068 const char *first, *max, *sort_field, *sort_order, *owner, *permission;
2069 const char *replace_task_id;
2070 const char *overrides, *autofp, *autofp_value, *min_qod;
2071 const char *level_high, *level_medium, *level_low, *level_log;
2072 const char *level_false_positive;
2074 no_filter_history =
params_value(params,
"no_filter_history")
2083 replace_task_id =
params_value (params,
"replace_task_id");
2096 level_false_positive =
params_value (params,
"level_false_positive");
2098 if (strcasecmp (type,
"info") == 0)
2099 filter_type = g_strdup (
params_value (params,
"info_type"));
2101 filter_type = g_strdup (type);
2105 if (no_filter_history == 0
2106 && strcmp (given_filt_id,
"0") && strcmp (given_filt_id,
"-2"))
2108 g_strdup (given_filt_id));
2109 filt_id = given_filt_id;
2113 if (no_filter_history == 0
2114 && (filter == NULL || strcmp (filter,
"") == 0))
2115 filt_id = g_tree_lookup (credentials->
last_filt_ids, filter_type);
2118 g_free (filter_type);
2122 switch (filter_exists (connection, filt_id))
2127 g_debug (
"%s filter doesn't exist anymore %s!\n", __FUNCTION__,
2132 g_debug (
"%s filter response didn't contain a status!\n", __FUNCTION__);
2136 g_debug (
"%s could not send filter request!\n", __FUNCTION__);
2140 g_debug (
"%s could not read entity from filter response!\n",
2148 xml = g_string_new (
"");
2149 type_many = g_string_new (type);
2152 if (strcmp (type,
"info") != 0)
2153 g_string_append (type_many,
"s");
2155 g_string_append_printf (xml,
"<get_%s>", type_many->str);
2158 g_string_append (xml, extra_xml);
2160 built_filter = NULL;
2162 || (strcmp (filt_id,
"") == 0)
2163 || (strcmp (filt_id,
"--") == 0))
2165 if ((build_filter && (strcmp (build_filter,
"1") == 0))
2166 || ((filter == NULL || strcmp (filter,
"") == 0)
2167 && (filter_extra == NULL || strcmp (filter_extra,
"") == 0)))
2169 if (build_filter && (strcmp (build_filter,
"1") == 0))
2172 const char *search_phrase, *task_id;
2174 if (strcmp (type,
"report") == 0
2175 || strcmp (type,
"task") == 0)
2177 task = g_strdup_printf (
"apply_overrides=%i min_qod=%s ",
2179 && strcmp (overrides,
"0"),
2180 min_qod ? min_qod :
"");
2182 else if (strcmp (type,
"result") == 0)
2185 = g_strdup_printf (
"%s%s%s%s%s",
2186 level_high ?
"h" :
"",
2187 level_medium ?
"m" :
"",
2188 level_low ?
"l" :
"",
2189 level_log ?
"g" :
"",
2190 level_false_positive ?
"f" :
"");
2191 task = g_strdup_printf (
"apply_overrides=%i min_qod=%s" 2192 " autofp=%s levels=%s ",
2194 && strcmp (overrides,
"0")),
2195 min_qod ? min_qod :
"",
2196 (autofp && autofp_value)
2197 ? autofp_value :
"0",
2204 search_phrase =
params_value (params,
"search_phrase");
2206 built_filter = g_strdup_printf
2207 (
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
2209 task_id ?
"task_id=" :
"",
2210 task_id ? task_id :
"",
2212 first ?
"first=" :
"",
2219 ? ((sort_order && strcmp (sort_order,
2224 sort_field ? sort_field :
"",
2225 sort_field ?
" " :
"",
2226 permission ?
"permission=" :
"",
2227 permission ? permission :
"",
2228 permission ?
" " :
"",
2229 owner ?
"owner=" :
"",
2232 (filter && search_phrase) ?
" " :
"",
2233 filter ? filter :
"",
2234 search_phrase ?
" " :
"",
2241 else if (strcmp (type,
"info") == 0
2244 if (strcmp (
params_value (params,
"info_type"),
"cve") == 0)
2245 filter =
"sort-reverse=published rows=-2";
2247 filter =
"sort-reverse=created rows=-2";
2249 else if (strcmp (type,
"user") == 0)
2250 filter =
"sort=roles rows=-2";
2251 else if (strcmp (type,
"report") == 0)
2253 const char *task_id;
2256 built_filter = g_strdup_printf (
"task_id=%s apply_overrides=1" 2257 " rows=-2 sort-reverse=date",
2260 filter =
"apply_overrides=1 rows=-2 sort-reverse=date";
2262 else if (strcmp (type,
"result") == 0)
2265 = g_strdup_printf(
"apply_overrides=%d autofp=%s rows=-2" 2266 " sort-reverse=created",
2268 || strcmp (overrides,
"0")),
2269 (autofp && strcmp (autofp,
"0"))
2273 else if (strcmp (type,
"task"))
2276 filter =
"apply_overrides=1 rows=-2";
2277 if (filt_id && strcmp (filt_id,
""))
2283 else if ((strcmp (filter,
"sort=nvt") == 0)
2284 && ((strcmp (type,
"note") == 0)
2285 || (strcmp (type,
"override") == 0)))
2287 else if ((strcmp (filter,
"apply_overrides=1") == 0)
2288 && (strcmp (type,
"task") == 0))
2291 else if (replace_task_id)
2293 const char *task_id;
2296 built_filter = g_strdup_printf (
"task_id=%s %s",
2298 filter ? filter :
"");
2303 request = g_markup_printf_escaped (
" %sfilt_id=\"%s\"" 2304 " %sfilter=\"%s%s%s%s\"" 2305 " filter_replace=\"%s\"" 2308 " sort_field=\"%s\"" 2309 " sort_order=\"%s\"",
2310 strcmp (type,
"report") ?
"" :
"report_",
2311 filt_id ? filt_id :
"0",
2312 strcmp (type,
"report") ?
"" :
"report_",
2315 : (filter ? filter :
""),
2316 filter_extra ?
" " :
"",
2317 filter_extra ? filter_extra :
"",
2318 filter_extra ?
" " :
"",
2319 replace_task_id ?
"task_id" :
"",
2320 first ? first :
"1",
2322 sort_field ? sort_field :
"name",
2323 sort_order ? sort_order :
"ascending");
2325 g_free (built_filter);
2326 if (openvas_connection_sendf (connection,
2329 strcmp (type,
"report") ?
"" :
" details=\"0\"",
2331 extra_attribs ? extra_attribs :
"")
2335 g_string_free (xml, TRUE);
2336 g_string_free (type_many, TRUE);
2339 "Internal error", __FUNCTION__, __LINE__,
2340 "An internal error occurred while getting a resource list. " 2341 "The current list of resources is not available. " 2342 "Diagnostics: Failure to send command to manager daemon.",
2343 "/omp?cmd=get_tasks", response_data);
2346 if (read_string_c (connection, &xml))
2348 g_string_free (xml, TRUE);
2349 g_string_free (type_many, TRUE);
2352 "Internal error", __FUNCTION__, __LINE__,
2353 "An internal error occurred while getting resources list. " 2354 "The current list of resources is not available. " 2355 "Diagnostics: Failure to receive response from manager daemon.",
2356 "/omp?cmd=get_tasks", response_data);
2365 g_string_append (xml,
"<filters>");
2367 if (openvas_connection_sendf_xml
2370 " filter=\"rows=-1 type=%s or type=\"/>",
2374 g_string_free (xml, TRUE);
2375 g_string_free (type_many, TRUE);
2378 "Internal error", __FUNCTION__, __LINE__,
2379 "An internal error occurred while getting the filter list. " 2380 "The current list of filters is not available. " 2381 "Diagnostics: Failure to send command to manager daemon.",
2382 "/omp?cmd=get_tasks", response_data);
2385 if (read_string_c (connection, &xml))
2387 g_string_free (xml, TRUE);
2388 g_string_free (type_many, TRUE);
2391 "Internal error", __FUNCTION__, __LINE__,
2392 "An internal error occurred while getting the filter list. " 2393 "The current list of filters is not available. " 2394 "Diagnostics: Failure to receive response from manager daemon.",
2395 "/omp?cmd=get_tasks", response_data);
2398 g_string_append (xml,
"</filters>");
2405 if (openvas_connection_sendf_xml
2408 " setting_id=\"20f3034c-e709-11e1-87e7-406186ea4fc5\"/>",
2412 g_string_free (xml, TRUE);
2413 g_string_free (type_many, TRUE);
2416 "Internal error", __FUNCTION__, __LINE__,
2417 "An internal error occurred while getting the filter list. " 2418 "The current list of filters is not available. " 2419 "Diagnostics: Failure to send command to manager daemon.",
2420 "/omp?cmd=get_tasks", response_data);
2423 if (read_string_c (connection, &xml))
2425 g_string_free (xml, TRUE);
2426 g_string_free (type_many, TRUE);
2429 "Internal error", __FUNCTION__, __LINE__,
2430 "An internal error occurred while getting the filter list. " 2431 "The current list of filters is not available. " 2432 "Diagnostics: Failure to receive response from manager daemon.",
2433 "/omp?cmd=get_tasks", response_data);
2442 if (openvas_connection_sendf (connection,
2444 " filter=\"resource_type=%s" 2449 strcmp (type,
"info")
2454 g_string_free (xml, TRUE);
2457 "Internal error", __FUNCTION__, __LINE__,
2458 "An internal error occurred while getting tag names list. " 2459 "The current list of resources is not available. " 2460 "Diagnostics: Failure to send command to manager daemon.",
2461 "/omp?cmd=get_resources", response_data);
2464 if (read_string_c (connection, &xml))
2466 g_string_free (xml, TRUE);
2469 "Internal error", __FUNCTION__, __LINE__,
2470 "An internal error occurred while getting tag names list. " 2471 "The current list of resources is not available. " 2472 "Diagnostics: Failure to receive response from manager daemon.",
2473 "/omp?cmd=get_resources", response_data);
2478 g_string_append_printf (xml,
"</get_%s>", type_many->str);
2479 g_string_free (type_many, TRUE);
2480 return xsl_transform_omp (connection, credentials, params,
2481 g_string_free (xml, FALSE), response_data);
2500 const char *extra_get_attribs,
const char *extra_xml,
2505 const char *resource_id;
2507 id_name = g_strdup_printf (
"%s_id", type);
2511 if (resource_id == NULL)
2515 "Internal error", __FUNCTION__, __LINE__,
2516 "An internal error occurred while editing a resource. " 2517 "The resource remains as it was. " 2518 "Diagnostics: Required ID parameter was NULL.",
2519 "/omp?cmd=get_tasks", response_data);
2522 if (openvas_connection_sendf (connection,
2531 extra_get_attribs ? extra_get_attribs :
"",
2538 "Internal error", __FUNCTION__, __LINE__,
2539 "An internal error occurred while getting a resource. " 2540 "Diagnostics: Failure to send command to manager daemon.",
2541 "/omp?cmd=get_tasks", response_data);
2544 xml = g_string_new (
"");
2546 g_string_append_printf (xml,
"<edit_%s>", type);
2549 g_string_append (xml, extra_xml);
2551 if (read_string_c (connection, &xml))
2553 g_string_free (xml, TRUE);
2556 "Internal error", __FUNCTION__, __LINE__,
2557 "An internal error occurred while getting a resource. " 2558 "Diagnostics: Failure to receive response from manager daemon.",
2559 "/omp?cmd=get_tasks", response_data);
2564 g_string_append_printf (xml,
"</edit_%s>", type);
2565 return xsl_transform_omp (connection, credentials, params,
2566 g_string_free (xml, FALSE), response_data);
2582 const char* type,
const char* uuid,
2583 entity_t resource_entity)
2585 gchar *creation_time, *modification_time, *name, *format_name;
2588 if (resource_entity)
2590 entity_t creation_time_entity, modification_time_entity;
2591 entity_t task_entity, format_entity, format_name_entity, name_entity;
2593 creation_time_entity = entity_child (resource_entity,
2596 if (creation_time_entity)
2597 creation_time = entity_text (creation_time_entity);
2599 creation_time = NULL;
2601 modification_time_entity = entity_child (resource_entity,
2602 "modification_time");
2604 if (modification_time_entity)
2605 modification_time = entity_text (modification_time_entity);
2607 modification_time = NULL;
2609 if (strcasecmp (type,
"report") == 0)
2611 task_entity = entity_child (resource_entity,
"task");
2613 name_entity = entity_child (task_entity,
"name");
2617 format_entity = entity_child (resource_entity,
"report_format");
2620 format_name_entity = entity_child (format_entity,
"name");
2623 format_name_entity = NULL;
2625 if (format_name_entity && strlen (entity_text (format_name_entity)))
2626 format_name = entity_text (format_name_entity);
2632 name_entity = entity_child (resource_entity,
"name");
2637 name = entity_text (name_entity);
2643 creation_time = NULL;
2644 modification_time = NULL;
2649 ret = openvas_export_file_name (fname_format, credentials->
username,
2650 type, uuid, creation_time, modification_time,
2674 char **content_disposition, gsize *content_length,
2679 entity_t resource_entity;
2680 char *content = NULL;
2682 gchar *fname_format, *file_name;
2684 const char *resource_id, *subtype;
2686 *content_length = 0;
2688 xml = g_string_new (
"");
2690 id_name = g_strdup_printf (
"%s_id", type);
2694 if (resource_id == NULL)
2697 return xsl_transform_omp (connection, credentials, params,
2698 g_string_free (xml, FALSE), response_data);
2703 if (openvas_connection_sendf (connection,
2712 subtype ?
" type=\"" :
"",
2713 subtype ? subtype :
"",
2714 subtype ?
"\"" :
"")
2717 g_string_free (xml, TRUE);
2720 "Internal error", __FUNCTION__, __LINE__,
2721 "An internal error occurred while getting a resource. " 2722 "The resource could not be delivered. " 2723 "Diagnostics: Failure to send command to manager daemon.",
2724 "/omp?cmd=get_tasks", response_data);
2728 if (read_entity_and_text_c (connection, &entity, &content))
2730 g_string_free (xml, TRUE);
2733 "Internal error", __FUNCTION__, __LINE__,
2734 "An internal error occurred while getting a resource. " 2735 "The resource could not be delivered. " 2736 "Diagnostics: Failure to receive response from manager daemon.",
2737 "/omp?cmd=get_tasks", response_data);
2740 if (!omp_success (entity))
2743 resource_entity = entity_child (entity, type);
2745 if (resource_entity == NULL)
2748 free_entity (entity);
2749 g_string_free (xml, TRUE);
2752 "Internal error", __FUNCTION__, __LINE__,
2753 "An internal error occurred while getting a resource. " 2754 "The resource could not be delivered. " 2755 "Diagnostics: Failure to receive resource from manager daemon.",
2756 "/omp?cmd=get_tasks", response_data);
2759 ret = setting_get_value (connection,
2760 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2",
2766 free_entity (entity);
2767 g_string_free (xml, TRUE);
2773 "Internal error", __FUNCTION__, __LINE__,
2774 "An internal error occurred while getting a setting. " 2775 "The setting could not be delivered. " 2776 "Diagnostics: Failure to send command to manager daemon.",
2777 "/omp?cmd=get_tasks", response_data);
2781 "Internal error", __FUNCTION__, __LINE__,
2782 "An internal error occurred while getting a setting. " 2783 "The setting could not be delivered. " 2784 "Diagnostics: Failure to receive response from manager daemon.",
2785 "/omp?cmd=get_tasks", response_data);
2789 "Internal error", __FUNCTION__, __LINE__,
2790 "An internal error occurred while getting a setting. " 2791 "The setting could not be delivered. " 2792 "Diagnostics: Internal error.",
2793 "/omp?cmd=get_tasks", response_data);
2797 if (fname_format == NULL)
2799 g_warning (
"%s : File name format setting not found.", __FUNCTION__);
2800 fname_format =
"%T-%U";
2803 file_name =
format_file_name (fname_format, credentials, type, resource_id,
2805 if (file_name == NULL)
2806 file_name = g_strdup_printf (
"%s-%s", type, resource_id);
2809 *content_disposition = g_strdup_printf (
"attachment; filename=\"%s.xml\"",
2811 *content_length = strlen (content);
2812 free_entity (entity);
2814 g_string_free (xml, TRUE);
2832 export_many (openvas_connection_t *connection,
const char *type,
2838 char *content = NULL;
2840 gchar *filter_escaped;
2842 gchar *fname_format, *file_name;
2845 *content_length = 0;
2849 filter_escaped = g_markup_escape_text (filter, -1);
2851 if (strcmp (type,
"info") == 0)
2853 if (openvas_connection_sendf (connection,
2860 filter_escaped ? filter_escaped :
"")
2863 g_free (filter_escaped);
2866 "Internal error", __FUNCTION__, __LINE__,
2867 "An internal error occurred while getting a list. " 2868 "The list could not be delivered. " 2869 "Diagnostics: Failure to send command to manager daemon.",
2870 "/omp?cmd=get_tasks", response_data);
2873 else if (strcmp (type,
"asset") == 0)
2875 if (openvas_connection_sendf (connection,
2882 filter_escaped ? filter_escaped :
"")
2885 g_free (filter_escaped);
2888 "Internal error", __FUNCTION__, __LINE__,
2889 "An internal error occurred while getting a list. " 2890 "The list could not be delivered. " 2891 "Diagnostics: Failure to send command to manager daemon.",
2892 "/omp?cmd=get_tasks", response_data);
2897 if (openvas_connection_sendf (connection,
2903 filter_escaped ? filter_escaped :
"")
2906 g_free (filter_escaped);
2909 "Internal error", __FUNCTION__, __LINE__,
2910 "An internal error occurred while getting a list. " 2911 "The list could not be delivered. " 2912 "Diagnostics: Failure to send command to manager daemon.",
2913 "/omp?cmd=get_tasks", response_data);
2916 g_free (filter_escaped);
2919 if (read_entity_and_text_c (connection, &entity, &content))
2923 "Internal error", __FUNCTION__, __LINE__,
2924 "An internal error occurred while getting a list. " 2925 "The list could not be delivered. " 2926 "Diagnostics: Failure to receive response from manager daemon.",
2927 "/omp?cmd=get_tasks", response_data);
2930 if (!omp_success (entity))
2933 ret = setting_get_value (connection,
2934 "0872a6ed-4f85-48c5-ac3f-a5ef5e006745",
2940 free_entity (entity);
2946 "Internal error", __FUNCTION__, __LINE__,
2947 "An internal error occurred while getting a setting. " 2948 "The setting could not be delivered. " 2949 "Diagnostics: Failure to send command to manager daemon.",
2950 "/omp?cmd=get_tasks", response_data);
2954 "Internal error", __FUNCTION__, __LINE__,
2955 "An internal error occurred while getting a setting. " 2956 "The setting could not be delivered. " 2957 "Diagnostics: Failure to receive response from manager daemon.",
2958 "/omp?cmd=get_tasks", response_data);
2962 "Internal error", __FUNCTION__, __LINE__,
2963 "An internal error occurred while getting a setting. " 2964 "The setting could not be delivered. " 2965 "Diagnostics: Internal error.",
2966 "/omp?cmd=get_tasks", response_data);
2970 if (fname_format == NULL)
2972 g_warning (
"%s : File name format setting not found.", __FUNCTION__);
2973 fname_format =
"%T-%D";
2976 if (strcmp (type,
"info") == 0)
2977 type_many = g_strdup (type);
2979 type_many = g_strdup_printf (
"%ss", type);
2981 file_name =
format_file_name (fname_format, credentials, type_many,
"list",
2983 if (file_name == NULL)
2984 file_name = g_strdup_printf (
"%s-%s", type_many,
"list");
2989 *content_disposition = g_strdup_printf (
"attachment; filename=\"%s.xml\"",
2991 *content_length = strlen (content);
2992 free_entity (entity);
3015 gchar *html, *response, *id_name, *resource_id, *extra_attribs;
3016 const char *no_redirect, *next_id;
3018 gchar *cap_type, *default_next, *prev_action;
3021 id_name = g_strdup_printf (
"%s_id", type);
3023 resource_id = g_strdup (
params_value (params, id_name));
3029 "Internal error", __FUNCTION__, __LINE__,
3030 "An internal error occurred while deleting a resource. " 3031 "The resource was not deleted. " 3032 "Diagnostics: Required parameter resource_id was NULL.",
3033 "/omp?cmd=get_tasks", response_data);
3051 extra_attribs = NULL;
3054 if (strcmp (type,
"user") == 0)
3056 const char* inheritor_id;
3059 extra_attribs = g_strdup_printf (
"inheritor_id=\"%s\"", inheritor_id);
3064 if (openvas_connection_sendf (connection,
3065 "<delete_%s %s_id=\"%s\" ultimate=\"%i\"%s%s/>",
3070 extra_attribs ?
" " :
"",
3071 extra_attribs ? extra_attribs :
"")
3074 g_free (resource_id);
3075 g_free (extra_attribs);
3078 "Internal error", __FUNCTION__, __LINE__,
3079 "An internal error occurred while deleting a resource. " 3080 "The resource is not deleted. " 3081 "Diagnostics: Failure to send command to manager daemon.",
3082 "/omp?cmd=get_tasks", response_data);
3085 g_free (resource_id);
3086 g_free (extra_attribs);
3089 if (read_entity_and_text_c (connection, &entity, &response))
3093 "Internal error", __FUNCTION__, __LINE__,
3094 "An internal error occurred while deleting a resource. " 3095 "It is unclear whether the resource has been deleted or not. " 3096 "Diagnostics: Failure to read response from manager daemon.",
3097 "/omp?cmd=get_tasks", response_data);
3100 if (!omp_success (entity))
3103 cap_type = capitalize (type);
3104 default_next = g_strdup_printf (
"get_%ss", type);
3105 prev_action = g_strdup_printf (
"Delete %s", cap_type);
3107 html = response_from_entity (connection, credentials, params, entity,
3108 (no_redirect && strcmp (no_redirect,
"0")),
3111 prev_action, response_data);
3114 free_entity (entity);
3116 g_free (default_next);
3117 g_free (prev_action);
3136 params_t *params,
const char *type,
const char *action,
3139 gchar *html, *response, *param_name;
3140 const char *no_redirect, *resource_id;
3141 gchar *cap_action, *cap_type, *get_cmd, *prev_action;
3148 param_name = g_strdup_printf (
"%s_id", type);
3152 if (resource_id == NULL)
3155 message = g_strdup_printf
3156 (
"An internal error occurred while performing an action. " 3157 "The resource remains the same. " 3158 "Diagnostics: Required parameter %s was NULL.",
3160 g_free (param_name);
3163 "Internal error", __FUNCTION__, __LINE__,
3165 "/omp?cmd=get_tasks", response_data);
3169 g_free (param_name);
3173 ret = ompf (connection, credentials, &response, &entity, response_data,
3174 "<%s_%s %s_id=\"%s\"/>",
3187 "Internal error", __FUNCTION__, __LINE__,
3188 "An internal error occurred while performing an action. " 3189 "The resource remains the same. " 3190 "Diagnostics: Failure to send command to manager daemon.",
3191 "/omp?cmd=get_tasks", response_data);
3195 "Internal error", __FUNCTION__, __LINE__,
3196 "An internal error occurred while performing an action. " 3197 "It is unclear whether the resource has been affected. " 3198 "Diagnostics: Failure to receive response from manager daemon.",
3199 "/omp?cmd=get_tasks", response_data);
3203 "Internal error", __FUNCTION__, __LINE__,
3204 "An internal error occurred while performing an action. " 3205 "It is unclear whether the resource has been affected. " 3206 "Diagnostics: Internal Error.",
3207 "/omp?cmd=get_tasks", response_data);
3210 if (!omp_success (entity))
3213 cap_action = capitalize (action);
3214 cap_type = capitalize (type);
3215 get_cmd = g_strdup_printf (
"get_%ss", type);
3216 prev_action = g_strdup_printf (
"%s %s", cap_action, cap_type);
3217 html = response_from_entity (connection, credentials, params, entity,
3218 (no_redirect && strcmp (no_redirect,
"0")),
3221 prev_action, response_data);
3224 free_entity (entity);
3225 g_free (cap_action);
3228 g_free (prev_action);
3286 openvas_connection_t *connection,
3287 const gchar *setting_id,
3291 switch (setting_get_value (connection, setting_id, value, response_data))
3298 "Internal error", __FUNCTION__, __LINE__,
3299 "An internal error occurred while getting a setting. " 3300 "The setting could not be delivered. " 3301 "Diagnostics: Failure to send command to manager daemon.",
3302 "/omp?cmd=get_tasks", response_data);
3306 "Internal error", __FUNCTION__, __LINE__,
3307 "An internal error occurred while getting a setting. " 3308 "The setting could not be delivered. " 3309 "Diagnostics: Failure to receive response from manager daemon.",
3310 "/omp?cmd=get_tasks", response_data);
3314 "Internal error", __FUNCTION__, __LINE__,
3315 "An internal error occurred while getting a setting. " 3316 "The setting could not be delivered. " 3317 "Diagnostics: Internal error.",
3318 "/omp?cmd=get_tasks", response_data);
3330 #define PARAM_OR_SETTING(value, param, setting_id, cleanup) \ 3331 if (params_valid (params, param)) \ 3332 value = g_strdup (params_value (params, param)); \ 3336 message = setting_get_value_error (credentials, connection, setting_id, \ 3337 &value, response_data); \ 3358 new_task (openvas_connection_t *connection,
credentials_t * credentials,
3359 const char *message,
params_t *params,
const char *extra_xml,
3363 int apply_overrides;
3364 const char *alerts, *overrides;
3366 gchar *alert, *schedule, *target;
3367 gchar *openvas_config, *osp_config, *openvas_scanner, *osp_scanner;
3372 apply_overrides = overrides ? strcmp (overrides,
"0") : 0;
3374 ret = setting_get_value (connection,
3375 "f9f5a546-8018-48d0-bef5-5ad4926ea899",
3385 "Internal error", __FUNCTION__, __LINE__,
3386 "An internal error occurred while getting a setting. " 3387 "The setting could not be delivered. " 3388 "Diagnostics: Failure to send command to manager daemon.",
3389 "/omp?cmd=get_tasks", response_data);
3393 "Internal error", __FUNCTION__, __LINE__,
3394 "An internal error occurred while getting a setting. " 3395 "The setting could not be delivered. " 3396 "Diagnostics: Failure to receive response from manager daemon.",
3397 "/omp?cmd=get_tasks", response_data);
3401 "Internal error", __FUNCTION__, __LINE__,
3402 "An internal error occurred while getting a setting. " 3403 "The setting could not be delivered. " 3404 "Diagnostics: Internal error.",
3405 "/omp?cmd=get_tasks", response_data);
3410 "778eedad-5550-4de0-abb6-1320d13b5e18",
3414 "23409203-940a-4b4a-b70c-447475f18323",
3419 "fe7ea321-e3e3-4cc6-9952-da836aae83ce",
3425 "fb19ac4b-614c-424c-b046-0bc32bf1be73",
3429 g_free (openvas_config));
3432 "f7d0f6ed-6f9e-45dc-8bd9-05cced84e80d",
3436 g_free (openvas_config);
3437 g_free (osp_config));
3440 "b20697c9-be0a-4cd4-8b4d-5fe7841ebb03",
3444 g_free (openvas_config);
3445 g_free (osp_config);
3446 g_free (openvas_scanner));
3448 xml = g_string_new (
"<new_task>");
3450 g_string_append_printf (xml,
3451 "<alert_id>%s</alert_id>" 3452 "<config_id>%s</config_id>" 3453 "<osp_config_id>%s</osp_config_id>" 3454 "<scanner_id>%s</scanner_id>" 3455 "<osp_scanner_id>%s</osp_scanner_id>" 3456 "<schedule_id>%s</schedule_id>" 3457 "<target_id>%s</target_id>",
3459 (openvas_config && strlen (openvas_config))
3461 :
"daba56c8-73ec-11df-a475-002264764cea",
3462 osp_config ? osp_config :
"",
3463 openvas_scanner ? openvas_scanner :
"",
3464 osp_scanner ? osp_scanner :
"",
3465 schedule ? schedule :
"",
3466 (target && strlen (target))
3468 :
"b493b7a8-7489-11df-a3ec-002264764cea");
3472 g_free (openvas_config);
3473 g_free (osp_config);
3474 g_free (openvas_scanner);
3475 g_free (osp_scanner);
3478 if (openvas_connection_sendf (connection,
3480 " filter=\"rows=-1 sort=name\"/>")
3483 g_string_free (xml, TRUE);
3486 "Internal error", __FUNCTION__, __LINE__,
3487 "An internal error occurred while getting targets list. " 3488 "The current list of targets is not available. " 3489 "Diagnostics: Failure to send command to manager daemon.",
3490 "/omp?cmd=get_tasks", response_data);
3493 if (read_string_c (connection, &xml))
3495 g_string_free (xml, TRUE);
3498 "Internal error", __FUNCTION__, __LINE__,
3499 "An internal error occurred while getting targets list. " 3500 "The current list of targets is not available. " 3501 "Diagnostics: Failure to receive response from manager daemon.",
3502 "/omp?cmd=get_tasks", response_data);
3506 if (openvas_connection_sendf (connection,
3508 " filter=\"rows=-1 sort=name\"/>")
3511 g_string_free (xml, TRUE);
3514 "Internal error", __FUNCTION__, __LINE__,
3515 "An internal error occurred while getting config list. " 3516 "The current list of configs is not available. " 3517 "Diagnostics: Failure to send command to manager daemon.",
3518 "/omp?cmd=get_tasks", response_data);
3521 if (read_string_c (connection, &xml))
3523 g_string_free (xml, TRUE);
3526 "Internal error", __FUNCTION__, __LINE__,
3527 "An internal error occurred while getting config list. " 3528 "The current list of configs is not available. " 3529 "Diagnostics: Failure to receive response from manager daemon.",
3530 "/omp?cmd=get_tasks", response_data);
3536 if (openvas_connection_sendf (connection,
3538 " filter=\"rows=-1 sort=name\"/>")
3541 g_string_free (xml, TRUE);
3544 "Internal error", __FUNCTION__, __LINE__,
3545 "An internal error occurred while getting alert list. " 3546 "The current list of alerts is not available. " 3547 "Diagnostics: Failure to send command to manager daemon.",
3548 "/omp?cmd=get_tasks", response_data);
3551 if (read_string_c (connection, &xml))
3553 g_string_free (xml, TRUE);
3556 "Internal error", __FUNCTION__, __LINE__,
3557 "An internal error occurred while getting alert list. " 3558 "The current list of alerts is not available. " 3559 "Diagnostics: Failure to receive response from manager daemon.",
3560 "/omp?cmd=get_tasks", response_data);
3567 if (openvas_connection_sendf
3570 " filter=\"rows=-1 sort=name\"/>")
3573 g_string_free (xml, TRUE);
3576 "Internal error", __FUNCTION__, __LINE__,
3577 "An internal error occurred while getting the schedule list. " 3578 "The current list of schedules is not available. " 3579 "Diagnostics: Failure to send command to manager daemon.",
3580 "/omp?cmd=get_tasks", response_data);
3583 if (read_string_c (connection, &xml))
3585 g_string_free (xml, TRUE);
3588 "Internal error", __FUNCTION__, __LINE__,
3589 "An internal error occurred while getting the schedule list. " 3590 "The current list of schedules is not available. " 3591 "Diagnostics: Failure to receive response from manager daemon.",
3592 "/omp?cmd=get_tasks", response_data);
3599 if (openvas_connection_sendf (connection,
3601 " filter=\"rows=-1\"/>")
3604 g_string_free (xml, TRUE);
3607 "Internal error", __FUNCTION__, __LINE__,
3608 "An internal error occurred while getting the" 3610 "The current list of scanners is not available. " 3611 "Diagnostics: Failure to send command to manager" 3613 "/omp?cmd=get_tasks", response_data);
3616 if (read_string_c (connection, &xml))
3618 g_string_free (xml, TRUE);
3621 "Internal error", __FUNCTION__, __LINE__,
3622 "An internal error occurred while getting" 3623 " the scanner list." 3624 "The current list of scanners is not available. " 3625 "Diagnostics: Failure to receive response from" 3627 "/omp?cmd=get_tasks", response_data);
3635 if (openvas_connection_sendf (connection,
3639 g_string_free (xml, TRUE);
3642 "Internal error", __FUNCTION__, __LINE__,
3643 "An internal error occurred while getting group list. " 3644 "The current list of groups is not available. " 3645 "Diagnostics: Failure to send command to manager daemon.",
3646 "/omp?cmd=get_tasks", response_data);
3649 if (read_string_c (connection, &xml))
3651 g_string_free (xml, TRUE);
3654 "Internal error", __FUNCTION__, __LINE__,
3655 "An internal error occurred while getting group list. " 3656 "The current list of groups is not available. " 3657 "Diagnostics: Failure to receive response from manager daemon.",
3658 "/omp?cmd=get_tasks", response_data);
3666 if (openvas_connection_sendf (connection,
3667 "<get_tags names_only=\"1\"" 3668 " filter=\"resource_type=task rows=-1\"/>")
3671 g_string_free (xml, TRUE);
3674 "Internal error", __FUNCTION__, __LINE__,
3675 "An internal error occurred while getting tag list. " 3676 "The current list of tags is not available. " 3677 "Diagnostics: Failure to send command to manager daemon.",
3678 "/omp?cmd=get_tasks", response_data);
3681 if (read_string_c (connection, &xml))
3683 g_string_free (xml, TRUE);
3686 "Internal error", __FUNCTION__, __LINE__,
3687 "An internal error occurred while getting tag list. " 3688 "The current list of tags is not available. " 3689 "Diagnostics: Failure to receive response from manager daemon.",
3690 "/omp?cmd=get_tasks", response_data);
3695 g_string_append (xml, extra_xml);
3698 g_string_append_printf (xml,
3700 "<apply_overrides>%i</apply_overrides>" 3701 "<alerts>%s</alerts>" 3705 alerts ? alerts :
"1");
3707 return xsl_transform_omp (connection, credentials, params,
3708 g_string_free (xml, FALSE), response_data);
3725 return new_task (connection, credentials, NULL, params, NULL, response_data);
3741 new_container_task (openvas_connection_t *connection,
3743 params_t *params,
const char *extra_xml,
3748 xml = g_string_new (
"<new_container_task>");
3751 g_string_append (xml, extra_xml);
3756 g_string_append_printf (xml,
"</new_container_task>");
3758 return xsl_transform_omp (connection, credentials, params,
3759 g_string_free (xml, FALSE), response_data);
3777 return new_container_task (connection, credentials, NULL, params, NULL,
3793 upload_report (openvas_connection_t *connection,
credentials_t *credentials,
3794 params_t *params,
const char *extra_xml,
3799 xml = g_string_new (
"<upload_report>");
3801 g_string_append (xml, extra_xml);
3807 if (simple_ompf (connection,
"getting Tasks", credentials, &response,
3811 " filter=\"target= rows=-1 owner=any permission=any\"/>"))
3813 g_string_free (xml, TRUE);
3817 g_string_append (xml, response);
3820 g_string_append (xml,
"</upload_report>");
3822 return xsl_transform_omp (connection, credentials, params,
3823 g_string_free (xml, FALSE), response_data);
3840 return upload_report (connection, credentials, params, NULL, response_data);
3860 gchar *command, *html, *response;
3861 const char *no_redirect, *cmd, *task_id, *name, *comment, *xml_file;
3862 const char *in_assets;
3871 if (task_id == NULL)
3881 if (strlen (xml_file) == 0)
3884 return message_invalid (connection, credentials, params, response_data,
3886 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
3887 "Create Report",
"new_container_task");
3891 command = g_markup_printf_escaped (
"<create_task>" 3892 "<target id=\"0\"/>" 3894 "<comment>%s</comment>" 3901 gchar **xml_file_array, *xml_file_escaped;
3903 xml_file_array = g_strsplit (xml_file,
"%", -1);
3904 if (xml_file_array != NULL && xml_file_array[0] != NULL)
3905 xml_file_escaped = g_strjoinv (
"%%", xml_file_array);
3907 xml_file_escaped = g_strdup (xml_file);
3908 g_strfreev (xml_file_array);
3911 command = g_strdup_printf (
"<create_report>" 3912 "<in_assets>%s</in_assets>" 3916 in_assets ? in_assets :
"0",
3917 task_id ? task_id :
"0",
3918 xml_file_escaped ? xml_file_escaped :
"");
3921 gchar *name_escaped, *comment_escaped;
3922 name_escaped = name ? g_markup_escape_text (name, -1)
3924 comment_escaped = comment ? g_markup_escape_text (comment, -1)
3926 command = g_strdup_printf (
"<create_report>" 3927 "<in_assets>%s</in_assets>" 3930 "<comment>%s</comment>" 3934 in_assets ? in_assets :
"",
3938 g_free (name_escaped);
3939 g_free (comment_escaped);
3941 g_free (xml_file_escaped);
3944 ret = omp (connection, credentials,
3961 "Internal error", __FUNCTION__, __LINE__,
3962 "An internal error occurred while creating a new report. " 3963 "No new report was created. " 3964 "Diagnostics: Failure to send command to manager daemon.",
3965 "/omp?cmd=get_tasks", response_data);
3969 "Internal error", __FUNCTION__, __LINE__,
3970 "An internal error occurred while creating a new report. " 3971 "It is unclear whether the report has been created or not. " 3972 "Diagnostics: Failure to receive response from manager daemon.",
3973 "/omp?cmd=get_tasks", response_data);
3977 "Internal error", __FUNCTION__, __LINE__,
3978 "An internal error occurred while creating a new report. " 3979 "It is unclear whether the report has been created or not. " 3980 "Diagnostics: Internal Error.",
3981 "/omp?cmd=get_tasks", response_data);
3985 html = response_from_entity (connection, credentials, params, entity,
3986 (no_redirect && strcmp (no_redirect,
"0")),
3989 (cmd && strcmp (cmd,
"import_report"))
3990 ?
"new_container_task" :
"upload_report",
3991 "Import Report", response_data);
3992 free_entity (entity);
4015 #define CHECK(name) \ 4016 CHECK_PARAM_INVALID (name, "Create Task", "new_task") 4035 gchar *command, *html, *response;
4036 const char *no_redirect, *name, *comment;
4044 command = g_markup_printf_escaped (
"<create_task>" 4045 "<target id=\"0\"/>" 4047 "<comment>%s</comment>" 4051 ret = omp (connection, credentials,
4068 "Internal error", __FUNCTION__, __LINE__,
4069 "An internal error occurred while creating a container task. " 4070 "No task was created. " 4071 "Diagnostics: Failure to send command to manager daemon.",
4072 "/omp?cmd=get_tasks", response_data);
4076 "Internal error", __FUNCTION__, __LINE__,
4077 "An internal error occurred while creating a container task. " 4078 "It is unclear whether the task has been created or not. " 4079 "Diagnostics: Failure to receive response from manager daemon.",
4080 "/omp?cmd=get_tasks", response_data);
4084 "Internal error", __FUNCTION__, __LINE__,
4085 "An internal error occurred while creating a container task. " 4086 "It is unclear whether the task has been created or not. " 4087 "Diagnostics: Internal Error.",
4088 "/omp?cmd=get_tasks", response_data);
4091 if (entity_attribute (entity,
"id"))
4092 params_add (params,
"task_id", entity_attribute (entity,
"id"));
4093 html = response_from_entity (connection, credentials, params, entity,
4094 (no_redirect && strcmp (no_redirect,
"0")),
4096 NULL,
"new_container_task",
4097 "Create Container Task", response_data);
4098 free_entity (entity);
4119 gchar *schedule_element, *command;
4120 gchar *response, *html;
4121 const char *no_redirect;
4122 const char *name, *comment, *config_id, *target_id, *scanner_type;
4123 const char *scanner_id, *schedule_id, *schedule_periods;
4124 const char *max_checks, *max_hosts;
4125 const char *in_assets, *hosts_ordering, *alterable, *source_iface;
4126 const char *add_tag, *tag_name, *tag_value, *auto_delete, *auto_delete_data;
4127 const char *apply_overrides, *min_qod;
4128 gchar *name_escaped, *comment_escaped;
4130 GString *alert_element;
4137 hosts_ordering =
params_value (params,
"hosts_ordering");
4139 schedule_periods =
params_value (params,
"schedule_periods");
4143 apply_overrides =
params_value (params,
"apply_overrides");
4148 auto_delete_data =
params_value (params,
"auto_delete_data");
4154 CHECK (scanner_type);
4155 if (!strcmp (scanner_type,
"1"))
4157 hosts_ordering =
"";
4162 else if (!strcmp (scanner_type,
"3"))
4165 hosts_ordering =
"";
4175 CHECK (hosts_ordering);
4177 CHECK (schedule_id);
4180 CHECK (schedule_periods);
4183 schedule_periods =
"0";
4185 if (!strcmp (in_assets,
"1"))
4187 CHECK (apply_overrides);
4194 apply_overrides =
"";
4201 CHECK (source_iface);
4202 CHECK (auto_delete);
4203 CHECK (auto_delete_data);
4213 if (schedule_id == NULL || strcmp (schedule_id,
"0") == 0)
4214 schedule_element = g_strdup (
"");
4216 schedule_element = g_strdup_printf (
"<schedule id=\"%s\"/>", schedule_id);
4218 alert_element = g_string_new (
"");
4233 g_string_append_printf (alert_element,
4234 "<alert id=\"%s\"/>",
4238 name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
4239 comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
4241 command = g_strdup_printf (
"<create_task>" 4242 "<config id=\"%s\"/>" 4243 "<schedule_periods>%s</schedule_periods>" 4245 "<target id=\"%s\"/>" 4246 "<scanner id=\"%s\"/>" 4247 "<hosts_ordering>%s</hosts_ordering>" 4249 "<comment>%s</comment>" 4252 "<scanner_name>max_checks</scanner_name>" 4256 "<scanner_name>max_hosts</scanner_name>" 4260 "<scanner_name>in_assets</scanner_name>" 4265 "assets_apply_overrides" 4270 "<scanner_name>assets_min_qod</scanner_name>" 4274 "<scanner_name>source_iface</scanner_name>" 4278 "<scanner_name>auto_delete</scanner_name>" 4282 "<scanner_name>auto_delete_data</scanner_name>" 4286 "<alterable>%i</alterable>" 4299 strcmp (in_assets,
"0") ?
"yes" :
"no",
4300 strcmp (apply_overrides,
"0") ?
"yes" :
"no",
4305 alterable ? strcmp (alterable,
"0") : 0);
4307 g_free (name_escaped);
4308 g_free (comment_escaped);
4310 ret = omp (connection, credentials,
4317 g_free (schedule_element);
4318 g_string_free (alert_element, TRUE);
4330 "Internal error", __FUNCTION__, __LINE__,
4331 "An internal error occurred while creating a new task. " 4332 "No new task was created. " 4333 "Diagnostics: Failure to send command to manager daemon.",
4334 "/omp?cmd=get_tasks", response_data);
4338 "Internal error", __FUNCTION__, __LINE__,
4339 "An internal error occurred while creating a new task. " 4340 "It is unclear whether the task has been created or not. " 4341 "Diagnostics: Failure to receive response from manager daemon.",
4342 "/omp?cmd=get_tasks", response_data);
4346 "Internal error", __FUNCTION__, __LINE__,
4347 "An internal error occurred while creating a new task. " 4348 "It is unclear whether the task has been created or not. " 4349 "Diagnostics: Internal Error.",
4350 "/omp?cmd=get_tasks", response_data);
4353 if (omp_success (entity))
4355 if (add_tag && strcmp (add_tag,
"0"))
4357 const char *new_task_id = entity_attribute (entity,
"id");
4358 gchar *tag_command, *tag_response;
4359 entity_t tag_entity;
4361 if (tag_value && strcmp (tag_value,
""))
4363 = g_markup_printf_escaped (
"<create_tag>" 4365 "<resource id=\"%s\">" 4375 = g_markup_printf_escaped (
"<create_tag>" 4377 "<resource id=\"%s\">" 4384 ret = omp (connection, credentials,
4396 free_entity (entity);
4399 = MHD_HTTP_INTERNAL_SERVER_ERROR;
4401 "Internal error", __FUNCTION__, __LINE__,
4402 "An internal error occurred while creating a new tag. " 4403 "No new tag was created. " 4404 "Diagnostics: Failure to send command to manager daemon.",
4405 "/omp?cmd=get_tasks", response_data);
4407 free_entity (entity);
4410 = MHD_HTTP_INTERNAL_SERVER_ERROR;
4412 "Internal error", __FUNCTION__, __LINE__,
4413 "An internal error occurred while creating a new tag. " 4414 "It is unclear whether the tag has been created or not. " 4415 "Diagnostics: Failure to receive response from manager daemon.",
4416 "/omp?cmd=get_tasks", response_data);
4418 free_entity (entity);
4421 = MHD_HTTP_INTERNAL_SERVER_ERROR;
4423 "Internal error", __FUNCTION__, __LINE__,
4424 "An internal error occurred while creating a new task. " 4425 "It is unclear whether the tag has been created or not. " 4426 "Diagnostics: Internal Error.",
4427 "/omp?cmd=get_tasks", response_data);
4430 if (entity_attribute (entity,
"id"))
4431 params_add (params,
"task_id", entity_attribute (entity,
"id"));
4433 = response_from_entity (connection, credentials, params, tag_entity,
4434 (no_redirect && strcmp (no_redirect,
"0")),
4437 "Create Task and Tag", response_data);
4438 free_entity (tag_entity);
4439 g_free (tag_response);
4443 if (entity_attribute (entity,
"id"))
4444 params_add (params,
"task_id", entity_attribute (entity,
"id"));
4446 = response_from_entity (connection, credentials, params, entity,
4447 (no_redirect && strcmp (no_redirect,
"0")),
4450 "Create Task", response_data);
4455 html = response_from_entity (connection, credentials, params, entity,
4456 (no_redirect && strcmp (no_redirect,
"0")),
4459 "Create Task", response_data);
4461 free_entity (entity);
4481 return delete_resource (connection,
"task", credentials, params, 0, NULL, response_data);
4496 edit_task (openvas_connection_t *connection,
credentials_t * credentials,
4497 params_t *params,
const char *extra_xml,
4501 const char *task_id, *next, *refresh_interval, *sort_field, *sort_order;
4502 const char *overrides, *alerts;
4503 int apply_overrides;
4507 refresh_interval =
params_value (params,
"refresh_interval");
4513 apply_overrides = overrides ? strcmp (overrides,
"0") : 1;
4515 if (task_id == NULL)
4519 "Internal error", __FUNCTION__, __LINE__,
4520 "An internal error occurred while editing a task. " 4521 "The task remains as it was. " 4522 "Diagnostics: Required parameter was NULL.",
4523 "/omp?cmd=get_tasks", response_data);
4529 if (openvas_connection_sendf (connection,
4531 "<get_tasks task_id=\"%s\" details=\"1\" />" 4533 " filter=\"rows=-1 sort=name\"/>" 4535 " filter=\"rows=-1 sort=name\"/>" 4544 " filter=\"rows=-1 sort=name\"/>" 4548 " filter=\"rows=-1 sort=name\"/>" 4552 " filter=\"rows=-1\"/>" 4561 "Internal error", __FUNCTION__, __LINE__,
4562 "An internal error occurred while getting task info. " 4563 "Diagnostics: Failure to send command to manager daemon.",
4564 "/omp?cmd=get_tasks", response_data);
4567 xml = g_string_new (
"");
4570 g_string_append (xml, extra_xml);
4572 g_string_append_printf (xml,
4576 "<alerts>%s</alerts>" 4580 "<refresh_interval>%s</refresh_interval>" 4581 "<sort_field>%s</sort_field>" 4582 "<sort_order>%s</sort_order>" 4583 "<apply_overrides>%i</apply_overrides>",
4586 alerts ? alerts :
"1",
4588 refresh_interval ? refresh_interval :
"",
4593 if (read_string_c (connection, &xml))
4595 g_string_free (xml, TRUE);
4598 "Internal error", __FUNCTION__, __LINE__,
4599 "An internal error occurred while getting task info. " 4600 "Diagnostics: Failure to receive response from manager daemon.",
4601 "/omp?cmd=get_tasks", response_data);
4606 g_string_append (xml,
"</edit_task>");
4607 return xsl_transform_omp (connection, credentials, params,
4608 g_string_free (xml, FALSE), response_data);
4625 return edit_task (connection, credentials, params, NULL, response_data);
4642 gchar *html, *response, *format;
4643 const char *no_redirect;
4644 const char *comment, *name, *schedule_id, *in_assets;
4645 const char *scanner_id, *task_id, *max_checks, *max_hosts;
4646 const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
4647 const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
4648 const char *apply_overrides, *min_qod;
4651 GString *alert_element;
4659 apply_overrides =
params_value (params,
"apply_overrides");
4663 hosts_ordering =
params_value (params,
"hosts_ordering");
4666 schedule_periods =
params_value (params,
"schedule_periods");
4671 auto_delete_data =
params_value (params,
"auto_delete_data");
4675 if (!strcmp (scanner_type,
"1"))
4677 hosts_ordering =
"";
4682 else if (!strcmp (scanner_type,
"3"))
4685 hosts_ordering =
"";
4699 CHECK (schedule_periods);
4702 schedule_periods =
"0";
4712 if (!strcmp (in_assets,
"1"))
4721 apply_overrides =
"";
4728 alert_element = g_string_new (
"");
4744 g_string_append_printf (alert_element,
4745 "<alert id=\"%s\"/>",
4751 if (strcmp (alert_element->str,
"") == 0)
4752 g_string_append_printf (alert_element,
"<alert id=\"0\"/>");
4754 format = g_strdup_printf (
"<modify_task task_id=\"%%s\">" 4756 "<comment>%%s</comment>" 4757 "<hosts_ordering>%s</hosts_ordering>" 4759 "<target id=\"%%s\"/>" 4760 "<config id=\"%%s\"/>" 4761 "<schedule id=\"%%s\"/>" 4762 "<schedule_periods>%%s</schedule_periods>" 4763 "<scanner id=\"%%s\"/>" 4766 "<scanner_name>max_checks</scanner_name>" 4767 "<value>%%s</value>" 4770 "<scanner_name>max_hosts</scanner_name>" 4771 "<value>%%s</value>" 4774 "<scanner_name>in_assets</scanner_name>" 4775 "<value>%%s</value>" 4778 "<scanner_name>assets_apply_overrides</scanner_name>" 4779 "<value>%%s</value>" 4782 "<scanner_name>assets_min_qod</scanner_name>" 4783 "<value>%%s</value>" 4786 "<scanner_name>source_iface</scanner_name>" 4787 "<value>%%s</value>" 4790 "<scanner_name>auto_delete</scanner_name>" 4791 "<value>%%s</value>" 4794 "<scanner_name>auto_delete_data</scanner_name>" 4795 "<value>%%s</value>" 4802 alterable ?
"<alterable>" :
"",
4803 alterable ? strcmp (alterable,
"0") : 0,
4804 alterable ?
"</alterable>" :
"");
4807 ret = ompf (connection,
4823 strcmp (in_assets,
"0") ?
"yes" :
"no",
4824 strcmp (apply_overrides,
"0") ?
"yes" :
"no",
4831 g_string_free (alert_element, TRUE);
4841 "Internal error", __FUNCTION__, __LINE__,
4842 "An internal error occurred while saving a task. " 4843 "The task was not saved. " 4844 "Diagnostics: Failure to send command to manager daemon.",
4845 "/omp?cmd=get_tasks", response_data);
4849 "Internal error", __FUNCTION__, __LINE__,
4850 "An internal error occurred while saving a task. " 4851 "It is unclear whether the task has been saved or not. " 4852 "Diagnostics: Failure to receive response from manager daemon.",
4853 "/omp?cmd=get_tasks", response_data);
4857 "Internal error", __FUNCTION__, __LINE__,
4858 "An internal error occurred while saving a task. " 4859 "It is unclear whether the task has been saved or not. " 4860 "Diagnostics: Internal Error.",
4861 "/omp?cmd=get_tasks", response_data);
4864 html = response_from_entity (connection, credentials, params, entity,
4865 (no_redirect && strcmp (no_redirect,
"0")),
4868 "Save Task", response_data);
4869 free_entity (entity);
4891 gchar *format, *response, *html;
4892 const char *no_redirect, *comment, *name, *task_id;
4893 const char *in_assets, *auto_delete, *auto_delete_data;
4903 auto_delete_data =
params_value (params,
"auto_delete_data");
4911 format = g_strdup_printf (
"<modify_task task_id=\"%%s\">" 4913 "<comment>%%s</comment>" 4916 "<scanner_name>in_assets</scanner_name>" 4917 "<value>%%s</value>" 4920 "<scanner_name>auto_delete</scanner_name>" 4921 "<value>%%s</value>" 4924 "<scanner_name>auto_delete_data</scanner_name>" 4925 "<value>%%s</value>" 4932 ret = ompf (connection, credentials, &response, &entity, response_data,
4933 format, task_id, name, comment,
4934 strcmp (in_assets,
"0") ?
"yes" :
"no",
4946 "Internal error", __FUNCTION__, __LINE__,
4947 "An internal error occurred while saving a task. " 4948 "No new task was created. " 4949 "Diagnostics: Failure to send command to manager daemon.",
4950 "/omp?cmd=get_tasks", response_data);
4954 "Internal error", __FUNCTION__, __LINE__,
4955 "An internal error occurred while saving a task. " 4956 "It is unclear whether the task has been created or not. " 4957 "Diagnostics: Failure to receive response from manager daemon.",
4958 "/omp?cmd=get_tasks", response_data);
4962 "Internal error", __FUNCTION__, __LINE__,
4963 "An internal error occurred while saving a task. " 4964 "It is unclear whether the task has been created or not. " 4965 "Diagnostics: Internal Error.",
4966 "/omp?cmd=get_tasks", response_data);
4969 html = response_from_entity (connection, credentials, params, entity,
4970 (no_redirect && strcmp (no_redirect,
"0")),
4973 "Save Container Task", response_data);
4974 free_entity (entity);
4995 char **content_disposition, gsize *content_length,
4999 content_disposition, content_length, response_data);
5019 char **content_disposition, gsize *content_length,
5022 return export_many (connection,
"task", credentials, params,
content_type,
5023 content_disposition, content_length, response_data);
5040 return resource_action (connection, credentials, params,
"task",
"stop",
5058 return resource_action (connection, credentials, params,
"task",
"resume",
5076 return resource_action (connection, credentials, params,
"task",
"start",
5094 gchar *command, *response, *html;
5095 const char *no_redirect, *task_id, *slave_id;
5103 command = g_strdup_printf (
"<move_task task_id=\"%s\" slave_id=\"%s\"/>",
5104 task_id ? task_id :
"",
5105 slave_id ? slave_id :
"");
5109 ret = omp (connection, credentials, &response, &entity, response_data,
5122 "Internal error", __FUNCTION__, __LINE__,
5123 "An internal error occurred while moving a task. " 5124 "The task was not moved. " 5125 "Diagnostics: Failure to send command to manager daemon.",
5126 "/omp?cmd=get_tasks", response_data);
5130 "Internal error", __FUNCTION__, __LINE__,
5131 "An internal error occurred while moving a task. " 5132 "It is unclear whether the task has been moved or not. " 5133 "Diagnostics: Failure to receive response from manager daemon.",
5134 "/omp?cmd=get_tasks", response_data);
5138 "Internal error", __FUNCTION__, __LINE__,
5139 "An internal error occurred while moving a task. " 5140 "It is unclear whether the task has been moved or not. " 5141 "Diagnostics: Internal Error.",
5142 "/omp?cmd=get_tasks", response_data);
5145 html = response_from_entity (connection, credentials, params, entity,
5146 (no_redirect && strcmp (no_redirect,
"0")),
5149 "Move Task", response_data);
5151 free_entity (entity);
5169 get_nvts (openvas_connection_t *connection,
credentials_t *credentials,
5170 params_t *params,
const char *commands,
const char *extra_xml,
5173 GString *xml = NULL;
5181 "Internal error", __FUNCTION__, __LINE__,
5182 "An internal error occurred while getting an NVT. " 5183 "Diagnostics: Required parameter was NULL.",
5184 "/omp?cmd=get_tasks", response_data);
5187 if (openvas_connection_sendf (connection,
5193 " preferences=\"1\"/>" 5196 " sort_field=\"notes.text\"/>" 5199 " sort_field=\"overrides.text\"/>" 5201 commands ? commands :
"",
5209 "Internal error", __FUNCTION__, __LINE__,
5210 "An internal error occurred while getting nvt details. " 5211 "Diagnostics: Failure to send command to manager daemon.",
5212 "/omp?cmd=get_tasks", response_data);
5215 xml = g_string_new (
"<get_nvts>");
5216 if (read_string_c (connection, &xml))
5218 g_string_free (xml, TRUE);
5221 "Internal error", __FUNCTION__, __LINE__,
5222 "An internal error occurred while getting nvt details. " 5223 "Diagnostics: Failure to receive response from manager daemon.",
5224 "/omp?cmd=get_tasks", response_data);
5229 g_string_append (xml, extra_xml);
5233 if (openvas_connection_sendf (connection,
5235 " filter=\"resource_type=nvt" 5242 g_string_free (xml, TRUE);
5245 "Internal error", __FUNCTION__, __LINE__,
5246 "An internal error occurred while getting tag names list. " 5247 "The current list of resources is not available. " 5248 "Diagnostics: Failure to send command to manager daemon.",
5249 "/omp?cmd=get_resources", response_data);
5252 if (read_string_c (connection, &xml))
5254 g_string_free (xml, TRUE);
5257 "Internal error", __FUNCTION__, __LINE__,
5258 "An internal error occurred while getting tag names list. " 5259 "The current list of resources is not available. " 5260 "Diagnostics: Failure to receive response from manager daemon.",
5261 "/omp?cmd=get_resources", response_data);
5264 g_string_append (xml,
"</get_nvts>");
5266 return xsl_transform_omp (connection, credentials, params,
5267 g_string_free (xml, FALSE), response_data);
5283 params_t *params,
const char *extra_xml,
5287 GString *extra_attribs, *extra_response;
5288 const char *info_type;
5291 if (info_type == NULL)
5300 if (strcmp (info_type,
"nvt")
5301 && strcmp (info_type,
"cve")
5302 && strcmp (info_type,
"cpe")
5303 && strcmp (info_type,
"ovaldef")
5304 && strcmp (info_type,
"cert_bund_adv")
5305 && strcmp (info_type,
"dfn_cert_adv")
5306 && strcmp (info_type,
"allinfo")
5307 && strcmp (info_type,
"NVT")
5308 && strcmp (info_type,
"CVE")
5309 && strcmp (info_type,
"CPE")
5310 && strcmp (info_type,
"OVALDEF")
5311 && strcmp (info_type,
"CERT_BUND_ADV")
5312 && strcmp (info_type,
"DFN_CERT_ADV")
5313 && strcmp (info_type,
"ALLINFO"))
5317 "Internal error", __FUNCTION__, __LINE__,
5318 "An internal error occurred while getting SecInfo. " 5319 "Diagnostics: Invalid info_type parameter value",
5320 "/omp?cmd=get_info", response_data);
5328 "Internal error", __FUNCTION__, __LINE__,
5329 "An internal error occurred while getting SecInfo. " 5330 "Diagnostics: Both ID and Name set.",
5331 "/omp?cmd=get_info", response_data);
5333 extra_response = g_string_new (extra_xml ? extra_xml :
"");
5336 && (strcasecmp (info_type,
"NVT") == 0)
5341 if (simple_ompf (connection,
"getting SecInfo", credentials, &response,
5345 " sort_field=\"notes.text\"/>",
5348 g_string_free (extra_response, TRUE);
5352 g_string_append (extra_response, response);
5356 && (strcasecmp (info_type,
"NVT") == 0)
5361 if (simple_ompf (connection,
"getting SecInfo", credentials, &response,
5365 " sort_field=\"overrides.text\"/>",
5368 g_string_free (extra_response, TRUE);
5372 g_string_append (extra_response, response);
5375 extra_attribs = g_string_new(
"");
5376 g_string_append_printf (extra_attribs,
"type=\"%s\"",
5379 g_string_append_printf (extra_attribs,
5383 g_string_append_printf (extra_attribs,
5387 g_string_append_printf (extra_attribs,
5390 ret = get_many (connection,
"info", credentials, params, extra_response->str,
5391 extra_attribs->str, response_data);
5393 g_string_free (extra_response, TRUE);
5394 g_string_free (extra_attribs, TRUE);
5414 return get_info (connection, credentials, params, NULL, response_data);
5431 return get_nvts (connection, credentials, params, NULL, NULL, response_data);
5441 params_toggle_overrides (
params_t *params,
const char *overrides)
5443 param_t *filt_id, *build_filter;
5444 const char *new_filt_id;
5446 build_filter =
params_get (params,
"build_filter");
5456 filt_id->
value = g_strdup (new_filt_id);
5464 if (build_filter == NULL)
5468 if (filter && filter->
value)
5471 old = filter->
value;
5472 filter->
value = g_strdup_printf (
"apply_overrides=%s %s",
5477 else if (strcmp (overrides,
"0"))
5479 "apply_overrides=1 rows=-2");
5482 "apply_overrides=0 rows=-2");
5498 get_tasks (openvas_connection_t *connection,
credentials_t *credentials,
5499 params_t *params,
const char *extra_xml,
5502 const char *overrides, *schedules_only, *ignore_pagination;
5503 gchar *extra_attribs, *ret;
5506 schedules_only =
params_value (params,
"schedules_only");
5507 ignore_pagination =
params_value (params,
"ignore_pagination");
5511 params_toggle_overrides (params, overrides);
5513 extra_attribs = g_strdup_printf (
"%s%s%s" 5515 schedules_only ?
"schedules_only=\"" :
"",
5516 schedules_only ? schedules_only :
"",
5517 schedules_only ?
"\" " :
"",
5519 ?
"ignore_pagination=\"" 5521 ignore_pagination ? ignore_pagination :
"",
5522 ignore_pagination ?
"\" " :
"");
5524 ret = get_many (connection,
"task", credentials, params, extra_xml,
5525 extra_attribs, response_data);
5526 g_free (extra_attribs);
5544 return get_tasks (connection, credentials, params, NULL, response_data);
5559 get_tasks_chart (openvas_connection_t *connection,
credentials_t *credentials,
5560 params_t *params,
const char *extra_xml,
5563 return xsl_transform_omp (connection, credentials, params,
5564 g_strdup (
"<get_tasks_chart/>"), response_data);
5582 return get_tasks_chart (connection, credentials, params, NULL, response_data);
5598 get_task (openvas_connection_t *connection,
credentials_t *credentials,
5599 params_t *params,
const char *extra_xml,
5602 GString *xml = NULL;
5603 GString *commands_xml = NULL;
5604 entity_t commands_entity = NULL;
5605 entity_t task_entity = NULL;
5606 int notes, get_overrides, apply_overrides;
5607 int get_target, get_alerts;
5608 const char *overrides, *task_id;
5611 if (task_id == NULL)
5612 return get_tasks (connection, credentials, params, extra_xml,
5616 apply_overrides = overrides ? strcmp (overrides,
"0") : 1;
5620 if (openvas_connection_sendf
5625 " filter=\"apply_overrides=%i\"" 5634 " sort_field=\"notes_nvt_name, notes.text\"" 5637 notes ? task_id :
"",
5638 notes ?
"\"/>" :
"",
5641 " sort_field=\"overrides_nvt_name, overrides.text\"" 5644 get_overrides ? task_id :
"",
5645 get_overrides ?
"\"/>" :
"")
5650 "Internal error", __FUNCTION__, __LINE__,
5651 "An internal error occurred while getting the status. " 5652 "No update on the requested task can be retrieved. " 5653 "Diagnostics: Failure to send command to manager daemon.",
5654 "/omp?cmd=get_tasks", response_data);
5657 commands_xml = g_string_new (
"");
5658 xml = g_string_new (
"<get_task>");
5661 g_string_append (xml, extra_xml);
5663 g_string_append_printf (xml,
5664 "<apply_overrides>%i</apply_overrides>" 5665 "<delta>%s</delta>",
5670 if (read_string_c (connection, &commands_xml))
5672 g_string_free (commands_xml, TRUE);
5673 g_string_free (xml, TRUE);
5676 "Internal error", __FUNCTION__, __LINE__,
5677 "An internal error occurred while getting the status. " 5678 "No update of the status can be retrieved. " 5679 "Diagnostics: Failure to receive response from manager daemon.",
5680 "/omp?cmd=get_tasks", response_data);
5682 g_string_append (xml, commands_xml->str);
5684 if (parse_entity (commands_xml->str, &commands_entity))
5686 g_string_free (commands_xml, TRUE);
5687 g_string_free (xml, TRUE);
5690 "Internal error", __FUNCTION__, __LINE__,
5691 "An internal error occurred while getting the status. " 5692 "No update of the status can be retrieved. " 5693 "Diagnostics: Failure to parse response from manager daemon.",
5694 "/omp?cmd=get_tasks", response_data);
5699 task_entity = entity_child (commands_entity,
"get_tasks_response");
5700 if (task_entity == NULL)
5702 g_warning (
"%s: No get_tasks_response found in manager response.",
5707 task_entity = entity_child (task_entity,
"task");
5708 if (task_entity == NULL)
5709 g_message (
"%s: No task found in manager response.", __FUNCTION__);
5710 else if (get_target || get_alerts)
5712 entities_t child_entities;
5713 entity_t child_entity;
5714 child_entities = task_entity->entities;
5716 while ((child_entity = first_entity (child_entities)))
5719 strcmp (entity_name (child_entity),
"alert") == 0)
5721 const char *resource_id
5722 = entity_attribute (child_entity,
"id");
5724 if (resource_id != NULL && strcmp (resource_id,
""))
5726 if (openvas_connection_sendf (connection,
5728 " alert_id=\"%s\"/>",
5731 g_string_free (xml, TRUE);
5732 g_string_free (commands_xml, TRUE);
5733 free_entity (commands_entity);
5735 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5738 __FUNCTION__, __LINE__,
5739 "An internal error occurred while getting an alert of a task. " 5740 "Diagnostics: Failure to send command to manager daemon.",
5741 "/omp?cmd=get_tasks",
5744 if (read_string_c (connection, &xml))
5746 g_string_free (commands_xml, TRUE);
5747 g_string_free (xml, TRUE);
5748 free_entity (commands_entity);
5750 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5753 __FUNCTION__, __LINE__,
5754 "An internal error occurred while getting an alert of a task. " 5755 "Diagnostics: Failure to receive response from manager daemon.",
5756 "/omp?cmd=get_tasks",
5763 strcmp (entity_name (child_entity),
"target") == 0)
5765 const char *resource_id
5766 = entity_attribute (child_entity,
"id");
5768 if (resource_id != NULL && strcmp (resource_id,
""))
5770 if (openvas_connection_sendf (connection,
5772 " target_id=\"%s\"/>",
5775 g_string_free (xml, TRUE);
5776 g_string_free (commands_xml, TRUE);
5777 free_entity (commands_entity);
5779 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5782 __FUNCTION__, __LINE__,
5783 "An internal error occurred while getting the target of a task. " 5784 "Diagnostics: Failure to send command to manager daemon.",
5785 "/omp?cmd=get_tasks",
5788 if (read_string_c (connection, &xml))
5790 g_string_free (commands_xml, TRUE);
5791 g_string_free (xml, TRUE);
5792 free_entity (commands_entity);
5794 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5797 __FUNCTION__, __LINE__,
5798 "An internal error occurred while getting the target of a task. " 5799 "Diagnostics: Failure to receive response from manager daemon.",
5800 "/omp?cmd=get_tasks",
5806 child_entities = next_entities (child_entities);
5811 g_string_free (commands_xml, TRUE);
5812 free_entity (commands_entity);
5818 if (openvas_connection_sendf (connection,
5820 " filter=\"first=1 rows=-1 type=4\"/>")
5823 g_string_free (xml, TRUE);
5826 "Internal error", __FUNCTION__, __LINE__,
5827 "An internal error occurred while getting slaves list. " 5828 "The current list of resources is not available. " 5829 "Diagnostics: Failure to send command to manager daemon.",
5830 "/omp?cmd=get_tasks", response_data);
5833 if (read_string_c (connection, &xml))
5835 g_string_free (xml, TRUE);
5838 "Internal error", __FUNCTION__, __LINE__,
5839 "An internal error occurred while getting slaves list. " 5840 "The current list of resources is not available. " 5841 "Diagnostics: Failure to receive response from manager daemon.",
5842 "/omp?cmd=get_tasks", response_data);
5848 if (openvas_connection_sendf (connection,
5850 " filter=\"resource_type=task" 5857 g_string_free (xml, TRUE);
5860 "Internal error", __FUNCTION__, __LINE__,
5861 "An internal error occurred while getting tag names list. " 5862 "The current list of resources is not available. " 5863 "Diagnostics: Failure to send command to manager daemon.",
5864 "/omp?cmd=get_resources", response_data);
5867 if (read_string_c (connection, &xml))
5869 g_string_free (xml, TRUE);
5872 "Internal error", __FUNCTION__, __LINE__,
5873 "An internal error occurred while getting tag names list. " 5874 "The current list of resources is not available. " 5875 "Diagnostics: Failure to receive response from manager daemon.",
5876 "/omp?cmd=get_resources", response_data);
5881 g_string_append (xml,
"<permissions>");
5883 if (openvas_connection_sendf (connection,
5885 " filter=\"name:^.*(task)s?$" 5886 " and resource_uuid=%s" 5887 " first=1 rows=-1\"/>",
5891 g_string_free (xml, TRUE);
5894 "Internal error", __FUNCTION__, __LINE__,
5895 "An internal error occurred while getting permissions list. " 5896 "The current list of resources is not available. " 5897 "Diagnostics: Failure to send command to manager daemon.",
5898 "/omp?cmd=get_resources", response_data);
5901 if (read_string_c (connection, &xml))
5903 g_string_free (xml, TRUE);
5906 "Internal error", __FUNCTION__, __LINE__,
5907 "An internal error occurred while getting permissions list. " 5908 "The current list of resources is not available. " 5909 "Diagnostics: Failure to receive response from manager daemon.",
5910 "/omp?cmd=get_resources", response_data);
5913 g_string_append (xml,
"</permissions>");
5915 g_string_append (xml,
"</get_task>");
5917 return xsl_transform_omp (connection, credentials, params,
5918 g_string_free (xml, FALSE), response_data);
5935 return get_task (connection, credentials, params, NULL, response_data);
5950 new_credential (openvas_connection_t *connection,
credentials_t *credentials,
5951 params_t *params,
const char *extra_xml,
5955 xml = g_string_new (
"<new_credential>");
5957 g_string_append (xml, extra_xml);
5958 g_string_append (xml,
"</new_credential>");
5959 return xsl_transform_omp (connection, credentials, params,
5960 g_string_free (xml, FALSE), response_data);
5979 gchar *html, *response;
5980 const char *no_redirect;
5981 const char *name, *comment, *login, *type, *password, *passphrase;
5982 const char *private_key, *certificate, *community, *privacy_password;
5983 const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
5997 privacy_password =
params_value (params,
"privacy_password");
5998 auth_algorithm =
params_value (params,
"auth_algorithm");
5999 privacy_algorithm =
params_value (params,
"privacy_algorithm");
6000 allow_insecure =
params_value (params,
"allow_insecure");
6003 autogenerate = strcmp (
params_value (params,
"autogenerate"),
"0");
6005 return message_invalid (connection, credentials, params, response_data,
6006 "Given autogenerate was invalid",
6007 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
6008 "Create Credential",
"new_credential");
6019 if (type && (strcmp (type,
"cc") == 0))
6022 ret = ompf (connection,
6027 "<create_credential>" 6029 "<comment>%s</comment>" 6031 "<allow_insecure>%s</allow_insecure>" 6032 "</create_credential>",
6034 comment ? comment :
"",
6043 ret = ompf (connection, credentials,
6047 "<create_credential>" 6049 "<comment>%s</comment>" 6052 "<allow_insecure>%s</allow_insecure>" 6053 "</create_credential>",
6055 comment ? comment :
"",
6063 if (type && (strcmp (type,
"up") == 0))
6066 "Create Credential",
"new_credential");
6068 "Create Credential",
"new_credential");
6070 ret = ompf (connection, credentials,
6074 "<create_credential>" 6076 "<comment>%s</comment>" 6079 "<password>%s</password>" 6080 "<allow_insecure>%s</allow_insecure>" 6081 "</create_credential>",
6083 comment ? comment :
"",
6086 password ? password :
"",
6089 else if (type && (strcmp (type,
"usk") == 0))
6092 "Create Credential",
"new_credential");
6094 "Create Credential",
"new_credential");
6096 "Create Credential",
"new_credential");
6098 ret = ompf (connection, credentials,
6102 "<create_credential>" 6104 "<comment>%s</comment>" 6108 "<private>%s</private>" 6109 "<phrase>%s</phrase>" 6111 "<allow_insecure>%s</allow_insecure>" 6112 "</create_credential>",
6114 comment ? comment :
"",
6117 private_key ? private_key :
"",
6118 passphrase ? passphrase :
"",
6121 else if (type && (strcmp (type,
"cc") == 0))
6124 "Create Credential",
"new_credential");
6126 "Create Credential",
"new_credential");
6128 ret = ompf (connection, credentials,
6132 "<create_credential>" 6134 "<comment>%s</comment>" 6136 "<certificate>%s</certificate>" 6138 "<private>%s</private>" 6140 "<allow_insecure>%s</allow_insecure>" 6141 "</create_credential>",
6143 comment ? comment :
"",
6145 certificate ? certificate :
"",
6146 private_key ? private_key :
"",
6150 else if (type && (strcmp (type,
"snmp") == 0))
6153 "Create Credential",
"new_credential");
6155 "Create Credential",
"new_credential");
6157 "Create Credential",
"new_credential");
6159 "Create Credential",
"new_credential");
6161 "Create Credential",
"new_credential");
6163 "Create Credential",
"new_credential");
6165 if (privacy_password && strcmp (privacy_password,
""))
6166 ret = ompf (connection, credentials,
6170 "<create_credential>" 6172 "<comment>%s</comment>" 6174 "<community>%s</community>" 6176 "<password>%s</password>" 6178 "<password>%s</password>" 6179 "<algorithm>%s</algorithm>" 6181 "<auth_algorithm>%s</auth_algorithm>" 6182 "<allow_insecure>%s</allow_insecure>" 6183 "</create_credential>",
6185 comment ? comment :
"",
6187 community ? community :
"",
6189 password ? password :
"",
6190 privacy_password ? privacy_password :
"",
6191 privacy_algorithm ? privacy_algorithm :
"",
6192 auth_algorithm ? auth_algorithm :
"",
6195 ret = ompf (connection, credentials,
6199 "<create_credential>" 6201 "<comment>%s</comment>" 6203 "<community>%s</community>" 6205 "<password>%s</password>" 6206 "<auth_algorithm>%s</auth_algorithm>" 6207 "<allow_insecure>%s</allow_insecure>" 6208 "</create_credential>",
6210 comment ? comment :
"",
6212 community ? community :
"",
6214 password ? password :
"",
6215 auth_algorithm ? auth_algorithm :
"",
6222 "Internal error", __FUNCTION__, __LINE__,
6223 "An internal error occurred while creating a new credential. " 6224 "The credential could not be created. " 6225 "Diagnostics: Unrecognized credential type.",
6226 "/omp?cmd=get_credentials", response_data);
6239 "Internal error", __FUNCTION__, __LINE__,
6240 "An internal error occurred while creating a new credential. " 6241 "It is unclear whether the credential has been created or not. " 6242 "Diagnostics: Failure to send command to manager daemon.",
6243 "/omp?cmd=get_credentials", response_data);
6247 "Internal error", __FUNCTION__, __LINE__,
6248 "An internal error occurred while creating a new credential. " 6249 "It is unclear whether the credential has been created or not. " 6250 "Diagnostics: Failure to receive response from manager daemon.",
6251 "/omp?cmd=get_credentials", response_data);
6255 "Internal error", __FUNCTION__, __LINE__,
6256 "An internal error occurred while creating a new credential. " 6257 "It is unclear whether the credential has been created or not. " 6258 "Diagnostics: Internal Error.",
6259 "/omp?cmd=get_credentials", response_data);
6262 if (entity_attribute (entity,
"id"))
6263 params_add (params,
"credential_id", entity_attribute (entity,
"id"));
6264 html = response_from_entity (connection, credentials, params, entity,
6265 (no_redirect && strcmp (no_redirect,
"0")),
6266 NULL,
"get_credentials",
6267 NULL,
"new_credential",
6268 "Create Credential",
6270 free_entity (entity);
6287 get_credential (openvas_connection_t *connection,
credentials_t * credentials,
6288 params_t *params,
const char *extra_xml,
6291 return get_one (connection,
"credential", credentials, params, extra_xml,
6292 "targets=\"1\" scanners=\"1\"", response_data);
6310 return get_credential (connection, credentials, params, NULL, response_data);
6337 const char *credential_id, *format;
6341 if (result_len) *result_len = 0;
6345 credential_id =
params_value (params,
"credential_id");
6348 if ((credential_id == NULL) || (format == NULL))
6352 "Internal error", __FUNCTION__, __LINE__,
6353 "An internal error occurred while getting a credential. " 6354 "Diagnostics: Required parameter was NULL.",
6355 "/omp?cmd=get_credentials", response_data);
6359 if (openvas_connection_sendf (connection,
6361 " credential_id=\"%s\"" 6369 "Internal error", __FUNCTION__, __LINE__,
6370 "An internal error occurred while getting a credential. " 6371 "Diagnostics: Failure to send command to manager daemon.",
6372 "/omp?cmd=get_credentials", response_data);
6378 if (strcmp (format,
"rpm") == 0
6379 || strcmp (format,
"deb") == 0
6380 || strcmp (format,
"exe") == 0)
6382 gchar *package_decoded = NULL;
6383 entity_t package_entity = NULL, credential_entity;
6388 if (read_entity_c (connection, &entity))
6392 "Internal error", __FUNCTION__, __LINE__,
6393 "An internal error occurred while getting a credential. " 6394 "The credential is not available. " 6395 "Diagnostics: Failure to receive response from manager daemon.",
6396 "/omp?cmd=get_credentials", response_data);
6400 credential_entity = entity_child (entity,
"credential");
6401 if (credential_entity)
6402 package_entity = entity_child (credential_entity,
"package");
6403 if (package_entity != NULL)
6406 char *package_encoded = entity_text (package_entity);
6407 if (strlen (package_encoded))
6409 package_decoded = (gchar *) g_base64_decode (package_encoded,
6411 if (package_decoded == NULL)
6413 package_decoded = (gchar *) g_strdup (
"");
6419 package_decoded = (gchar *) g_strdup (
"");
6422 if (result_len) *result_len = len;
6423 *html = package_decoded;
6426 entity_t login_entity;
6427 login_entity = entity_child (credential_entity,
"login");
6429 *login = g_strdup (entity_text (login_entity));
6433 free_entity (entity);
6438 free_entity (entity);
6441 "Internal error", __FUNCTION__, __LINE__,
6442 "An internal error occurred while getting a credential. " 6443 "The credential could not be delivered. " 6444 "Diagnostics: Failure to receive credential from manager daemon.",
6445 "/omp?cmd=get_credentials", response_data);
6451 entity_t credential_entity, key_entity = NULL;
6456 if (read_entity_c (connection, &entity))
6460 "Internal error", __FUNCTION__, __LINE__,
6461 "An internal error occurred while getting a credential. " 6462 "The credential could not be delivered. " 6463 "Diagnostics: Failure to receive credential from manager daemon.",
6464 "/omp?cmd=get_credentials", response_data);
6468 credential_entity = entity_child (entity,
"credential");
6469 if (credential_entity)
6471 if (strcmp (format,
"pem") == 0)
6472 key_entity = entity_child (credential_entity,
"certificate");
6474 key_entity = entity_child (credential_entity,
"public_key");
6476 if (key_entity != NULL)
6478 *html = g_strdup (entity_text (key_entity));
6481 entity_t login_entity = entity_child (credential_entity,
"login");
6483 *login = g_strdup (entity_text (login_entity));
6487 free_entity (entity);
6492 "Internal error", __FUNCTION__, __LINE__,
6493 "An internal error occurred while getting a credential. " 6494 "The credential could not be delivered. " 6495 "Diagnostics: Failure to parse credential from manager daemon.",
6496 "/omp?cmd=get_credentials", response_data);
6497 free_entity (entity);
6520 char **content_disposition, gsize *content_length,
6523 return export_resource (connection,
"credential", credentials, params,
6546 char **content_disposition, gsize *content_length,
6549 return export_many (connection,
"credential", credentials, params,
6567 get_credentials (openvas_connection_t *connection,
credentials_t * credentials,
6568 params_t *params,
const char *extra_xml,
6571 return get_many (connection,
"credential", credentials, params, extra_xml,
6572 NULL, response_data);
6590 return get_credentials (connection, credentials, params, NULL, response_data);
6608 return delete_resource (connection,
"credential", credentials, params, 0,
6609 "get_credentials", response_data);
6627 return new_credential (connection, credentials, params, NULL, response_data);
6642 edit_credential (openvas_connection_t *connection,
credentials_t * credentials,
6643 params_t *params,
const char *extra_xml,
6646 return edit_resource (connection,
"credential", credentials, params, NULL,
6647 extra_xml, response_data);
6665 return edit_credential (connection, credentials, params, NULL, response_data);
6683 int ret, change_password, change_passphrase;
6684 int change_community, change_privacy_password;
6685 gchar *html, *response;
6686 const char *no_redirect, *credential_id;
6687 const char *name, *comment, *login, *password, *passphrase;
6688 const char *private_key, *certificate, *community, *privacy_password;
6689 const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6694 credential_id =
params_value (params,
"credential_id");
6703 privacy_password =
params_value (params,
"privacy_password");
6704 auth_algorithm =
params_value (params,
"auth_algorithm");
6705 privacy_algorithm =
params_value (params,
"privacy_algorithm");
6706 allow_insecure =
params_value (params,
"allow_insecure");
6722 "Save Credential",
"edit_credential");
6724 change_community = (
params_value (params,
"change_community") ? 1 : 0);
6725 if (change_community)
6727 change_passphrase = (
params_value (params,
"change_passphrase") ? 1 : 0);
6728 if (change_passphrase)
6730 change_password = (
params_value (params,
"change_password") ? 1 : 0);
6731 if (change_password)
6733 change_privacy_password
6734 = (
params_value (params,
"change_privacy_password") ? 1 : 0);
6735 if (change_privacy_password)
6737 "Save Credential",
"edit_credential");
6740 command = g_string_new (
"");
6742 xml_string_append (command,
6743 "<modify_credential credential_id=\"%s\">" 6745 "<comment>%s</comment>" 6746 "<allow_insecure>%s</allow_insecure>",
6753 xml_string_append (command,
6754 "<auth_algorithm>%s</auth_algorithm>",
6757 if (certificate && strcmp (certificate,
""))
6758 xml_string_append (command,
6759 "<certificate>%s</certificate>",
6762 if (change_community)
6763 xml_string_append (command,
6764 "<community>%s</community>",
6767 if (login && strcmp (login,
""))
6768 xml_string_append (command,
6769 "<login>%s</login>",
6772 if (change_password)
6773 xml_string_append (command,
6774 "<password>%s</password>",
6777 if (privacy_algorithm || change_privacy_password)
6779 xml_string_append (command,
6781 if (privacy_algorithm && strcmp (privacy_algorithm,
""))
6783 xml_string_append (command,
6784 "<algorithm>%s</algorithm>",
6786 if (change_privacy_password)
6787 xml_string_append (command,
6788 "<password>%s</password>",
6791 else if (privacy_algorithm)
6793 xml_string_append (command,
6794 "<algorithm></algorithm>");
6795 xml_string_append (command,
6796 "<password></password>");
6799 xml_string_append (command,
6803 if ((private_key && strcmp (private_key,
"")) || change_passphrase)
6805 xml_string_append (command,
6807 if (change_passphrase)
6808 xml_string_append (command,
6809 "<phrase>%s</phrase>",
6812 xml_string_append (command,
6813 "<private>%s</private>",
6815 xml_string_append (command,
6819 xml_string_append (command,
6820 "</modify_credential>");
6825 ret = omp (connection, credentials,
6830 g_string_free (command, TRUE);
6842 "Internal error", __FUNCTION__, __LINE__,
6843 "An internal error occurred while saving a Credential. " 6844 "The Credential was not saved. " 6845 "Diagnostics: Failure to send command to manager daemon.",
6846 "/omp?cmd=get_credentials", response_data);
6850 "Internal error", __FUNCTION__, __LINE__,
6851 "An internal error occurred while saving a Credential. " 6852 "It is unclear whether the Credential has been saved or not. " 6853 "Diagnostics: Failure to receive response from manager daemon.",
6854 "/omp?cmd=get_credentials", response_data);
6858 "Internal error", __FUNCTION__, __LINE__,
6859 "An internal error occurred while saving a Credential. " 6860 "It is unclear whether the Credential has been saved or not. " 6861 "Diagnostics: Internal Error.",
6862 "/omp?cmd=get_credentials", response_data);
6865 html = response_from_entity (connection, credentials, params, entity,
6866 (no_redirect && strcmp (no_redirect,
"0")),
6867 NULL,
"get_credentials",
6868 NULL,
"edit_credential",
6869 "Save Credential", response_data);
6870 free_entity (entity);
6887 new_agent (openvas_connection_t *connection,
credentials_t *credentials,
6888 params_t *params,
const char *extra_xml,
6892 xml = g_string_new (
"<new_agent>");
6894 g_string_append (xml, extra_xml);
6895 g_string_append (xml,
"</new_agent>");
6896 return xsl_transform_omp (connection, credentials, params,
6897 g_string_free (xml, FALSE), response_data);
6914 return new_agent (connection, credentials, params, NULL, response_data);
6932 gchar *response, *html;
6933 const char *no_redirect;
6934 const char *name, *comment, *installer, *installer_filename, *installer_sig;
6935 const char *howto_install, *howto_use;
6936 int installer_size, installer_sig_size, howto_install_size, howto_use_size;
6938 gchar *name_escaped, *comment_escaped;
6939 gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
6948 installer_sig =
params_value (params,
"installer_sig");
6950 howto_install =
params_value (params,
"howto_install");
6960 installer_64 = (installer_size > 0)
6961 ? g_base64_encode ((guchar *) installer,
6965 installer_sig_64 = (installer_sig_size > 0)
6966 ? g_base64_encode ((guchar *) installer_sig,
6970 howto_install_64 = (howto_install_size > 0)
6971 ? g_base64_encode ((guchar *) howto_install,
6975 howto_use_64 = (howto_use_size > 0)
6976 ? g_base64_encode ((guchar *) howto_use,
6980 name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
6981 comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
6983 command = g_strdup_printf (
"<create_agent>" 6988 "<signature>%s</signature>" 6989 "<filename>%s</filename>" 6991 "<howto_install>%s</howto_install>" 6992 "<howto_use>%s</howto_use>" 6995 comment_escaped ?
"<comment>" :
"",
6996 comment_escaped ? comment_escaped :
"",
6997 comment_escaped ?
"</comment>" :
"",
7000 installer_filename ? installer_filename :
"",
7004 ret = omp (connection, credentials,
7011 g_free (installer_64);
7012 g_free (howto_install_64);
7013 g_free (howto_use_64);
7014 g_free (name_escaped);
7015 g_free (comment_escaped);
7027 "Internal error", __FUNCTION__, __LINE__,
7028 "An internal error occurred while creating a new agent. " 7029 "No new agent was created. " 7030 "Diagnostics: Failure to send command to manager daemon.",
7031 "/omp?cmd=get_agents", response_data);
7035 "Internal error", __FUNCTION__, __LINE__,
7036 "An internal error occurred while creating a new agent. " 7037 "It is unclear whether the agent has been created or not. " 7038 "Diagnostics: Failure to receive response from manager daemon.",
7039 "/omp?cmd=get_agents", response_data);
7043 "Internal error", __FUNCTION__, __LINE__,
7044 "An internal error occurred while creating a new agent. " 7045 "It is unclear whether the agent has been created or not. " 7046 "Diagnostics: Internal Error.",
7047 "/omp?cmd=get_agents", response_data);
7050 if (entity_attribute (entity,
"id"))
7051 params_add (params,
"agent_id", entity_attribute (entity,
"id"));
7052 html = response_from_entity (connection, credentials, params, entity,
7053 (no_redirect && strcmp (no_redirect,
"0")),
7056 "Create Agent", response_data);
7057 free_entity (entity);
7077 "get_agents", response_data);
7104 const char *agent_id, *format;
7109 if ((agent_id == NULL) || (format == NULL))
7113 "Internal error", __FUNCTION__, __LINE__,
7114 "An internal error occurred while downloading " 7116 "Diagnostics: Required parameter was NULL.",
7117 "/omp?cmd=get_agents", response_data);
7125 if (openvas_connection_sendf (connection,
7126 "<get_agents agent_id=\"%s\" format=\"%s\"/>",
7133 "Internal error", __FUNCTION__, __LINE__,
7134 "An internal error occurred while getting agent list. " 7135 "The current list of agents is not available. " 7136 "Diagnostics: Failure to send command to manager daemon.",
7137 "/omp?cmd=get_agents", response_data);
7143 if (strcmp (format,
"installer") == 0
7144 || strcmp (format,
"howto_install") == 0
7145 || strcmp (format,
"howto_use") == 0)
7147 gchar *package_decoded = NULL;
7148 entity_t package_entity = NULL, agent_entity;
7153 if (read_entity_c (connection, &entity))
7157 "Internal error", __FUNCTION__, __LINE__,
7158 "An internal error occurred while getting a agent. " 7159 "The agent is not available. " 7160 "Diagnostics: Failure to receive response from manager daemon.",
7161 "/omp?cmd=get_agents", response_data);
7165 agent_entity = entity_child (entity,
"agent");
7167 package_entity = entity_child (agent_entity,
"package");
7168 if (package_entity != NULL)
7170 char *package_encoded = entity_text (package_entity);
7171 if (strlen (package_encoded))
7173 package_decoded = (gchar *) g_base64_decode (package_encoded,
7175 if (package_decoded == NULL)
7177 package_decoded = (gchar *) g_strdup (
"");
7183 package_decoded = (gchar *) g_strdup (
"");
7186 *html = package_decoded;
7189 entity_t filename_entity;
7190 filename_entity = entity_child (package_entity,
7192 if (filename_entity)
7193 *filename = g_strdup (entity_text (filename_entity));
7196 if (!(*filename && strlen (*filename)))
7199 *filename = g_strdup_printf (
"agent-%s-%s", agent_id, format);
7202 free_entity (entity);
7207 free_entity (entity);
7210 "Internal error", __FUNCTION__, __LINE__,
7211 "An internal error occurred while getting a agent. " 7212 "The agent could not be delivered. " 7213 "Diagnostics: Failure to receive agent from manager daemon.",
7214 "/omp?cmd=get_tasks", response_data);
7223 if (read_entity_c (connection, &entity))
7227 "Internal error", __FUNCTION__, __LINE__,
7228 "An internal error occurred while getting a agent. " 7229 "The agent could not be delivered. " 7230 "Diagnostics: Failure to receive agent from manager daemon.",
7231 "/omp?cmd=get_tasks", response_data);
7235 free_entity (entity);
7238 "Internal error", __FUNCTION__, __LINE__,
7239 "An internal error occurred while getting a agent. " 7240 "The agent could not be delivered. " 7241 "Diagnostics: Failure to parse agent from manager daemon.",
7242 "/omp?cmd=get_tasks", response_data);
7260 params_t *params,
const char *extra_xml,
7263 return edit_resource (connection,
"agent", credentials, params, NULL,
7264 extra_xml, response_data);
7281 return edit_agent (connection, credentials, params, NULL, response_data);
7299 gchar *html, *response;
7300 const char *no_redirect, *agent_id, *name, *comment;
7316 ret = ompf (connection, credentials,
7320 "<modify_agent agent_id=\"%s\">" 7322 "<comment>%s</comment>" 7336 "Internal error", __FUNCTION__, __LINE__,
7337 "An internal error occurred while saving a agent. " 7338 "The agent was not saved. " 7339 "Diagnostics: Failure to send command to manager daemon.",
7340 "/omp?cmd=get_agents", response_data);
7344 "Internal error", __FUNCTION__, __LINE__,
7345 "An internal error occurred while saving a agent. " 7346 "It is unclear whether the agent has been saved or not. " 7347 "Diagnostics: Failure to receive response from manager daemon.",
7348 "/omp?cmd=get_agents", response_data);
7352 "Internal error", __FUNCTION__, __LINE__,
7353 "An internal error occurred while saving a agent. " 7354 "It is unclear whether the agent has been saved or not. " 7355 "Diagnostics: Internal Error.",
7356 "/omp?cmd=get_agents", response_data);
7359 html = response_from_entity (connection, credentials, params, entity,
7360 (no_redirect && strcmp (no_redirect,
"0")),
7363 "Save Agent", response_data);
7364 free_entity (entity);
7381 get_agent (openvas_connection_t *connection,
credentials_t * credentials,
7382 params_t *params,
const char *extra_xml,
7385 return get_one (connection,
"agent", credentials, params, extra_xml, NULL,
7403 return get_agent (connection, credentials, params, NULL, response_data);
7418 get_agents (openvas_connection_t *connection,
credentials_t * credentials,
7419 params_t *params,
const char *extra_xml,
7422 return get_many (connection,
"agent", credentials, params, extra_xml, NULL,
7440 return get_agents (connection, credentials, params, NULL, response_data);
7457 gchar *html, *response;
7458 const char *agent_id;
7463 if (agent_id == NULL)
7467 "Internal error", __FUNCTION__, __LINE__,
7468 "An internal error occurred while verifying an agent. " 7469 "Diagnostics: Required parameter was NULL.",
7470 "/omp?cmd=get_agents", response_data);
7474 ret = ompf (connection, credentials,
7478 "<verify_agent agent_id=\"%s\" />",
7489 "Internal error", __FUNCTION__, __LINE__,
7490 "An internal error occurred while verifying a agent. " 7491 "The agent was not verified. " 7492 "Diagnostics: Failure to send command to manager daemon.",
7493 "/omp?cmd=get_agents", response_data);
7497 "Internal error", __FUNCTION__, __LINE__,
7498 "An internal error occurred while verifying a agent. " 7499 "It is unclear whether the agent was verified or not. " 7500 "Diagnostics: Failure to send command to manager daemon.",
7501 "/omp?cmd=get_agents", response_data);
7505 "Internal error", __FUNCTION__, __LINE__,
7506 "An internal error occurred while verifying a agent. " 7507 "It is unclear whether the agent was verified or not. " 7508 "Diagnostics: Failure to send command to manager daemon.",
7509 "/omp?cmd=get_agents", response_data);
7512 if (omp_success (entity))
7514 html = next_page (connection, credentials, params, response,
7518 free_entity (entity);
7522 "Internal error", __FUNCTION__, __LINE__,
7523 "An internal error occurred while verifying a agent. " 7524 "It is unclear whether the agent was verified or not. " 7525 "Diagnostics: Failure to receive response from manager daemon.",
7526 "/omp?cmd=get_agents", response_data);
7532 html = get_agents (connection, credentials, params, response,
7535 free_entity (entity);
7556 char **content_disposition, gsize *content_length,
7584 return export_many (connection,
"agent", credentials, params,
content_type,
7585 content_disposition, content_length, response_data);
7603 params_t *data_columns, *text_columns;
7604 params_t *sort_fields, *sort_stats, *sort_orders;
7611 const char *data_column, *group_column, *subgroup_column, *type;
7612 const char *filter, *filt_id, *xml_param;
7613 const char *first_group, *max_groups;
7615 gchar *filter_escaped, *command_escaped, *response;
7617 GString *xml, *command;
7624 subgroup_column =
params_value (params,
"subgroup_column");
7634 if (filter && strcmp (filter,
""))
7635 filter_escaped = g_markup_escape_text (filter, -1);
7639 || strcmp (filt_id,
"") == 0
7640 || strcmp (filt_id,
"0") == 0)
7641 filter_escaped = g_strdup (
"rows=-2");
7643 filter_escaped = NULL;
7647 if (xml_param == NULL || atoi (xml_param) == 0)
7649 return xsl_transform_omp (connection, credentials, params,
7650 g_strdup (
"<get_aggregate/>"), response_data);
7652 xml = g_string_new (
"<get_aggregate>");
7654 command = g_string_new (
"<get_aggregates");
7655 g_string_append_printf (command,
" type=\"%s\"", type);
7657 g_string_append_printf (command,
" data_column=\"%s\"", data_column);
7659 g_string_append_printf (command,
" group_column=\"%s\"", group_column);
7660 if (subgroup_column)
7661 g_string_append_printf (command,
7662 " subgroup_column=\"%s\"", subgroup_column);
7663 if (filter_escaped && strcmp (filter_escaped,
""))
7664 g_string_append_printf (command,
" filter=\"%s\"", filter_escaped);
7665 if (filt_id && strcmp (filt_id,
""))
7666 g_string_append_printf (command,
" filt_id=\"%s\"", filt_id);
7667 if (first_group && strcmp (first_group,
""))
7668 g_string_append_printf (command,
" first_group=\"%s\"", first_group);
7669 if (max_groups && strcmp (max_groups,
""))
7670 g_string_append_printf (command,
" max_groups=\"%s\"", max_groups);
7671 if (mode && strcmp (mode,
""))
7672 g_string_append_printf (command,
" mode=\"%s\"", mode);
7673 g_string_append (command,
">");
7675 if (sort_fields && sort_stats && sort_orders)
7677 param_t *field_param, *stat_param, *order_param;
7678 gchar *field_i, *stat_i, *order_i;
7685 &field_i, &field_param)
7687 &stat_i, &stat_param)
7689 &order_i, &order_param))
7693 xml_string_append (command,
7694 "<sort field=\"%s\"" 7697 field_param->
value ? field_param->
value :
"",
7699 order_param->
value ? order_param->
value :
"");
7711 xml_string_append (command,
7712 "<data_column>%s</data_column>",
7725 xml_string_append (command,
7726 "<text_column>%s</text_column>",
7732 g_string_append (command,
"</get_aggregates>");
7734 g_free (filter_escaped);
7736 command_escaped = g_markup_escape_text (command->str, -1);
7737 g_string_append (xml, command_escaped);
7738 g_free (command_escaped);
7740 ret = omp (connection, credentials, &response, &entity, response_data,
7742 g_string_free (command, TRUE);
7753 "Internal error", __FUNCTION__, __LINE__,
7754 "An internal error occurred while getting aggregates. " 7755 "Diagnostics: Failure to send command to manager daemon.",
7756 "/omp?cmd=get_tasks", response_data);
7760 "Internal error", __FUNCTION__, __LINE__,
7761 "An internal error occurred while getting aggregates. " 7762 "Diagnostics: Failure to receive response from manager daemon.",
7763 "/omp?cmd=get_tasks", response_data);
7767 "Internal error", __FUNCTION__, __LINE__,
7768 "An internal error occurred while getting aggregates. " 7769 "Diagnostics: Internal Error.",
7770 "/omp?cmd=get_tasks", response_data);
7773 g_string_append (xml, response);
7775 g_string_append (xml,
"</get_aggregate>");
7777 return xsl_transform_omp (connection, credentials, params,
7778 g_string_free (xml, FALSE), response_data);
7793 new_alert (openvas_connection_t *connection,
credentials_t *credentials,
7794 params_t *params,
const char *extra_xml,
7802 xml = g_string_new (
"<new_alert>");
7804 g_string_append (xml, extra_xml);
7810 ret = omp (connection, credentials, &response, &entity, response_data,
7811 "<get_report_formats filter=\"rows=-1\"/>");
7820 "Internal error", __FUNCTION__, __LINE__,
7821 "An internal error occurred while getting Report " 7822 "Formats for new alert. " 7823 "Diagnostics: Failure to send command to manager daemon.",
7824 "/omp?cmd=get_alerts", response_data);
7828 "Internal error", __FUNCTION__, __LINE__,
7829 "An internal error occurred while getting Report " 7830 "Formats for new alert. " 7831 "Diagnostics: Failure to receive response from manager daemon.",
7832 "/omp?cmd=get_alerts", response_data);
7836 "Internal error", __FUNCTION__, __LINE__,
7837 "An internal error occurred while getting Report " 7838 "Formats for new alert. It is unclear whether" 7839 " the alert has been saved or not. " 7840 "Diagnostics: Internal Error.",
7841 "/omp?cmd=get_alerts", response_data);
7843 g_string_append (xml, response);
7845 free_entity (entity);
7849 ret = omp (connection, credentials, &response, &entity, response_data,
7850 "<get_filters filter=\"rows=-1\"/>");
7860 "Internal error", __FUNCTION__, __LINE__,
7861 "An internal error occurred while getting Report " 7862 "Filters for new alert. " 7863 "The task was not saved. " 7864 "Diagnostics: Failure to send command to manager daemon.",
7865 "/omp?cmd=get_alerts", response_data);
7869 "Internal error", __FUNCTION__, __LINE__,
7870 "An internal error occurred while getting Report " 7871 "Filters for new alert. " 7872 "Diagnostics: Failure to receive response from manager daemon.",
7873 "/omp?cmd=get_alerts", response_data);
7877 "Internal error", __FUNCTION__, __LINE__,
7878 "An internal error occurred while getting Report " 7879 "Filters for new alert. " 7880 "Diagnostics: Internal Error.",
7881 "/omp?cmd=get_alerts", response_data);
7883 g_string_append (xml, response);
7885 free_entity (entity);
7889 ret = omp (connection, credentials, &response, &entity, response_data,
7891 " schedules_only=\"1\"" 7892 " filter=\"owner=any permission=start_task rows=-1\"/>");
7902 "Internal error", __FUNCTION__, __LINE__,
7903 "An internal error occurred while getting Tasks" 7905 "The task was not saved. " 7906 "Diagnostics: Failure to send command to manager daemon.",
7907 "/omp?cmd=get_alerts",
7912 "Internal error", __FUNCTION__, __LINE__,
7913 "An internal error occurred while getting Tasks" 7915 "Diagnostics: Failure to receive response from manager daemon.",
7916 "/omp?cmd=get_alerts",
7921 "Internal error", __FUNCTION__, __LINE__,
7922 "An internal error occurred while getting Tasks" 7924 "Diagnostics: Internal Error.",
7925 "/omp?cmd=get_alerts",
7928 g_string_append (xml, response);
7930 free_entity (entity);
7934 ret = omp (connection, credentials, &response, &entity, response_data,
7936 " filter=\"type=up owner=any permission=any rows=-1\"/>");
7946 "Internal error", __FUNCTION__, __LINE__,
7947 "An internal error occurred while getting" 7948 " Credentials for new alert. " 7949 "The task was not saved. " 7950 "Diagnostics: Failure to send command to manager daemon.",
7951 "/omp?cmd=get_alerts",
7956 "Internal error", __FUNCTION__, __LINE__,
7957 "An internal error occurred while getting" 7958 " Credentials for new alert. " 7959 "Diagnostics: Failure to receive response from manager daemon.",
7960 "/omp?cmd=get_alerts",
7965 "Internal error", __FUNCTION__, __LINE__,
7966 "An internal error occurred while getting" 7967 " Credentials for new alert. " 7968 "Diagnostics: Internal Error.",
7969 "/omp?cmd=get_alerts",
7973 g_string_append (xml, response);
7975 free_entity (entity);
7977 g_string_append (xml,
"</new_alert>");
7978 return xsl_transform_omp (connection, credentials, params,
7979 g_string_free (xml, FALSE), response_data);
7996 return new_alert (connection, credentials, params, NULL, response_data);
8013 append_alert_event_data (GString *xml,
params_t *data,
const char *event)
8023 if ((strcmp (event,
"Task run status changed") == 0
8024 && strcmp (name,
"status") == 0)
8025 || ((strcmp (event,
"New SecInfo arrived") == 0
8026 || strcmp (event,
"Updated SecInfo arrived") == 0)
8027 && strcmp (name,
"secinfo_type") == 0))
8028 xml_string_append (xml,
8029 "<data><name>%s</name>%s</data>",
8043 append_alert_condition_data (GString *xml,
params_t *data,
8044 const char * condition)
8055 if (strcmp (condition,
"Filter count at least") == 0)
8057 if (strcmp (name,
"at_least_count") == 0)
8058 xml_string_append (xml,
8059 "<data><name>count</name>%s</data>",
8061 if (strcmp (name,
"at_least_filter_id") == 0)
8062 xml_string_append (xml,
8063 "<data><name>filter_id</name>%s</data>",
8066 else if (strcmp (condition,
"Filter count changed") == 0)
8068 if (strcmp (name,
"count") == 0
8069 || strcmp (name,
"filter_id") == 0)
8070 xml_string_append (xml,
8071 "<data><name>%s</name>%s</data>",
8074 else if (strcmp (name,
"filter_direction") == 0)
8075 xml_string_append (xml,
8076 "<data><name>direction</name>%s</data>",
8079 else if ((strcmp (condition,
"Severity at least") == 0
8080 && strcmp (name,
"severity") == 0)
8081 || (strcmp (condition,
"Severity changed") == 0
8082 && strcmp (name,
"direction") == 0))
8083 xml_string_append (xml,
8084 "<data><name>%s</name>%s</data>",
8099 append_alert_method_data (GString *xml,
params_t *data,
const char *method)
8113 if (strcmp (name,
"notice") == 0)
8119 if (strcmp (method,
"Sourcefire Connector"))
8124 if ((strcmp (method,
"HTTP Get") == 0
8125 && strcmp (name,
"URL") == 0)
8126 || (strcmp (method,
"Send") == 0
8127 && (strcmp (name,
"send_host") == 0
8128 || strcmp (name,
"send_port") == 0
8129 || strcmp (name,
"send_report_format") == 0))
8130 || (strcmp (method,
"SCP") == 0
8131 && (strcmp (name,
"scp_credential") == 0
8132 || strcmp (name,
"scp_host") == 0
8133 || strcmp (name,
"scp_known_hosts") == 0
8134 || strcmp (name,
"scp_path") == 0
8135 || strcmp (name,
"scp_report_format") == 0))
8136 || (strcmp (method,
"SMB") == 0
8137 && (strcmp (name,
"smb_credential") == 0
8138 || strcmp (name,
"smb_file_path") == 0
8139 || strcmp (name,
"smb_report_format") == 0
8140 || strcmp (name,
"smb_share_path") == 0))
8141 || (strcmp (method,
"SNMP") == 0
8142 && (strcmp (name,
"snmp_community") == 0
8143 || strcmp (name,
"snmp_agent") == 0
8144 || strcmp (name,
"snmp_message") == 0))
8145 || (strcmp (method,
"TippingPoint SMS") == 0
8146 && (strcmp (name,
"tp_sms_credential") == 0
8147 || strcmp (name,
"tp_sms_hostname") == 0
8148 || strcmp (name,
"tp_sms_tls_certificate") == 0
8149 || strcmp (name,
"tp_sms_tls_workaround") == 0))
8150 || (strcmp (method,
"verinice Connector") == 0
8151 && (strcmp (name,
"verinice_server_credential") == 0
8152 || strcmp (name,
"verinice_server_url") == 0
8153 || strcmp (name,
"verinice_server_report_format") == 0))
8154 || (strcmp (method,
"Email") == 0
8155 && (strcmp (name,
"to_address") == 0
8156 || strcmp (name,
"from_address") == 0
8157 || strcmp (name,
"subject") == 0
8158 || strcmp (name,
"notice") == 0
8159 || (strcmp (name,
"notice_report_format") == 0
8161 || (strcmp (name,
"notice_attach_format") == 0
8163 || (strcmp (method,
"Syslog") == 0
8164 && strcmp (name,
"submethod") == 0)
8165 || (strcmp (method,
"Start Task") == 0
8166 && strcmp (name,
"start_task_task") == 0)
8167 || strcmp (name,
"details_url") == 0)
8168 xml_string_append (xml,
8169 "<data><name>%s</name>%s</data>",
8172 else if (strcmp (method,
"Email") == 0
8174 && strcmp (name,
"message") == 0)
8175 xml_string_append (xml,
8176 "<data><name>message</name>%s</data>",
8178 else if (strcmp (method,
"Email") == 0
8180 && strcmp (name,
"message_attach") == 0)
8181 xml_string_append (xml,
8182 "<data><name>message</name>%s</data>",
8190 if (strcmp (name,
"pkcs12"))
8192 if (strcmp (name,
"defense_center_ip") == 0
8193 || strcmp (name,
"defense_center_port") == 0)
8194 xml_string_append (xml,
8195 "<data><name>%s</name>%s</data>",
8209 xml_string_append (xml,
8210 "<data><name>%s</name>%s</data>",
8232 gchar *html, *response;
8233 const char *no_redirect;
8234 const char *name, *comment, *condition, *event, *method, *filter_id;
8235 params_t *method_data, *event_data, *condition_data;
8245 condition =
"Always";
8255 if (strcmp (event,
"Task run status changed") == 0)
8266 xml = g_string_new (
"");
8268 if ((strcmp (event,
"New SecInfo arrived") == 0) && event_data)
8276 if ((strcmp (name,
"feed_event") == 0)
8280 event =
"Updated SecInfo arrived";
8285 xml_string_append (xml,
8288 "<filter id=\"%s\"/>" 8289 "<comment>%s</comment>" 8293 comment ? comment :
"",
8296 append_alert_event_data (xml, event_data, event);
8298 xml_string_append (xml,
8303 append_alert_method_data (xml, method_data, method);
8305 xml_string_append (xml,
8310 append_alert_condition_data (xml, condition_data, condition);
8312 xml_string_append (xml,
8316 ret = omp (connection, credentials,
8321 g_string_free (xml, TRUE);
8330 "Internal error", __FUNCTION__, __LINE__,
8331 "An internal error occurred while creating a new alert. " 8332 "No new alert was created. " 8333 "Diagnostics: Failure to send command to manager daemon.",
8334 "/omp?cmd=get_alerts", response_data);
8338 "Internal error", __FUNCTION__, __LINE__,
8339 "An internal error occurred while creating a new alert. " 8340 "It is unclear whether the alert has been created or not. " 8341 "Diagnostics: Failure to receive response from manager daemon.",
8342 "/omp?cmd=get_alerts", response_data);
8346 "Internal error", __FUNCTION__, __LINE__,
8347 "An internal error occurred while creating a new alert. " 8348 "It is unclear whether the alert has been created or not. " 8349 "Diagnostics: Internal Error.",
8350 "/omp?cmd=get_alerts", response_data);
8353 if (entity_attribute (entity,
"id"))
8354 params_add (params,
"alert_id", entity_attribute (entity,
"id"));
8355 html = response_from_entity (connection, credentials, params, entity,
8356 (no_redirect && strcmp (no_redirect,
"0")),
8359 "Create Alert", response_data);
8360 free_entity (entity);
8380 "get_alerts", response_data);
8395 get_alert (openvas_connection_t *connection,
credentials_t * credentials,
8396 params_t *params,
const char *extra_xml,
8402 extra = g_string_new (
"");
8404 g_string_append (extra, extra_xml);
8412 switch (omp (connection, credentials, &response, &entity, response_data,
8413 "<get_report_formats" 8414 " filter=\"rows=-1\"/>"))
8422 "Internal error", __FUNCTION__, __LINE__,
8423 "An internal error occurred while getting Report " 8424 "Formats for the alert. " 8425 "Diagnostics: Failure to send command to manager daemon.",
8426 "/omp?cmd=get_alerts", response_data);
8430 "Internal error", __FUNCTION__, __LINE__,
8431 "An internal error occurred while getting Report " 8432 "Formats for the alert. " 8433 "Diagnostics: Failure to receive response from manager daemon.",
8434 "/omp?cmd=get_alerts", response_data);
8438 "Internal error", __FUNCTION__, __LINE__,
8439 "An internal error occurred while getting Report " 8440 "Formats for the alert. " 8441 "It is unclear whether the task has been saved or not. " 8442 "Diagnostics: Internal Error.",
8443 "/omp?cmd=get_alerts", response_data);
8446 g_string_append (extra, response);
8448 free_entity (entity);
8459 switch (omp (connection, credentials, &response, &entity, response_data,
8461 " schedules_only=\"1\"" 8462 " filter=\"owner=any permission=start_task rows=-1\"/>"))
8470 "Internal error", __FUNCTION__, __LINE__,
8471 "An internal error occurred while getting Tasks " 8473 "Diagnostics: Failure to send command to manager daemon.",
8474 "/omp?cmd=get_alerts", response_data);
8478 "Internal error", __FUNCTION__, __LINE__,
8479 "An internal error occurred while getting Tasks " 8481 "Diagnostics: Failure to receive response from manager daemon.",
8482 "/omp?cmd=get_alerts", response_data);
8486 "Internal error", __FUNCTION__, __LINE__,
8487 "An internal error occurred while getting Tasks " 8489 "Diagnostics: Internal Error.",
8490 "/omp?cmd=get_alerts", response_data);
8493 g_string_append (extra, response);
8495 free_entity (entity);
8508 switch (omp (connection, credentials, &response, &entity, response_data,
8510 " filter=\"type=result rows=-1\"/>"))
8518 "Internal error", __FUNCTION__, __LINE__,
8519 "An internal error occurred while getting filters " 8521 "Diagnostics: Failure to send command to manager daemon.",
8522 "/omp?cmd=get_alerts", response_data);
8526 "Internal error", __FUNCTION__, __LINE__,
8527 "An internal error occurred while getting filters " 8529 "Diagnostics: Failure to receive response from manager daemon.",
8530 "/omp?cmd=get_alerts", response_data);
8534 "Internal error", __FUNCTION__, __LINE__,
8535 "An internal error occurred while getting filters " 8537 "Diagnostics: Internal Error.",
8538 "/omp?cmd=get_alerts", response_data);
8541 g_string_append (extra, response);
8543 free_entity (entity);
8547 html =
get_one (connection,
"alert", credentials, params, extra->str,
8548 "tasks=\"1\"", response_data);
8549 g_string_free (extra, TRUE);
8567 return get_alert (connection, credentials, params, NULL, response_data);
8582 get_alerts (openvas_connection_t *connection,
credentials_t * credentials,
8583 params_t *params,
const char *extra_xml,
8589 extra = g_string_new (
"");
8597 switch (omp (connection, credentials, &response, &entity, response_data,
8599 " schedules_only=\"1\"" 8600 " filter=\"owner=any permission=start_task rows=-1\"/>"))
8608 "Internal error", __FUNCTION__, __LINE__,
8609 "An internal error occurred getting the tasks. " 8610 "Diagnostics: Failure to send command to manager daemon.",
8611 "/omp?cmd=get_tasks",
8616 "Internal error", __FUNCTION__, __LINE__,
8617 "An internal error occurred getting the tasks. " 8618 "Diagnostics: Failure to receive response from manager daemon.",
8619 "/omp?cmd=get_tasks",
8624 "Internal error", __FUNCTION__, __LINE__,
8625 "An internal error occurred getting the reports. " 8626 "Diagnostics: Internal Error.",
8627 "/omp?cmd=get_tasks",
8631 g_string_append (extra, response);
8633 free_entity (entity);
8647 switch (omp (connection, credentials, &response, &entity, response_data,
8649 " filter=\"type=result rows=-1\"/>"))
8657 "Internal error", __FUNCTION__, __LINE__,
8658 "An internal error occurred while getting filters " 8660 "Diagnostics: Failure to send command to manager daemon.",
8661 "/omp?cmd=get_tasks", response_data);
8665 "Internal error", __FUNCTION__, __LINE__,
8666 "An internal error occurred while getting filters " 8668 "Diagnostics: Failure to receive response from manager daemon.",
8669 "/omp?cmd=get_tasks", response_data);
8673 "Internal error", __FUNCTION__, __LINE__,
8674 "An internal error occurred while getting filters " 8676 "Diagnostics: Internal Error.",
8677 "/omp?cmd=get_tasks", response_data);
8680 g_string_append (extra, response);
8682 free_entity (entity);
8687 g_string_append (extra, extra_xml);
8688 html = get_many (connection,
"alert", credentials, params, extra->str, NULL,
8690 g_string_free (extra, TRUE);
8708 return get_alerts (connection, credentials, params, NULL, response_data);
8724 params_t *params,
const char *extra_xml,
8729 const char *alert_id, *next, *filter;
8735 if (alert_id == NULL)
8739 "Internal error", __FUNCTION__, __LINE__,
8740 "An internal error occurred while editing an alert. " 8741 "The alert remains as it was. " 8742 "Diagnostics: Required parameter alert_id was NULL.",
8743 "/omp?cmd=get_alerts", response_data);
8747 next =
"get_alerts";
8749 if (openvas_connection_sendf (connection,
8758 "Internal error", __FUNCTION__, __LINE__,
8759 "An internal error occurred while getting alert info. " 8760 "Diagnostics: Failure to send command to manager daemon.",
8761 "/omp?cmd=get_alerts", response_data);
8764 xml = g_string_new (
"<edit_alert>");
8767 g_string_append (xml, extra_xml);
8769 edit = g_markup_printf_escaped (
"<alert id=\"%s\"/>" 8773 "<filters><term>%s</term></filters>",
8777 g_string_append (xml, edit);
8780 if (read_string_c (connection, &xml))
8782 g_string_free (xml, TRUE);
8785 "Internal error", __FUNCTION__, __LINE__,
8786 "An internal error occurred while getting alert info. " 8787 "Diagnostics: Failure to receive response from manager daemon.",
8788 "/omp?cmd=get_alerts", response_data);
8795 if (openvas_connection_sendf (connection,
8796 "<get_report_formats" 8797 " filter=\"rows=-1\"/>")
8800 g_string_free (xml, TRUE);
8803 "Internal error", __FUNCTION__, __LINE__,
8804 "An internal error occurred while getting report formats. " 8805 "The current list of report formats is not available. " 8806 "Diagnostics: Failure to send command to manager daemon.",
8807 "/omp?cmd=get_alerts", response_data);
8810 if (read_string_c (connection, &xml))
8812 g_string_free (xml, TRUE);
8815 "Internal error", __FUNCTION__, __LINE__,
8816 "An internal error occurred while getting report formats. " 8817 "The current list of report formats is not available. " 8818 "Diagnostics: Failure to receive response from manager daemon.",
8819 "/omp?cmd=get_alerts", response_data);
8827 if (openvas_connection_sendf (connection,
8828 "<get_filters filter=\"rows=-1\"/>")
8831 g_string_free (xml, TRUE);
8834 "Internal error", __FUNCTION__, __LINE__,
8835 "An internal error occurred while getting the list " 8837 "The current list of filters is not available. " 8838 "Diagnostics: Failure to send command to manager daemon.",
8839 "/omp?cmd=get_alerts", response_data);
8842 if (read_string_c (connection, &xml))
8844 g_string_free (xml, TRUE);
8847 "Internal error", __FUNCTION__, __LINE__,
8848 "An internal error occurred while getting the list " 8850 "The current list of filters is not available. " 8851 "Diagnostics: Failure to receive response from manager daemon.",
8852 "/omp?cmd=get_filters", response_data);
8860 if (openvas_connection_sendf (connection,
8862 " schedules_only=\"1\"" 8863 " filter=\"owner=any permission=start_task" 8867 g_string_free (xml, TRUE);
8870 "Internal error", __FUNCTION__, __LINE__,
8871 "An internal error occurred while getting the list " 8873 "The current list of tasks is not available. " 8874 "Diagnostics: Failure to send command to manager daemon.",
8875 "/omp?cmd=get_alerts", response_data);
8878 if (read_string_c (connection, &xml))
8880 g_string_free (xml, TRUE);
8883 "Internal error", __FUNCTION__, __LINE__,
8884 "An internal error occurred while getting the list " 8886 "The current list of tasks is not available. " 8887 "Diagnostics: Failure to receive response from manager daemon.",
8888 "/omp?cmd=get_tasks", response_data);
8896 if (openvas_connection_sendf (connection,
8898 " filter=\"type=up owner=any permission=any" 8902 g_string_free (xml, TRUE);
8905 "Internal error", __FUNCTION__, __LINE__,
8906 "An internal error occurred while getting the list " 8908 "The current list of tasks is not available. " 8909 "Diagnostics: Failure to send command to manager daemon.",
8910 "/omp?cmd=get_alerts", response_data);
8913 if (read_string_c (connection, &xml))
8915 g_string_free (xml, TRUE);
8918 "Internal error", __FUNCTION__, __LINE__,
8919 "An internal error occurred while getting the list " 8921 "The current list of tasks is not available. " 8922 "Diagnostics: Failure to receive response from manager daemon.",
8923 "/omp?cmd=get_tasks", response_data);
8929 g_string_append (xml,
"</edit_alert>");
8930 return xsl_transform_omp (connection, credentials, params,
8931 g_string_free (xml, FALSE), response_data);
8948 return edit_alert (connection, credentials, params, NULL, response_data);
8967 gchar *html, *response;
8968 const char *no_redirect, *name, *comment, *alert_id;
8969 const char *event, *condition, *method;
8970 const char *filter_id;
8971 params_t *event_data, *condition_data, *method_data;
8980 condition =
"Always";
8992 if (strcmp (event,
"Task run status changed") == 0)
8997 xml = g_string_new (
"");
9005 if ((strcmp (event,
"New SecInfo arrived") == 0) && event_data)
9013 if ((strcmp (name,
"feed_event") == 0)
9017 event =
"Updated SecInfo arrived";
9022 xml_string_append (xml,
9023 "<modify_alert alert_id=\"%s\">" 9025 "<filter id=\"%s\"/>" 9026 "<comment>%s</comment>" 9031 comment ? comment :
"",
9034 append_alert_event_data (xml, event_data, event);
9036 xml_string_append (xml,
9041 append_alert_method_data (xml, method_data, method);
9043 xml_string_append (xml,
9048 append_alert_condition_data (xml, condition_data, condition);
9050 xml_string_append (xml,
9054 ret = omp (connection, credentials,
9059 g_string_free (xml, TRUE);
9068 "Internal error", __FUNCTION__, __LINE__,
9069 "An internal error occurred while saving a new alert. " 9070 "No new alert was created. " 9071 "Diagnostics: Failure to send command to manager daemon.",
9072 "/omp?cmd=get_alerts", response_data);
9076 "Internal error", __FUNCTION__, __LINE__,
9077 "An internal error occurred while saving a new alert. " 9078 "It is unclear whether the alert has been created or not. " 9079 "Diagnostics: Failure to receive response from manager daemon.",
9080 "/omp?cmd=get_alerts", response_data);
9084 "Internal error", __FUNCTION__, __LINE__,
9085 "An internal error occurred while saving a new alert. " 9086 "It is unclear whether the alert has been created or not. " 9087 "Diagnostics: Internal Error.",
9088 "/omp?cmd=get_alerts", response_data);
9091 html = response_from_entity (connection, credentials, params, entity,
9092 (no_redirect && strcmp (no_redirect,
"0")),
9095 "Save Alert", response_data);
9096 free_entity (entity);
9115 gchar *html, *response;
9116 const char *no_redirect, *alert_id;
9122 if (alert_id == NULL)
9126 "Internal error", __FUNCTION__, __LINE__,
9127 "An internal error occurred while testing an alert. " 9128 "Diagnostics: Required parameter was NULL.",
9129 "/omp?cmd=get_alerts", response_data);
9134 if (openvas_connection_sendf (connection,
9135 "<test_alert alert_id=\"%s\"/>",
9141 "Internal error", __FUNCTION__, __LINE__,
9142 "An internal error occurred while testing an alert. " 9143 "Diagnostics: Failure to send command to manager daemon.",
9144 "/omp?cmd=get_alerts", response_data);
9148 if (read_entity_and_text_c (connection, &entity, &response))
9152 "Internal error", __FUNCTION__, __LINE__,
9153 "An internal error occurred while testing an alert. " 9154 "Diagnostics: Failure to receive response from manager daemon.",
9155 "/omp?cmd=get_alerts", response_data);
9160 html = response_from_entity (connection, credentials, params, entity,
9161 (no_redirect && strcmp (no_redirect,
"0")),
9164 "Test Alert", response_data);
9166 free_entity (entity);
9187 char **content_disposition, gsize *content_length,
9215 return export_many (connection,
"alert", credentials, params,
content_type,
9216 content_disposition, content_length, response_data);
9231 new_target (openvas_connection_t *connection,
credentials_t *credentials,
9232 params_t *params,
const char *extra_xml,
9237 gchar *ssh_credential, *smb_credential, *esxi_credential, *snmp_credential;
9239 const char *filter, *first, *max;
9254 "d74a9ee8-7d35-4879-9485-ab23f1bd45bc",);
9257 "6fc56b72-c1cf-451c-a4c4-3a9dc784c3bd",
9258 g_free (port_list));
9261 "a25c0cfe-f977-417b-b1da-47da370c03e8",
9263 g_free (ssh_credential));
9266 "83545bcf-0c49-4b4c-abbf-63baf82cc2a7",
9268 g_free (ssh_credential);
9269 g_free (smb_credential));
9272 "024550b8-868e-4b3c-98bf-99bb732f6a0d",
9274 g_free (ssh_credential);
9275 g_free (smb_credential);
9276 g_free (esxi_credential));
9278 xml = g_string_new (
"<new_target>");
9280 g_string_append_printf (xml,
9281 "<port_list_id>%s</port_list_id>" 9282 "<ssh_credential_id>%s</ssh_credential_id>" 9283 "<smb_credential_id>%s</smb_credential_id>" 9284 "<esxi_credential_id>%s</esxi_credential_id>" 9285 "<snmp_credential_id>%s</snmp_credential_id>",
9286 (port_list && strlen (port_list))
9288 :
"33d0cd82-57c6-11e1-8ed1-406186ea4fc5",
9289 ssh_credential ? ssh_credential :
"",
9290 smb_credential ? smb_credential :
"",
9291 esxi_credential ? esxi_credential :
"",
9292 snmp_credential ? snmp_credential :
"");
9295 g_free (ssh_credential);
9296 g_free (smb_credential);
9297 g_free (esxi_credential);
9300 g_string_append (xml, extra_xml);
9306 if (openvas_connection_sendf (connection,
9308 " filter=\"rows=-1 sort=name\"/>")
9311 g_string_free (xml, TRUE);
9314 "Internal error", __FUNCTION__, __LINE__,
9315 "An internal error occurred while getting targets list. " 9316 "The current list of targets is not available. " 9317 "Diagnostics: Failure to send command to manager daemon.",
9318 "/omp?cmd=get_targets", response_data);
9321 if (read_string_c (connection, &xml))
9323 g_string_free (xml, TRUE);
9326 "Internal error", __FUNCTION__, __LINE__,
9327 "An internal error occurred while getting targets list. " 9328 "The current list of targets is not available. " 9329 "Diagnostics: Failure to receive response from manager daemon.",
9330 "/omp?cmd=get_targets", response_data);
9338 if (openvas_connection_sendf (connection,
9340 " filter=\"rows=-1 sort=name\"/>")
9343 g_string_free (xml, TRUE);
9346 "Internal error", __FUNCTION__, __LINE__,
9347 "An internal error occurred while getting targets list. " 9348 "The current list of targets is not available. " 9349 "Diagnostics: Failure to send command to manager daemon.",
9350 "/omp?cmd=get_tasks", response_data);
9353 if (read_string_c (connection, &xml))
9355 g_string_free (xml, TRUE);
9358 "Internal error", __FUNCTION__, __LINE__,
9359 "An internal error occurred while getting targets list. " 9360 "The current list of targets is not available. " 9361 "Diagnostics: Failure to receive response from manager daemon.",
9362 "/omp?cmd=get_tasks", response_data);
9366 end = g_markup_printf_escaped (
"<filters><term>%s</term></filters>" 9367 "<targets start=\"%s\" max=\"%s\"/>" 9372 g_string_append (xml, end);
9375 return xsl_transform_omp (connection, credentials, params,
9376 g_string_free (xml, FALSE), response_data);
9393 return new_target (connection, credentials, params, NULL, response_data);
9412 gchar *html, *response, *command;
9413 const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
9414 const char *target_ssh_credential, *port, *target_smb_credential;
9415 const char *target_esxi_credential, *target_snmp_credential, *target_source;
9416 const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
9417 const char *alive_tests, *hosts_filter, *file;
9418 gchar *ssh_credentials_element, *smb_credentials_element;
9419 gchar *esxi_credentials_element, *snmp_credentials_element;
9420 gchar *asset_hosts_element;
9421 gchar* comment_element = NULL;
9428 exclude_hosts =
params_value (params,
"exclude_hosts");
9429 reverse_lookup_only =
params_value (params,
"reverse_lookup_only");
9430 reverse_lookup_unify =
params_value (params,
"reverse_lookup_unify");
9431 target_source =
params_value (params,
"target_source");
9434 target_ssh_credential =
params_value (params,
"ssh_credential_id");
9436 target_smb_credential =
params_value (params,
"smb_credential_id");
9437 target_esxi_credential =
params_value (params,
"esxi_credential_id");
9438 target_snmp_credential =
params_value (params,
"snmp_credential_id");
9445 if (hosts == NULL && strcmp (target_source,
"manual") == 0)
9446 return message_invalid (connection, credentials, params, response_data,
9447 "Missing manual list of hosts",
9448 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9449 "Create Target",
"new_target");
9450 if (strcmp (target_source,
"file") == 0 && file == NULL)
9451 return message_invalid (connection, credentials, params, response_data,
9452 "Missing hosts file",
9453 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9454 "Create Target",
"new_target");
9457 if (strcmp (target_source,
"asset_hosts") == 0)
9463 if (strcmp (target_ssh_credential,
"--"))
9470 if (comment != NULL)
9471 comment_element = g_strdup_printf (
"<comment>%s</comment>", comment);
9473 comment_element = g_strdup (
"");
9475 if (strcmp (target_ssh_credential,
"0") == 0)
9476 ssh_credentials_element = g_strdup (
"");
9478 ssh_credentials_element =
9479 g_strdup_printf (
"<ssh_credential id=\"%s\">" 9481 "</ssh_credential>",
9482 target_ssh_credential,
9485 if (strcmp (target_smb_credential,
"0") == 0)
9486 smb_credentials_element = g_strdup (
"");
9488 smb_credentials_element =
9489 g_strdup_printf (
"<smb_credential id=\"%s\"/>",
9490 target_smb_credential);
9492 if (strcmp (target_esxi_credential,
"0") == 0)
9493 esxi_credentials_element = g_strdup (
"");
9495 esxi_credentials_element =
9496 g_strdup_printf (
"<esxi_credential id=\"%s\"/>",
9497 target_esxi_credential);
9499 if (strcmp (target_snmp_credential,
"0") == 0)
9500 snmp_credentials_element = g_strdup (
"");
9502 snmp_credentials_element =
9503 g_strdup_printf (
"<snmp_credential id=\"%s\"/>",
9504 target_snmp_credential);
9506 if (strcmp (target_source,
"asset_hosts") == 0)
9507 asset_hosts_element = g_strdup_printf (
"<asset_hosts filter=\"%s\"/>",
9510 asset_hosts_element = g_strdup (
"");
9514 xml = g_string_new (
"");
9516 xml_string_append (xml,
9519 "<exclude_hosts>%s</exclude_hosts>" 9520 "<reverse_lookup_only>%s</reverse_lookup_only>" 9521 "<reverse_lookup_unify>%s</reverse_lookup_unify>" 9522 "<port_list id=\"%s\"/>" 9523 "<alive_tests>%s</alive_tests>",
9525 strcmp (target_source,
"file") == 0 ? file : hosts,
9526 exclude_hosts ? exclude_hosts :
"",
9527 reverse_lookup_only ? reverse_lookup_only :
"0",
9528 reverse_lookup_unify ? reverse_lookup_unify :
"0",
9532 command = g_strdup_printf (
"<create_target>" 9537 ssh_credentials_element,
9538 smb_credentials_element,
9539 esxi_credentials_element,
9540 snmp_credentials_element,
9541 asset_hosts_element);
9543 g_string_free (xml, TRUE);
9544 g_free (comment_element);
9545 g_free (ssh_credentials_element);
9546 g_free (smb_credentials_element);
9547 g_free (esxi_credentials_element);
9549 ret = omp (connection, credentials,
9565 "Internal error", __FUNCTION__, __LINE__,
9566 "An internal error occurred while creating a new target. " 9567 "No new target was created. " 9568 "Diagnostics: Failure to send command to manager daemon.",
9569 "/omp?cmd=get_targets", response_data);
9573 "Internal error", __FUNCTION__, __LINE__,
9574 "An internal error occurred while creating a new target. " 9575 "It is unclear whether the target has been created or not. " 9576 "Diagnostics: Failure to receive response from manager daemon.",
9577 "/omp?cmd=get_targets", response_data);
9581 "Internal error", __FUNCTION__, __LINE__,
9582 "An internal error occurred while creating a new target. " 9583 "It is unclear whether the target has been created or not. " 9584 "Diagnostics: Internal Error.",
9585 "/omp?cmd=get_targets", response_data);
9588 if (entity_attribute (entity,
"id"))
9589 params_add (params,
"target_id", entity_attribute (entity,
"id"));
9590 html = response_from_entity (connection, credentials, params, entity,
9591 (no_redirect && strcmp (no_redirect,
"0")),
9592 NULL,
"get_targets",
9594 "Create Target", response_data);
9595 free_entity (entity);
9605 #define CHECK(name) \ 9608 response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \ 9609 return gsad_message (credentials, \ 9610 "Internal error", __FUNCTION__, __LINE__, \ 9611 "An internal error occurred while cloning a resource. " \ 9612 "The resource was not cloned. " \ 9613 "Diagnostics: Required parameter '" G_STRINGIFY (name) \ 9615 "/omp?cmd=get_tasks", response_data); \ 9632 gchar *html, *response;
9633 const char *id, *type, *alterable, *no_redirect, *next_id;
9634 gchar *next_id_name, *cap_type, *prev_action;
9647 if (alterable && strcmp (alterable,
"0"))
9649 if (openvas_connection_sendf (connection,
9652 "<alterable>1</alterable>" 9661 "Internal error", __FUNCTION__, __LINE__,
9662 "An internal error occurred while cloning a resource. " 9663 "The resource was not cloned. " 9664 "Diagnostics: Failure to send command to manager daemon.",
9665 "/omp?cmd=get_tasks", response_data);
9668 else if (openvas_connection_sendf (connection,
9679 "Internal error", __FUNCTION__, __LINE__,
9680 "An internal error occurred while cloning a resource. " 9681 "The resource was not cloned. " 9682 "Diagnostics: Failure to send command to manager daemon.",
9683 "/omp?cmd=get_tasks", response_data);
9687 if (read_entity_and_text_c (connection, &entity, &response))
9691 "Internal error", __FUNCTION__, __LINE__,
9692 "An internal error occurred while cloning a resource. " 9693 "It is unclear whether the resource has been cloned or not. " 9694 "Diagnostics: Failure to read response from manager daemon.",
9695 "/omp?cmd=get_tasks", response_data);
9700 if (omp_success (entity) == 0 ||
params_given (params,
"next") == 0)
9703 next = g_strdup_printf (
"get_%ss", type);
9708 if (omp_success (entity))
9710 next_id = entity_attribute (entity,
"id");
9711 if (next_id == NULL)
9713 free_entity (entity);
9717 "Internal error", __FUNCTION__, __LINE__,
9718 "An internal error occurred while cloning a resource. " 9719 "The resource remains the same. " 9720 "Diagnostics: Error getting new resource.",
9721 "/omp?cmd=get_tasks", response_data);
9723 next_id_name = g_strdup_printf (
"%s_id", type);
9725 g_free (next_id_name);
9730 next_id_name = NULL;
9734 cap_type = capitalize (type);
9735 prev_action = g_strdup_printf (
"Clone %s", cap_type);
9736 html = response_from_entity (connection, credentials, params, entity,
9737 (no_redirect && strcmp (no_redirect,
"0")),
9740 prev_action, response_data);
9742 free_entity (entity);
9744 g_free (prev_action);
9768 "get_targets", response_data);
9787 "get_trash", response_data);
9806 "get_trash", response_data);
9825 "get_trash", response_data);
9843 return delete_resource (connection,
"credential", credentials, params, 1,
9844 "get_trash", response_data);
9862 return delete_resource (connection,
"report_format", credentials, params, 1,
9863 "get_trash", response_data);
9881 return delete_resource (connection,
"schedule", credentials, params, 1,
9882 "get_trash", response_data);
9901 "get_trash", response_data);
9920 "get_trash", response_data);
9940 const char *target_id, *no_redirect;
9945 if (target_id == NULL)
9949 "Internal error", __FUNCTION__, __LINE__,
9950 "An internal error occurred while restoring a resource. " 9951 "The resource was not restored. " 9952 "Diagnostics: Required parameter was NULL.",
9953 "/omp?cmd=get_tasks", response_data);
9956 xml = g_string_new (
"");
9960 if (openvas_connection_sendf (connection,
9966 g_string_free (xml, TRUE);
9969 "Internal error", __FUNCTION__, __LINE__,
9970 "An internal error occurred while restoring a resource. " 9971 "The resource was not deleted. " 9972 "Diagnostics: Failure to send command to manager daemon.",
9973 "/omp?cmd=get_trash", response_data);
9976 if (read_entity_and_string_c (connection, &entity, &xml))
9978 g_string_free (xml, TRUE);
9981 "Internal error", __FUNCTION__, __LINE__,
9982 "An internal error occurred while restoring a resource. " 9983 "It is unclear whether the resource has been restored or not. " 9984 "Diagnostics: Failure to read response from manager daemon.",
9985 "/omp?cmd=get_trash", response_data);
9990 ret = response_from_entity (connection, credentials, params, entity,
9991 (no_redirect && strcmp (no_redirect,
"0")),
9994 "Restore", response_data);
9995 free_entity (entity);
9996 g_string_free (xml, FALSE);
10016 const char* no_redirect;
10022 xml = g_string_new (
"");
10026 if (openvas_connection_sendf (connection,
10027 "<empty_trashcan/>")
10030 g_string_free (xml, TRUE);
10033 "Internal error", __FUNCTION__, __LINE__,
10034 "An internal error occurred while emptying the trashcan. " 10035 "Diagnostics: Failure to send command to manager daemon.",
10036 "/omp?cmd=get_trash", response_data);
10039 if (read_entity_and_string_c (connection, &entity, &xml))
10041 g_string_free (xml, TRUE);
10044 "Internal error", __FUNCTION__, __LINE__,
10045 "An internal error occurred while emptying the trashcan. " 10046 "Diagnostics: Failure to read response from manager daemon.",
10047 "/omp?cmd=get_trash", response_data);
10052 ret = response_from_entity (connection, credentials, params, entity,
10053 (no_redirect && strcmp (no_redirect,
"0")),
10056 "Empty Trashcan", response_data);
10057 free_entity (entity);
10058 g_string_free (xml, FALSE);
10074 new_tag (openvas_connection_t *connection,
credentials_t *credentials,
10075 params_t *params,
const char *extra_xml,
10080 const char *resource_type, *resource_id, *tag_id, *tag_name;
10082 resource_type =
params_value (params,
"resource_type");
10088 xml = g_string_new (
"<new_tag>");
10091 g_string_append (xml, extra_xml);
10093 end = g_markup_printf_escaped (
"<tag id=\"%s\"/>" 10094 "<resource_type>%s</resource_type>" 10095 "<resource_id>%s</resource_id>" 10096 "<tag_name>%s%s</tag_name>" 10097 "<tag_value></tag_value>" 10098 "<comment></comment>" 10099 "<active>1</active>" 10101 tag_id ? tag_id :
"0",
10102 resource_type ? resource_type :
"",
10103 resource_id ? resource_id :
"",
10104 tag_name ? tag_name : (resource_type
10107 tag_name ?
"" :
":unnamed");
10108 g_string_append (xml, end);
10111 return xsl_transform_omp (connection, credentials, params,
10112 g_string_free (xml, FALSE), response_data);
10129 return new_tag (connection, credentials, params, NULL, response_data);
10147 const char* no_redirect;
10149 const char *name, *comment, *value, *resource_type, *resource_id, *active;
10156 resource_type =
params_value (params,
"resource_type");
10169 switch (ompf (connection, credentials,
10175 "<comment>%s</comment>" 10176 "<value>%s</value>" 10177 "<resource id=\"%s\">" 10180 "<active>%s</active>" 10195 "Internal error", __FUNCTION__, __LINE__,
10196 "An internal error occurred while creating a new tag. " 10197 "No new tag was created. " 10198 "Diagnostics: Failure to send command to manager daemon.",
10199 "/omp?cmd=get_targets", response_data);
10203 "Internal error", __FUNCTION__, __LINE__,
10204 "An internal error occurred while creating a new tag. " 10205 "It is unclear whether the tag has been created or not. " 10206 "Diagnostics: Failure to receive response from manager daemon.",
10207 "/omp?cmd=get_tags", response_data);
10211 "Internal error", __FUNCTION__, __LINE__,
10212 "An internal error occurred while creating a new tag. " 10213 "It is unclear whether the tag has been created or not. " 10214 "Diagnostics: Internal Error.",
10215 "/omp?cmd=get_tags", response_data);
10218 if (entity_attribute (entity,
"id"))
10219 params_add (params,
"tag_id", entity_attribute (entity,
"id"));
10220 ret = response_from_entity (connection, credentials, params, entity,
10221 (no_redirect && strcmp (no_redirect,
"0")),
10224 "Create Tag", response_data);
10226 free_entity (entity);
10245 return delete_resource (connection,
"tag", credentials, params, 0, NULL,
10265 "get_trash", response_data);
10281 params_t *params,
const char *extra_xml,
10286 const char *tag_id;
10289 if (tag_id == NULL)
10293 "Internal error", __FUNCTION__, __LINE__,
10294 "An internal error occurred while editing a tag. " 10295 "The tag remains as it was. " 10296 "Diagnostics: Required parameter was NULL.",
10297 "/omp?cmd=get_tags", response_data);
10300 if (openvas_connection_sendf (connection,
10309 "Internal error", __FUNCTION__, __LINE__,
10310 "An internal error occurred while getting tag info. " 10311 "Diagnostics: Failure to send command to manager daemon.",
10312 "/omp?cmd=get_tags", response_data);
10315 xml = g_string_new (
"");
10317 edit = g_markup_printf_escaped (
"<edit_tag>" 10318 "<tag id=\"%s\"/>",
10321 g_string_append (xml, edit);
10325 g_string_append (xml, extra_xml);
10327 if (read_string_c (connection, &xml))
10329 g_string_free (xml, TRUE);
10332 "Internal error", __FUNCTION__, __LINE__,
10333 "An internal error occurred while getting target info. " 10334 "Diagnostics: Failure to receive response from manager daemon.",
10335 "/omp?cmd=get_tags", response_data);
10340 g_string_append (xml,
"</edit_tag>");
10341 return xsl_transform_omp (connection, credentials, params,
10342 g_string_free (xml, FALSE), response_data);
10359 return edit_tag (connection, credentials, params, NULL, response_data);
10377 const char *name, *comment, *value, *resource_type, *resource_id, *active;
10378 const char *tag_id, *no_redirect;
10387 resource_type =
params_value (params,
"resource_type");
10401 switch (ompf (connection, credentials,
10405 "<modify_tag tag_id=\"%s\">" 10407 "<comment>%s</comment>" 10408 "<value>%s</value>" 10409 "<resource id=\"%s\">" 10412 "<active>%s</active>" 10428 "Internal error", __FUNCTION__, __LINE__,
10429 "An internal error occurred while saving a tag. " 10430 "The tag remains the same. " 10431 "Diagnostics: Failure to send command to " 10433 "/omp?cmd=get_targets", response_data);
10437 "Internal error", __FUNCTION__, __LINE__,
10438 "An internal error occurred while saving a tag. " 10439 "It is unclear whether the tag has been saved " 10441 "Diagnostics: Failure to receive response from " 10443 "/omp?cmd=get_tags", response_data);
10447 "Internal error", __FUNCTION__, __LINE__,
10448 "An internal error occurred while saving a tag. " 10449 "It is unclear whether the tag has been saved " 10451 "Diagnostics: Internal Error.",
10452 "/omp?cmd=get_tags", response_data);
10455 ret = response_from_entity (connection, credentials, params, entity,
10456 (no_redirect && strcmp (no_redirect,
"0")),
10459 "Save Tag", response_data);
10461 free_entity (entity);
10484 char **content_disposition, gsize *content_length,
10488 content_disposition, content_length, response_data);
10508 char **content_disposition, gsize *content_length,
10511 return export_many (connection,
"tag", credentials, params,
content_type,
10512 content_disposition, content_length, response_data);
10527 get_tag (openvas_connection_t *connection,
credentials_t * credentials,
10528 params_t *params,
const char *extra_xml,
10531 return get_one (connection,
"tag", credentials, params, extra_xml, NULL,
10549 return get_tag (connection, credentials, params, NULL, response_data);
10564 get_tags (openvas_connection_t *connection,
credentials_t * credentials,
10565 params_t *params,
const char *extra_xml,
10568 return get_many (connection,
"tag", credentials, params, extra_xml, NULL,
10586 return get_tags (connection, credentials, params, NULL, response_data);
10603 gchar *html, *response;
10604 const char *no_redirect, *tag_id, *enable;
10611 if (tag_id == NULL)
10615 "Internal error", __FUNCTION__, __LINE__,
10616 "An internal error occurred while modifying a tag. " 10617 "The tag was not modified. " 10618 "Diagnostics: Required parameter tag_id was NULL.",
10619 "/omp?cmd=get_tasks", response_data);
10621 if (enable == NULL)
10625 "Internal error", __FUNCTION__, __LINE__,
10626 "An internal error occurred while modifying a tag. " 10627 "The tag was not modified. " 10628 "Diagnostics: Required parameter enable was NULL.",
10629 "/omp?cmd=get_tasks", response_data);
10634 if (openvas_connection_sendf (connection,
10635 "<modify_tag tag_id=\"%s\">" 10636 "<active>%s</active>" 10644 "Internal error", __FUNCTION__, __LINE__,
10645 "An internal error occurred while modifying a tag. " 10646 "The tag is not modified. " 10647 "Diagnostics: Failure to send command to" 10648 " manager daemon.",
10649 "/omp?cmd=get_tasks", response_data);
10653 if (read_entity_and_text_c (connection, &entity, &response))
10657 "Internal error", __FUNCTION__, __LINE__,
10658 "An internal error occurred while modifying a tag. " 10659 "It is unclear whether the tag has been modified" 10661 "Diagnostics: Failure to read response from" 10662 " manager daemon.",
10663 "/omp?cmd=get_tasks", response_data);
10666 if (! omp_success (entity))
10668 html = response_from_entity (connection, credentials, params, entity,
10669 (no_redirect && strcmp (no_redirect,
"0")),
10672 "Toggle Tag", response_data);
10674 free_entity (entity);
10693 params_t *params,
const char *extra_xml,
10698 const char *target_id, *next, *filter, *first, *max;
10706 if (target_id == NULL)
10710 "Internal error", __FUNCTION__, __LINE__,
10711 "An internal error occurred while editing a target. " 10712 "The target remains as it was. " 10713 "Diagnostics: Required parameter was NULL.",
10714 "/omp?cmd=get_targets", response_data);
10718 next =
"get_target";
10720 if (openvas_connection_sendf (connection,
10722 " target_id=\"%s\"" 10723 " details=\"1\"/>",
10729 "Internal error", __FUNCTION__, __LINE__,
10730 "An internal error occurred while getting target info. " 10731 "Diagnostics: Failure to send command to manager daemon.",
10732 "/omp?cmd=get_targets", response_data);
10735 xml = g_string_new (
"");
10738 g_string_append (xml, extra_xml);
10741 edit = g_markup_printf_escaped (
"<edit_target>" 10742 "<target id=\"%s\"/>" 10746 "<filters><term>%s</term></filters>" 10747 "<targets start=\"%s\" max=\"%s\"/>",
10753 g_string_append (xml, edit);
10756 if (read_string_c (connection, &xml))
10758 g_string_free (xml, TRUE);
10761 "Internal error", __FUNCTION__, __LINE__,
10762 "An internal error occurred while getting target info. " 10763 "Diagnostics: Failure to receive response from manager daemon.",
10764 "/omp?cmd=get_targets", response_data);
10771 if (openvas_connection_sendf (connection,
10773 " filter=\"rows=-1 sort=name\"/>")
10776 g_string_free (xml, TRUE);
10779 "Internal error", __FUNCTION__, __LINE__,
10780 "An internal error occurred while getting targets list. " 10781 "The current list of targets is not available. " 10782 "Diagnostics: Failure to send command to manager daemon.",
10783 "/omp?cmd=get_targets", response_data);
10786 if (read_string_c (connection, &xml))
10788 g_string_free (xml, TRUE);
10791 "Internal error", __FUNCTION__, __LINE__,
10792 "An internal error occurred while getting targets list. " 10793 "The current list of targets is not available. " 10794 "Diagnostics: Failure to receive response from manager daemon.",
10795 "/omp?cmd=get_targets", response_data);
10803 if (openvas_connection_sendf (connection,
10805 " filter=\"rows=-1 sort=name\"/>")
10808 g_string_free (xml, TRUE);
10811 "Internal error", __FUNCTION__, __LINE__,
10812 "An internal error occurred while getting targets list. " 10813 "The current list of targets is not available. " 10814 "Diagnostics: Failure to send command to manager daemon.",
10815 "/omp?cmd=get_tasks", response_data);
10818 if (read_string_c (connection, &xml))
10820 g_string_free (xml, TRUE);
10823 "Internal error", __FUNCTION__, __LINE__,
10824 "An internal error occurred while getting targets list. " 10825 "The current list of targets is not available. " 10826 "Diagnostics: Failure to receive response from manager daemon.",
10827 "/omp?cmd=get_tasks", response_data);
10833 g_string_append (xml,
"</edit_target>");
10834 return xsl_transform_omp (connection, credentials, params,
10835 g_string_free (xml, FALSE), response_data);
10852 return edit_target (connection, credentials, params, NULL, response_data);
10867 get_target (openvas_connection_t *connection,
credentials_t * credentials,
10868 params_t *params,
const char *extra_xml,
10871 return get_one (connection,
"target", credentials, params, extra_xml,
10872 "tasks=\"1\"", response_data);
10889 return get_target (connection, credentials, params, NULL, response_data);
10904 get_targets (openvas_connection_t *connection,
credentials_t * credentials,
10905 params_t *params,
const char *extra_xml,
10908 return get_many (connection,
"target", credentials, params, extra_xml, NULL,
10926 return get_targets (connection, credentials, params, NULL, response_data);
10943 gchar *html, *response;
10944 const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
10945 const char *target_ssh_credential, *port, *target_smb_credential;
10946 const char *target_esxi_credential, *target_snmp_credential, *target_source;
10947 const char *target_id, *port_list_id, *reverse_lookup_only;
10948 const char *reverse_lookup_unify, *alive_tests, *in_use;
10964 if (strcmp (in_use,
"0"))
10971 command = g_string_new (
"");
10972 xml_string_append (command,
10973 "<modify_target target_id=\"%s\">" 10975 "<comment>%s</comment>" 10976 "<alive_tests>%s</alive_tests>" 10977 "</modify_target>",
10980 comment ? comment :
"",
10985 ret = omp (connection, credentials, &response, &entity, response_data,
10987 g_string_free (command, TRUE);
10996 "Internal error", __FUNCTION__, __LINE__,
10997 "An internal error occurred while saving a target. " 10998 "The target remains the same. " 10999 "Diagnostics: Failure to send command to manager daemon.",
11000 "/omp?cmd=get_targets", response_data);
11004 "Internal error", __FUNCTION__, __LINE__,
11005 "An internal error occurred while saving a target. " 11006 "It is unclear whether the target has been saved or not. " 11007 "Diagnostics: Failure to receive response from manager daemon.",
11008 "/omp?cmd=get_targets", response_data);
11012 "Internal error", __FUNCTION__, __LINE__,
11013 "An internal error occurred while saving a target. " 11014 "It is unclear whether the target has been saved or not. " 11015 "Diagnostics: Internal Error.",
11016 "/omp?cmd=get_targets", response_data);
11019 html = response_from_entity (connection, credentials, params, entity,
11020 (no_redirect && strcmp (no_redirect,
"0")),
11021 NULL,
"get_targets",
11022 NULL,
"edit_target",
11023 "Save Target", response_data);
11025 free_entity (entity);
11031 exclude_hosts =
params_value (params,
"exclude_hosts");
11032 reverse_lookup_only =
params_value (params,
"reverse_lookup_only");
11033 reverse_lookup_unify =
params_value (params,
"reverse_lookup_unify");
11034 target_source =
params_value (params,
"target_source");
11036 target_ssh_credential =
params_value (params,
"ssh_credential_id");
11038 target_smb_credential =
params_value (params,
"smb_credential_id");
11039 target_esxi_credential =
params_value (params,
"esxi_credential_id");
11040 target_snmp_credential =
params_value (params,
"snmp_credential_id");
11049 if (strcmp (target_ssh_credential,
"--")
11050 && strcmp (target_ssh_credential,
"0"))
11053 if (hosts == NULL && strcmp (target_source,
"manual") == 0)
11055 return new_target (connection, credentials, params,
11059 if (strcmp (target_source,
"import") == 0 && name == NULL)
11063 "Given target_source was invalid",
11065 html = new_target (connection, credentials, params, msg, response_data);
11073 gchar *ssh_credentials_element, *smb_credentials_element;
11074 gchar *esxi_credentials_element, *snmp_credentials_element;
11075 gchar* comment_element;
11079 comment_element = g_strdup_printf (
"<comment>%s</comment>", comment);
11081 comment_element = g_strdup (
"");
11083 if (strcmp (target_ssh_credential,
"--") == 0)
11084 ssh_credentials_element = g_strdup (
"");
11086 ssh_credentials_element =
11087 g_strdup_printf (
"<ssh_credential id=\"%s\">" 11089 "</ssh_credential>",
11090 target_ssh_credential,
11093 if (strcmp (target_smb_credential,
"--") == 0)
11094 smb_credentials_element = g_strdup (
"");
11096 smb_credentials_element =
11097 g_strdup_printf (
"<smb_credential id=\"%s\"/>",
11098 target_smb_credential);
11100 if (strcmp (target_esxi_credential,
"--") == 0)
11101 esxi_credentials_element = g_strdup (
"");
11103 esxi_credentials_element =
11104 g_strdup_printf (
"<esxi_credential id=\"%s\"/>",
11105 target_esxi_credential);
11107 if (strcmp (target_snmp_credential,
"--") == 0)
11108 snmp_credentials_element = g_strdup (
"");
11110 snmp_credentials_element =
11111 g_strdup_printf (
"<snmp_credential id=\"%s\"/>",
11112 target_snmp_credential);
11114 command = g_string_new (
"");
11115 xml_string_append (command,
11116 "<modify_target target_id=\"%s\">" 11118 "<hosts>%s</hosts>" 11119 "<exclude_hosts>%s</exclude_hosts>" 11120 "<reverse_lookup_only>%s</reverse_lookup_only>" 11121 "<reverse_lookup_unify>%s</reverse_lookup_unify>" 11122 "<port_list id=\"%s\"/>" 11123 "<alive_tests>%s</alive_tests>",
11126 strcmp (target_source,
"file") == 0
11129 exclude_hosts ? exclude_hosts :
"",
11130 reverse_lookup_only ? reverse_lookup_only :
"0",
11131 reverse_lookup_unify ? reverse_lookup_unify :
"0",
11135 g_string_append_printf (command,
11137 "</modify_target>",
11139 ssh_credentials_element,
11140 smb_credentials_element,
11141 esxi_credentials_element,
11142 snmp_credentials_element);
11144 g_free (comment_element);
11145 g_free (ssh_credentials_element);
11146 g_free (smb_credentials_element);
11147 g_free (esxi_credentials_element);
11148 g_free (snmp_credentials_element);
11152 ret = openvas_connection_sendf (connection,
"%s", command->str);
11153 g_string_free (command, TRUE);
11159 "Internal error", __FUNCTION__, __LINE__,
11160 "An internal error occurred while modifying target. " 11161 "No target was modified. " 11162 "Diagnostics: Failure to send command to manager daemon.",
11163 "/omp?cmd=get_targets", response_data);
11167 if (read_entity_and_text_c (connection, &entity, &response))
11171 "Internal error", __FUNCTION__, __LINE__,
11172 "An internal error occurred while modifying a target. " 11173 "It is unclear whether the target has been modified or not. " 11174 "Diagnostics: Failure to receive response from manager daemon.",
11175 "/omp?cmd=get_targets", response_data);
11178 html = response_from_entity (connection, credentials, params, entity,
11179 (no_redirect && strcmp (no_redirect,
"0")),
11180 NULL,
"get_targets",
11181 NULL,
"edit_target",
11182 "Save Target", response_data);
11235 return export_many (connection,
"target", credentials, params,
content_type,
11236 content_disposition, content_length, response_data);
11251 new_config (openvas_connection_t *connection,
credentials_t *credentials,
11252 params_t *params,
const char *extra_xml,
11257 entity_t entity = NULL;
11258 gchar *response = NULL;
11260 xml = g_string_new (
"<new_config>");
11262 g_string_append (xml, extra_xml);
11265 ret = omp (connection, credentials, &response, &entity, response_data,
11266 "<get_scanners/>");
11275 "Internal error", __FUNCTION__, __LINE__,
11276 "An internal error occurred while getting scanners" 11277 " for new config. Diagnostics: Failure to send" 11278 " command to manager daemon.",
11279 "/omp?cmd=get_configs", response_data);
11283 "Internal error", __FUNCTION__, __LINE__,
11284 "An internal error occurred while getting scanners" 11285 " for new config. " "Diagnostics: Failure to" 11286 " receive response from manager daemon.",
11287 "/omp?cmd=get_configs", response_data);
11291 "Internal error", __FUNCTION__, __LINE__,
11292 "An internal error occurred while getting scanners" 11293 "for new config. It is unclear whether the config" 11294 " has been saved or not. " 11295 "Diagnostics: Internal Error.",
11296 "/omp?cmd=get_configs", response_data);
11298 g_string_append (xml, response);
11300 free_entity (entity);
11302 g_string_append (xml,
"</new_config>");
11303 return xsl_transform_omp (connection, credentials, params,
11304 g_string_free (xml, FALSE), response_data);
11321 return new_config (connection, credentials, params, NULL, response_data);
11336 upload_config (openvas_connection_t *connection,
credentials_t *credentials,
11337 params_t *params,
const char *extra_xml,
11342 xml = g_string_new (
"<upload_config>");
11344 g_string_append (xml, extra_xml);
11345 g_string_append (xml,
"</upload_config>");
11347 return xsl_transform_omp (connection, credentials, params,
11348 g_string_free (xml, FALSE), response_data);
11365 return upload_config (connection, credentials, params, NULL, response_data);
11383 gchar *html, *response;
11384 const char *no_redirect, *name, *comment, *base, *scanner = NULL;
11395 if (!strcmp (base,
"0"))
11402 switch (ompf (connection, credentials,
11409 "<comment>%s</comment>" 11410 "<scanner>%s</scanner>" 11411 "</create_config>",
11412 name, base, comment,
11421 "Internal error", __FUNCTION__, __LINE__,
11422 "An internal error occurred while creating a new config. " 11423 "No new config was created. " 11424 "Diagnostics: Failure to send command to manager daemon.",
11425 "/omp?cmd=get_configs", response_data);
11429 "Internal error", __FUNCTION__, __LINE__,
11430 "An internal error occurred while creating a new config. " 11431 "It is unclear whether the config has been created or not. " 11432 "Diagnostics: Failure to receive response from manager daemon.",
11433 "/omp?cmd=get_configs", response_data);
11437 "Internal error", __FUNCTION__, __LINE__,
11438 "An internal error occurred while creating a new config. " 11439 "It is unclear whether the config has been created or not. " 11440 "Diagnostics: Internal Error.",
11441 "/omp?cmd=get_configs", response_data);
11444 if (entity_attribute (entity,
"id"))
11445 params_add (params,
"config_id", entity_attribute (entity,
"id"));
11446 html = response_from_entity (connection, credentials, params, entity,
11447 (no_redirect && strcmp (no_redirect,
"0")),
11448 NULL,
"get_configs",
11449 NULL,
"new_config",
11450 "Create Config", response_data);
11452 free_entity (entity);
11472 const char *no_redirect;
11473 gchar *command, *html, *response;
11483 command = g_strdup_printf (
"<create_config>" 11485 "</create_config>",
11487 ret = omp (connection, credentials, &response, &entity, response_data,
11498 "Internal error", __FUNCTION__, __LINE__,
11499 "An internal error occurred while importing a config. " 11500 "The schedule remains the same. " 11501 "Diagnostics: Failure to send command to manager daemon.",
11502 "/omp?cmd=get_configs", response_data);
11506 "Internal error", __FUNCTION__, __LINE__,
11507 "An internal error occurred while importing a config. " 11508 "It is unclear whether the schedule has been saved or not. " 11509 "Diagnostics: Failure to receive response from manager daemon.",
11510 "/omp?cmd=get_configs", response_data);
11514 "Internal error", __FUNCTION__, __LINE__,
11515 "An internal error occurred while importing a config. " 11516 "It is unclear whether the schedule has been saved or not. " 11517 "Diagnostics: Internal Error.",
11518 "/omp?cmd=get_configs", response_data);
11523 html = response_from_entity (connection, credentials, params, entity,
11524 (no_redirect && strcmp (no_redirect,
"0")),
11525 NULL,
"get_configs",
11526 NULL,
"new_config",
11527 "Import Config", response_data);
11528 free_entity (entity);
11545 get_configs (openvas_connection_t *connection,
credentials_t *credentials,
11546 params_t *params,
const char *extra_xml,
11549 return get_many (connection,
"config", credentials, params, extra_xml, NULL,
11567 return get_configs (connection, credentials, params, NULL, response_data);
11583 get_config (openvas_connection_t *connection,
credentials_t * credentials,
11584 params_t *params,
const char *extra_xml,
int edit,
11588 const char *config_id;
11592 if (config_id == NULL)
11593 return get_configs (connection, credentials, params, extra_xml,
11596 xml = g_string_new (
"<get_config_response>");
11597 if (edit) g_string_append (xml,
"<edit/>");
11600 g_string_append (xml, extra_xml);
11603 if (openvas_connection_sendf (connection,
11605 " config_id=\"%s\"" 11608 " preferences=\"1\"/>",
11612 g_string_free (xml, TRUE);
11615 "Internal error", __FUNCTION__, __LINE__,
11616 "An internal error occurred while getting the config. " 11617 "The config is not available. " 11618 "Diagnostics: Failure to send command to manager daemon.",
11619 "/omp?cmd=get_configs", response_data);
11622 if (read_string_c (connection, &xml))
11624 g_string_free (xml, TRUE);
11627 "Internal error", __FUNCTION__, __LINE__,
11628 "An internal error occurred while getting the config. " 11629 "The config is not available. " 11630 "Diagnostics: Failure to receive response from manager daemon.",
11631 "/omp?cmd=get_configs", response_data);
11636 if (openvas_connection_sendf (connection,
"<get_nvt_families/>") == -1)
11638 g_string_free (xml, TRUE);
11641 "Internal error", __FUNCTION__, __LINE__,
11642 "An internal error occurred while getting the config. " 11643 "The config is not available. " 11644 "Diagnostics: Failure to send command to manager daemon.",
11645 "/omp?cmd=get_configs", response_data);
11648 if (read_string_c (connection, &xml))
11650 g_string_free (xml, TRUE);
11653 "Internal error", __FUNCTION__, __LINE__,
11654 "An internal error occurred while getting the config. " 11655 "The config is not available. " 11656 "Diagnostics: Failure to receive response from manager daemon.",
11657 "/omp?cmd=get_configs", response_data);
11663 if (openvas_connection_sendf (connection,
"<get_scanners filter=\"type=1\"/>")
11666 g_string_free (xml, TRUE);
11669 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11670 "An internal error occurred while getting the config. " 11671 "The config is not available. " 11672 "Diagnostics: Failure to send command to manager daemon.",
11673 "/omp?cmd=get_configs", response_data);
11676 if (read_string_c (connection, &xml))
11678 g_string_free (xml, TRUE);
11681 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11682 "An internal error occurred while getting the config. " 11683 "The config is not available. " 11684 "Diagnostics: Failure to receive response from manager daemon.",
11685 "/omp?cmd=get_configs", response_data);
11691 if (openvas_connection_sendf (connection,
"<get_credentials/>") == -1)
11693 g_string_free (xml, TRUE);
11696 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11697 "An internal error occurred while getting the config. " 11698 "The config is not available. " 11699 "Diagnostics: Failure to send command to manager daemon.",
11700 "/omp?cmd=get_configs", response_data);
11702 if (read_string_c (connection, &xml))
11704 g_string_free (xml, TRUE);
11707 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11708 "An internal error occurred while getting the config. " 11709 "The config is not available. " 11710 "Diagnostics: Failure to receive response from manager daemon.",
11711 "/omp?cmd=get_configs", response_data);
11716 g_string_append (xml,
"<permissions>");
11718 if (openvas_connection_sendf (connection,
11720 " filter=\"name:^.*(config)s?$" 11721 " and resource_uuid=%s" 11722 " first=1 rows=-1\"/>",
11726 g_string_free (xml, TRUE);
11729 "Internal error", __FUNCTION__, __LINE__,
11730 "An internal error occurred while getting permissions list. " 11731 "The current list of resources is not available. " 11732 "Diagnostics: Failure to send command to manager daemon.",
11733 "/omp?cmd=get_resources", response_data);
11736 if (read_string_c (connection, &xml))
11738 g_string_free (xml, TRUE);
11741 "Internal error", __FUNCTION__, __LINE__,
11742 "An internal error occurred while getting permissions list. " 11743 "The current list of resources is not available. " 11744 "Diagnostics: Failure to receive response from manager daemon.",
11745 "/omp?cmd=get_resources", response_data);
11748 g_string_append (xml,
"</permissions>");
11752 g_string_append (xml,
"</get_config_response>");
11753 return xsl_transform_omp (connection, credentials, params,
11754 g_string_free (xml, FALSE), response_data);
11771 return get_config (connection, credentials, params, NULL, 0, response_data);
11785 edit_config (openvas_connection_t *connection,
credentials_t * credentials,
11786 params_t *params,
const char *extra_xml,
11789 return get_config (connection, credentials, params, extra_xml, 1,
11807 return edit_config (connection, credentials, params, NULL, response_data);
11825 const char *config_id, *next;
11829 CHECK_PARAM (config_id,
"Synchronize Config", get_configs);
11831 if (openvas_connection_sendf (connection,
"<sync_config config_id=\"%s\"/>",
11837 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11838 "An internal error occurred while synchronizing a config. " 11839 "The config is not synchronized. " 11840 "Diagnostics: Failure to send command to manager daemon.",
11841 "/omp?cmd=get_configs", response_data);
11844 xml = g_string_new (
"");
11846 if (read_string_c (connection, &xml))
11848 g_string_free (xml, TRUE);
11851 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11852 "An internal error occurred while synchronizing a config. " 11853 "It is unclear whether the config has been synchronized or not. " 11854 "Diagnostics: Failure to receive response from manager daemon.",
11855 "/omp?cmd=get_configs", response_data);
11859 if (next && !strcmp (next,
"get_config"))
11860 ret = get_config (connection, credentials, params, xml->str, 0,
11863 ret = get_configs (connection, credentials, params, xml->str,
11865 g_string_free (xml, TRUE);
11884 save_osp_prefs (
credentials_t *credentials, openvas_connection_t *connection,
11885 params_t *params,
const char *next,
const char *fail_next,
11888 GHashTableIter iter;
11889 gpointer param_name, val;
11891 const char *config_id;
11894 g_hash_table_iter_init (&iter, params);
11896 while (g_hash_table_iter_next (&iter, ¶m_name, &val))
11904 if (!g_str_has_prefix (param_name,
"osp_pref_"))
11911 param_name = ((
char *) param_name) + 9;
11912 if (openvas_connection_sendf (connection,
11913 "<modify_config config_id=\"%s\">" 11914 "<preference><name>%s</name>" 11915 "<value>%s</value></preference>" 11916 "</modify_config>",
11918 (
char *) param_name,
11925 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11926 "An internal error occurred while saving a config. It is" 11927 " unclear whether the entire config has been saved. " 11928 "Diagnostics: Failure to send command to manager daemon.",
11929 "/omp?cmd=get_configs", response_data);
11933 ret = check_modify_config (credentials, connection, params, next,
11934 fail_next, success, response_data);
11956 char *ret, *osp_ret;
11957 params_t *preferences, *selects, *trends;
11958 const char *config_id, *name, *comment, *scanner_id;
11973 omp_ret = openvas_connection_sendf_xml (connection,
11974 "<modify_config config_id=\"%s\">" 11976 "<comment>%s</comment>" 11977 "<scanner>%s</scanner>" 11978 "</modify_config>",
11984 omp_ret = openvas_connection_sendf_xml (connection,
11985 "<modify_config config_id=\"%s\">" 11987 "<comment>%s</comment>" 11988 "</modify_config>",
11997 "Internal error", __FUNCTION__, __LINE__,
11998 "An internal error occurred while saving a config. " 11999 "It is unclear whether the entire config has been saved. " 12000 "Diagnostics: Failure to send command to manager daemon.",
12001 "/omp?cmd=get_configs", response_data);
12004 ret = check_modify_config (credentials, connection, params,
12005 "get_config",
"edit_config",
12006 &success, response_data);
12031 if (openvas_connection_sendf (connection,
12032 "<modify_config config_id=\"%s\">" 12035 "<value>%s</value>" 12037 "</modify_config>",
12046 "Internal error", __FUNCTION__, __LINE__,
12047 "An internal error occurred while saving a config. " 12048 "It is unclear whether the entire config has been saved. " 12049 "Diagnostics: Failure to send command to manager daemon.",
12050 "/omp?cmd=get_configs", response_data);
12055 ret = check_modify_config (credentials, connection, params,
12056 "get_config",
"edit_config",
12057 &success, response_data);
12066 osp_ret = save_osp_prefs (credentials, connection, params,
12067 "get_config",
"edit_config",
12068 &success, response_data);
12078 if (osp_ret == NULL)
12082 "Internal error", __FUNCTION__, __LINE__,
12083 "An internal error occurred while saving a config. " 12084 "It is unclear whether the entire config has been saved. " 12085 "Diagnostics: save_osp_prefs returned NULL unexpectedly.",
12086 "/omp?cmd=get_configs", response_data);
12096 if (trends || selects ||
params_value (params,
"trend"))
12098 if (openvas_connection_sendf (connection,
12099 "<modify_config config_id=\"%s\">" 12100 "<family_selection>" 12101 "<growing>%i</growing>",
12110 "Internal error", __FUNCTION__, __LINE__,
12111 "An internal error occurred while saving a config. " 12112 "It is unclear whether the entire config has been saved. " 12113 "Diagnostics: Failure to send command to manager daemon.",
12114 "/omp?cmd=get_configs", response_data);
12125 if (openvas_connection_sendf (connection,
12129 "<growing>%i</growing>" 12132 trends &&
member1 (trends, family))
12137 "Internal error", __FUNCTION__, __LINE__,
12138 "An internal error occurred while saving a config. " 12139 "It is unclear whether the entire config has been saved. " 12140 "Diagnostics: Failure to send command to manager daemon.",
12141 "/omp?cmd=get_configs", response_data);
12156 if (selects && member (selects, family))
continue;
12157 if (openvas_connection_sendf (connection,
12161 "<growing>1</growing>" 12168 "Internal error", __FUNCTION__, __LINE__,
12169 "An internal error occurred while saving a config. " 12170 "It is unclear whether the entire config has been saved. " 12171 "Diagnostics: Failure to send command to manager daemon.",
12172 "/omp?cmd=get_configs", response_data);
12177 if (openvas_connection_sendf (connection,
12178 "</family_selection>" 12179 "</modify_config>")
12184 "Internal error", __FUNCTION__, __LINE__,
12185 "An internal error occurred while saving a config. " 12186 "It is unclear whether the entire config has been saved. " 12187 "Diagnostics: Failure to send command to manager daemon.",
12188 "/omp?cmd=get_configs", response_data);
12192 ret = check_modify_config (credentials, connection, params,
12193 "get_config",
"edit_config",
12194 NULL, response_data);
12211 get_config_family (openvas_connection_t *connection,
12216 const char *config_id, *name, *family, *sort_field, *sort_order;
12222 if ((config_id == NULL) || (name == NULL) || (family == NULL))
12226 "Internal error", __FUNCTION__, __LINE__,
12227 "An internal error occurred while getting config family. " 12228 "Diagnostics: Required parameter was NULL.",
12229 "/omp?cmd=get_configs", response_data);
12232 xml = g_string_new (
"<get_config_family_response>");
12233 if (edit) g_string_append (xml,
"<edit/>");
12235 g_string_append_printf (xml,
12236 "<config id=\"%s\">" 12237 "<name>%s</name><family>%s</family>" 12248 if (openvas_connection_sendf (connection,
12250 " config_id=\"%s\" details=\"1\"" 12251 " family=\"%s\" timeout=\"1\" preference_count=\"1\"" 12252 " sort_field=\"%s\" sort_order=\"%s\"/>",
12255 sort_field ? sort_field :
"nvts.name",
12256 sort_order ? sort_order :
"ascending")
12259 g_string_free (xml, TRUE);
12262 "Internal error", __FUNCTION__, __LINE__,
12263 "An internal error occurred while getting list of configs. " 12264 "The current list of configs is not available. " 12265 "Diagnostics: Failure to send command to manager daemon.",
12266 "/omp?cmd=get_configs", response_data);
12269 if (read_string_c (connection, &xml))
12271 g_string_free (xml, TRUE);
12274 "Internal error", __FUNCTION__, __LINE__,
12275 "An internal error occurred while getting list of configs. " 12276 "The current list of configs is not available. " 12277 "Diagnostics: Failure to receive response from manager daemon.",
12278 "/omp?cmd=get_configs", response_data);
12285 g_string_append (xml,
"<all>");
12287 if (openvas_connection_sendf (connection,
12292 " preferences_config_id=\"%s\"" 12293 " preference_count=\"1\"" 12294 " sort_field=\"%s\"" 12295 " sort_order=\"%s\"/>",
12298 sort_field ? sort_field :
"nvts.name",
12299 sort_order ? sort_order :
"ascending")
12302 g_string_free (xml, TRUE);
12305 "Internal error", __FUNCTION__, __LINE__,
12306 "An internal error occurred while getting list of configs. " 12307 "The current list of configs is not available. " 12308 "Diagnostics: Failure to send command to manager daemon.",
12309 "/omp?cmd=get_configs", response_data);
12312 if (read_string_c (connection, &xml))
12314 g_string_free (xml, TRUE);
12317 "Internal error", __FUNCTION__, __LINE__,
12318 "An internal error occurred while getting list of configs. " 12319 "The current list of configs is not available. " 12320 "Diagnostics: Failure to receive response from manager daemon.",
12321 "/omp?cmd=get_configs", response_data);
12324 g_string_append (xml,
"</all>");
12327 g_string_append (xml,
"</get_config_family_response>");
12328 return xsl_transform_omp (connection, credentials, params,
12329 g_string_free (xml, FALSE), response_data);
12347 return get_config_family (connection, credentials, params, 0, response_data);
12365 return get_config_family (connection, credentials, params, 1, response_data);
12384 const char *config_id, *family;
12390 if ((config_id == NULL) || (family == NULL))
12394 "Internal error", __FUNCTION__, __LINE__,
12395 "An internal error occurred while saving getting config family. " 12396 "The config has not been saved. " 12397 "Diagnostics: Required parameter was NULL.",
12398 "/omp?cmd=get_configs", response_data);
12403 if (openvas_connection_sendf (connection,
12404 "<modify_config config_id=\"%s\">" 12406 "<family>%s</family>",
12413 "Internal error", __FUNCTION__, __LINE__,
12414 "An internal error occurred while saving a config. " 12415 "It is unclear whether the entire config has been saved. " 12416 "Diagnostics: Failure to send command to manager daemon.",
12417 "/omp?cmd=get_configs", response_data);
12429 if (openvas_connection_sendf (connection,
12430 "<nvt oid=\"%s\"/>",
12436 "Internal error", __FUNCTION__, __LINE__,
12437 "An internal error occurred while saving a config. " 12438 "It is unclear whether the entire config has been saved. " 12439 "Diagnostics: Failure to send command to manager daemon.",
12440 "/omp?cmd=get_configs", response_data);
12444 if (openvas_connection_sendf (connection,
12446 "</modify_config>")
12451 "Internal error", __FUNCTION__, __LINE__,
12452 "An internal error occurred while saving a config. " 12453 "It is unclear whether the entire config has been saved. " 12454 "Diagnostics: Failure to send command to manager daemon.",
12455 "/omp?cmd=get_configs", response_data);
12458 ret = check_modify_config (credentials, connection, params,
12459 "get_config_family",
"edit_config_family",
12460 NULL, response_data);
12477 get_config_nvt (openvas_connection_t *connection,
credentials_t * credentials,
12481 const char *config_id, *name, *family, *sort_field, *sort_order, *nvt;
12488 if ((config_id == NULL) || (name == NULL))
12492 "Internal error", __FUNCTION__, __LINE__,
12493 "An internal error occurred while getting config family. " 12494 "Diagnostics: Required parameter was NULL.",
12495 "/omp?cmd=get_configs", response_data);
12498 xml = g_string_new (
"<get_config_nvt_response>");
12499 if (edit) g_string_append (xml,
"<edit/>");
12501 g_string_append_printf (xml,
12502 "<config id=\"%s\">" 12503 "<name>%s</name><family>%s</family>" 12507 family ? family :
"");
12512 if (openvas_connection_sendf (connection,
12514 " config_id=\"%s\" nvt_oid=\"%s\"" 12515 " details=\"1\" preferences=\"1\"" 12516 " sort_field=\"%s\" sort_order=\"%s\"/>",
12519 sort_field ? sort_field :
"nvts.name",
12520 sort_order ? sort_order :
"ascending")
12523 g_string_free (xml, TRUE);
12526 "Internal error", __FUNCTION__, __LINE__,
12527 "An internal error occurred while getting list of configs. " 12528 "The current list of configs is not available. " 12529 "Diagnostics: Failure to send command to manager daemon.",
12530 "/omp?cmd=get_configs", response_data);
12533 if (read_string_c (connection, &xml))
12535 g_string_free (xml, TRUE);
12538 "Internal error", __FUNCTION__, __LINE__,
12539 "An internal error occurred while getting list of configs. " 12540 "The current list of configs is not available. " 12541 "Diagnostics: Failure to receive response from manager daemon.",
12542 "/omp?cmd=get_configs", response_data);
12545 g_string_append (xml,
"</get_config_nvt_response>");
12547 if (openvas_connection_sendf (connection,
12550 " sort_field=\"notes.text\"/>",
12554 g_string_free (xml, TRUE);
12557 "Internal error", __FUNCTION__, __LINE__,
12558 "An internal error occurred while getting list of notes. " 12559 "The current list of notes is not available. " 12560 "Diagnostics: Failure to send command to manager daemon.",
12561 "/omp?cmd=get_configs", response_data);
12564 if (read_string_c (connection, &xml))
12566 g_string_free (xml, TRUE);
12569 "Internal error", __FUNCTION__, __LINE__,
12570 "An internal error occurred while getting list of notes. " 12571 "The current list of notes is not available. " 12572 "Diagnostics: Failure to receive response from manager daemon.",
12573 "/omp?cmd=get_configs", response_data);
12576 if (openvas_connection_sendf (connection,
12579 " sort_field=\"overrides.text\"/>",
12583 g_string_free (xml, TRUE);
12586 "Internal error", __FUNCTION__, __LINE__,
12587 "An internal error occurred while getting list of overrides. " 12588 "The current list of overrides is not available. " 12589 "Diagnostics: Failure to send command to manager daemon.",
12590 "/omp?cmd=get_configs", response_data);
12593 if (read_string_c (connection, &xml))
12595 g_string_free (xml, TRUE);
12598 "Internal error", __FUNCTION__, __LINE__,
12599 "An internal error occurred while getting list of overrides. " 12600 "The current list of overrides is not available. " 12601 "Diagnostics: Failure to receive response from manager daemon.",
12602 "/omp?cmd=get_configs", response_data);
12605 return xsl_transform_omp (connection, credentials, params,
12606 g_string_free (xml, FALSE), response_data);
12624 return get_config_nvt (connection, credentials, params, 0, response_data);
12642 return get_config_nvt (connection, credentials, params, 1, response_data);
12661 const char *config_id;
12663 char *modify_config_ret;
12665 modify_config_ret = NULL;
12672 gchar *preference_name;
12680 int type_start, type_end, count, ret, is_timeout = 0;
12683 g_free (modify_config_ret);
12684 modify_config_ret = NULL;
12691 count = sscanf (preference_name,
12692 "%*[^[][%n%*[^]]%n]:",
12695 if (count == 0 && type_start > 0 && type_end > 0)
12697 if (strncmp (preference_name + type_start,
12699 type_end - type_start)
12709 gchar *password_name;
12716 if (strcmp (password_name, preference_name) == 0)
12726 else if (strncmp (preference_name + type_start,
12728 type_end - type_start)
12745 if (strcmp (file_name, preference_name) == 0)
12755 else if (strncmp (preference_name + type_start,
12757 type_end - type_start)
12766 ? g_base64_encode ((guchar *) preference->
value,
12772 const char *timeout;
12773 gchar *preference_name_escaped;
12777 if (timeout == NULL)
12782 "Internal error", __FUNCTION__, __LINE__,
12783 "An internal error occurred while saving a config. " 12784 "It is unclear whether the entire config has been saved. " 12785 "Diagnostics: Required parameter was NULL.",
12786 "/omp?cmd=get_configs", response_data);
12789 preference_name_escaped = g_markup_escape_text (preference_name,
12792 if (strcmp (timeout,
"0") == 0)
12794 ret = openvas_connection_sendf (connection,
12796 " config_id=\"%s\">" 12800 "</modify_config>",
12802 preference_name_escaped);
12804 ret = openvas_connection_sendf (connection,
12806 " config_id=\"%s\">" 12809 "<value>%s</value>" 12811 "</modify_config>",
12813 preference_name_escaped,
12816 g_free (preference_name_escaped);
12820 gchar *preference_name_escaped;
12821 preference_name_escaped = g_markup_escape_text (preference_name,
12823 ret = openvas_connection_sendf (connection,
12825 " config_id=\"%s\">" 12827 "<nvt oid=\"%s\"/>" 12829 "<value>%s</value>" 12831 "</modify_config>",
12834 preference_name_escaped,
12836 g_free (preference_name_escaped);
12844 "Internal error", __FUNCTION__, __LINE__,
12845 "An internal error occurred while saving a config. " 12846 "It is unclear whether the entire config has been saved. " 12847 "Diagnostics: Failure to send command to manager daemon.",
12848 "/omp?cmd=get_configs", response_data);
12852 modify_config_ret = check_modify_config (credentials, connection,
12856 &success, response_data);
12859 return modify_config_ret;
12864 return modify_config_ret;
12882 return delete_resource (connection,
"config", credentials, params, 0,
12883 "get_configs", response_data);
12930 return export_many (connection,
"config", credentials, params,
content_type,
12931 content_disposition, content_length, response_data);
12950 char **content_disposition, gsize *content_length,
12954 content_disposition, content_length, response_data);
12974 char **content_disposition, gsize *content_length,
12977 return export_many (connection,
"note", credentials, params,
content_type,
12978 content_disposition, content_length, response_data);
12998 char **content_disposition, gsize *content_length,
13024 char **content_disposition, gsize *content_length,
13027 return export_many (connection,
"override", credentials, params,
content_type,
13028 content_disposition, content_length, response_data);
13049 char **content_disposition, gsize *content_length,
13052 return export_resource (connection,
"port_list", credentials, params,
13075 char **content_disposition, gsize *content_length,
13078 return export_many (connection,
"port_list", credentials, params,
13100 char **content_disposition, gsize *content_length,
13104 entity_t entity, preference_entity, value_entity;
13105 const char *config_id, *oid, *preference_name;
13107 *content_length = 0;
13111 preference_name =
params_value (params,
"preference_name");
13113 xml = g_string_new (
"<get_preferences_response>");
13115 if (config_id == NULL || oid == NULL || preference_name == NULL)
13119 if (openvas_connection_sendf (connection,
13121 " config_id=\"%s\"" 13123 " preference=\"%s\"/>",
13129 g_string_free (xml, TRUE);
13132 "Internal error", __FUNCTION__, __LINE__,
13133 "An internal error occurred while getting a preference file. " 13134 "The file could not be delivered. " 13135 "Diagnostics: Failure to send command to manager daemon.",
13136 "/omp?cmd=get_tasks", response_data);
13140 if (read_entity_c (connection, &entity))
13142 g_string_free (xml, TRUE);
13145 "Internal error", __FUNCTION__, __LINE__,
13146 "An internal error occurred while getting a preference file. " 13147 "The file could not be delivered. " 13148 "Diagnostics: Failure to receive response from manager daemon.",
13149 "/omp?cmd=get_tasks", response_data);
13152 preference_entity = entity_child (entity,
"preference");
13153 if (preference_entity != NULL
13154 && (value_entity = entity_child (preference_entity,
"value")))
13156 char *content = strdup (entity_text (value_entity));
13158 *content_disposition = g_strdup_printf (
"attachment; filename=\"pref_file.bin\"");
13159 *content_length = strlen (content);
13160 free_entity (entity);
13161 g_string_free (xml, TRUE);
13166 free_entity (entity);
13167 g_string_free (xml, TRUE);
13170 "Internal error", __FUNCTION__, __LINE__,
13171 "An internal error occurred while getting a preference file. " 13172 "The file could not be delivered. " 13173 "Diagnostics: Failure to receive file from manager daemon.",
13174 "/omp?cmd=get_tasks", response_data);
13178 g_string_append (xml,
"</get_preferences_response>");
13179 return xsl_transform_omp (connection, credentials, params,
13180 g_string_free (xml, FALSE), response_data);
13201 char **content_disposition, gsize *content_length,
13204 return export_resource (connection,
"report_format", credentials, params,
13227 char **content_disposition, gsize *content_length,
13230 return export_many (connection,
"report_format", credentials, params,
13250 return delete_resource (connection,
"report", credentials, params, 0, NULL,
13271 get_report (openvas_connection_t *connection,
credentials_t * credentials,
13272 params_t *params,
const char *commands,
13273 gsize *report_len, gchar **
content_type,
char **content_disposition,
13274 const char *extra_xml,
int *error,
13277 GString *xml, *commands_xml;
13279 entity_t report_entity;
13280 unsigned int first, max;
13281 GString *levels, *delta_states;
13282 const char *alert_id, *search_phrase, *min_qod, *type, *zone;
13283 const char *autofp, *autofp_value, *notes, *overrides, *result_hosts_only;
13284 const char *apply_overrides;
13285 const char *report_id, *sort_field, *sort_order, *result_id, *delta_report_id;
13286 const char *format_id, *first_result, *max_results, *host, *pos;
13287 const char *given_filt_id, *filt_id, *filter, *apply_filter, *report_section;
13288 const char *build_filter, *filter_extra;
13289 const char *host_search_phrase, *host_levels;
13290 const char *host_first_result, *host_max_results;
13292 int ignore_filter, ignore_pagination;
13293 gchar *built_filter;
13294 gchar *fname_format, *esc_response;
13302 apply_filter =
"no_pagination";
13306 report_section =
params_value (params,
"report_section");
13308 report_section =
"";
13310 ignore_filter = (strcmp (apply_filter,
"full")
13311 && strcmp (apply_filter,
"no_pagination")
13312 && strcmp (report_section,
"")
13313 && strcmp (report_section,
"results")
13314 && strcmp (report_section,
"summary"));
13318 const char *ignore_pagination_str =
params_value (params,
13319 "ignore_pagination");
13320 ignore_pagination = (ignore_pagination_str
13321 && strcmp (ignore_pagination_str,
"")
13322 && strcmp (ignore_pagination_str,
"0"));
13326 ignore_pagination = (strcmp (apply_filter,
"full")
13327 && strcmp (report_section,
"")
13328 && strcmp (report_section,
"results")
13329 && strcmp (report_section,
"summary"));
13333 if (alert_id == NULL)
13334 params_given (params,
"alert_id") || (alert_id =
"0");
13336 search_phrase =
params_value (params,
"search_phrase");
13337 if (search_phrase == NULL)
13338 params_given (params,
"search_phrase") || (search_phrase =
"");
13351 if (autofp == NULL)
13355 if (autofp_value == NULL)
13356 params_given (params,
"autofp_value") || (autofp_value =
"1");
13371 if (overrides == NULL)
13377 params_given (params,
"overrides") || (overrides =
"1");
13380 apply_overrides =
params_value (params,
"apply_overrides");
13381 if (apply_overrides == NULL)
13385 apply_overrides =
"0";
13387 params_given (params,
"apply_overrides") || (apply_overrides =
"1");
13390 result_hosts_only =
params_value (params,
"result_hosts_only");
13391 if (result_hosts_only == NULL)
13397 result_hosts_only =
"0";
13399 params_given (params,
"result_hosts_only") || (result_hosts_only =
"1");
13403 if (report_len) *report_len = 0;
13405 if (autofp == NULL || strlen (autofp) == 0) autofp =
"0";
13407 if (autofp_value == NULL || strlen (autofp_value) == 0) autofp_value =
"1";
13409 if (strcmp (autofp,
"2") == 0)
13410 autofp_value =
"2";
13412 if (notes == NULL || strlen (notes) == 0) notes =
"1";
13414 if (overrides == NULL || strlen (overrides) == 0) overrides =
"1";
13416 if (result_hosts_only == NULL || strlen (result_hosts_only) == 0)
13417 result_hosts_only =
"1";
13421 commands_xml = g_string_new (
"");
13424 if (openvas_connection_sendf (connection,
"%s", commands)
13427 g_string_free (commands_xml, TRUE);
13428 if (error) *error = 1;
13431 "Internal error", __FUNCTION__, __LINE__,
13432 "An internal error occurred while getting a report. " 13433 "The report could not be delivered. " 13434 "Diagnostics: Failure to send extra commands to manager daemon.",
13435 "/omp?cmd=get_tasks", response_data);
13438 if (read_string_c (connection, &commands_xml))
13440 g_string_free (commands_xml, TRUE);
13441 if (error) *error = 1;
13444 "Internal error", __FUNCTION__, __LINE__,
13445 "An internal error occurred while getting a report. " 13446 "The report could not be delivered. " 13447 "Diagnostics: Failure to receive response from manager daemon.",
13448 "/omp?cmd=get_tasks", response_data);
13455 delta_states = g_string_new (
params_value (params,
"delta_states"));
13458 delta_states = g_string_new (
"");
13460 && atoi (
params_value (params,
"delta_state_changed")))
13461 g_string_append (delta_states,
"c");
13464 g_string_append (delta_states,
"g");
13467 g_string_append (delta_states,
"n");
13470 g_string_append (delta_states,
"s");
13473 if (strlen (delta_states->str) == 0) g_string_append (delta_states,
"gn");
13476 levels = g_string_new (
params_value (params,
"levels"));
13479 levels = g_string_new (
"");
13482 g_string_append (levels,
"h");
13485 g_string_append (levels,
"m");
13488 g_string_append (levels,
"l");
13491 g_string_append (levels,
"g");
13493 && atoi (
params_value (params,
"level_false_positive")))
13494 g_string_append (levels,
"f");
13497 if (type && (strcmp (type,
"assets") == 0))
13499 if (strlen (levels->str) == 0)
13500 g_string_append (levels,
"");
13502 else if (strlen (levels->str) == 0)
13503 g_string_append (levels,
"hml");
13509 if (report_id == NULL
13511 || (strcmp (type,
"prognostic")
13512 && strcmp (type,
"assets"))))
13513 return get_reports (connection, credentials, params, extra_xml,
13516 if (strcmp (alert_id,
"0"))
13518 const char *status, *esc_filter;
13521 if (esc_filter == NULL)
13523 || (esc_filter =
"first=1 rows=-1" 13524 " result_hosts_only=0" 13525 " apply_overrides=1" 13526 " notes=1 overrides=1" 13527 " sort-reverse=severity");
13530 ret = openvas_connection_sendf_xml (connection,
13532 " report_id=\"%s\"" 13533 " filter=\"first=1 rows=-1" 13534 " result_hosts_only=0" 13535 " apply_overrides=1" 13536 " notes=1 overrides=1" 13537 " sort-reverse=severity\"" 13538 " alert_id=\"%s\"/>",
13542 ret = openvas_connection_sendf_xml (connection,
13544 " report_id=\"%s\"" 13545 " ignore_pagination=\"%d\"" 13547 " alert_id=\"%s\"/>",
13550 esc_filter ? esc_filter :
"",
13554 g_string_free (commands_xml, TRUE);
13555 g_string_free (delta_states, TRUE);
13556 g_string_free (levels, TRUE);
13557 if (error) *error = 1;
13560 "Internal error", __FUNCTION__, __LINE__,
13561 "An internal error occurred while getting a report. " 13562 "The report could not be delivered. " 13563 "Diagnostics: Failure to send command to manager daemon.",
13564 "/omp?cmd=get_tasks", response_data);
13567 if (read_entity_and_text_c (connection, &entity, &esc_response))
13569 g_string_free (commands_xml, TRUE);
13570 g_string_free (delta_states, TRUE);
13571 g_string_free (levels, TRUE);
13572 if (error) *error = 1;
13575 "Internal error", __FUNCTION__, __LINE__,
13576 "An internal error occurred while getting a report. " 13577 "The report could not be delivered. " 13578 "Diagnostics: Failure to receive response from manager daemon.",
13579 "/omp?cmd=get_tasks", response_data);
13581 status = entity_attribute (entity,
"status");
13582 if ((status == NULL)
13583 || (strlen (status) == 0))
13585 free_entity (entity);
13586 g_string_free (commands_xml, TRUE);
13587 g_string_free (delta_states, TRUE);
13588 if (error) *error = 1;
13591 "Internal error", __FUNCTION__, __LINE__,
13592 "An internal error occurred while getting a report. " 13593 "The report could not be delivered. " 13594 "Diagnostics: Failure to parse response from manager daemon.",
13595 "/omp?cmd=get_tasks", response_data);
13597 free_entity (entity);
13600 esc_response = NULL;
13603 delta_report_id =
params_value (params,
"delta_report_id");
13604 format_id =
params_value (params,
"report_format_id");
13607 if (first_result == NULL
13608 || sscanf (first_result,
"%u", &first) != 1)
13609 first_result =
"1";
13612 if (max_results == NULL
13613 || sscanf (max_results,
"%u", &max) != 1)
13616 if (openvas_connection_sendf (connection,
13621 (type && (strcmp (type,
"prognostic") == 0))
13622 ?
" type=\"prognostic\"" 13624 (type && (strcmp (type,
"assets") == 0))
13625 ?
" type=\"assets\"" 13628 && (strcmp (type,
"assets") == 0)
13631 || strcmp (report_section,
"summary"),
13632 host ?
" host=\"" :
"",
13637 g_string_free (delta_states, TRUE);
13638 g_string_free (commands_xml, TRUE);
13639 g_string_free (levels, TRUE);
13640 if (error) *error = 1;
13643 "Internal error", __FUNCTION__, __LINE__,
13644 "An internal error occurred while getting a report. " 13645 "The report could not be delivered. " 13646 "Diagnostics: Failure to send command to manager daemon.",
13647 "/omp?cmd=get_tasks", response_data);
13656 g_tree_replace (credentials->
last_filt_ids, g_strdup (
"report_result"),
13657 g_strdup (given_filt_id));
13658 filt_id = given_filt_id;
13660 else if (filter == NULL || strcmp (filter,
"") == 0)
13661 filt_id = g_tree_lookup (credentials->
last_filt_ids,
"report_result");
13665 if (filter == NULL)
13668 if ((build_filter && (strcmp (build_filter,
"1") == 0))
13669 || ((filter == NULL || strcmp (filter,
"") == 0)
13670 && (filter_extra == NULL || strcmp (filter_extra,
"") == 0)))
13672 GString *filter_buffer;
13673 filter_buffer = g_string_new (
"");
13675 g_string_append_printf (filter_buffer,
13677 " apply_overrides=%i" 13680 " result_hosts_only=%i" 13685 strcmp (autofp,
"0") ? autofp_value :
"0",
13687 ? (strcmp (apply_overrides,
"0") ? 1 : 0)
13689 strcmp (notes,
"0") ? 1 : 0,
13690 strcmp (overrides,
"0") ? 1 : 0,
13691 strcmp (result_hosts_only,
"0") ? 1 : 0,
13695 ? strcmp (sort_order,
"ascending")
13698 : ((sort_field == NULL
13699 || strcmp (sort_field,
"type") == 0
13700 || strcmp (sort_field,
"severity") == 0)
13703 sort_field ? sort_field :
"severity",
13706 if (search_phrase && strcmp (search_phrase,
""))
13708 gchar *search_phrase_escaped;
13709 search_phrase_escaped = g_markup_escape_text (search_phrase, -1);
13710 g_string_append_printf (filter_buffer,
13712 search_phrase_escaped);
13713 g_free (search_phrase_escaped);
13716 if (delta_states->str && strcmp (delta_states->str,
"")
13717 && delta_report_id && strcmp (delta_report_id,
""))
13718 g_string_append_printf (filter_buffer,
13719 " delta_states=%s",
13720 delta_states->str);
13722 if (min_qod && strcmp (min_qod,
""))
13723 g_string_append_printf (filter_buffer,
13727 if (zone && strcmp (zone,
""))
13728 g_string_append_printf (filter_buffer,
13732 if (filter && strcmp (filter,
""))
13733 g_string_append_printf (filter_buffer,
13737 built_filter = g_string_free (filter_buffer, FALSE);
13739 else if (filter || filter_extra)
13740 built_filter = g_strdup_printf (
"%s%s%s",
13741 filter ? filter :
"",
13742 filter && filter_extra ?
" " :
"",
13743 filter_extra ? filter_extra :
"");
13745 built_filter = NULL;
13747 if (type && (strcmp (type,
"prognostic") == 0))
13749 host_search_phrase =
params_value (params,
"host_search_phrase");
13750 if (host_search_phrase == NULL)
13752 || (host_search_phrase =
"");
13755 if (host_levels == NULL)
13757 || (host_levels =
"");
13759 host_first_result =
params_value (params,
"host_first_result");
13760 if (host_first_result == NULL
13761 || sscanf (host_first_result,
"%u", &first) != 1)
13762 host_first_result =
"1";
13764 host_max_results =
params_value (params,
"host_max_results");
13765 if (host_max_results == NULL
13766 || sscanf (host_max_results,
"%u", &max) != 1)
13769 if (host_search_phrase == NULL)
13771 g_string_free (delta_states, TRUE);
13772 g_string_free (commands_xml, TRUE);
13773 g_string_free (levels, TRUE);
13774 xml = g_string_new (
"");
13776 "Given host search_phrase was invalid",
13778 if (error) *error = 1;
13780 return g_string_free (xml, FALSE);
13783 if (openvas_connection_sendf_xml (connection,
13784 " host_search_phrase=\"%s\"" 13785 " host_levels=\"%s\"" 13786 " host_first_result=\"%s\"" 13787 " host_max_results=\"%s\"",
13788 host_search_phrase,
13793 g_string_free (delta_states, TRUE);
13794 g_string_free (commands_xml, TRUE);
13795 g_string_free (levels, TRUE);
13796 if (error) *error = 1;
13799 "Internal error", __FUNCTION__, __LINE__,
13800 "An internal error occurred while getting a report. " 13801 "The report could not be delivered. " 13802 "Diagnostics: Failure to send command to manager daemon.",
13803 "/omp?cmd=get_tasks", response_data);
13808 host_search_phrase = NULL;
13809 host_levels = NULL;
13810 host_first_result = NULL;
13811 host_max_results = NULL;
13816 if (sort_field == NULL && sort_order == NULL)
13817 if ((filt_id == NULL || strcmp (filt_id,
"") == 0)
13818 && (filter == NULL || strcmp (filter,
"") == 0))
13822 ret = openvas_connection_sendf_xml (connection,
13824 " filter=\"first=1 rows=-1" 13825 " result_hosts_only=0 apply_overrides=1" 13826 " notes=1 overrides=1" 13827 " sort-reverse=severity\"" 13828 " report_id=\"%s\"" 13829 " delta_report_id=\"%s\"" 13830 " format_id=\"%s\"/>",
13831 (type && ((strcmp (type,
"assets") == 0)
13832 || (strcmp (type,
"prognostic")
13836 delta_report_id ? delta_report_id :
"0",
13839 :
"a994b278-1f62-11e1-96ac-406186ea4fc5");
13841 ret = openvas_connection_sendf_xml (connection,
13842 " ignore_pagination=\"%d\"" 13846 " notes_details=\"1\"" 13847 " overrides_details=\"1\"" 13848 " report_id=\"%s\"" 13849 " delta_report_id=\"%s\"" 13850 " format_id=\"%s\"/>",
13852 filt_id ? filt_id :
"0",
13853 built_filter ? built_filter :
"",
13855 (type && ((strcmp (type,
"assets") == 0)
13856 || (strcmp (type,
"prognostic")
13860 delta_report_id ? delta_report_id :
"0",
13863 :
"a994b278-1f62-11e1-96ac-406186ea4fc5",
13866 sort_field ? sort_field :
"severity",
13869 : ((sort_field == NULL
13870 || strcmp (sort_field,
"type") == 0
13871 || strcmp (sort_field,
"severity") == 0)
13881 g_string_free (delta_states, TRUE);
13882 g_string_free (commands_xml, TRUE);
13883 g_string_free (levels, TRUE);
13884 if (error) *error = 1;
13887 "Internal error", __FUNCTION__, __LINE__,
13888 "An internal error occurred while getting a report. " 13889 "The report could not be delivered. " 13890 "Diagnostics: Failure to send command to manager daemon.",
13891 "/omp?cmd=get_tasks", response_data);
13894 g_string_free (delta_states, TRUE);
13898 g_string_free (commands_xml, TRUE);
13899 g_string_free (levels, TRUE);
13900 if ((strcmp (format_id,
"a994b278-1f62-11e1-96ac-406186ea4fc5") == 0)
13901 || strcmp (format_id,
"5057e5cc-b825-11e4-9d0e-28d24461215b") == 0)
13903 const char *extension, *requested_content_type;
13906 if (read_entity_c (connection, &entity))
13908 if (error) *error = 1;
13911 "Internal error", __FUNCTION__, __LINE__,
13912 "An internal error occurred while getting a report. " 13913 "The report could not be delivered. " 13914 "Diagnostics: Failure to receive response from manager daemon.",
13915 "/omp?cmd=get_tasks", response_data);
13917 entity_t report = entity_child (entity,
"report");
13918 if (report == NULL)
13920 free_entity (entity);
13921 if (error) *error = 1;
13924 "Internal error", __FUNCTION__, __LINE__,
13925 "An internal error occurred while getting a report. " 13926 "The report could not be delivered. " 13927 "Diagnostics: Response from manager daemon did not contain a report.",
13928 "/omp?cmd=get_tasks", response_data);
13930 extension = entity_attribute (report,
"extension");
13931 requested_content_type = entity_attribute (report,
"content_type");
13932 if (extension && requested_content_type &&
content_type 13933 && content_disposition)
13936 ret = setting_get_value (connection,
13937 "e1a2ae0b-736e-4484-b029-330c9e15b900",
13946 = MHD_HTTP_INTERNAL_SERVER_ERROR;
13948 "Internal error", __FUNCTION__, __LINE__,
13949 "An internal error occurred while getting a setting. " 13950 "The setting could not be delivered. " 13951 "Diagnostics: Failure to send command to manager daemon.",
13952 "/omp?cmd=get_tasks",
13956 = MHD_HTTP_INTERNAL_SERVER_ERROR;
13958 "Internal error", __FUNCTION__, __LINE__,
13959 "An internal error occurred while getting a setting. " 13960 "The setting could not be delivered. " 13961 "Diagnostics: Failure to receive response from manager daemon.",
13962 "/omp?cmd=get_tasks",
13966 = MHD_HTTP_INTERNAL_SERVER_ERROR;
13968 "Internal error", __FUNCTION__, __LINE__,
13969 "An internal error occurred while getting a setting. " 13970 "The setting could not be delivered. " 13971 "Diagnostics: Internal error.",
13972 "/omp?cmd=get_tasks",
13977 if (fname_format == NULL)
13979 g_warning (
"%s : File name format setting not found.",
13981 fname_format =
"%T-%U";
13988 && ((strcmp (type,
"assets") == 0)
13989 || (strcmp (type,
"prognostic")
13994 if (file_name == NULL)
13995 file_name = g_strdup_printf (
"%s-%s",
13998 && ((strcmp (type,
"assets") == 0)
13999 || (strcmp (type,
"prognostic")
14005 *content_disposition
14006 = g_strdup_printf (
"attachment; filename=\"%s.%s\"",
14010 g_free (file_name);
14012 xml = g_string_new (
"");
14013 print_entity_to_string (report, xml);
14014 free_entity (entity);
14015 if (error) *error = 1;
14016 return g_string_free (xml, FALSE);
14022 if (report_len == NULL)
14024 if (error) *error = 1;
14027 "Internal error", __FUNCTION__, __LINE__,
14028 "An internal error occurred while getting a report. " 14029 "The report could not be delivered. " 14030 "Diagnostics: Parameter error.",
14031 "/omp?cmd=get_tasks", response_data);
14035 if (read_entity_c (connection, &entity))
14037 if (error) *error = 1;
14040 "Internal error", __FUNCTION__, __LINE__,
14041 "An internal error occurred while getting a report. " 14042 "The report could not be delivered. " 14043 "Diagnostics: Failure to receive response from manager daemon.",
14044 "/omp?cmd=get_tasks", response_data);
14047 report_entity = entity_child (entity,
"report");
14048 if (report_entity != NULL)
14050 const char *extension, *requested_content_type;
14051 char *report_encoded;
14052 gchar *report_decoded;
14053 extension = entity_attribute (report_entity,
"extension");
14054 requested_content_type = entity_attribute (report_entity,
14056 report_encoded = entity_text (report_entity);
14058 (gchar *) g_base64_decode (report_encoded, report_len);
14061 if (report_decoded == NULL)
14063 report_decoded = g_strdup (
"");
14066 if (extension && requested_content_type &&
content_type 14067 && content_disposition)
14073 else if (type && (strcmp (type,
"prognostic") == 0))
14078 ret = setting_get_value
14080 "e1a2ae0b-736e-4484-b029-330c9e15b900",
14089 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14091 "Internal error", __FUNCTION__, __LINE__,
14092 "An internal error occurred while getting a setting. " 14093 "The setting could not be delivered. " 14094 "Diagnostics: Failure to send command to manager daemon.",
14095 "/omp?cmd=get_tasks",
14099 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14101 "Internal error", __FUNCTION__, __LINE__,
14102 "An internal error occurred while getting a setting. " 14103 "The setting could not be delivered. " 14104 "Diagnostics: Failure to receive response from manager daemon.",
14105 "/omp?cmd=get_tasks",
14109 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14111 "Internal error", __FUNCTION__, __LINE__,
14112 "An internal error occurred while getting a setting. " 14113 "The setting could not be delivered. " 14114 "Diagnostics: Internal error.",
14115 "/omp?cmd=get_tasks",
14120 if (fname_format == NULL)
14122 g_warning (
"%s : File name format setting not found.",
14124 fname_format =
"%T-%U";
14128 "report",
id, report_entity);
14129 if (file_name == NULL)
14130 file_name = g_strdup_printf (
"%s-%s",
14134 *content_disposition
14135 = g_strdup_printf (
"attachment; filename=\"%s.%s\"",
14139 g_free (file_name);
14141 free_entity (entity);
14142 if (error) *error = 1;
14143 return report_decoded;
14147 free_entity (entity);
14148 if (error) *error = 1;
14151 "Internal error", __FUNCTION__, __LINE__,
14152 "An internal error occurred while getting a report. " 14153 "The report could not be delivered. " 14154 "Diagnostics: Failure to receive report from manager daemon.",
14155 "/omp?cmd=get_tasks", response_data);
14167 if (delta_report_id && result_id && strcmp (result_id,
"0"))
14168 xml = g_string_new (
"<get_delta_result>");
14169 else if (host || (type && (strcmp (type,
"prognostic") == 0)))
14171 if (type && (strcmp (type,
"prognostic") == 0))
14173 xml = g_string_new (
"<get_prognostic_report>");
14175 xml_string_append (xml,
14176 "<host_search_phrase>" 14178 "</host_search_phrase>" 14179 "<host_levels>%s</host_levels>" 14180 "<results start=\"%s\" max=\"%s\"/>",
14181 host_search_phrase,
14187 xml = g_string_new (
"<get_asset>");
14188 xml_string_append (xml,
14189 "<search_phrase>%s</search_phrase>" 14190 "<levels>%s</levels>" 14191 "<hosts start=\"%s\" max=\"%s\"/>",
14198 xml = g_string_new (
"<get_report>");
14201 g_string_append (xml, extra_xml);
14204 g_string_append (xml, commands_xml->str);
14205 g_string_free (commands_xml, TRUE);
14206 g_string_free (levels, TRUE);
14208 if (strcmp (alert_id,
"0"))
14210 g_string_append_printf (xml,
"<get_reports_alert_response>");
14213 g_string_append (xml, esc_response);
14214 g_free (esc_response);
14216 g_string_append_printf (xml,
"</get_reports_alert_response>");
14218 else if (delta_report_id)
14219 g_string_append_printf (xml,
14220 "<delta>%s</delta>" 14221 "<result id=\"%s\"/>",
14223 result_id ? result_id :
"0");
14226 if (read_entity_and_string_c (connection, &entity, &xml))
14228 if (error) *error = 1;
14231 "Internal error", __FUNCTION__, __LINE__,
14232 "An internal error occurred while getting a report. " 14233 "The report could not be delivered. " 14234 "Diagnostics: Failure to receive response from manager daemon.",
14235 "/omp?cmd=get_tasks", response_data);
14238 if ((filt_id == NULL) && (
params_value (params,
"filter") == NULL))
14245 term = entity_child (entity,
"report");
14247 && ((term = entity_child (term,
"report")))
14248 && ((term = entity_child (term,
"filters")))
14249 && ((term = entity_child (term,
"term"))))
14258 if ((type && (strcmp (type,
"prognostic") == 0))
14261 if (openvas_connection_sendf
14263 "<get_report_formats" 14264 " filter=\"rows=-1 sort=name\"/>")
14267 g_string_free (xml, TRUE);
14268 if (error) *error = 1;
14271 "Internal error", __FUNCTION__, __LINE__,
14272 "An internal error occurred while getting a report. " 14273 "The report could not be delivered. " 14274 "Diagnostics: Failure to send command to manager daemon.",
14275 "/omp?cmd=get_tasks", response_data);
14278 if (read_string_c (connection, &xml))
14280 g_string_free (xml, TRUE);
14281 if (error) *error = 1;
14284 "Internal error", __FUNCTION__, __LINE__,
14285 "An internal error occurred while getting a report. " 14286 "The report could not be delivered. " 14287 "Diagnostics: Failure to receive response from manager daemon.",
14288 "/omp?cmd=get_tasks", response_data);
14292 if (type && (strcmp (type,
"prognostic") == 0))
14298 g_string_append (xml,
"<filters>");
14300 if (openvas_connection_sendf_xml (connection,
14302 " filter=\"type=result\"/>")
14305 g_string_free (xml, TRUE);
14306 if (error) *error = 1;
14308 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14310 "Internal error", __FUNCTION__, __LINE__,
14311 "An internal error occurred while getting the filter list. " 14312 "The current list of filters is not available. " 14313 "Diagnostics: Failure to send command to manager daemon.",
14314 "/omp?cmd=get_tasks", response_data);
14317 if (read_string_c (connection, &xml))
14319 g_string_free (xml, TRUE);
14320 if (error) *error = 1;
14322 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14324 "Internal error", __FUNCTION__, __LINE__,
14325 "An internal error occurred while getting the filter list. " 14326 "The current list of filters is not available. " 14327 "Diagnostics: Failure to receive response from manager daemon.",
14328 "/omp?cmd=get_tasks", response_data);
14331 g_string_append (xml,
"</filters>");
14334 g_string_append (xml,
"</get_prognostic_report>");
14335 return g_string_free (xml, FALSE);
14338 if (type && (strcmp (type,
"assets") == 0))
14341 g_string_append (xml,
"</get_asset>");
14343 g_string_append (xml,
"</get_report>");
14344 return g_string_free (xml, FALSE);
14347 report_entity = entity_child (entity,
"report");
14349 report_entity = entity_child (report_entity,
"report");
14353 entity_t task_entity, name;
14356 task_entity = entity_child (report_entity,
"task");
14359 id = entity_attribute (task_entity,
"id");
14360 name = entity_child (task_entity,
"name");
14365 task_id = g_strdup (
id);
14366 if (delta_report_id && result_id &&
id && name)
14367 g_string_append_printf (xml,
14368 "<task id=\"%s\"><name>%s</name></task>",
14370 entity_text (name));
14372 free_entity (entity);
14377 if (openvas_connection_sendf (connection,
14378 "<get_tasks task_id=\"%s\" details=\"0\" />",
14383 g_string_free (xml, TRUE);
14384 if (error) *error = 1;
14387 "Internal error", __FUNCTION__, __LINE__,
14388 "An internal error occurred while getting a report. " 14389 "The report could not be delivered. " 14390 "Diagnostics: Failure to send command to manager daemon.",
14391 "/omp?cmd=get_tasks", response_data);
14394 if (read_string_c (connection, &xml))
14397 g_string_free (xml, TRUE);
14398 if (error) *error = 1;
14401 "Internal error", __FUNCTION__, __LINE__,
14402 "An internal error occurred while getting a report. " 14403 "The report could not be delivered. " 14404 "Diagnostics: Failure to send command to manager daemon.",
14405 "/omp?cmd=get_tasks", response_data);
14411 if (delta_report_id && result_id && strcmp (result_id,
"0"))
14413 g_string_append (xml,
"</get_delta_result>");
14414 return g_string_free (xml, FALSE);
14419 gchar *default_report_format, *err;
14423 err = setting_get_value_error (credentials,
14425 "353304fc-645e-11e6-ba7a-28d24461215b",
14426 &default_report_format,
14430 g_string_free (xml, TRUE);
14431 if (error) *error = 1;
14435 g_string_append_printf (xml,
14436 "<report_format_id>%s</report_format_id>",
14437 default_report_format);
14441 if (openvas_connection_sendf
14443 "<get_report_formats" 14444 " filter=\"rows=-1 sort=name\"/>")
14447 g_string_free (xml, TRUE);
14448 if (error) *error = 1;
14451 "Internal error", __FUNCTION__, __LINE__,
14452 "An internal error occurred while getting a report. " 14453 "The report could not be delivered. " 14454 "Diagnostics: Failure to send command to manager daemon.",
14455 "/omp?cmd=get_tasks", response_data);
14458 if (read_string_c (connection, &xml))
14460 g_string_free (xml, TRUE);
14461 if (error) *error = 1;
14464 "Internal error", __FUNCTION__, __LINE__,
14465 "An internal error occurred while getting a report. " 14466 "The report could not be delivered. " 14467 "Diagnostics: Failure to receive response from manager daemon.",
14468 "/omp?cmd=get_tasks", response_data);
14474 if (openvas_connection_sendf
14477 " filter=\"rows=-1 sort=name\"/>")
14480 g_string_free (xml, TRUE);
14481 if (error) *error = 1;
14484 "Internal error", __FUNCTION__, __LINE__,
14485 "An internal error occurred while getting a report. " 14486 "The report could not be delivered. " 14487 "Diagnostics: Failure to send command to manager daemon.",
14488 "/omp?cmd=get_tasks", response_data);
14491 if (read_string_c (connection, &xml))
14493 g_string_free (xml, TRUE);
14494 if (error) *error = 1;
14497 "Internal error", __FUNCTION__, __LINE__,
14498 "An internal error occurred while getting a report. " 14499 "The report could not be delivered. " 14500 "Diagnostics: Failure to receive response from manager daemon.",
14501 "/omp?cmd=get_tasks", response_data);
14509 g_string_append (xml,
"<filters>");
14511 if (openvas_connection_sendf_xml (connection,
14513 " filter=\"type=result\"/>")
14516 g_string_free (xml, TRUE);
14517 if (error) *error = 1;
14520 "Internal error", __FUNCTION__, __LINE__,
14521 "An internal error occurred while getting the filter list. " 14522 "The current list of filters is not available. " 14523 "Diagnostics: Failure to send command to manager daemon.",
14524 "/omp?cmd=get_tasks", response_data);
14527 if (read_string_c (connection, &xml))
14529 g_string_free (xml, TRUE);
14530 if (error) *error = 1;
14533 "Internal error", __FUNCTION__, __LINE__,
14534 "An internal error occurred while getting the filter list. " 14535 "The current list of filters is not available. " 14536 "Diagnostics: Failure to receive response from manager daemon.",
14537 "/omp?cmd=get_tasks", response_data);
14540 g_string_append (xml,
"</filters>");
14545 if (openvas_connection_sendf (connection,
14547 " filter=\"resource_type=report" 14550 " names_only=\"1\"" 14554 g_string_free (xml, TRUE);
14557 "Internal error", __FUNCTION__, __LINE__,
14558 "An internal error occurred while getting tag names list. " 14559 "The current list of resources is not available. " 14560 "Diagnostics: Failure to send command to manager daemon.",
14561 "/omp?cmd=get_resources", response_data);
14564 if (read_string_c (connection, &xml))
14566 g_string_free (xml, TRUE);
14569 "Internal error", __FUNCTION__, __LINE__,
14570 "An internal error occurred while getting tag names list. " 14571 "The current list of resources is not available. " 14572 "Diagnostics: Failure to receive response from manager daemon.",
14573 "/omp?cmd=get_resources", response_data);
14576 g_string_append (xml,
"</get_report>");
14577 return g_string_free (xml, FALSE);
14602 result = get_report (connection, credentials, params, NULL, report_len,
14606 return error ? result : xsl_transform_omp (connection, credentials, params,
14607 result, response_data);
14622 get_reports (openvas_connection_t *connection,
credentials_t * credentials,
14623 params_t *params,
const char *extra_xml,
14626 const char *overrides;
14631 params_toggle_overrides (params, overrides);
14633 return get_many (connection,
"report", credentials, params, extra_xml, NULL,
14651 return get_reports (connection, credentials, params, NULL, response_data);
14665 get_report_section (openvas_connection_t *connection,
14670 const char *report_id, *report_section, *type;
14674 report_section =
params_value (params,
"report_section");
14678 if (report_section == NULL)
14679 report_section =
"results";
14681 if (report_id == NULL && (type == NULL || strcmp (type,
"prognostic")))
14685 "Internal error", __FUNCTION__, __LINE__,
14686 "An internal error occurred." 14687 " Diagnostics: report_id was NULL.",
14688 "/omp?cmd=get_tasks", response_data);
14691 if (!strcmp (report_section,
"results"))
14695 result = get_report (connection, credentials, params, NULL, NULL, NULL,
14696 NULL, extra_xml, &error, response_data);
14698 return error ? result : xsl_transform_omp (connection, credentials,
14699 params, result, response_data);
14702 result = get_report (connection, credentials, params, NULL, NULL, NULL,
14703 NULL, NULL, &error, response_data);
14707 xml = g_string_new (
"");
14708 g_string_append_printf (xml,
"<get_report_%s_response>", report_section);
14710 g_string_append (xml, extra_xml);
14711 g_string_append (xml, result);
14712 if (strcmp (
params_value (params,
"report_section"),
"topology") == 0)
14717 ret = omp (connection, credentials,
14721 "<get_report_formats" 14722 " filter=\"rows=-1\"/>");
14730 g_string_free (xml, TRUE);
14733 "Internal error", __FUNCTION__, __LINE__,
14734 "An internal error occurred while getting the " 14735 "result formats list. " 14736 "Diagnostics: Failure to send command to manager daemon.",
14737 "/omp?cmd=get_tasks", response_data);
14739 g_string_free (xml, TRUE);
14742 "Internal error", __FUNCTION__, __LINE__,
14743 "An internal error occurred while getting the " 14744 "result formats list. " 14745 "Diagnostics: Failure to receive response from manager daemon.",
14746 "/omp?cmd=get_tasks", response_data);
14748 g_string_free (xml, TRUE);
14751 "Internal error", __FUNCTION__, __LINE__,
14752 "An internal error occurred while getting the " 14753 "result formats list. " 14754 "Diagnostics: Internal Error.",
14755 "/omp?cmd=get_tasks", response_data);
14758 g_string_append (xml, response);
14762 g_string_append_printf (xml,
"</get_report_%s_response>", report_section);
14764 return xsl_transform_omp (connection, credentials, params,
14765 g_string_free (xml, FALSE), response_data);
14783 return get_report_section (connection, credentials, params, NULL, response_data);
14802 const char *ssl_cert;
14807 if (ssl_cert == NULL)
14811 "Internal error", __FUNCTION__, __LINE__,
14812 "An internal error occurred." 14813 " Diagnostics: ssl_cert was NULL.",
14814 "/omp?cmd=get_reports", response_data);
14817 unescaped = g_uri_unescape_string (ssl_cert, NULL);
14819 cert = g_strdup_printf (
"-----BEGIN CERTIFICATE-----\n" 14820 "%s\n-----END CERTIFICATE-----\n",
14823 *response_size = strlen (cert);
14825 g_free (unescaped);
14842 params_t *params, gsize *response_size,
14845 const char *ca_pub;
14849 if (ca_pub == NULL)
14853 "Internal error", __FUNCTION__, __LINE__,
14854 "An internal error occurred." 14855 " Diagnostics: ca_pub was NULL.",
14856 "/omp?cmd=get_reports", response_data);
14859 unescaped = g_uri_unescape_string (ca_pub, NULL);
14860 *response_size = strlen (unescaped);
14877 params_t *params, gsize *response_size,
14880 const char *key_pub;
14884 if (key_pub == NULL)
14888 "Internal error", __FUNCTION__, __LINE__,
14889 "An internal error occurred." 14890 " Diagnostics: key_pub was NULL.",
14891 "/omp?cmd=get_reports", response_data);
14895 unescaped = g_uri_unescape_string (key_pub, NULL);
14896 *response_size = strlen (unescaped);
14943 char **content_disposition, gsize *content_length,
14946 return export_many (connection,
"result", credentials, params,
content_type,
14947 content_disposition, content_length, response_data);
14962 get_results (openvas_connection_t *connection,
credentials_t * credentials,
14963 params_t *params,
const char *extra_xml,
14966 const char *overrides;
14971 params_toggle_overrides (params, overrides);
14973 return get_many (connection,
"result", credentials, params, extra_xml, NULL,
14991 return get_results (connection, credentials,
15015 get_result (openvas_connection_t *connection,
credentials_t *credentials,
15016 params_t *params,
const char *result_id,
const char *task_id,
15017 const char *task_name,
const char *apply_overrides,
15018 const char *commands,
const char *report_id,
const char *autofp,
15023 if (apply_overrides == NULL)
15024 apply_overrides =
"1";
15026 if (autofp == NULL)
15029 xml = g_string_new (
"<get_result>");
15032 g_string_append (xml, extra_xml);
15034 xml_string_append (xml,
15035 "<task id=\"%s\"><name>%s</name></task>" 15036 "<report id=\"%s\"/>",
15043 if (openvas_connection_sendf (connection,
15047 " result_id=\"%s\"" 15048 " get_counts=\"0\"" 15050 " filter=\"autofp=%s" 15051 " apply_overrides=%s" 15054 " overrides_details=\"1\"" 15055 " notes_details=\"1\"" 15058 commands ? commands :
"",
15060 task_id ?
" task_id=\"" :
"",
15061 task_id ? task_id :
"",
15062 task_id ?
"\"" :
"",
15068 g_string_free (xml, TRUE);
15071 "Internal error", __FUNCTION__, __LINE__,
15072 "An internal error occurred while getting a result. " 15073 "Diagnostics: Failure to send command to manager daemon.",
15074 "/omp?cmd=get_tasks", response_data);
15077 if (read_string_c (connection, &xml))
15079 g_string_free (xml, TRUE);
15082 "Internal error", __FUNCTION__, __LINE__,
15083 "An internal error occurred while getting a result. " 15084 "Diagnostics: Failure to receive response from manager daemon.",
15085 "/omp?cmd=get_tasks", response_data);
15090 if (openvas_connection_sendf (connection,
15092 " filter=\"resource_type=result" 15095 " names_only=\"1\"" 15099 g_string_free (xml, TRUE);
15102 "Internal error", __FUNCTION__, __LINE__,
15103 "An internal error occurred while getting tag names list. " 15104 "The current list of resources is not available. " 15105 "Diagnostics: Failure to send command to manager daemon.",
15106 "/omp?cmd=get_resources", response_data);
15109 if (read_string_c (connection, &xml))
15111 g_string_free (xml, TRUE);
15114 "Internal error", __FUNCTION__, __LINE__,
15115 "An internal error occurred while getting tag names list. " 15116 "The current list of resources is not available. " 15117 "Diagnostics: Failure to receive response from manager daemon.",
15118 "/omp?cmd=get_resources", response_data);
15123 g_string_append (xml,
"</get_result>");
15124 return xsl_transform_omp (connection, credentials, params,
15125 g_string_free (xml, FALSE), response_data);
15142 return get_result (connection, credentials, params,
15166 get_result_page (openvas_connection_t *connection,
credentials_t *credentials,
15167 params_t *params,
const char *extra_xml,
15170 return get_result (connection, credentials, params,
15195 get_notes (openvas_connection_t *connection,
credentials_t *credentials,
15196 params_t *params,
const char *extra_xml,
15199 return get_many (connection,
"note", credentials, params, extra_xml, NULL,
15217 return get_notes (connection, credentials, params, NULL, response_data);
15232 get_note (openvas_connection_t *connection,
credentials_t *credentials,
15233 params_t *params,
const char *extra_xml,
15236 return get_one (connection,
"note", credentials, params, extra_xml, NULL,
15254 return get_note (connection, credentials, params, NULL, response_data);
15270 params_t *params,
const char *extra_xml,
15274 const char *oid, *hosts, *port, *severity, *task_id, *task_name, *result_id;
15277 const char *report_id, *first_result, *max_results, *sort_field;
15278 const char *sort_order, *levels, *autofp, *notes;
15279 const char *overrides, *result_hosts_only, *search_phrase;
15291 search_phrase =
params_value (params,
"search_phrase");
15296 result_hosts_only =
params_value (params,
"result_hosts_only");
15303 if (result_id == NULL || task_id == NULL)
15305 xml = g_string_new (
"");
15307 xml_string_append (xml,
15315 g_string_append (xml, extra_xml);
15317 if (openvas_connection_sendf (connection,
15319 " schedules_only=\"1\"" 15320 " details=\"0\"/>")
15325 "Internal error", __FUNCTION__, __LINE__,
15326 "An internal error occurred while creating a new note. " 15327 "No new note was created. " 15328 "Diagnostics: Failure to send command to manager daemon.",
15329 "/omp?cmd=get_notes", response_data);
15332 if (read_string_c (connection, &xml))
15334 g_string_free (xml, TRUE);
15337 "Internal error", __FUNCTION__, __LINE__,
15338 "An internal error occurred while creating a new note. " 15339 "No new note was created. " 15340 "Diagnostics: Failure to receive response from manager daemon.",
15341 "/omp?cmd=get_notes", response_data);
15344 g_string_append (xml,
"</new_note>");
15345 return xsl_transform_omp (connection, credentials, params,
15346 g_string_free (xml, FALSE), response_data);
15349 if (openvas_connection_sendf (connection,
15351 " result_id=\"%s\"" 15353 " notes_details=\"1\"" 15355 " result_hosts_only=\"1\"/>",
15362 "Internal error", __FUNCTION__, __LINE__,
15363 "An internal error occurred while creating a new note. " 15364 "No new note was created. " 15365 "Diagnostics: Failure to send command to manager daemon.",
15366 "/omp?cmd=get_notes", response_data);
15369 xml = g_string_new (
"");
15371 xml_string_append (xml,
15374 "<hosts>%s</hosts>" 15376 "<severity>%s</severity>" 15380 "<result id=\"%s\"/>" 15383 "<report id=\"%s\"/>" 15384 "<first_result>%s</first_result>" 15385 "<max_results>%s</max_results>" 15386 "<sort_field>%s</sort_field>" 15387 "<sort_order>%s</sort_order>" 15388 "<levels>%s</levels>" 15389 "<autofp>%s</autofp>" 15390 "<notes>%s</notes>" 15391 "<overrides>%s</overrides>" 15392 "<result_hosts_only>%s</result_hosts_only>" 15393 "<search_phrase>%s</search_phrase>",
15416 g_string_append (xml, extra_xml);
15418 if (read_string_c (connection, &xml))
15420 g_string_free (xml, TRUE);
15423 "Internal error", __FUNCTION__, __LINE__,
15424 "An internal error occurred while creating a new note. " 15425 "It is unclear whether the note has been created or not. " 15426 "Diagnostics: Failure to receive response from manager daemon.",
15427 "/omp?cmd=get_notes", response_data);
15432 g_string_append (xml,
"</new_note>");
15433 return xsl_transform_omp (connection, credentials, params,
15434 g_string_free (xml, FALSE), response_data);
15451 return new_note (connection, credentials, params, NULL, response_data);
15470 const char *no_redirect, *oid, *severity, *port, *hosts;
15471 const char *text, *task_id, *note_result_id;
15473 const char *active, *days;
15492 if (strcmp (port,
"--") == 0)
15499 if (num < 0 || num > 65535)
15507 if (strcmp (hosts,
"--") == 0)
15528 if (task_id && (strcmp (task_id,
"0") == 0))
15543 note_result_id =
params_value (params,
"note_result_id");
15544 if (note_result_id && (strcmp (note_result_id,
"0") == 0))
15545 note_result_id =
params_value (params,
"note_result_uuid");
15549 switch (ompf (connection, credentials,
15554 "<active>%s</active>" 15555 "<nvt oid=\"%s\"/>" 15556 "<hosts>%s</hosts>" 15558 "<severity>%s</severity>" 15560 "<task id=\"%s\"/>" 15561 "<result id=\"%s\"/>" 15563 strcmp (active,
"1")
15565 : (days ? days :
"-1"),
15580 "Internal error", __FUNCTION__, __LINE__,
15581 "An internal error occurred while creating a new note. " 15582 "No new note was created. " 15583 "Diagnostics: Failure to send command to manager daemon.",
15584 "/omp?cmd=get_notes", response_data);
15588 "Internal error", __FUNCTION__, __LINE__,
15589 "An internal error occurred while creating a new note. " 15590 "It is unclear whether the note has been created or not. " 15591 "Diagnostics: Failure to receive response from manager daemon.",
15592 "/omp?cmd=get_notes", response_data);
15596 "Internal error", __FUNCTION__, __LINE__,
15597 "An internal error occurred while creating a new note. " 15598 "It is unclear whether the note has been created or not. " 15599 "Diagnostics: Internal Error.",
15600 "/omp?cmd=get_notes", response_data);
15603 if (entity_attribute (entity,
"id"))
15604 params_add (params,
"note_id", entity_attribute (entity,
"id"));
15605 ret = response_from_entity (connection, credentials, params, entity,
15606 (no_redirect && strcmp (no_redirect,
"0")),
15609 "Create Note", response_data);
15610 free_entity (entity);
15629 return delete_resource (connection,
"note", credentials, params, 0, NULL,
15649 "get_trash", response_data);
15665 params_t *params,
const char *extra_xml,
15669 const char *note_id;
15673 if (openvas_connection_sendf (connection,
15683 "Internal error", __FUNCTION__, __LINE__,
15684 "An internal error occurred while editing a note. " 15685 "The note remains as it was. " 15686 "Diagnostics: Failure to send command to manager daemon.",
15687 "/omp?cmd=get_notes", response_data);
15690 xml = g_string_new (
"");
15692 xml_string_append (xml,
"<edit_note>");
15695 g_string_append (xml, extra_xml);
15697 if (read_string_c (connection, &xml))
15699 g_string_free (xml, TRUE);
15702 "Internal error", __FUNCTION__, __LINE__,
15703 "An internal error occurred while editing a note. " 15704 "The note remains as it was. " 15705 "Diagnostics: Failure to receive response from manager daemon.",
15706 "/omp?cmd=get_notes", response_data);
15711 g_string_append (xml,
"</edit_note>");
15712 return xsl_transform_omp (connection, credentials, params,
15713 g_string_free (xml, FALSE), response_data);
15730 return edit_note (connection, credentials, params, NULL, response_data);
15749 const char *no_redirect;
15750 const char *note_id, *text, *hosts, *port, *severity, *note_task_id;
15751 const char *note_result_id, *active, *days;
15783 note_result_id =
params_value (params,
"note_result_id");
15800 switch (ompf (connection, credentials,
15804 "<modify_note note_id=\"%s\">" 15805 "<active>%s</active>" 15806 "<hosts>%s</hosts>" 15808 "<severity>%s</severity>" 15810 "<task id=\"%s\"/>" 15811 "<result id=\"%s\"/>" 15814 strcmp (active,
"1")
15816 : (days ? days :
"-1"),
15817 hosts ? hosts :
"",
15819 severity ? severity :
"",
15830 "Internal error", __FUNCTION__, __LINE__,
15831 "An internal error occurred while saving a note. " 15832 "The note remains the same. " 15833 "Diagnostics: Failure to send command to manager daemon.",
15834 "/omp?cmd=get_notes", response_data);
15838 "Internal error", __FUNCTION__, __LINE__,
15839 "An internal error occurred while saving a note. " 15840 "It is unclear whether the note has been saved or not. " 15841 "Diagnostics: Failure to receive response from manager daemon.",
15842 "/omp?cmd=get_notes", response_data);
15846 "Internal error", __FUNCTION__, __LINE__,
15847 "An internal error occurred while saving a note. " 15848 "It is unclear whether the note has been saved or not. " 15849 "Diagnostics: Internal Error.",
15850 "/omp?cmd=get_notes", response_data);
15853 ret = response_from_entity (connection, credentials, params, entity,
15854 (no_redirect && strcmp (no_redirect,
"0")),
15857 "Save Note", response_data);
15859 free_entity (entity);
15876 get_overrides (openvas_connection_t *connection,
credentials_t *credentials,
15877 params_t *params,
const char *extra_xml,
15880 return get_many (connection,
"override", credentials, params, extra_xml, NULL,
15898 return get_overrides (connection, credentials, params, NULL, response_data);
15913 get_override (openvas_connection_t *connection,
credentials_t *credentials,
15914 params_t *params,
const char *extra_xml,
15917 return get_one (connection,
"override", credentials, params, extra_xml, NULL,
15935 return get_override (connection, credentials, params, NULL, response_data);
15951 params_t *params,
const char *extra_xml,
15955 const char *oid, *hosts, *port, *severity, *task_id, *task_name, *result_id;
15958 const char *report_id, *first_result, *max_results, *sort_field;
15959 const char *sort_order, *levels, *autofp, *notes;
15960 const char *overrides, *result_hosts_only, *search_phrase;
15972 search_phrase =
params_value (params,
"search_phrase");
15977 result_hosts_only =
params_value (params,
"result_hosts_only");
15984 if (result_id == NULL || task_id == NULL)
15986 xml = g_string_new (
"");
15988 xml_string_append (xml,
15996 g_string_append (xml, extra_xml);
15998 if (openvas_connection_sendf (connection,
16000 " schedules_only=\"1\"" 16001 " details=\"0\"/>")
16006 "Internal error", __FUNCTION__, __LINE__,
16007 "An internal error occurred while creating a new override. " 16008 "No new override was created. " 16009 "Diagnostics: Failure to send command to manager daemon.",
16010 "/omp?cmd=get_overrides", response_data);
16013 if (read_string_c (connection, &xml))
16015 g_string_free (xml, TRUE);
16018 "Internal error", __FUNCTION__, __LINE__,
16019 "An internal error occurred while creating a new override. " 16020 "No new override was created. " 16021 "Diagnostics: Failure to receive response from manager daemon.",
16022 "/omp?cmd=get_overrides", response_data);
16025 g_string_append (xml,
"</new_override>");
16026 return xsl_transform_omp (connection, credentials, params,
16027 g_string_free (xml, FALSE), response_data);
16030 if (openvas_connection_sendf (connection,
16032 " result_id=\"%s\"" 16034 " notes_details=\"1\"" 16036 " overrides_details=\"1\"" 16038 " result_hosts_only=\"1\"/>",
16045 "Internal error", __FUNCTION__, __LINE__,
16046 "An internal error occurred while creating a new override. " 16047 "No new override was created. " 16048 "Diagnostics: Failure to send command to manager daemon.",
16049 "/omp?cmd=get_overrides", response_data);
16052 xml = g_string_new (
"");
16054 xml_string_append (xml,
16057 "<hosts>%s</hosts>" 16059 "<severity>%s</severity>" 16063 "<result id=\"%s\"/>" 16066 "<report id=\"%s\"/>" 16067 "<first_result>%s</first_result>" 16068 "<max_results>%s</max_results>" 16069 "<sort_field>%s</sort_field>" 16070 "<sort_order>%s</sort_order>" 16071 "<levels>%s</levels>" 16072 "<autofp>%s</autofp>" 16073 "<notes>%s</notes>" 16074 "<overrides>%s</overrides>" 16075 "<result_hosts_only>%s</result_hosts_only>" 16076 "<search_phrase>%s</search_phrase>",
16099 g_string_append (xml, extra_xml);
16101 if (read_string_c (connection, &xml))
16103 g_string_free (xml, TRUE);
16106 "Internal error", __FUNCTION__, __LINE__,
16107 "An internal error occurred while creating a new override. " 16108 "It is unclear whether the override has been created or not. " 16109 "Diagnostics: Failure to receive response from manager daemon.",
16110 "/omp?cmd=get_overrides", response_data);
16115 g_string_append (xml,
"</new_override>");
16116 return xsl_transform_omp (connection, credentials, params,
16117 g_string_free (xml, FALSE), response_data);
16134 return new_override (connection, credentials, params, NULL, response_data);
16154 const char *no_redirect;
16155 const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
16156 const char *text, *task_id, *override_result_id;
16158 const char *active, *days;
16174 custom_severity =
params_value (params,
"custom_severity");
16177 if (custom_severity != NULL && strcmp (custom_severity,
"0"))
16183 new_severity = NULL;
16191 new_severity =
params_value (params,
"new_severity_from_list");
16194 "new_severity_from_list"),
16196 new_severity = NULL;
16205 if (strcmp (port,
"--") == 0)
16212 if (num < 0 || num > 65535)
16220 if (strcmp (hosts,
"--") == 0)
16241 if (task_id && (strcmp (task_id,
"0") == 0))
16242 task_id =
params_value (params,
"override_task_uuid");
16253 override_result_id =
params_value (params,
"override_result_id");
16254 if (override_result_id && (strcmp (override_result_id,
"0") == 0))
16255 override_result_id =
params_value (params,
"override_result_uuid");
16259 switch (ompf (connection, credentials,
16263 "<create_override>" 16264 "<active>%s</active>" 16265 "<nvt oid=\"%s\"/>" 16266 "<hosts>%s</hosts>" 16268 "<severity>%s</severity>" 16269 "<new_severity>%s</new_severity>" 16271 "<task id=\"%s\"/>" 16272 "<result id=\"%s\"/>" 16273 "</create_override>",
16274 strcmp (active,
"1")
16276 : (days ? days :
"-1"),
16284 override_result_id))
16292 "Internal error", __FUNCTION__, __LINE__,
16293 "An internal error occurred while creating a new override. " 16294 "No new override was created. " 16295 "Diagnostics: Failure to send command to manager daemon.",
16296 "/omp?cmd=get_overrides", response_data);
16300 "Internal error", __FUNCTION__, __LINE__,
16301 "An internal error occurred while creating a new override. " 16302 "It is unclear whether the override has been created or not. " 16303 "Diagnostics: Failure to receive response from manager daemon.",
16304 "/omp?cmd=get_overrides", response_data);
16308 "Internal error", __FUNCTION__, __LINE__,
16309 "An internal error occurred while creating a new override. " 16310 "It is unclear whether the override has been created or not. " 16311 "Diagnostics: Internal Error.",
16312 "/omp?cmd=get_overrides", response_data);
16315 if (entity_attribute (entity,
"id"))
16316 params_add (params,
"override_id", entity_attribute (entity,
"id"));
16317 ret = response_from_entity (connection, credentials, params, entity,
16318 (no_redirect && strcmp (no_redirect,
"0")),
16319 NULL,
"get_overrides",
16320 NULL,
"new_override",
16321 "Create Override", response_data);
16322 free_entity (entity);
16342 return delete_resource (connection,
"override", credentials, params, 0, NULL,
16361 return delete_resource (connection,
"override", credentials, params, 1,
16362 "get_trash", response_data);
16378 params_t *params,
const char *extra_xml,
16382 const char *override_id;
16386 if (openvas_connection_sendf (connection,
16388 " override_id=\"%s\"" 16396 "Internal error", __FUNCTION__, __LINE__,
16397 "An internal error occurred while editing an override. " 16398 "The override remains as it was. " 16399 "Diagnostics: Failure to send command to manager daemon.",
16400 "/omp?cmd=get_overrides", response_data);
16403 xml = g_string_new (
"");
16405 xml_string_append (xml,
"<edit_override>");
16408 g_string_append (xml, extra_xml);
16410 if (read_string_c (connection, &xml))
16412 g_string_free (xml, TRUE);
16415 "Internal error", __FUNCTION__, __LINE__,
16416 "An internal error occurred while editing an override. " 16417 "The override remains as it was. " 16418 "Diagnostics: Failure to receive response from manager daemon.",
16419 "/omp?cmd=get_overrides", response_data);
16424 g_string_append (xml,
"</edit_override>");
16425 return xsl_transform_omp (connection, credentials, params,
16426 g_string_free (xml, FALSE), response_data);
16443 return edit_override (connection, credentials, params, NULL, response_data);
16463 const char *no_redirect, *override_id, *text, *hosts, *port;
16464 const char *severity, *custom_severity, *new_severity;
16465 const char *override_task_id, *override_result_id, *active, *days;
16496 custom_severity =
params_value (params,
"custom_severity");
16497 if (custom_severity && strcmp (custom_severity,
"0") != 0)
16500 new_severity =
params_value (params,
"new_severity_from_list");
16502 override_task_id =
params_value (params,
"override_task_id");
16503 override_result_id =
params_value (params,
"override_result_id");
16521 switch (ompf (connection, credentials,
16525 "<modify_override override_id=\"%s\">" 16526 "<active>%s</active>" 16527 "<hosts>%s</hosts>" 16529 "<severity>%s</severity>" 16530 "<new_severity>%s</new_severity>" 16532 "<task id=\"%s\"/>" 16533 "<result id=\"%s\"/>" 16534 "</modify_override>",
16536 strcmp (active,
"1")
16538 : (days ? days :
"-1"),
16539 hosts ? hosts :
"",
16541 severity ? severity :
"",
16545 override_result_id))
16553 "Internal error", __FUNCTION__, __LINE__,
16554 "An internal error occurred while saving a override. " 16555 "The override remains the same. " 16556 "Diagnostics: Failure to send command to manager daemon.",
16557 "/omp?cmd=get_overrides", response_data);
16561 "Internal error", __FUNCTION__, __LINE__,
16562 "An internal error occurred while saving a override. " 16563 "It is unclear whether the override has been saved or not. " 16564 "Diagnostics: Failure to receive response from manager daemon.",
16565 "/omp?cmd=get_overrides", response_data);
16569 "Internal error", __FUNCTION__, __LINE__,
16570 "An internal error occurred while saving a override. " 16571 "It is unclear whether the override has been saved or not. " 16572 "Diagnostics: Internal Error.",
16573 "/omp?cmd=get_overrides", response_data);
16576 ret = response_from_entity (connection, credentials, params, entity,
16577 (no_redirect && strcmp (no_redirect,
"0")),
16578 NULL,
"get_overrides",
16579 NULL,
"edit_override",
16580 "Save Override", response_data);
16582 free_entity (entity);
16602 get_scanners (openvas_connection_t *connection,
credentials_t *credentials,
16603 params_t *params,
const char *extra_xml,
16606 return get_many (connection,
"scanner", credentials, params, extra_xml, NULL,
16624 return get_scanners (connection, credentials, params, NULL, response_data);
16639 get_scanner (openvas_connection_t *connection,
credentials_t * credentials,
16640 params_t *params,
const char *extra_xml,
16643 return get_one (connection,
"scanner", credentials, params, extra_xml, NULL,
16661 return get_scanner (connection, credentials, params, NULL, response_data);
16681 char **content_disposition, gsize *content_length,
16706 char **content_disposition, gsize *content_length,
16709 return export_many (connection,
"scanner", credentials, params,
content_type,
16710 content_disposition, content_length, response_data);
16725 new_scanner (openvas_connection_t *connection,
credentials_t *credentials,
16726 params_t *params,
const char *extra_xml,
16731 if (openvas_connection_sendf (connection,
16733 " filter=\"first=1 rows=-1\" />")
16738 "Internal error", __FUNCTION__, __LINE__,
16739 "An internal error occurred while getting the credentials list. " 16740 "Diagnostics: Failure to send command to manager daemon.",
16741 "/omp?cmd=get_tasks", response_data);
16744 xml = g_string_new (
"<new_scanner>");
16746 g_string_append (xml, extra_xml);
16748 if (read_string_c (connection, &xml))
16750 g_string_free (xml, TRUE);
16753 "Internal error", __FUNCTION__, __LINE__,
16754 "An internal error occurred while getting the credentials list. " 16755 "Diagnostics: Failure to receive response from manager daemon.",
16756 "/omp?cmd=get_tasks", response_data);
16759 g_string_append (xml,
"</new_scanner>");
16760 return xsl_transform_omp (connection, credentials, params,
16761 g_string_free (xml, FALSE), response_data);
16778 return new_scanner (connection, credentials, params, NULL, response_data);
16796 gchar *html, *response;
16797 const char *scanner_id, *next;
16802 CHECK_PARAM (scanner_id,
"Verify Scanner", get_scanners);
16805 ret = ompf (connection, credentials,
16809 "<verify_scanner scanner_id=\"%s\"/>",
16820 "Internal error", __FUNCTION__, __LINE__,
16821 "An internal error occurred while verifying a scanner. " 16822 "The scanner was not verified. " 16823 "Diagnostics: Failure to send command to manager daemon.",
16824 "/omp?cmd=get_scanners", response_data);
16828 "Internal error", __FUNCTION__, __LINE__,
16829 "An internal error occurred while verifying a scanner. " 16830 "It is unclear whether the scanner was verified or not. " 16831 "Diagnostics: Failure to send command to manager daemon.",
16832 "/omp?cmd=get_scanners", response_data);
16836 "Internal error", __FUNCTION__, __LINE__,
16837 "An internal error occurred while verifying a scanner. " 16838 "It is unclear whether the scanner was verified or not. " 16839 "Diagnostics: Failure to send command to manager daemon.",
16840 "/omp?cmd=get_scanners", response_data);
16843 if (omp_success (entity))
16845 html = next_page (connection, credentials, params, response,
16849 free_entity (entity);
16853 "Internal error", __FUNCTION__, __LINE__,
16854 "An internal error occurred while verifying a scanner. " 16855 "It is unclear whether the scanner was verified or not. " 16856 "Diagnostics: Failure to receive response from manager daemon.",
16857 "/omp?cmd=get_scanners", response_data);
16864 if (next && !strcmp (next,
"get_scanner"))
16865 html = get_scanner (connection, credentials, params, response,
16868 html = get_scanners (connection, credentials, params, response,
16872 free_entity (entity);
16894 gchar *response = NULL;
16895 const char *no_redirect;
16896 const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
16897 entity_t entity = NULL;
16906 credential_id =
params_value (params,
"credential_id");
16917 ret = ompf (connection, credentials, &response, &entity, response_data,
16919 "<name>%s</name><comment>%s</comment>" 16920 "<host>%s</host><port>%s</port><type>%s</type>" 16921 "<ca_pub>%s</ca_pub>" 16922 "<credential id=\"%s\"/>" 16923 "</create_scanner>",
16924 name, comment, host, port, type, ca_pub, credential_id);
16926 ret = ompf (connection, credentials, &response, &entity, response_data,
16928 "<name>%s</name><comment>%s</comment>" 16929 "<host>%s</host><port>%s</port><type>%s</type>" 16930 "<credential id=\"%s\"/>" 16931 "</create_scanner>",
16932 name, comment, host, port, type, credential_id);
16941 (credentials,
"Internal error", __FUNCTION__, __LINE__,
16942 "An internal error occurred while creating a new scanner. " 16943 "No new scanner was created. " 16944 "Diagnostics: Failure to send command to manager daemon.",
16945 "/omp?cmd=get_scanners", response_data);
16949 (credentials,
"Internal error", __FUNCTION__, __LINE__,
16950 "An internal error occurred while creating a new scanner. " 16951 "It is unclear whether the scanner has been created or not. " 16952 "Diagnostics: Failure to receive response from manager daemon.",
16953 "/omp?cmd=get_scanners", response_data);
16957 (credentials,
"Internal error", __FUNCTION__, __LINE__,
16958 "An internal error occurred while creating a new scanner. " 16959 "It is unclear whether the scanner has been created or not. " 16960 "Diagnostics: Internal Error.",
16961 "/omp?cmd=get_scanners", response_data);
16964 if (entity_attribute (entity,
"id"))
16965 params_add (params,
"scanner_id", entity_attribute (entity,
"id"));
16966 html = response_from_entity (connection, credentials, params, entity,
16967 (no_redirect && strcmp (no_redirect,
"0")),
16968 NULL,
"get_scanners",
16969 NULL,
"new_scanner",
16970 "Create Scanner", response_data);
16971 free_entity (entity);
16991 return delete_resource (connection,
"scanner", credentials, params, 0,
16992 "get_scanners", response_data);
17010 return delete_resource (connection,
"scanner", credentials, params, 1,
17011 "get_trash", response_data);
17027 params_t *params,
const char *extra_xml,
17031 const char *scanner_id, *next;
17036 if (scanner_id == NULL)
17040 "Internal error", __FUNCTION__, __LINE__,
17041 "An internal error occurred while editing a scanner. " 17042 "The scanner remains as it was. " 17043 "Diagnostics: Required parameter was NULL.",
17044 "/omp?cmd=get_tasks", response_data);
17048 next =
"get_scanner";
17050 if (openvas_connection_sendf (connection,
17052 "<get_scanners scanner_id=\"%s\" details=\"1\" />" 17053 "<get_credentials filter=\"first=1 rows=-1\" />" 17060 "Internal error", __FUNCTION__, __LINE__,
17061 "An internal error occurred while getting scanner info. " 17062 "Diagnostics: Failure to send command to manager daemon.",
17063 "/omp?cmd=get_tasks", response_data);
17066 xml = g_string_new (
"");
17069 g_string_append (xml, extra_xml);
17071 g_string_append_printf (xml,
17073 "<scanner id=\"%s\"/>" 17079 if (read_string_c (connection, &xml))
17081 g_string_free (xml, TRUE);
17084 "Internal error", __FUNCTION__, __LINE__,
17085 "An internal error occurred while getting scanner info. " 17086 "Diagnostics: Failure to receive response from manager daemon.",
17087 "/omp?cmd=get_tasks", response_data);
17092 g_string_append (xml,
"</edit_scanner>");
17093 return xsl_transform_omp (connection, credentials, params,
17094 g_string_free (xml, FALSE), response_data);
17111 return edit_scanner (connection, credentials, params, NULL, response_data);
17128 gchar *response = NULL;
17129 entity_t entity = NULL;
17130 const char *no_redirect;
17131 const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
17132 const char *credential_id, *which_cert;
17134 int ret, is_unix_socket, in_use;
17141 is_unix_socket = (host && *host ==
'/') ? 1 : 0;
17146 credential_id =
params_value (params,
"credential_id");
17158 if (is_unix_socket == 0)
17165 if (is_unix_socket)
17167 ret = ompf (connection, credentials, &response, &entity, response_data,
17168 "<modify_scanner scanner_id=\"%s\">" 17170 "<comment>%s</comment>" 17171 "</modify_scanner>",
17172 scanner_id, name, comment ?:
"");
17174 else if (strcmp (which_cert,
"new") == 0
17175 || strcmp (which_cert,
"default") == 0)
17177 if (ca_pub == NULL)
17180 ret = ompf (connection, credentials, &response, &entity, response_data,
17181 "<modify_scanner scanner_id=\"%s\">" 17183 "<comment>%s</comment>" 17184 "<ca_pub>%s</ca_pub>" 17185 "<credential id=\"%s\"/>" 17186 "</modify_scanner>",
17187 scanner_id, name, comment ?:
"",
17188 strcmp (which_cert,
"new") == 0 ? ca_pub :
"",
17191 ret = ompf (connection, credentials, &response, &entity, response_data,
17192 "<modify_scanner scanner_id=\"%s\">" 17194 "<comment>%s</comment>" 17198 "<ca_pub>%s</ca_pub>" 17199 "<credential id=\"%s\"/>" 17200 "</modify_scanner>",
17201 scanner_id, name, comment ?:
"", host, port, type,
17202 strcmp (which_cert,
"new") == 0 ? ca_pub :
"",
17209 ret = ompf (connection, credentials, &response, &entity, response_data,
17210 "<modify_scanner scanner_id=\"%s\">" 17212 "<comment>%s</comment>" 17213 "<credential id=\"%s\"/>" 17214 "</modify_scanner>",
17215 scanner_id, name, comment ?:
"", credential_id);
17217 ret = ompf (connection, credentials, &response, &entity, response_data,
17218 "<modify_scanner scanner_id=\"%s\">" 17220 "<comment>%s</comment>" 17224 "<credential id=\"%s\"/>" 17225 "</modify_scanner>",
17226 scanner_id, name, comment ?:
"", host, port, type,
17238 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17239 "An internal error occurred while saving a scanner. " 17240 "The scanner remains the same. " 17241 "Diagnostics: Failure to send command to manager daemon.",
17242 "/omp?cmd=get_scanners", response_data);
17246 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17247 "An internal error occurred while saving a scanner. " 17248 "It is unclear whether the scanner has been saved or not. " 17249 "Diagnostics: Failure to receive response from manager daemon.",
17250 "/omp?cmd=get_scanners", response_data);
17254 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17255 "An internal error occurred while saving a scanner. " 17256 "It is unclear whether the scanner has been saved or not. " 17257 "Diagnostics: Internal Error.",
17258 "/omp?cmd=get_scanners", response_data);
17261 html = response_from_entity (connection, credentials, params, entity,
17262 (no_redirect && strcmp (no_redirect,
"0")),
17263 NULL,
"get_scanners",
17264 NULL,
"edit_scanner",
17265 "Save Scanner", response_data);
17267 free_entity (entity);
17287 get_schedule (openvas_connection_t *connection,
credentials_t * credentials,
17288 params_t *params,
const char *extra_xml,
17291 return get_one (connection,
"schedule", credentials, params, extra_xml,
17292 "tasks=\"1\"", response_data);
17309 return get_schedule (connection, credentials, params, NULL, response_data);
17324 get_schedules (openvas_connection_t *connection,
credentials_t *credentials,
17325 params_t *params,
const char *extra_xml,
17328 return get_many (connection,
"schedule", credentials, params, extra_xml, NULL,
17347 return get_schedules (connection, credentials, params, NULL, response_data);
17362 new_schedule (openvas_connection_t *connection,
credentials_t *credentials,
17363 params_t *params,
const char *extra_xml,
17368 struct tm *now_broken;
17369 xml = g_string_new (
"<new_schedule>");
17371 now_broken = localtime (&now);
17372 g_string_append_printf (xml,
17374 "<minute>%s%i</minute>" 17375 "<hour>%s%i</hour>" 17376 "<day_of_month>%s%i</day_of_month>" 17377 "<month>%s%i</month>" 17380 (now_broken->tm_min > 9 ?
"" :
"0"),
17381 now_broken->tm_min,
17382 (now_broken->tm_hour > 9 ?
"" :
"0"),
17383 now_broken->tm_hour,
17384 (now_broken->tm_mday > 9 ?
"" :
"0"),
17385 now_broken->tm_mday,
17386 ((now_broken->tm_mon + 1) > 9 ?
"" :
"0"),
17387 (now_broken->tm_mon + 1),
17388 (now_broken->tm_year + 1900));
17391 g_string_append (xml, extra_xml);
17392 g_string_append (xml,
"</new_schedule>");
17393 return xsl_transform_omp (connection, credentials, params,
17394 g_string_free (xml, FALSE), response_data);
17411 return new_schedule (connection, credentials, params, NULL, response_data);
17431 const char *no_redirect;
17432 const char *name, *comment, *hour, *minute, *day_of_month, *month, *year;
17433 const char *period, *period_unit, *duration, *duration_unit, *timezone;
17443 duration_unit =
params_value (params,
"duration_unit");
17465 switch (ompf (connection, credentials,
17469 "<create_schedule>" 17471 "<comment>%s</comment>" 17474 "<minute>%s</minute>" 17475 "<day_of_month>%s</day_of_month>" 17476 "<month>%s</month>" 17487 "<timezone>%s</timezone>" 17488 "</create_schedule>",
17496 (strcmp (period_unit,
"")
17500 (strcmp (duration_unit,
"")
17512 "Internal error", __FUNCTION__, __LINE__,
17513 "An internal error occurred while creating a new schedule. " 17514 "No new schedule was created. " 17515 "Diagnostics: Failure to send command to manager daemon.",
17516 "/omp?cmd=get_schedules", response_data);
17520 "Internal error", __FUNCTION__, __LINE__,
17521 "An internal error occurred while creating a new schedule. " 17522 "It is unclear whether the schedule has been created or not. " 17523 "Diagnostics: Failure to receive response from manager daemon.",
17524 "/omp?cmd=get_schedules", response_data);
17528 "Internal error", __FUNCTION__, __LINE__,
17529 "An internal error occurred while creating a new schedule. " 17530 "It is unclear whether the schedule has been created or not. " 17531 "Diagnostics: Internal Error.",
17532 "/omp?cmd=get_schedules", response_data);
17535 if (entity_attribute (entity,
"id"))
17536 params_add (params,
"schedule_id", entity_attribute (entity,
"id"));
17537 ret = response_from_entity (connection, credentials, params, entity,
17538 (no_redirect && strcmp (no_redirect,
"0")),
17539 NULL,
"get_schedules",
17540 NULL,
"new_schedule",
17541 "Create Schedule", response_data);
17542 free_entity (entity);
17562 return delete_resource (connection,
"schedule", credentials, params, 0,
17563 "get_schedules", response_data);
17582 time_t now, duration, duration_start;
17583 struct tm start_time, end_time;
17585 const char *slave_id, *given_duration, *range_type;
17586 const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
17587 const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
17596 range_type =
"duration";
17598 duration = given_duration ? atoi (given_duration) : 86400;
17599 duration_start = now - duration;
17601 xml = g_string_new (
"<get_system_reports>");
17603 g_string_append_printf (xml,
17604 "<slave id=\"%s\"/>",
17605 slave_id ? slave_id :
"0");
17606 if (strcmp (range_type,
"duration") == 0)
17608 struct tm *time_broken;
17609 time_broken = localtime (&now);
17610 end_time.tm_year = time_broken->tm_year;
17611 end_time.tm_mon = time_broken->tm_mon;
17612 end_time.tm_mday = time_broken->tm_mday;
17613 end_time.tm_hour = time_broken->tm_hour;
17614 end_time.tm_min = time_broken->tm_min;
17616 time_broken = localtime (&duration_start);
17617 start_time.tm_year = time_broken->tm_year;
17618 start_time.tm_mon = time_broken->tm_mon;
17619 start_time.tm_mday = time_broken->tm_mday;
17620 start_time.tm_hour = time_broken->tm_hour;
17621 start_time.tm_min = time_broken->tm_min;
17623 g_string_append_printf (xml,
17624 "<duration>%ld</duration>",
17629 struct tm *time_broken;
17630 time_broken = localtime (&now);
17644 start_time.tm_year = start_year ? atoi (start_year) - 1900
17645 : time_broken->tm_year;
17646 start_time.tm_mon = start_month ? atoi (start_month) - 1
17647 : time_broken->tm_mon;
17648 start_time.tm_mday = start_day ? atoi (start_day)
17649 : time_broken->tm_mday;
17650 start_time.tm_hour = start_hour ? atoi (start_hour)
17651 : time_broken->tm_hour;
17652 start_time.tm_min = start_minute ? atoi (start_minute)
17653 : time_broken->tm_min;
17655 end_time.tm_year = end_year ? atoi (end_year) - 1900
17656 : time_broken->tm_year;
17657 end_time.tm_mon = end_month ? atoi (end_month) - 1
17658 : time_broken->tm_mon;
17659 end_time.tm_mday = end_day ? atoi (end_day)
17660 : time_broken->tm_mday;
17661 end_time.tm_hour = end_hour ? atoi (end_hour)
17662 : time_broken->tm_hour;
17663 end_time.tm_min = end_minute ? atoi (end_minute)
17664 : time_broken->tm_min;
17667 g_string_append_printf (xml,
17669 "<minute>%i</minute>" 17671 "<day_of_month>%i</day_of_month>" 17672 "<month>%i</month>" 17676 start_time.tm_hour,
17677 start_time.tm_mday,
17678 start_time.tm_mon + 1,
17679 start_time.tm_year + 1900);
17681 g_string_append_printf (xml,
17683 "<minute>%i</minute>" 17685 "<day_of_month>%i</day_of_month>" 17686 "<month>%i</month>" 17692 end_time.tm_mon + 1,
17693 end_time.tm_year + 1900);
17697 if (openvas_connection_sendf (connection,
17698 "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
17699 slave_id ? slave_id :
"0")
17702 g_string_free (xml, TRUE);
17705 "Internal error", __FUNCTION__, __LINE__,
17706 "An internal error occurred while getting the system reports. " 17707 "The current list of system reports is not available. " 17708 "Diagnostics: Failure to send command to manager daemon.",
17709 "/omp?cmd=get_tasks", response_data);
17712 if (read_string_c (connection, &xml))
17714 g_string_free (xml, TRUE);
17717 "Internal error", __FUNCTION__, __LINE__,
17718 "An internal error occurred while getting the system reports. " 17719 "The current list of system reports is not available. " 17720 "Diagnostics: Failure to receive response from manager daemon.",
17721 "/omp?cmd=get_tasks", response_data);
17728 if (openvas_connection_sendf (connection,
17730 " filter=\"sort=name rows=-1 type=4\"/>")
17733 g_string_free (xml, TRUE);
17736 "Internal error", __FUNCTION__, __LINE__,
17737 "An internal error occurred while getting the system reports. " 17738 "The current list of system reports is not available. " 17739 "Diagnostics: Failure to send command to manager daemon.",
17740 "/omp?cmd=get_tasks", response_data);
17743 if (read_string_c (connection, &xml))
17745 g_string_free (xml, TRUE);
17748 "Internal error", __FUNCTION__, __LINE__,
17749 "An internal error occurred while getting the system reports. " 17750 "The current list of system reports is not available. " 17751 "Diagnostics: Failure to receive response from manager daemon.",
17752 "/omp?cmd=get_tasks", response_data);
17758 g_string_append (xml,
"</get_system_reports>");
17759 return xsl_transform_omp (connection, credentials, params,
17760 g_string_free (xml, FALSE), response_data);
17781 gsize *content_length,
17785 entity_t report_entity;
17788 struct tm *now_broken;
17789 const char *slave_id, *duration;
17790 const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
17791 const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
17792 struct tm start_time, end_time;
17793 gchar *start_time_str, *end_time_str;
17794 gchar *omp_command;
17796 *content_length = 0;
17804 if (sscanf (url,
"%500[^ /]./report.png", name) == 1)
17808 if (duration && strcmp (duration,
""))
17810 omp_command = g_markup_printf_escaped (
"<get_system_reports" 17813 " slave_id=\"%s\"/>",
17816 slave_id ? slave_id :
"0");
17821 now_broken = localtime (&now);
17835 start_time.tm_year = start_year ? atoi (start_year) - 1900
17836 : now_broken->tm_year;
17837 start_time.tm_mon = start_month ? atoi (start_month) - 1
17838 : now_broken->tm_mon;
17839 start_time.tm_mday = start_day ? atoi (start_day)
17840 : now_broken->tm_mday;
17841 start_time.tm_hour = start_hour ? atoi (start_hour)
17842 : now_broken->tm_hour;
17843 start_time.tm_min = start_minute ? atoi (start_minute)
17844 : now_broken->tm_min;
17845 start_time.tm_zone = now_broken->tm_zone;
17847 end_time.tm_year = end_year ? atoi (end_year) - 1900
17848 : now_broken->tm_year;
17849 end_time.tm_mon = end_month ? atoi (end_month) - 1
17850 : now_broken->tm_mon;
17851 end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
17852 end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
17853 end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
17854 end_time.tm_zone = now_broken->tm_zone;
17859 = g_strdup_printf (
"%04d-%02d-%02dT%02d:%02d:00",
17860 start_time.tm_year + 1900,
17861 start_time.tm_mon + 1,
17862 start_time.tm_mday,
17863 start_time.tm_hour,
17864 start_time.tm_min);
17867 = g_strdup_printf (
"%04d-%02d-%02dT%02d:%02d:00",
17868 end_time.tm_year + 1900,
17869 end_time.tm_mon + 1,
17875 = g_markup_printf_escaped (
"<get_system_reports" 17877 " start_time=\"%s\"" 17879 " slave_id=\"%s\"/>",
17883 slave_id ? slave_id :
"0");
17884 g_free (start_time_str);
17885 g_free (end_time_str);
17888 if (openvas_connection_sendf (connection,
17893 g_free (omp_command);
17896 g_free (omp_command);
17899 if (read_entity_c (connection, &entity))
17904 report_entity = entity_child (entity,
"system_report");
17905 if (report_entity == NULL)
17907 free_entity (entity);
17911 report_entity = entity_child (report_entity,
"report");
17912 if (report_entity == NULL)
17914 free_entity (entity);
17919 char *content_64 = entity_text (report_entity);
17920 char *content = NULL;
17922 if (content_64 && strlen (content_64))
17924 content = (
char *) g_base64_decode (content_64,
17932 content = g_strdup (
"helo");
17936 free_entity (entity);
17956 get_report_format (openvas_connection_t *connection,
17960 return get_one (connection,
"report_format", credentials, params, extra_xml,
17961 "alerts =\"1\" params=\"1\"", response_data);
17979 return get_report_format (connection, credentials, params, NULL,
17995 get_report_formats (openvas_connection_t *connection,
17999 return get_many (connection,
"report_format", credentials, params, extra_xml,
18000 NULL, response_data);
18018 return get_report_formats (connection, credentials, params, NULL,
18034 new_report_format (openvas_connection_t *connection,
credentials_t *credentials,
18035 params_t *params,
const char *extra_xml,
18039 xml = g_string_new (
"<new_report_format>");
18041 g_string_append (xml, extra_xml);
18042 g_string_append (xml,
"</new_report_format>");
18043 return xsl_transform_omp (connection, credentials, params,
18044 g_string_free (xml, FALSE), response_data);
18062 return new_report_format (connection, credentials, params, NULL,
18081 return delete_resource (connection,
"report_format", credentials, params, 0,
18082 "get_report_formats", response_data);
18097 edit_report_format (openvas_connection_t *connection,
18101 gchar *all_rfs_response, *response, *ext_extra_xml;
18103 if (simple_ompf (connection,
"getting Report Formats",
18104 credentials, &all_rfs_response, response_data,
18105 "<get_report_formats" 18106 " filter=\"rows=-1\"/>"))
18108 return all_rfs_response;
18111 ext_extra_xml = g_strdup_printf (
"%s" 18112 "<all_formats>%s</all_formats>",
18113 extra_xml ? extra_xml :
"",
18115 g_free (all_rfs_response);
18117 response =
edit_resource (connection,
"report_format", credentials, params,
18118 NULL, ext_extra_xml, response_data);
18119 g_free (ext_extra_xml);
18138 return edit_report_format (connection, credentials, params, NULL,
18157 const char* no_redirect;
18158 gchar *command, *html, *response;
18168 command = g_strdup_printf (
"<create_report_format>" 18170 "</create_report_format>",
18172 ret = omp (connection, credentials, &response, &entity, response_data,
18183 "Internal error", __FUNCTION__, __LINE__,
18184 "An internal error occurred while importing a report format. " 18185 "The schedule remains the same. " 18186 "Diagnostics: Failure to send command to manager daemon.",
18187 "/omp?cmd=get_report_formats", response_data);
18191 "Internal error", __FUNCTION__, __LINE__,
18192 "An internal error occurred while importing a report format. " 18193 "It is unclear whether the schedule has been saved or not. " 18194 "Diagnostics: Failure to receive response from manager daemon.",
18195 "/omp?cmd=get_report_formats", response_data);
18199 "Internal error", __FUNCTION__, __LINE__,
18200 "An internal error occurred while importing a report format. " 18201 "It is unclear whether the schedule has been saved or not. " 18202 "Diagnostics: Internal Error.",
18203 "/omp?cmd=get_report_formats", response_data);
18208 if (entity_attribute (entity,
"id"))
18209 params_add (params,
"report_format_id", entity_attribute (entity,
"id"));
18210 html = response_from_entity (connection, credentials, params, entity,
18211 (no_redirect && strcmp (no_redirect,
"0")),
18212 NULL,
"get_report_formats",
18213 NULL,
"new_report_format",
18214 "Create Report Format", response_data);
18216 free_entity (entity);
18237 gchar *html, *response;
18238 params_t *preferences, *id_list_params, *include_id_lists;
18239 const char *no_redirect, *report_format_id, *name, *summary, *enable;
18243 report_format_id =
params_value (params,
"report_format_id");
18249 "edit_report_format");
18255 include_id_lists =
params_values (params,
"include_id_list:");
18256 if (include_id_lists)
18258 GHashTable *id_lists;
18260 gchar *param_name, *pref_name, *value, *old_values, *new_values;
18262 GHashTableIter hash_table_iter;
18264 id_lists = g_hash_table_new_full (g_str_hash, g_str_equal,
18273 g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (
""));
18282 gchar *colon_pos = strchr (
param->
value,
':');
18285 value = g_strdup (colon_pos + 1);
18287 old_values = g_hash_table_lookup (id_lists, pref_name);
18289 if (old_values && strcmp (old_values,
""))
18291 new_values = g_strdup_printf (
"%s,%s", old_values, value);
18292 g_hash_table_insert (id_lists, pref_name, new_values);
18295 else if (old_values)
18297 g_hash_table_insert (id_lists, pref_name, value);
18301 g_hash_table_iter_init (&hash_table_iter, id_lists);
18302 while (g_hash_table_iter_next (&hash_table_iter,
18303 (
void**)&pref_name, (
void**)&value))
18307 value_64 = strlen (value)
18308 ? g_base64_encode ((guchar *) value, strlen (value))
18313 ret = ompf (connection, credentials,
18317 "<modify_report_format" 18318 " report_format_id=\"%s\">" 18321 "<value>%s</value>" 18323 "</modify_report_format>",
18334 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18336 "Internal error", __FUNCTION__, __LINE__,
18337 "An internal error occurred while saving a Report Format. " 18338 "The Report Format was not saved. " 18339 "Diagnostics: Failure to send command to manager daemon.",
18340 "/omp?cmd=get_report_formats",
18344 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18346 "Internal error", __FUNCTION__, __LINE__,
18347 "An internal error occurred while saving a Report Format. " 18348 "It is unclear whether the Report Format has been saved or not. " 18349 "Diagnostics: Failure to receive response from manager daemon.",
18350 "/omp?cmd=get_report_formats",
18355 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18357 "Internal error", __FUNCTION__, __LINE__,
18358 "An internal error occurred while saving a Report Format. " 18359 "It is unclear whether the Report Format has been saved or not. " 18360 "Diagnostics: Internal Error.",
18361 "/omp?cmd=get_report_formats",
18385 int type_start, type_end, count;
18387 count = sscanf (param_name,
18388 "%*[^[][%n%*[^]]%n]:",
18391 if (count == 0 && type_start > 0 && type_end > 0)
18402 ret = ompf (connection, credentials,
18406 "<modify_report_format" 18407 " report_format_id=\"%s\">" 18410 "<value>%s</value>" 18412 "</modify_report_format>",
18414 param_name + type_end + 2,
18423 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18425 "Internal error", __FUNCTION__, __LINE__,
18426 "An internal error occurred while saving a Report Format. " 18427 "The Report Format was not saved. " 18428 "Diagnostics: Failure to send command to manager daemon.",
18429 "/omp?cmd=get_report_formats",
18433 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18435 "Internal error", __FUNCTION__, __LINE__,
18436 "An internal error occurred while saving a Report Format. " 18437 "It is unclear whether the Report Format has been saved or not. " 18438 "Diagnostics: Failure to receive response from manager daemon.",
18439 "/omp?cmd=get_report_formats",
18444 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18446 "Internal error", __FUNCTION__, __LINE__,
18447 "An internal error occurred while saving a Report Format. " 18448 "It is unclear whether the Report Format has been saved or not. " 18449 "Diagnostics: Internal Error.",
18450 "/omp?cmd=get_report_formats",
18461 ret = ompf (connection, credentials,
18465 "<modify_report_format" 18466 " report_format_id=\"%s\">" 18468 "<summary>%s</summary>" 18469 "<active>%s</active>" 18470 "</modify_report_format>",
18485 "Internal error", __FUNCTION__, __LINE__,
18486 "An internal error occurred while saving a Report Format. " 18487 "The Report Format was not saved. " 18488 "Diagnostics: Failure to send command to manager daemon.",
18489 "/omp?cmd=get_report_formats", response_data);
18493 "Internal error", __FUNCTION__, __LINE__,
18494 "An internal error occurred while saving a Report Format. " 18495 "It is unclear whether the Report Format has been saved or not. " 18496 "Diagnostics: Failure to receive response from manager daemon.",
18497 "/omp?cmd=get_report_formats", response_data);
18501 "Internal error", __FUNCTION__, __LINE__,
18502 "An internal error occurred while saving a Report Format. " 18503 "It is unclear whether the Report Format has been saved or not. " 18504 "Diagnostics: Internal Error.",
18505 "/omp?cmd=get_report_formats", response_data);
18508 html = response_from_entity (connection, credentials, params, entity,
18509 (no_redirect && strcmp (no_redirect,
"0")),
18510 NULL,
"get_report_formats",
18511 NULL,
"edit_report_format",
18512 "Save Report Format", response_data);
18513 free_entity (entity);
18534 gchar *html, *response;
18535 const char *report_format_id;
18538 report_format_id =
params_value (params,
"report_format_id");
18539 if (report_format_id == NULL)
18543 "Internal error", __FUNCTION__, __LINE__,
18544 "An internal error occurred while verifying a report format. " 18545 "Diagnostics: Required parameter was NULL.",
18546 "/omp?cmd=get_report_formats", response_data);
18553 ret = ompf (connection, credentials,
18557 "<verify_report_format report_format_id=\"%s\"/>",
18568 "Internal error", __FUNCTION__, __LINE__,
18569 "An internal error occurred while verifying a report format. " 18570 "The report format was not verified. " 18571 "Diagnostics: Failure to send command to manager daemon.",
18572 "/omp?cmd=get_report_formats", response_data);
18576 "Internal error", __FUNCTION__, __LINE__,
18577 "An internal error occurred while verifying a report format. " 18578 "It is unclear whether the report format was verified or not. " 18579 "Diagnostics: Failure to send command to manager daemon.",
18580 "/omp?cmd=get_report_formats", response_data);
18584 "Internal error", __FUNCTION__, __LINE__,
18585 "An internal error occurred while verifying a report format. " 18586 "It is unclear whether the report format was verified or not. " 18587 "Diagnostics: Failure to send command to manager daemon.",
18588 "/omp?cmd=get_report_formats", response_data);
18591 if (omp_success (entity))
18593 html = next_page (connection, credentials, params, response,
18597 free_entity (entity);
18601 "Internal error", __FUNCTION__, __LINE__,
18602 "An internal error occurred while verifying a report format. " 18603 "It is unclear whether the report format was verified or not. " 18604 "Diagnostics: Failure to receive response from manager daemon.",
18605 "/omp?cmd=get_report_formats", response_data);
18611 html = get_report_formats (connection, credentials, params, response,
18614 free_entity (entity);
18633 const char *no_redirect, *name;
18637 gchar *param_name, *html, *response;
18652 "Internal error", __FUNCTION__, __LINE__,
18653 "An internal error occurred while trying to start a wizard. " 18654 "Diagnostics: Required parameter 'name' was NULL.",
18655 "/omp?cmd=get_tasks", response_data);
18657 run = g_string_new (
"<run_wizard>");
18659 g_string_append_printf (run,
18669 xml_string_append (run,
18672 "<value>%s</value>" 18678 g_string_append (run,
"</params></run_wizard>");
18682 ret = omp (connection, credentials, &response, &entity, response_data,
18684 g_string_free (run, TRUE);
18693 "Internal error", __FUNCTION__, __LINE__,
18694 "An internal error occurred while running a wizard. " 18695 "The wizard did not start. " 18696 "Diagnostics: Failure to send command to manager daemon.",
18697 "/omp?cmd=get_tasks", response_data);
18701 "Internal error", __FUNCTION__, __LINE__,
18702 "An internal error occurred while running a wizard. " 18703 "It is unclear whether the wizard started or not. " 18704 "Diagnostics: Failure to receive response from manager daemon.",
18705 "/omp?cmd=get_tasks", response_data);
18709 "Internal error", __FUNCTION__, __LINE__,
18710 "An internal error occurred while running a wizard. " 18711 "It is unclear whether the wizard started or not. " 18712 "Diagnostics: Internal Error.",
18713 "/omp?cmd=get_tasks", response_data);
18716 html = response_from_entity (connection, credentials, params, entity,
18717 (no_redirect && strcmp (no_redirect,
"0")),
18720 "Run Wizard", response_data);
18721 free_entity (entity);
18726 #define GET_TRASH_RESOURCE(capability, command, name) \ 18727 if (command_enabled (credentials, capability)) \ 18729 if (openvas_connection_sendf \ 18732 " filter=\"rows=-1 sort=name\"" \ 18733 " trash=\"1\"/>") \ 18736 g_string_free (xml, TRUE); \ 18737 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \ 18738 return gsad_message \ 18740 "Internal error", __FUNCTION__, __LINE__, \ 18741 "An internal error occurred while getting " \ 18742 name " list for trash." \ 18743 "Diagnostics: Failure to send command to" \ 18744 " manager daemon.", \ 18745 "/omp?cmd=get_trash", response_data); \ 18748 if (read_string_c (connection, &xml)) \ 18750 g_string_free (xml, TRUE); \ 18751 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \ 18752 return gsad_message \ 18754 "Internal error", __FUNCTION__, __LINE__, \ 18755 "An internal error occurred while getting " name " list."\ 18756 "Diagnostics: Failure to receive response from" \ 18757 " manager daemon.", \ 18758 "/omp?cmd=get_tasks", response_data); \ 18774 get_trash (openvas_connection_t *connection,
credentials_t * credentials,
18775 params_t *params,
const char *extra_xml,
18780 xml = g_string_new (
"<get_trash>");
18783 g_string_append (xml, extra_xml);
18822 g_string_append (xml,
"</get_trash>");
18823 return xsl_transform_omp (connection, credentials, params,
18824 g_string_free (xml, FALSE), response_data);
18826 #undef GET_TRASH_RESOURCE 18842 return get_trash (connection, credentials, params, NULL, response_data);
18857 get_my_settings (openvas_connection_t *connection,
credentials_t * credentials,
18858 params_t *params,
const char *extra_xml,
18863 xml = g_string_new (
"<get_my_settings>");
18866 g_string_append (xml, extra_xml);
18870 if (openvas_connection_sendf (connection,
18872 " sort_field=\"name\"" 18873 " sort_order=\"ascending\"/>")
18876 g_string_free (xml, TRUE);
18879 "Internal error", __FUNCTION__, __LINE__,
18880 "An internal error occurred while getting the settings. " 18881 "The current list of settings is not available. " 18882 "Diagnostics: Failure to send command to manager daemon.",
18883 "/omp?cmd=get_tasks", response_data);
18886 if (read_string_c (connection, &xml))
18888 g_string_free (xml, TRUE);
18891 "Internal error", __FUNCTION__, __LINE__,
18892 "An internal error occurred while getting the settings. " 18893 "The current list of settings is not available. " 18894 "Diagnostics: Failure to receive response from manager daemon.",
18895 "/omp?cmd=get_tasks", response_data);
18900 g_string_append (xml,
"</get_my_settings>");
18901 return xsl_transform_omp (connection, credentials, params,
18902 g_string_free (xml, FALSE), response_data);
18925 commands = g_string_new (
"<commands>");
18927 g_string_append (commands,
"<get_alerts/>");
18929 g_string_append (commands,
"<get_configs/>");
18931 g_string_append (commands,
"<get_filters/>");
18933 g_string_append (commands,
"<get_credentials/>");
18935 g_string_append (commands,
"<get_port_lists/>");
18937 g_string_append (commands,
"<get_report_formats/>");
18939 g_string_append (commands,
"<get_scanners/>");
18941 g_string_append (commands,
"<get_schedules/>");
18943 g_string_append (commands,
"<get_targets/>");
18944 g_string_append (commands,
"</commands>");
18949 ret = omp (connection, credentials, &response, &entity, response_data,
18951 g_string_free (commands, TRUE);
18960 "Internal error", __FUNCTION__, __LINE__,
18961 "An internal error occurred while getting resources " 18962 "for the settings. " 18963 "Diagnostics: Failure to send command to manager daemon.",
18964 "/omp?cmd=get_my_settings", response_data);
18968 "Internal error", __FUNCTION__, __LINE__,
18969 "An internal error occurred while getting resources " 18970 "for the settings. " 18971 "Diagnostics: Failure to receive response from manager daemon.",
18972 "/omp?cmd=get_alerts", response_data);
18976 "Internal error", __FUNCTION__, __LINE__,
18977 "An internal error occurred while getting resources " 18978 "for the settings. " 18979 "It is unclear whether the task has been saved or not. " 18980 "Diagnostics: Internal Error.",
18981 "/omp?cmd=get_alerts", response_data);
18983 free_entity (entity);
18985 return get_my_settings (connection, credentials, params, response,
19001 edit_my_settings (openvas_connection_t *connection,
19005 GString *commands, *xml;
19007 gchar *filters_xml;
19011 commands = g_string_new (
"<commands>");
19013 g_string_append (commands,
"<get_alerts/>");
19015 g_string_append (commands,
"<get_configs/>");
19017 g_string_append (commands,
"<get_credentials/>");
19019 g_string_append (commands,
"<get_filters/>");
19021 g_string_append (commands,
"<get_port_lists/>");
19023 g_string_append (commands,
"<get_report_formats/>");
19025 g_string_append (commands,
"<get_scanners/>");
19027 g_string_append (commands,
"<get_schedules/>");
19029 g_string_append (commands,
"<get_targets/>");
19030 g_string_append (commands,
"</commands>");
19032 filters_xml = NULL;
19034 ret = omp (connection, credentials, &filters_xml, &entity, response_data,
19036 g_string_free (commands, TRUE);
19045 "Internal error", __FUNCTION__, __LINE__,
19046 "An internal error occurred while getting resources " 19047 "for the settings. " 19048 "Diagnostics: Failure to send command to manager daemon.",
19049 "/omp?cmd=get_my_settings", response_data);
19053 "Internal error", __FUNCTION__, __LINE__,
19054 "An internal error occurred while getting resources " 19056 "Diagnostics: Failure to receive response from manager daemon.",
19057 "/omp?cmd=get_my_settings", response_data);
19061 "Internal error", __FUNCTION__, __LINE__,
19062 "An internal error occurred while getting resources " 19063 "for the settings. " 19064 "Diagnostics: Internal Error.",
19065 "/omp?cmd=get_my_settings", response_data);
19067 free_entity (entity);
19069 xml = g_string_new (
"<edit_my_settings>");
19072 g_string_append (xml, extra_xml);
19074 g_string_append (xml, filters_xml);
19075 g_free (filters_xml);
19079 if (openvas_connection_sendf (connection,
19081 " sort_field=\"name\"" 19082 " sort_order=\"ascending\"/>")
19085 g_string_free (xml, TRUE);
19088 "Internal error", __FUNCTION__, __LINE__,
19089 "An internal error occurred while getting the settings. " 19090 "The current list of settings is not available. " 19091 "Diagnostics: Failure to send command to manager daemon.",
19092 "/omp?cmd=get_my_settings", response_data);
19095 if (read_string_c (connection, &xml))
19097 g_string_free (xml, TRUE);
19100 "Internal error", __FUNCTION__, __LINE__,
19101 "An internal error occurred while getting the settings. " 19102 "The current list of settings is not available. " 19103 "Diagnostics: Failure to receive response from manager daemon.",
19104 "/omp?cmd=get_my_settings", response_data);
19109 g_string_append (xml,
"</edit_my_settings>");
19110 return xsl_transform_omp (connection, credentials, params,
19111 g_string_free (xml, FALSE), response_data);
19129 return edit_my_settings (connection, credentials, params, NULL,
19145 send_settings_filters (openvas_connection_t *connection,
params_t *data,
19146 params_t *changed, GString *xml,
int *modify_failed_flag,
19159 const char* changed_value =
params_value (changed, uuid);
19160 if (changed_value == NULL
19161 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19165 base64 = g_base64_encode ((guchar*)
param->
value,
19168 base64 = g_strdup(
"");
19169 if (openvas_connection_sendf_xml (connection,
19170 "<modify_setting setting_id=\"%s\">" 19171 "<value>%s</value>" 19172 "</modify_setting>",
19183 xml_string_append (xml,
19184 "<save_setting id=\"%s\">",
19186 if (read_entity_and_string_c (connection, &entity, &xml))
19188 free_entity (entity);
19191 xml_string_append (xml,
"</save_setting>");
19192 if (! omp_success (entity))
19195 if (modify_failed_flag)
19196 *modify_failed_flag = 1;
19198 free_entity(entity);
19223 const char *accept_language,
char **timezone,
19224 char **password,
char **severity,
char **language,
19227 const char *lang, *text, *old_passwd, *passwd, *status, *max;
19228 const char *details_fname, *list_fname, *report_fname;
19229 gchar *lang_64, *text_64, *max_64, *fname_64;
19232 params_t *changed, *defaults, *filters;
19233 int modify_failed = 0;
19234 const char *changed_value;
19247 details_fname =
params_value (params,
"details_fname");
19251 || (passwd == NULL)
19252 || (old_passwd == NULL)
19255 || (details_fname == NULL)
19256 || (list_fname == NULL)
19257 || (report_fname == NULL))
19258 return edit_my_settings (connection, credentials, params,
19260 (
"Save My Settings"),
19263 xml = g_string_new (
"");
19266 if ((strlen (passwd) || strlen (old_passwd))
19267 && (changed_value == NULL
19268 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0"))))
19271 omp_authenticate_info_opts_t auth_opts;
19275 auth_opts = omp_authenticate_info_opts_defaults;
19276 auth_opts.username = credentials->
username;
19277 auth_opts.password = old_passwd;
19278 switch (omp_authenticate_info_ext_c (connection, auth_opts))
19285 "Internal error", __FUNCTION__, __LINE__,
19286 "An internal error occurred while saving settings. " 19287 "The settings remains the same. " 19288 "Diagnostics: Manager closed connection during authenticate.",
19289 "/omp?cmd=get_my_settings", response_data);
19293 "Invalid Password", __FUNCTION__, __LINE__,
19294 "You tried to change your password, but the old" 19295 " password was not provided or was incorrect. " 19296 " Please enter the correct old password or remove" 19297 " old and new passwords to apply any other changes" 19298 " of your settings.",
19299 "/omp?cmd=get_my_settings", response_data);
19303 "Internal error", __FUNCTION__, __LINE__,
19304 "An internal error occurred while saving settings. " 19305 "The settings remains the same. " 19306 "Diagnostics: Internal Error.",
19307 "/omp?cmd=get_my_settings", response_data);
19310 passwd_64 = g_base64_encode ((guchar*) passwd, strlen (passwd));
19312 if (openvas_connection_sendf (connection,
19314 "<name>Password</name>" 19315 "<value>%s</value>" 19316 "</modify_setting>",
19317 passwd_64 ? passwd_64 :
"")
19320 g_free (passwd_64);
19323 "Internal error", __FUNCTION__, __LINE__,
19324 "An internal error occurred while saving settings. " 19325 "It is unclear whether all the settings were saved. " 19326 "Diagnostics: Failure to send command to manager daemon.",
19327 "/omp?cmd=get_my_settings", response_data);
19329 g_free (passwd_64);
19332 xml_string_append (xml,
"<save_setting name=\"Password\">");
19333 if (read_entity_and_string_c (connection, &entity, &xml))
19335 g_string_free (xml, TRUE);
19338 "Internal error", __FUNCTION__, __LINE__,
19339 "An internal error occurred while saving settings. " 19340 "Diagnostics: Failure to receive response from manager daemon.",
19341 "/omp?cmd=get_my_settings", response_data);
19343 xml_string_append (xml,
"</save_setting>");
19345 status = entity_attribute (entity,
"status");
19346 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
19349 credentials->
password = g_strdup (passwd);
19350 *password = g_strdup (passwd);
19361 if (changed_value == NULL
19362 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19364 text_64 = g_base64_encode ((guchar*) text, strlen (text));
19366 if (openvas_connection_sendf (connection,
19368 "<name>Timezone</name>" 19369 "<value>%s</value>" 19370 "</modify_setting>",
19371 text_64 ? text_64 :
"")
19377 "Internal error", __FUNCTION__, __LINE__,
19378 "An internal error occurred while saving settings. " 19379 "It is unclear whether all the settings were saved. " 19380 "Diagnostics: Failure to send command to manager daemon.",
19381 "/omp?cmd=get_my_settings", response_data);
19386 xml_string_append (xml,
"<save_setting name=\"Timezone\">");
19387 if (read_entity_and_string_c (connection, &entity, &xml))
19389 g_string_free (xml, TRUE);
19392 "Internal error", __FUNCTION__, __LINE__,
19393 "An internal error occurred while saving settings. " 19394 "Diagnostics: Failure to receive response from manager daemon.",
19395 "/omp?cmd=get_my_settings", response_data);
19397 xml_string_append (xml,
"</save_setting>");
19399 status = entity_attribute (entity,
"status");
19400 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
19403 credentials->
timezone = g_strdup (strlen (text) ? text :
"UTC");
19404 *timezone = g_strdup (strlen (text) ? text :
"UTC");
19409 if (setenv (
"TZ", credentials->
timezone, 1) == -1)
19411 g_critical (
"%s: failed to set TZ\n", __FUNCTION__);
19412 exit (EXIT_FAILURE);
19425 if (changed_value == NULL
19426 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19428 max_64 = g_base64_encode ((guchar*) max, strlen (max));
19430 if (openvas_connection_sendf (connection,
19433 "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">" 19434 "<value>%s</value>" 19435 "</modify_setting>",
19436 max_64 ? max_64 :
"")
19442 "Internal error", __FUNCTION__, __LINE__,
19443 "An internal error occurred while saving settings. " 19444 "It is unclear whether all the settings were saved. " 19445 "Diagnostics: Failure to send command to manager daemon.",
19446 "/omp?cmd=get_my_settings", response_data);
19451 xml_string_append (xml,
19452 "<save_setting id=\"%s\">",
19453 "5f5a8712-8017-11e1-8556-406186ea4fc5");
19454 if (read_entity_and_string_c (connection, &entity, &xml))
19456 g_string_free (xml, TRUE);
19459 "Internal error", __FUNCTION__, __LINE__,
19460 "An internal error occurred while saving settings. " 19461 "It is unclear whether all the settings were saved. " 19462 "Diagnostics: Failure to receive response from manager daemon.",
19463 "/omp?cmd=get_my_settings", response_data);
19465 xml_string_append (xml,
"</save_setting>");
19466 if (! omp_success (entity))
19474 changed_value =
params_value (changed,
"details_fname");
19475 if (changed_value == NULL
19476 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19478 fname_64 = g_base64_encode ((guchar*) details_fname, strlen (details_fname));
19480 if (openvas_connection_sendf (connection,
19483 "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">" 19484 "<value>%s</value>" 19485 "</modify_setting>",
19486 fname_64 ? fname_64 :
"")
19492 "Internal error", __FUNCTION__, __LINE__,
19493 "An internal error occurred while saving settings. " 19494 "It is unclear whether all the settings were saved. " 19495 "Diagnostics: Failure to send command to manager daemon.",
19496 "/omp?cmd=get_my_settings", response_data);
19501 xml_string_append (xml,
19502 "<save_setting id=\"%s\">",
19503 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
19504 if (read_entity_and_string_c (connection, &entity, &xml))
19506 g_string_free (xml, TRUE);
19509 "Internal error", __FUNCTION__, __LINE__,
19510 "An internal error occurred while saving settings. " 19511 "It is unclear whether all the settings were saved. " 19512 "Diagnostics: Failure to receive response from manager daemon.",
19513 "/omp?cmd=get_my_settings", response_data);
19515 xml_string_append (xml,
"</save_setting>");
19516 if (omp_success (entity) != 1)
19525 if (changed_value == NULL
19526 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19528 fname_64 = g_base64_encode ((guchar*) list_fname, strlen (list_fname));
19530 if (openvas_connection_sendf (connection,
19533 "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">" 19534 "<value>%s</value>" 19535 "</modify_setting>",
19536 fname_64 ? fname_64 :
"")
19542 "Internal error", __FUNCTION__, __LINE__,
19543 "An internal error occurred while saving settings. " 19544 "It is unclear whether all the settings were saved. " 19545 "Diagnostics: Failure to send command to manager daemon.",
19546 "/omp?cmd=get_my_settings", response_data);
19551 xml_string_append (xml,
19552 "<save_setting id=\"%s\">",
19553 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
19554 if (read_entity_and_string_c (connection, &entity, &xml))
19556 g_string_free (xml, TRUE);
19559 "Internal error", __FUNCTION__, __LINE__,
19560 "An internal error occurred while saving settings. " 19561 "It is unclear whether all the settings were saved. " 19562 "Diagnostics: Failure to receive response from manager daemon.",
19563 "/omp?cmd=get_my_settings", response_data);
19565 xml_string_append (xml,
"</save_setting>");
19566 if (omp_success (entity) != 1)
19574 changed_value =
params_value (changed,
"report_fname");
19575 if (changed_value == NULL
19576 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19578 fname_64 = g_base64_encode ((guchar*) report_fname, strlen (report_fname));
19580 if (openvas_connection_sendf (connection,
19583 "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">" 19584 "<value>%s</value>" 19585 "</modify_setting>",
19586 fname_64 ? fname_64 :
"")
19592 "Internal error", __FUNCTION__, __LINE__,
19593 "An internal error occurred while saving settings. " 19594 "It is unclear whether all the settings were saved. " 19595 "Diagnostics: Failure to send command to manager daemon.",
19596 "/omp?cmd=get_my_settings", response_data);
19601 xml_string_append (xml,
19602 "<save_setting id=\"%s\">",
19603 "e1a2ae0b-736e-4484-b029-330c9e15b900");
19604 if (read_entity_and_string_c (connection, &entity, &xml))
19606 g_string_free (xml, TRUE);
19609 "Internal error", __FUNCTION__, __LINE__,
19610 "An internal error occurred while saving settings. " 19611 "It is unclear whether all the settings were saved. " 19612 "Diagnostics: Failure to receive response from manager daemon.",
19613 "/omp?cmd=get_my_settings", response_data);
19615 xml_string_append (xml,
"</save_setting>");
19616 if (omp_success (entity) != 1)
19625 if (changed_value == NULL
19626 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19628 lang_64 = g_base64_encode ((guchar*) lang, strlen (lang));
19630 if (openvas_connection_sendf (connection,
19633 "=\"6765549a-934e-11e3-b358-406186ea4fc5\">" 19634 "<value>%s</value>" 19635 "</modify_setting>",
19636 lang_64 ? lang_64 :
"")
19642 "Internal error", __FUNCTION__, __LINE__,
19643 "An internal error occurred while saving settings. " 19644 "It is unclear whether all the settings were saved. " 19645 "Diagnostics: Failure to send command to manager daemon.",
19646 "/omp?cmd=get_my_settings", response_data);
19651 xml_string_append (xml,
19652 "<save_setting id=\"%s\">",
19653 "6765549a-934e-11e3-b358-406186ea4fc5");
19654 if (read_entity_and_string_c (connection, &entity, &xml))
19656 g_string_free (xml, TRUE);
19659 "Internal error", __FUNCTION__, __LINE__,
19660 "An internal error occurred while saving settings. " 19661 "It is unclear whether all the settings were saved. " 19662 "Diagnostics: Failure to receive response from manager daemon.",
19663 "/omp?cmd=get_my_settings", response_data);
19665 xml_string_append (xml,
"</save_setting>");
19666 if (omp_success (entity))
19668 gchar *language_code;
19673 credentials->
language = language_code;
19674 *language = g_strdup (lang);
19693 if (send_settings_filters (connection, defaults, changed, xml,
19694 &modify_failed, response_data))
19698 "Internal error", __FUNCTION__, __LINE__,
19699 "An internal error occurred while saving settings. " 19700 "It is unclear whether all the settings were saved. " 19701 "Diagnostics: Failure to send command to manager daemon.",
19702 "/omp?cmd=get_my_settings", response_data);
19708 if (send_settings_filters (connection, filters, changed, xml, &modify_failed,
19713 "Internal error", __FUNCTION__, __LINE__,
19714 "An internal error occurred while saving settings. " 19715 "It is unclear whether all the settings were saved. " 19716 "Diagnostics: Failure to send command to manager daemon.",
19717 "/omp?cmd=get_my_settings", response_data);
19722 changed_value =
params_value (changed,
"severity_class");
19723 if (changed_value == NULL
19724 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19728 ? g_base64_encode ((guchar*) text, strlen (text))
19731 if (openvas_connection_sendf (connection,
19734 "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">" 19735 "<value>%s</value>" 19736 "</modify_setting>",
19737 text_64 ? text_64 :
"")
19743 "Internal error", __FUNCTION__, __LINE__,
19744 "An internal error occurred while saving settings. " 19745 "It is unclear whether all the settings were saved. " 19746 "Diagnostics: Failure to send command to manager daemon.",
19747 "/omp?cmd=get_my_settings", response_data);
19752 xml_string_append (xml,
19753 "<save_setting id=\"%s\">",
19754 "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
19755 if (read_entity_and_string_c (connection, &entity, &xml))
19757 g_string_free (xml, TRUE);
19760 "Internal error", __FUNCTION__, __LINE__,
19761 "An internal error occurred while saving settings. " 19762 "It is unclear whether all the settings were saved. " 19763 "Diagnostics: Failure to receive response from manager daemon.",
19764 "/omp?cmd=get_my_settings", response_data);
19766 xml_string_append (xml,
"</save_setting>");
19768 status = entity_attribute (entity,
"status");
19769 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
19772 if ((text != NULL) && (strlen (text) > 0))
19774 credentials->
severity = g_strdup (text);
19775 *severity = g_strdup (text);
19787 changed_value =
params_value (changed,
"dynamic_severity");
19788 if (changed_value == NULL
19789 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19793 ? g_base64_encode ((guchar*) text, strlen (text))
19796 if (openvas_connection_sendf (connection,
19799 "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">" 19800 "<value>%s</value>" 19801 "</modify_setting>",
19802 text_64 ? text_64 :
"")
19808 "Internal error", __FUNCTION__, __LINE__,
19809 "An internal error occurred while saving settings. " 19810 "It is unclear whether all the settings were saved. " 19811 "Diagnostics: Failure to send command to manager daemon.",
19812 "/omp?cmd=get_my_settings", response_data);
19817 xml_string_append (xml,
19818 "<save_setting id=\"%s\">",
19819 "77ec2444-e7f2-4a80-a59b-f4237782d93f");
19820 if (read_entity_and_string_c (connection, &entity, &xml))
19822 g_string_free (xml, TRUE);
19825 "Internal error", __FUNCTION__, __LINE__,
19826 "An internal error occurred while saving settings. " 19827 "It is unclear whether all the settings were saved. " 19828 "Diagnostics: Failure to receive response from manager daemon.",
19829 "/omp?cmd=get_my_settings", response_data);
19831 xml_string_append (xml,
"</save_setting>");
19832 if (! omp_success (entity))
19840 changed_value =
params_value (changed,
"default_severity");
19841 if (changed_value == NULL
19842 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19846 ? g_base64_encode ((guchar*) text, strlen (text))
19849 if (openvas_connection_sendf (connection,
19852 "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">" 19853 "<value>%s</value>" 19854 "</modify_setting>",
19855 text_64 ? text_64 :
"")
19861 "Internal error", __FUNCTION__, __LINE__,
19862 "An internal error occurred while saving settings. " 19863 "It is unclear whether all the settings were saved. " 19864 "Diagnostics: Failure to send command to manager daemon.",
19865 "/omp?cmd=get_my_settings", response_data);
19870 xml_string_append (xml,
19871 "<save_setting id=\"%s\">",
19872 "7eda49c5-096c-4bef-b1ab-d080d87300df");
19873 if (read_entity_and_string_c (connection, &entity, &xml))
19875 g_string_free (xml, TRUE);
19878 "Internal error", __FUNCTION__, __LINE__,
19879 "An internal error occurred while saving settings. " 19880 "It is unclear whether all the settings were saved. " 19881 "Diagnostics: Failure to receive response from manager daemon.",
19882 "/omp?cmd=get_my_settings", response_data);
19884 xml_string_append (xml,
"</save_setting>");
19885 if (! omp_success (entity))
19894 changed_value =
params_value (changed,
"auto_cache_rebuild");
19895 if (changed_value == NULL
19896 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19900 ? g_base64_encode ((guchar*) text, strlen (text))
19903 if (openvas_connection_sendf (connection,
19906 "=\"a09285b0-2d47-49b6-a4ef-946ee71f1d5c\">" 19907 "<value>%s</value>" 19908 "</modify_setting>",
19909 text_64 ? text_64 :
"")
19915 "Internal error", __FUNCTION__, __LINE__,
19916 "An internal error occurred while saving settings. " 19917 "It is unclear whether all the settings were saved. " 19918 "Diagnostics: Failure to send command to manager daemon.",
19919 "/omp?cmd=get_my_settings", response_data);
19924 xml_string_append (xml,
19925 "<save_setting id=\"%s\">",
19926 "a09285b0-2d47-49b6-a4ef-946ee71f1d5c");
19927 if (read_entity_and_string_c (connection, &entity, &xml))
19929 g_string_free (xml, TRUE);
19932 "Internal error", __FUNCTION__, __LINE__,
19933 "An internal error occurred while saving settings. " 19934 "It is unclear whether all the settings were saved. " 19935 "Diagnostics: Failure to receive response from manager daemon.",
19936 "/omp?cmd=get_my_settings", response_data);
19938 xml_string_append (xml,
"</save_setting>");
19939 if (! omp_success (entity))
19947 return edit_my_settings (connection, credentials, params,
19948 g_string_free (xml, FALSE), response_data);
19950 return get_my_settings (connection, credentials, params,
19951 g_string_free (xml, FALSE), response_data);
19970 entity_t help_response;
19972 xml = g_string_new (
"");
19973 g_string_append_printf (xml,
"<get_protocol_doc>");
19977 if (openvas_connection_sendf (connection,
"<help format=\"XML\"/>")
19980 g_string_free (xml, TRUE);
19983 "Internal error", __FUNCTION__, __LINE__,
19984 "An internal error occurred while getting the OMP doc. " 19985 "Diagnostics: Failure to send command to manager daemon.",
19986 "/omp?cmd=get_tasks", response_data);
19989 help_response = NULL;
19990 if (read_entity_and_string_c (connection, &help_response, &xml))
19992 g_string_free (xml, TRUE);
19995 "Internal error", __FUNCTION__, __LINE__,
19996 "An internal error occurred while getting the OMP doc. " 19997 "Diagnostics: Failure to receive response from manager daemon.",
19998 "/omp?cmd=get_tasks", response_data);
20000 free_entity (help_response);
20004 g_string_append_printf (xml,
"</get_protocol_doc>");
20005 return xsl_transform_omp (connection, credentials, params,
20006 g_string_free (xml, FALSE), response_data);
20026 char **content_disposition, gsize *content_length,
20029 entity_t entity, response;
20030 char *content = NULL;
20031 const char *format;
20035 *content_length = 0;
20041 if (openvas_connection_sendf (connection,
20042 "<help format=\"%s\"/>",
20048 "Internal error", __FUNCTION__, __LINE__,
20049 "An internal error occurred while getting a list. " 20050 "The list could not be delivered. " 20051 "Diagnostics: Failure to send command to manager daemon.",
20052 "/omp?cmd=get_protocol_doc", response_data);
20056 if (read_entity_and_text_c (connection, &response, &content))
20060 "Internal error", __FUNCTION__, __LINE__,
20061 "An internal error occurred while getting OMP doc. " 20062 "Diagnostics: Failure to receive response from manager daemon.",
20063 "/omp?cmd=get_protocol_doc", response_data);
20066 if (strcmp (format,
"xml") == 0)
20067 *content_length = strlen (content);
20071 entity = entity_child (response,
"schema");
20072 if (entity == NULL)
20074 free_entity (response);
20077 "Internal error", __FUNCTION__, __LINE__,
20078 "An internal error occurred while getting OMP doc. " 20079 "Diagnostics: Schema element missing.",
20080 "/omp?cmd=get_protocol_doc", response_data);
20083 content_64 = entity_text (entity);
20084 if (strlen (content_64) == 0)
20086 free_entity (response);
20089 "Internal error", __FUNCTION__, __LINE__,
20090 "An internal error occurred while getting OMP doc. " 20091 "Diagnostics: Schema empty.",
20092 "/omp?cmd=get_protocol_doc", response_data);
20095 content = (
char *) g_base64_decode (content_64, content_length);
20099 tm = localtime (&now);
20101 *content_disposition = g_strdup_printf (
"attachment;" 20102 " filename=\"omp-%d-%d-%d.%s\"",
20107 free_entity (response);
20126 get_group (openvas_connection_t *connection,
credentials_t * credentials,
20127 params_t *params,
const char *extra_xml,
20130 return get_one (connection,
"group", credentials, params, extra_xml, NULL,
20148 return get_group (connection, credentials, params, NULL, response_data);
20163 get_groups (openvas_connection_t *connection,
credentials_t * credentials,
20164 params_t *params,
const char *extra_xml,
20167 return get_many (connection,
"group", credentials, params, extra_xml, NULL,
20185 return get_groups (connection, credentials, params, NULL, response_data);
20200 new_group (openvas_connection_t *connection,
credentials_t *credentials,
20201 params_t *params,
const char *extra_xml,
20205 xml = g_string_new (
"<new_group>");
20207 g_string_append (xml, extra_xml);
20208 g_string_append (xml,
"</new_group>");
20209 return xsl_transform_omp (connection, credentials, params,
20210 g_string_free (xml, FALSE), response_data);
20227 return new_group (connection, credentials, params, NULL, response_data);
20246 "get_trash", response_data);
20264 "get_groups", response_data);
20281 gchar *html, *response, *command, *specials_element;
20282 const char *no_redirect, *name, *comment, *
users, *grant_full;
20299 xml = g_string_new (
"");
20301 xml_string_append (xml,
20303 "<comment>%s</comment>" 20304 "<users>%s</users>",
20310 specials_element = g_strdup_printf (
"<full/>");
20312 specials_element = NULL;
20314 command = g_strdup_printf (
"<create_group>" 20323 g_string_free (xml, TRUE);
20324 g_free (specials_element);
20326 ret = omp (connection, credentials, &response, &entity, response_data,
20337 "Internal error", __FUNCTION__, __LINE__,
20338 "An internal error occurred while creating a new group. " 20339 "No new group was created. " 20340 "Diagnostics: Failure to send command to manager daemon.",
20341 "/omp?cmd=get_groups", response_data);
20345 "Internal error", __FUNCTION__, __LINE__,
20346 "An internal error occurred while creating a new group. " 20347 "It is unclear whether the group has been created or not. " 20348 "Diagnostics: Failure to receive response from manager daemon.",
20349 "/omp?cmd=get_groups", response_data);
20353 "Internal error", __FUNCTION__, __LINE__,
20354 "An internal error occurred while creating a new group. " 20355 "It is unclear whether the group has been created or not. " 20356 "Diagnostics: Internal Error.",
20357 "/omp?cmd=get_groups", response_data);
20360 if (entity_attribute (entity,
"id"))
20361 params_add (params,
"group_id", entity_attribute (entity,
"id"));
20362 html = response_from_entity (connection, credentials, params, entity,
20363 (no_redirect && strcmp (no_redirect,
"0")),
20364 NULL,
"get_groups",
20366 "Create Group", response_data);
20367 free_entity (entity);
20385 params_t *params,
const char *extra_xml,
20388 return edit_resource (connection,
"group", credentials, params, NULL,
20389 extra_xml, response_data);
20406 return edit_group (connection, credentials, params, NULL, response_data);
20453 return export_many (connection,
"group", credentials, params,
content_type,
20454 content_disposition, content_length, response_data);
20472 gchar *html, *response;
20473 const char *no_redirect, *group_id, *name, *comment, *
users;
20491 ret = ompf (connection, credentials,
20495 "<modify_group group_id=\"%s\">" 20497 "<comment>%s</comment>" 20498 "<users>%s</users>" 20513 "Internal error", __FUNCTION__, __LINE__,
20514 "An internal error occurred while saving a group. " 20515 "The group was not saved. " 20516 "Diagnostics: Failure to send command to manager daemon.",
20517 "/omp?cmd=get_groups", response_data);
20521 "Internal error", __FUNCTION__, __LINE__,
20522 "An internal error occurred while saving a group. " 20523 "It is unclear whether the group has been saved or not. " 20524 "Diagnostics: Failure to receive response from manager daemon.",
20525 "/omp?cmd=get_groups", response_data);
20529 "Internal error", __FUNCTION__, __LINE__,
20530 "An internal error occurred while saving a group. " 20531 "It is unclear whether the group has been saved or not. " 20532 "Diagnostics: Internal Error.",
20533 "/omp?cmd=get_groups", response_data);
20536 html = response_from_entity (connection, credentials, params, entity,
20537 (no_redirect && strcmp (no_redirect,
"0")),
20538 NULL,
"get_groups",
20539 NULL,
"edit_group",
20540 "Save Group", response_data);
20541 free_entity (entity);
20561 get_permission (openvas_connection_t *connection,
credentials_t * credentials,
20562 params_t *params,
const char *extra_xml,
20565 return get_one (connection,
"permission", credentials, params, extra_xml,
20566 "alerts=\"1\"", response_data);
20584 return get_permission (connection, credentials, params, NULL, response_data);
20599 get_permissions (openvas_connection_t *connection,
credentials_t * credentials,
20600 params_t *params,
const char *extra_xml,
20603 return get_many (connection,
"permission", credentials, params, extra_xml,
20604 NULL, response_data);
20622 return get_permissions (connection, credentials, params, NULL, response_data);
20640 return delete_resource (connection,
"permission", credentials, params, 1,
20641 "get_trash", response_data);
20659 return delete_resource (connection,
"permission", credentials, params, 0,
20660 NULL, response_data);
20676 params_t *params,
const char *extra_xml,
20681 xml = g_string_new (
"<new_permission>");
20690 switch (omp (connection, credentials, &response, &entity, response_data,
20691 "<get_users filter=\"rows=-1 permission=get_users\"/>"))
20699 "Internal error", __FUNCTION__, __LINE__,
20700 "An internal error occurred getting the user list. " 20701 "No new user was created. " 20702 "Diagnostics: Failure to send command to manager daemon.",
20703 "/omp?cmd=get_users", response_data);
20707 "Internal error", __FUNCTION__, __LINE__,
20708 "An internal error occurred getting the user list. " 20709 "No new user was created. " 20710 "Diagnostics: Failure to receive response from manager daemon.",
20711 "/omp?cmd=get_users", response_data);
20715 "Internal error", __FUNCTION__, __LINE__,
20716 "An internal error occurred getting the user list. " 20717 "No new user was created. " 20718 "Diagnostics: Internal Error.",
20719 "/omp?cmd=get_users", response_data);
20722 g_string_append (xml, response);
20724 free_entity (entity);
20735 switch (omp (connection, credentials, &response, &entity, response_data,
20736 "<get_groups filter=\"rows=-1 permission=get_groups\"/>"))
20744 "Internal error", __FUNCTION__, __LINE__,
20745 "An internal error occurred getting the group list. " 20746 "No new user was created. " 20747 "Diagnostics: Failure to send command to manager daemon.",
20748 "/omp?cmd=get_users", response_data);
20752 "Internal error", __FUNCTION__, __LINE__,
20753 "An internal error occurred getting the group list. " 20754 "No new user was created. " 20755 "Diagnostics: Failure to receive response from manager daemon.",
20756 "/omp?cmd=get_users", response_data);
20760 "Internal error", __FUNCTION__, __LINE__,
20761 "An internal error occurred getting the group list. " 20762 "No new user was created. " 20763 "Diagnostics: Internal Error.",
20764 "/omp?cmd=get_users", response_data);
20767 g_string_append (xml, response);
20769 free_entity (entity);
20780 switch (omp (connection, credentials, &response, &entity, response_data,
20781 "<get_roles filter=\"rows=-1 permission=get_roles\"/>"))
20789 "Internal error", __FUNCTION__, __LINE__,
20790 "An internal error occurred getting the role list. " 20791 "No new user was created. " 20792 "Diagnostics: Failure to send command to manager daemon.",
20793 "/omp?cmd=get_users", response_data);
20797 "Internal error", __FUNCTION__, __LINE__,
20798 "An internal error occurred getting the role list. " 20799 "No new user was created. " 20800 "Diagnostics: Failure to receive response from manager daemon.",
20801 "/omp?cmd=get_users", response_data);
20805 "Internal error", __FUNCTION__, __LINE__,
20806 "An internal error occurred getting the role list. " 20807 "No new user was created. " 20808 "Diagnostics: Internal Error.",
20809 "/omp?cmd=get_users", response_data);
20812 g_string_append (xml, response);
20814 free_entity (entity);
20819 g_string_append (xml, extra_xml);
20821 g_string_append (xml,
"</new_permission>");
20823 return xsl_transform_omp (connection, credentials, params,
20824 g_string_free (xml, FALSE), response_data);
20842 return new_permission (connection, credentials, params, NULL, response_data);
20861 gchar *html, *response;
20862 const char *no_redirect, *name, *comment, *resource_id, *resource_type;
20863 const char *subject_id, *subject_type, *subject_name;
20866 gchar *subject_response;
20867 entity_t get_subject_entity = NULL;
20868 entity_t subject_entity;
20874 resource_type =
params_value (params,
"optional_resource_type");
20889 "Create Permission",
"new_permission");
20891 ret = ompf (connection, credentials,
20893 &get_subject_entity,
20895 "<get_%ss filter=\"rows=1 name=%s\">" 20909 "Internal error", __FUNCTION__, __LINE__,
20910 "An internal error occurred while getting" 20911 " the subject for a permission. " 20912 "The permission was not created. " 20913 "Diagnostics: Failure to send command" 20914 " to manager daemon.",
20915 "/omp?cmd=get_permissions", response_data);
20919 "Internal error", __FUNCTION__, __LINE__,
20920 "An internal error occurred while getting" 20921 " the subject for a permission. " 20922 "The permission was not created. " 20923 "Diagnostics: Failure to receive response" 20924 " from manager daemon.",
20925 "/omp?cmd=get_permissions", response_data);
20929 "Internal error", __FUNCTION__, __LINE__,
20930 "An internal error occurred while getting" 20931 " the subject for a permission. " 20932 "The permission was not created. " 20933 "Diagnostics: Internal Error.",
20934 "/omp?cmd=get_permissions", response_data);
20937 subject_entity = entity_child (get_subject_entity, subject_type);
20939 if (subject_entity)
20940 subject_id = entity_attribute (subject_entity,
"id");
20942 if (subject_id == NULL)
20945 msg = g_strdup_printf (
"<gsad_msg status_text=\"Subject not found\"" 20946 " operation=\"create_permission\">" 20947 "Could not find a %s with name '%s'." 20950 subject_name ? subject_name :
"");
20951 return next_page (connection, credentials, params, msg,
20955 else if (strcmp (subject_type,
"user") == 0)
20956 subject_id =
params_value (params,
"permission_user_id");
20957 else if (strcmp (subject_type,
"group") == 0)
20958 subject_id =
params_value (params,
"permission_group_id");
20959 else if (strcmp (subject_type,
"role") == 0)
20960 subject_id =
params_value (params,
"permission_role_id");
20967 if (strcmp (name,
"task_proxy") == 0)
20971 ret = ompf (connection, credentials,
20976 "<create_permission>" 20977 "<name>get_tasks</name>" 20978 "<comment>%s</comment>" 20979 "<resource id=\"%s\"/>" 20980 "<subject id=\"%s\"><type>%s</type></subject>" 20981 "</create_permission>" 20982 "<create_permission>" 20983 "<name>modify_task</name>" 20984 "<comment>%s</comment>" 20985 "<resource id=\"%s\"/>" 20986 "<subject id=\"%s\"><type>%s</type></subject>" 20987 "</create_permission>" 20988 "<create_permission>" 20989 "<name>start_task</name>" 20990 "<comment>%s</comment>" 20991 "<resource id=\"%s\"/>" 20992 "<subject id=\"%s\"><type>%s</type></subject>" 20993 "</create_permission>" 20994 "<create_permission>" 20995 "<name>stop_task</name>" 20996 "<comment>%s</comment>" 20997 "<resource id=\"%s\"/>" 20998 "<subject id=\"%s\"><type>%s</type></subject>" 20999 "</create_permission>" 21000 "<create_permission>" 21001 "<name>resume_task</name>" 21002 "<comment>%s</comment>" 21003 "<resource id=\"%s\"/>" 21004 "<subject id=\"%s\"><type>%s</type></subject>" 21005 "</create_permission>" 21007 comment ? comment :
"",
21008 resource_id ? resource_id :
"",
21011 comment ? comment :
"",
21012 resource_id ? resource_id :
"",
21015 comment ? comment :
"",
21016 resource_id ? resource_id :
"",
21019 comment ? comment :
"",
21020 resource_id ? resource_id :
"",
21023 comment ? comment :
"",
21024 resource_id ? resource_id :
"",
21028 if (get_subject_entity)
21029 free_entity (get_subject_entity);
21039 "Internal error", __FUNCTION__, __LINE__,
21040 "An internal error occurred while creating a permission. " 21041 "The permission was not created. " 21042 "Diagnostics: Failure to send command to manager daemon.",
21043 "/omp?cmd=get_permissions", response_data);
21047 "Internal error", __FUNCTION__, __LINE__,
21048 "An internal error occurred while creating a permission. " 21049 "It is unclear whether the permission has been created or not. " 21050 "Diagnostics: Failure to receive response from manager daemon.",
21051 "/omp?cmd=get_permissions", response_data);
21055 "Internal error", __FUNCTION__, __LINE__,
21056 "An internal error occurred while creating a permission. " 21057 "It is unclear whether the permission has been created or not. " 21058 "Diagnostics: Internal Error.",
21059 "/omp?cmd=get_permissions", response_data);
21062 if (entity_attribute (entity,
"id"))
21063 params_add (params,
"permission_id", entity_attribute (entity,
"id"));
21064 html = response_from_entity (connection, credentials, params, entity,
21065 (no_redirect && strcmp (no_redirect,
"0")),
21066 NULL,
"get_permissions",
21067 NULL,
"new_permission",
21068 "Create Permission", response_data);
21074 ret = ompf (connection, credentials,
21078 "<create_permission>" 21080 "<comment>%s</comment>" 21081 "<resource id=\"%s\">" 21084 "<subject id=\"%s\"><type>%s</type></subject>" 21085 "</create_permission>",
21087 comment ? comment :
"",
21088 resource_id ? resource_id :
"",
21089 resource_type ? resource_type :
"",
21093 if (get_subject_entity)
21094 free_entity (get_subject_entity);
21104 "Internal error", __FUNCTION__, __LINE__,
21105 "An internal error occurred while creating a permission. " 21106 "The permission was not created. " 21107 "Diagnostics: Failure to send command to manager daemon.",
21108 "/omp?cmd=get_permissions", response_data);
21112 "Internal error", __FUNCTION__, __LINE__,
21113 "An internal error occurred while creating a permission. " 21114 "It is unclear whether the permission has been created or not. " 21115 "Diagnostics: Failure to receive response from manager daemon.",
21116 "/omp?cmd=get_permissions", response_data);
21120 "Internal error", __FUNCTION__, __LINE__,
21121 "An internal error occurred while creating a permission. " 21122 "It is unclear whether the permission has been created or not. " 21123 "Diagnostics: Internal Error.",
21124 "/omp?cmd=get_permissions", response_data);
21127 if (entity_attribute (entity,
"id"))
21128 params_add (params,
"permission_id", entity_attribute (entity,
"id"));
21129 html = response_from_entity (connection, credentials, params, entity,
21130 (no_redirect && strcmp (no_redirect,
"0")),
21131 NULL,
"get_permissions",
21132 NULL,
"new_permission",
21133 "Create Permission", response_data);
21135 free_entity (entity);
21140 #define CHECK_OMPF_RET \ 21147 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \ 21148 return gsad_message (credentials, \ 21149 "Internal error", __FUNCTION__, __LINE__, \ 21150 "An internal error occurred while creating a permission. " \ 21151 "The permission was not created. " \ 21152 "Diagnostics: Failure to send command to manager daemon.", \ 21153 "/omp?cmd=get_permissions", response_data); \ 21155 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \ 21156 return gsad_message (credentials, \ 21157 "Internal error", __FUNCTION__, __LINE__, \ 21158 "An internal error occurred while creating a permission. " \ 21159 "It is unclear whether the permission has been created or not. " \ 21160 "Diagnostics: Failure to receive response from manager daemon.", \ 21161 "/omp?cmd=get_permissions", response_data); \ 21163 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \ 21164 return gsad_message (credentials, \ 21165 "Internal error", __FUNCTION__, __LINE__, \ 21166 "An internal error occurred while creating a permission. " \ 21167 "It is unclear whether the permission has been created or not. " \ 21168 "Diagnostics: Internal Error.", \ 21169 "/omp?cmd=get_permissions", response_data); \ 21171 if (omp_success (entity)) \ 21174 free_entity (entity); \ 21175 g_free (response); \ 21180 = response_from_entity (connection, credentials, params, entity, \ 21181 (no_redirect && strcmp (no_redirect, "0")), \ 21182 NULL, "get_permissions", \ 21183 NULL, "new_permissions", \ 21184 "Create Permissions", response_data); \ 21185 free_entity (entity); \ 21186 g_free (response); \ 21203 params_t *params,
const char *extra_xml,
21207 const char *resource_id, *restrict_type;
21213 xml = g_string_new (
"<new_permissions>");
21222 switch (omp (connection, credentials, &response, &entity, response_data,
21223 "<get_users filter=\"rows=-1 permission=get_users\"/>"))
21231 "Internal error", __FUNCTION__, __LINE__,
21232 "An internal error occurred getting the user list. " 21233 "No new user was created. " 21234 "Diagnostics: Failure to send command to manager daemon.",
21235 "/omp?cmd=get_users", response_data);
21239 "Internal error", __FUNCTION__, __LINE__,
21240 "An internal error occurred getting the user list. " 21241 "No new user was created. " 21242 "Diagnostics: Failure to receive response from manager daemon.",
21243 "/omp?cmd=get_users", response_data);
21247 "Internal error", __FUNCTION__, __LINE__,
21248 "An internal error occurred getting the user list. " 21249 "No new user was created. " 21250 "Diagnostics: Internal Error.",
21251 "/omp?cmd=get_users", response_data);
21254 g_string_append (xml, response);
21256 free_entity (entity);
21267 switch (omp (connection, credentials, &response, &entity, response_data,
21268 "<get_groups filter=\"rows=-1 permission=get_groups\"/>"))
21276 "Internal error", __FUNCTION__, __LINE__,
21277 "An internal error occurred getting the group list. " 21278 "No new user was created. " 21279 "Diagnostics: Failure to send command to manager daemon.",
21280 "/omp?cmd=get_users", response_data);
21284 "Internal error", __FUNCTION__, __LINE__,
21285 "An internal error occurred getting the group list. " 21286 "No new user was created. " 21287 "Diagnostics: Failure to receive response from manager daemon.",
21288 "/omp?cmd=get_users", response_data);
21292 "Internal error", __FUNCTION__, __LINE__,
21293 "An internal error occurred getting the group list. " 21294 "No new user was created. " 21295 "Diagnostics: Internal Error.",
21296 "/omp?cmd=get_users", response_data);
21299 g_string_append (xml, response);
21301 free_entity (entity);
21312 switch (omp (connection, credentials, &response, &entity, response_data,
21313 "<get_roles filter=\"rows=-1 permission=get_roles\"/>"))
21321 "Internal error", __FUNCTION__, __LINE__,
21322 "An internal error occurred getting the role list. " 21323 "No new user was created. " 21324 "Diagnostics: Failure to send command to manager daemon.",
21325 "/omp?cmd=get_users", response_data);
21329 "Internal error", __FUNCTION__, __LINE__,
21330 "An internal error occurred getting the role list. " 21331 "No new user was created. " 21332 "Diagnostics: Failure to receive response from manager daemon.",
21333 "/omp?cmd=get_users", response_data);
21337 "Internal error", __FUNCTION__, __LINE__,
21338 "An internal error occurred getting the role list. " 21339 "No new user was created. " 21340 "Diagnostics: Internal Error.",
21341 "/omp?cmd=get_users", response_data);
21344 g_string_append (xml, response);
21346 free_entity (entity);
21351 restrict_type =
params_value (params,
"restrict_type");
21352 if (resource_id && restrict_type)
21354 gchar *get_command;
21358 get_command = g_strdup_printf (
"get_%ss", restrict_type);
21361 switch (ompf (connection, credentials, &response, &entity, response_data,
21362 "<%s %s_id=\"%s\" details=\"0\"/>",
21363 get_command, restrict_type, resource_id))
21369 g_free (get_command);
21371 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21373 "Internal error", __FUNCTION__, __LINE__,
21374 "An internal error occurred getting a resource. " 21375 "No new permission was created. " 21376 "Diagnostics: Failure to send command to manager daemon.",
21377 "/omp?cmd=get_users", response_data);
21379 g_free (get_command);
21381 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21383 "Internal error", __FUNCTION__, __LINE__,
21384 "An internal error occurred getting a resource. " 21385 "No new permission was created. " 21386 "Diagnostics: Failure to receive response from manager daemon.",
21387 "/omp?cmd=get_users", response_data);
21389 g_free (get_command);
21391 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21393 "Internal error", __FUNCTION__, __LINE__,
21394 "An internal error occurred getting a resource. " 21395 "No new permission was created. " 21396 "Diagnostics: Internal Error.",
21397 "/omp?cmd=get_users", response_data);
21399 g_string_append (xml, response);
21401 free_entity (entity);
21413 &related_id, &related_param))
21415 const char* related_type;
21416 gchar *get_command;
21420 related_type = related_param->
value;
21422 get_command = g_strdup_printf (
"get_%ss", related_type);
21425 switch (ompf (connection, credentials, &response, &entity, response_data,
21426 "<%s %s_id=\"%s\" details=\"0\"/>",
21427 get_command, related_type, related_id))
21433 g_free (get_command);
21435 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21437 "Internal error", __FUNCTION__, __LINE__,
21438 "An internal error occurred getting a resource. " 21439 "No new permission was created. " 21440 "Diagnostics: Failure to send command to manager daemon.",
21441 "/omp?cmd=get_users", response_data);
21443 g_free (get_command);
21445 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21447 "Internal error", __FUNCTION__, __LINE__,
21448 "An internal error occurred getting a resource. " 21449 "No new permission was created. " 21450 "Diagnostics: Failure to receive response from manager daemon.",
21451 "/omp?cmd=get_users", response_data);
21453 g_free (get_command);
21455 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21457 "Internal error", __FUNCTION__, __LINE__,
21458 "An internal error occurred getting a resource. " 21459 "No new permission was created. " 21460 "Diagnostics: Internal Error.",
21461 "/omp?cmd=get_users", response_data);
21463 g_string_append (xml, response);
21465 free_entity (entity);
21470 g_string_append (xml, extra_xml);
21472 g_string_append (xml,
"</new_permissions>");
21474 return xsl_transform_omp (connection, credentials, params,
21475 g_string_free (xml, FALSE), response_data);
21493 return new_permissions (connection, credentials, params, NULL, response_data);
21512 gchar *html, *response, *summary_response, *next_url;
21514 const char *no_redirect, *permission, *comment, *resource_id, *resource_type;
21515 const char *subject_id, *subject_type, *subject_name;
21516 int include_related;
21520 gchar *subject_response;
21521 entity_t get_subject_entity = NULL;
21522 entity_t subject_entity;
21528 resource_type =
params_value (params,
"resource_type");
21532 include_related = atoi (
params_value (params,
"include_related"));
21546 ret = ompf (connection, credentials,
21548 &get_subject_entity,
21550 "<get_%ss filter=\"rows=1 name=%s\">" 21564 "Internal error", __FUNCTION__, __LINE__,
21565 "An internal error occurred while getting" 21566 " the subject for a permission. " 21567 "The permission was not created. " 21568 "Diagnostics: Failure to send command" 21569 " to manager daemon.",
21570 "/omp?cmd=get_permissions", response_data);
21574 "Internal error", __FUNCTION__, __LINE__,
21575 "An internal error occurred while getting" 21576 " the subject for a permission. " 21577 "The permission was not created. " 21578 "Diagnostics: Failure to receive response" 21579 " from manager daemon.",
21580 "/omp?cmd=get_permissions", response_data);
21584 "Internal error", __FUNCTION__, __LINE__,
21585 "An internal error occurred while getting" 21586 " the subject for a permission. " 21587 "The permission was not created. " 21588 "Diagnostics: Internal Error.",
21589 "/omp?cmd=get_permissions", response_data);
21592 subject_entity = entity_child (get_subject_entity, subject_type);
21594 if (subject_entity)
21595 subject_id = entity_attribute (subject_entity,
"id");
21597 if (subject_id == NULL)
21600 msg = g_strdup_printf (
"<gsad_msg status_text=\"Subject not found\"" 21601 " operation=\"create_permission\">" 21602 "Could not find a %s with name '%s'." 21605 subject_name ? subject_name :
"");
21606 return next_page (connection, credentials, params, msg,
21610 else if (strcmp (subject_type,
"user") == 0)
21611 subject_id =
params_value (params,
"permission_user_id");
21612 else if (strcmp (subject_type,
"group") == 0)
21613 subject_id =
params_value (params,
"permission_group_id");
21614 else if (strcmp (subject_type,
"role") == 0)
21615 subject_id =
params_value (params,
"permission_role_id");
21625 if (include_related != 2)
21627 if (strcmp (permission,
"read") == 0
21628 || strcmp (permission,
"proxy") == 0)
21632 ret = ompf (connection, credentials,
21636 "<create_permission>" 21637 "<name>get_%ss</name>" 21638 "<comment>%s</comment>" 21639 "<resource id=\"%s\">" 21641 "<subject id=\"%s\"><type>%s</type></subject>" 21642 "</create_permission>",
21644 comment ? comment :
"",
21652 if ((strcmp (permission,
"proxy") == 0)
21653 && strcmp (resource_type,
"result")
21654 && strcmp (resource_type,
"report"))
21658 ret = ompf (connection, credentials,
21662 "<create_permission>" 21663 "<name>modify_%s</name>" 21664 "<comment>%s</comment>" 21665 "<resource id=\"%s\">" 21667 "<subject id=\"%s\"><type>%s</type></subject>" 21668 "</create_permission>",
21670 comment ? comment :
"",
21677 if (strcmp (resource_type,
"task") == 0)
21681 ret = ompf (connection, credentials,
21685 "<create_permission>" 21686 "<name>start_%s</name>" 21687 "<comment>%s</comment>" 21688 "<resource id=\"%s\">" 21690 "<subject id=\"%s\"><type>%s</type></subject>" 21691 "</create_permission>",
21693 comment ? comment :
"",
21702 ret = ompf (connection, credentials,
21706 "<create_permission>" 21707 "<name>stop_%s</name>" 21708 "<comment>%s</comment>" 21709 "<resource id=\"%s\">" 21711 "<subject id=\"%s\"><type>%s</type></subject>" 21712 "</create_permission>",
21714 comment ? comment :
"",
21723 ret = ompf (connection, credentials,
21727 "<create_permission>" 21728 "<name>resume_%s</name>" 21729 "<comment>%s</comment>" 21730 "<resource id=\"%s\">" 21732 "<subject id=\"%s\"><type>%s</type></subject>" 21733 "</create_permission>",
21735 comment ? comment :
"",
21743 if (strcmp (resource_type,
"alert") == 0)
21747 ret = ompf (connection, credentials,
21751 "<create_permission>" 21752 "<name>test_%s</name>" 21753 "<comment>%s</comment>" 21754 "<resource id=\"%s\">" 21756 "<subject id=\"%s\"><type>%s</type></subject>" 21757 "</create_permission>",
21759 comment ? comment :
"",
21767 if (strcmp (resource_type,
"agent") == 0
21768 || strcmp (resource_type,
"report_format") == 0
21769 || strcmp (resource_type,
"scanner") == 0)
21773 ret = ompf (connection, credentials,
21777 "<create_permission>" 21778 "<name>verify_%s</name>" 21779 "<comment>%s</comment>" 21780 "<resource id=\"%s\">" 21782 "<subject id=\"%s\"><type>%s</type></subject>" 21783 "</create_permission>",
21785 comment ? comment :
"",
21796 if (include_related)
21809 char *related_id = name;
21812 if (strcmp (permission,
"read") == 0
21813 || strcmp (permission,
"proxy") == 0)
21817 ret = ompf (connection, credentials,
21821 "<create_permission>" 21822 "<name>get_%ss</name>" 21823 "<comment>%s</comment>" 21824 "<resource id=\"%s\">" 21826 "<subject id=\"%s\"><type>%s</type></subject>" 21827 "</create_permission>",
21829 comment ? comment :
"",
21837 if ((strcmp (permission,
"proxy") == 0)
21838 && strcmp (related_type,
"result")
21839 && strcmp (related_type,
"report"))
21843 ret = ompf (connection, credentials,
21847 "<create_permission>" 21848 "<name>modify_%s</name>" 21849 "<comment>%s</comment>" 21850 "<resource id=\"%s\">" 21852 "<subject id=\"%s\"><type>%s</type></subject>" 21853 "</create_permission>",
21855 comment ? comment :
"",
21862 if (strcmp (related_type,
"task") == 0)
21866 ret = ompf (connection, credentials,
21870 "<create_permission>" 21871 "<name>start_%s</name>" 21872 "<comment>%s</comment>" 21873 "<resource id=\"%s\">" 21875 "<subject id=\"%s\"><type>%s</type></subject>" 21876 "</create_permission>",
21878 comment ? comment :
"",
21887 ret = ompf (connection, credentials,
21891 "<create_permission>" 21892 "<name>stop_%s</name>" 21893 "<comment>%s</comment>" 21894 "<resource id=\"%s\">" 21896 "<subject id=\"%s\"><type>%s</type></subject>" 21897 "</create_permission>",
21899 comment ? comment :
"",
21908 ret = ompf (connection, credentials,
21912 "<create_permission>" 21913 "<name>resume_%s</name>" 21914 "<comment>%s</comment>" 21915 "<resource id=\"%s\">" 21917 "<subject id=\"%s\"><type>%s</type></subject>" 21918 "</create_permission>",
21920 comment ? comment :
"",
21928 if (strcmp (related_type,
"alert") == 0)
21932 ret = ompf (connection, credentials,
21936 "<create_permission>" 21937 "<name>test_%s</name>" 21938 "<comment>%s</comment>" 21939 "<resource id=\"%s\">" 21941 "<subject id=\"%s\"><type>%s</type></subject>" 21942 "</create_permission>",
21944 comment ? comment :
"",
21952 if (strcmp (related_type,
"agent") == 0
21953 || strcmp (related_type,
"report_format") == 0
21954 || strcmp (related_type,
"scanner") == 0)
21958 ret = ompf (connection, credentials,
21962 "<create_permission>" 21963 "<name>verify_%s</name>" 21964 "<comment>%s</comment>" 21965 "<resource id=\"%s\">" 21967 "<subject id=\"%s\"><type>%s</type></subject>" 21968 "</create_permission>",
21970 comment ? comment :
"",
21982 if (get_subject_entity)
21983 free_entity (get_subject_entity);
21985 summary_response = g_strdup_printf(
"Successfully created %i permissions",
21988 next_url = next_page_url (credentials, params,
21989 NULL,
"new_permissions",
21990 "Create Permissions",
21991 G_STRINGIFY (MHD_HTTP_CREATED),
21996 html = action_result_page (connection, credentials, params, response_data,
21997 "Create Permissions",
21998 G_STRINGIFY (MHD_HTTP_CREATED),
22007 response_data->
redirect = next_url;
22012 #undef CHECK_OMPF_RET 22027 params_t *params,
const char *extra_xml,
22033 extra = g_string_new (
"");
22042 switch (omp (connection, credentials, &response, &entity, response_data,
22043 "<get_users filter=\"rows=-1\"/>"))
22051 "Internal error", __FUNCTION__, __LINE__,
22052 "An internal error occurred getting the user list. " 22053 "No new user was created. " 22054 "Diagnostics: Failure to send command to manager daemon.",
22055 "/omp?cmd=get_users", response_data);
22059 "Internal error", __FUNCTION__, __LINE__,
22060 "An internal error occurred getting the user list. " 22061 "No new user was created. " 22062 "Diagnostics: Failure to receive response from manager daemon.",
22063 "/omp?cmd=get_users", response_data);
22067 "Internal error", __FUNCTION__, __LINE__,
22068 "An internal error occurred getting the user list. " 22069 "No new user was created. " 22070 "Diagnostics: Internal Error.",
22071 "/omp?cmd=get_users", response_data);
22074 g_string_append (extra, response);
22076 free_entity (entity);
22087 switch (omp (connection, credentials, &response, &entity, response_data,
22088 "<get_groups filter=\"rows=-1\"/>"))
22096 "Internal error", __FUNCTION__, __LINE__,
22097 "An internal error occurred getting the group list. " 22098 "No new user was created. " 22099 "Diagnostics: Failure to send command to manager daemon.",
22100 "/omp?cmd=get_users", response_data);
22104 "Internal error", __FUNCTION__, __LINE__,
22105 "An internal error occurred getting the group list. " 22106 "No new user was created. " 22107 "Diagnostics: Failure to receive response from manager daemon.",
22108 "/omp?cmd=get_users", response_data);
22112 "Internal error", __FUNCTION__, __LINE__,
22113 "An internal error occurred getting the group list. " 22114 "No new user was created. " 22115 "Diagnostics: Internal Error.",
22116 "/omp?cmd=get_users", response_data);
22119 g_string_append (extra, response);
22121 free_entity (entity);
22132 switch (omp (connection, credentials, &response, &entity, response_data,
22133 "<get_roles filter=\"rows=-1\"/>"))
22141 "Internal error", __FUNCTION__, __LINE__,
22142 "An internal error occurred getting the role list. " 22143 "No new user was created. " 22144 "Diagnostics: Failure to send command to manager daemon.",
22145 "/omp?cmd=get_users", response_data);
22149 "Internal error", __FUNCTION__, __LINE__,
22150 "An internal error occurred getting the role list. " 22151 "No new user was created. " 22152 "Diagnostics: Failure to receive response from manager daemon.",
22153 "/omp?cmd=get_users", response_data);
22157 "Internal error", __FUNCTION__, __LINE__,
22158 "An internal error occurred getting the role list. " 22159 "No new user was created. " 22160 "Diagnostics: Internal Error.",
22161 "/omp?cmd=get_users", response_data);
22164 g_string_append (extra, response);
22166 free_entity (entity);
22171 g_string_append (extra, extra_xml);
22172 html =
edit_resource (connection,
"permission", credentials, params, NULL,
22173 extra->str, response_data);
22174 g_string_free (extra, TRUE);
22193 return edit_permission (connection, credentials, params, NULL, response_data);
22213 char **content_disposition, gsize *content_length,
22216 return export_resource (connection,
"permission", credentials, params,
22239 char **content_disposition, gsize *content_length,
22242 return export_many (connection,
"permission", credentials, params,
22262 gchar *html, *response;
22263 const char *no_redirect;
22264 const char *permission_id, *name, *comment, *resource_id, *resource_type;
22265 const char *subject_id, *subject_type;
22270 permission_id =
params_value (params,
"permission_id");
22275 resource_type =
params_value (params,
"optional_resource_type");
22286 if (strcmp (subject_type,
"user") == 0)
22288 else if (strcmp (subject_type,
"group") == 0)
22290 else if (strcmp (subject_type,
"role") == 0)
22300 ret = ompf (connection, credentials,
22304 "<modify_permission permission_id=\"%s\">" 22306 "<comment>%s</comment>" 22307 "<subject id=\"%s\">" 22310 "<resource id=\"%s\">" 22313 "</modify_permission>",
22319 (resource_id && strlen (resource_id)) ? resource_id :
"0",
22320 resource_type ? resource_type :
"");
22329 "Internal error", __FUNCTION__, __LINE__,
22330 "An internal error occurred while modifying a permission. " 22331 "The permission was not modified. " 22332 "Diagnostics: Failure to send command to manager daemon.",
22333 "/omp?cmd=get_permissions", response_data);
22337 "Internal error", __FUNCTION__, __LINE__,
22338 "An internal error occurred while modifying a permission. " 22339 "It is unclear whether the permission has been modified or not. " 22340 "Diagnostics: Failure to receive response from manager daemon.",
22341 "/omp?cmd=get_permissions", response_data);
22345 "Internal error", __FUNCTION__, __LINE__,
22346 "An internal error occurred while modifying a permission. " 22347 "It is unclear whether the permission has been modified or not. " 22348 "Diagnostics: Internal Error.",
22349 "/omp?cmd=get_permissions", response_data);
22352 html = response_from_entity (connection, credentials, params, entity,
22353 (no_redirect && strcmp (no_redirect,
"0")),
22354 NULL,
"get_permissions",
22355 NULL,
"edit_permission",
22356 "Save Permission", response_data);
22357 free_entity (entity);
22377 new_port_list (openvas_connection_t *connection,
credentials_t *credentials,
22378 params_t *params,
const char *extra_xml,
22382 xml = g_string_new (
"<new_port_list>");
22384 g_string_append (xml, extra_xml);
22385 g_string_append (xml,
"</new_port_list>");
22386 return xsl_transform_omp (connection, credentials, params,
22387 g_string_free (xml, FALSE), response_data);
22402 upload_port_list (openvas_connection_t *connection,
credentials_t *credentials,
22403 params_t *params,
const char *extra_xml,
22408 xml = g_string_new (
"<upload_port_list>");
22410 g_string_append (xml, extra_xml);
22411 g_string_append (xml,
"</upload_port_list>");
22413 return xsl_transform_omp (connection, credentials, params,
22414 g_string_free (xml, FALSE), response_data);
22432 return upload_port_list (connection, credentials, params, NULL,
22451 gchar *html, *response;
22452 const char *no_redirect, *name, *comment, *port_range, *from_file;
22468 switch (ompf (connection, credentials,
22472 "<create_port_list>" 22474 "<port_range>%s</port_range>" 22475 "<comment>%s</comment>" 22476 "</create_port_list>",
22478 strcmp (from_file,
"0")
22481 comment ? comment :
""))
22489 "Internal error", __FUNCTION__, __LINE__,
22490 "An internal error occurred while creating a new port list. " 22491 "No new port list was created. " 22492 "Diagnostics: Failure to send command to manager daemon.",
22493 "/omp?cmd=get_port_lists", response_data);
22497 "Internal error", __FUNCTION__, __LINE__,
22498 "An internal error occurred while creating a new port list. " 22499 "It is unclear whether the port list has been created or not. " 22500 "Diagnostics: Failure to receive response from manager daemon.",
22501 "/omp?cmd=get_port_lists", response_data);
22505 "Internal error", __FUNCTION__, __LINE__,
22506 "An internal error occurred while creating a new port list. " 22507 "It is unclear whether the port list has been created or not. " 22508 "Diagnostics: Internal Error.",
22509 "/omp?cmd=get_port_lists", response_data);
22512 if (entity_attribute (entity,
"id"))
22513 params_add (params,
"port_list_id", entity_attribute (entity,
"id"));
22514 html = response_from_entity (connection, credentials, params, entity,
22515 (no_redirect && strcmp (no_redirect,
"0")),
22516 NULL,
"get_port_lists",
22517 NULL,
"new_port_list",
22518 "Create Port List", response_data);
22519 free_entity (entity);
22536 new_port_range (openvas_connection_t *connection,
credentials_t *credentials,
22537 params_t *params,
const char *extra_xml,
22541 xml = g_string_new (
"<new_port_range>");
22543 g_string_append (xml, extra_xml);
22544 g_string_append (xml,
"</new_port_range>");
22545 return xsl_transform_omp (connection, credentials, params,
22546 g_string_free (xml, FALSE), response_data);
22564 return new_port_range (connection, credentials, params, NULL, response_data);
22583 gchar *html, *response;
22584 const char *no_redirect, *port_list_id, *start, *end, *type;
22602 ret = ompf (connection, credentials,
22606 "<create_port_range>" 22607 "<port_list id=\"%s\"/>" 22608 "<start>%s</start>" 22611 "</create_port_range>",
22625 "Internal error", __FUNCTION__, __LINE__,
22626 "An internal error occurred while creating a Port Range. " 22627 "The Port Range was not created. " 22628 "Diagnostics: Failure to send command to manager daemon.",
22629 "/omp?cmd=get_port_lists", response_data);
22633 "Internal error", __FUNCTION__, __LINE__,
22634 "An internal error occurred while creating a Port Range. " 22635 "It is unclear whether the Port Range has been created or not. " 22636 "Diagnostics: Failure to receive response from manager daemon.",
22637 "/omp?cmd=get_port_lists", response_data);
22641 "Internal error", __FUNCTION__, __LINE__,
22642 "An internal error occurred while creating a Port Range. " 22643 "It is unclear whether the Port Range has been created or not. " 22644 "Diagnostics: Internal Error.",
22645 "/omp?cmd=get_port_lists", response_data);
22648 html = response_from_entity (connection, credentials, params, entity,
22649 (no_redirect && strcmp (no_redirect,
"0")),
22650 NULL,
"edit_port_list",
22651 NULL,
"edit_port_list",
22652 "Create Port Range", response_data);
22653 free_entity (entity);
22670 get_port_list (openvas_connection_t *connection,
22674 return get_one (connection,
"port_list", credentials, params, extra_xml,
22675 "targets=\"1\" details=\"1\"", response_data);
22693 return get_port_list (connection, credentials, params, NULL, response_data);
22708 get_port_lists (openvas_connection_t *connection,
22712 return get_many (connection,
"port_list", credentials, params, extra_xml,
22713 NULL, response_data);
22731 return get_port_lists (connection, credentials, params, NULL, response_data);
22748 return new_port_list (connection, credentials, params, NULL, response_data);
22763 edit_port_list (openvas_connection_t *connection,
credentials_t * credentials,
22764 params_t *params,
const char *extra_xml,
22767 return edit_resource (connection,
"port_list", credentials, params, NULL,
22768 extra_xml, response_data);
22786 return edit_port_list (connection, credentials, params, NULL, response_data);
22805 gchar *html, *response;
22806 const char *no_redirect, *port_list_id, *name, *comment;
22822 ret = ompf (connection, credentials,
22826 "<modify_port_list port_list_id=\"%s\">" 22828 "<comment>%s</comment>" 22829 "</modify_port_list>",
22842 "Internal error", __FUNCTION__, __LINE__,
22843 "An internal error occurred while saving a Port List. " 22844 "The Port List was not saved. " 22845 "Diagnostics: Failure to send command to manager daemon.",
22846 "/omp?cmd=get_port_lists", response_data);
22850 "Internal error", __FUNCTION__, __LINE__,
22851 "An internal error occurred while saving a Port List. " 22852 "It is unclear whether the Port List has been saved or not. " 22853 "Diagnostics: Failure to receive response from manager daemon.",
22854 "/omp?cmd=get_port_lists", response_data);
22858 "Internal error", __FUNCTION__, __LINE__,
22859 "An internal error occurred while saving a Port List. " 22860 "It is unclear whether the Port List has been saved or not. " 22861 "Diagnostics: Internal Error.",
22862 "/omp?cmd=get_port_lists", response_data);
22865 html = response_from_entity (connection, credentials, params, entity,
22866 (no_redirect && strcmp (no_redirect,
"0")),
22867 NULL,
"get_port_lists",
22868 NULL,
"edit_port_list",
22869 "Save Port List", response_data);
22870 free_entity (entity);
22890 return delete_resource (connection,
"port_list", credentials, params, 0,
22891 "get_port_lists", response_data);
22909 return delete_resource (connection,
"port_list", credentials, params, 1,
22910 "get_trash", response_data);
22928 return delete_resource (connection,
"port_range", credentials, params, 1,
22929 "edit_port_list", response_data);
22947 const char *no_redirect;
22948 gchar *command, *html, *response;
22958 command = g_strdup_printf (
"<create_port_list>" 22960 "</create_port_list>",
22962 ret = omp (connection, credentials, &response, &entity, response_data,
22973 "Internal error", __FUNCTION__, __LINE__,
22974 "An internal error occurred while importing a port_list. " 22975 "The schedule remains the same. " 22976 "Diagnostics: Failure to send command to manager daemon.",
22977 "/omp?cmd=get_port_lists",
22982 "Internal error", __FUNCTION__, __LINE__,
22983 "An internal error occurred while importing a port_list. " 22984 "It is unclear whether the schedule has been saved or not. " 22985 "Diagnostics: Failure to receive response from manager daemon.",
22986 "/omp?cmd=get_port_lists",
22991 "Internal error", __FUNCTION__, __LINE__,
22992 "An internal error occurred while importing a port_list. " 22993 "It is unclear whether the schedule has been saved or not. " 22994 "Diagnostics: Internal Error.",
22995 "/omp?cmd=get_port_lists",
23001 html = response_from_entity (connection, credentials, params, entity,
23002 (no_redirect && strcmp (no_redirect,
"0")),
23003 NULL,
"get_port_lists",
23004 NULL,
"new_port_list",
23005 "Import Port List", response_data);
23006 free_entity (entity);
23026 new_role (openvas_connection_t *connection,
credentials_t *credentials,
23027 params_t *params,
const char *extra_xml,
23031 xml = g_string_new (
"<new_role>");
23033 g_string_append (xml, extra_xml);
23034 g_string_append (xml,
"</new_role>");
23035 return xsl_transform_omp (connection, credentials, params,
23036 g_string_free (xml, FALSE), response_data);
23053 return new_role (connection, credentials, params, NULL, response_data);
23072 "get_trash", response_data);
23090 "get_roles", response_data);
23109 const char *no_redirect, *name, *comment, *
users;
23123 switch (ompf (connection, credentials,
23129 "<comment>%s</comment>" 23130 "<users>%s</users>" 23142 "Internal error", __FUNCTION__, __LINE__,
23143 "An internal error occurred while creating a new role. " 23144 "No new role was created. " 23145 "Diagnostics: Failure to send command to manager daemon.",
23146 "/omp?cmd=get_targets", response_data);
23150 "Internal error", __FUNCTION__, __LINE__,
23151 "An internal error occurred while creating a new role. " 23152 "It is unclear whether the role has been created or not. " 23153 "Diagnostics: Failure to receive response from manager daemon.",
23154 "/omp?cmd=get_roles", response_data);
23158 "Internal error", __FUNCTION__, __LINE__,
23159 "An internal error occurred while creating a new role. " 23160 "It is unclear whether the role has been created or not. " 23161 "Diagnostics: Internal Error.",
23162 "/omp?cmd=get_roles", response_data);
23165 if (entity_attribute (entity,
"id"))
23166 params_add (params,
"role_id", entity_attribute (entity,
"id"));
23167 ret = response_from_entity (connection, credentials, params, entity,
23168 (no_redirect && strcmp (no_redirect,
"0")),
23171 "Create Role", response_data);
23172 free_entity (entity);
23189 edit_role (openvas_connection_t *connection,
23196 extra = g_string_new (
"");
23205 switch (ompf (connection, credentials, &response, &entity, response_data,
23207 " filter=\"rows=-1 subject_type=role and subject_uuid=%s\"/>",
23216 "Internal error", __FUNCTION__, __LINE__,
23217 "An internal error occurred getting the permission list. " 23218 "Diagnostics: Failure to send command to manager daemon.",
23219 "/omp?cmd=get_roles", response_data);
23223 "Internal error", __FUNCTION__, __LINE__,
23224 "An internal error occurred getting the permission list. " 23225 "Diagnostics: Failure to receive response from manager daemon.",
23226 "/omp?cmd=get_roles", response_data);
23230 "Internal error", __FUNCTION__, __LINE__,
23231 "An internal error occurred getting the permission list. " 23232 "Diagnostics: Internal Error.",
23233 "/omp?cmd=get_roles", response_data);
23236 g_string_append (extra, response);
23238 free_entity (entity);
23249 switch (ompf (connection, credentials, &response, &entity, response_data,
23251 " filter=\"rows=-1 owner=%s\"/>",
23260 "Internal error", __FUNCTION__, __LINE__,
23261 "An internal error occurred getting the group list. " 23262 "Diagnostics: Failure to send command to manager daemon.",
23263 "/omp?cmd=get_roles", response_data);
23267 "Internal error", __FUNCTION__, __LINE__,
23268 "An internal error occurred getting the group list. " 23269 "Diagnostics: Failure to receive response from manager daemon.",
23270 "/omp?cmd=get_roles", response_data);
23274 "Internal error", __FUNCTION__, __LINE__,
23275 "An internal error occurred getting the group list. " 23276 "Diagnostics: Internal Error.",
23277 "/omp?cmd=get_roles", response_data);
23280 g_string_append (extra, response);
23282 free_entity (entity);
23287 g_string_append (extra, extra_xml);
23288 html =
edit_resource (connection,
"role", credentials, params, NULL,
23289 extra->str, response_data);
23290 g_string_free (extra, TRUE);
23309 return edit_role (connection, credentials, params, NULL, response_data);
23324 get_role (openvas_connection_t *connection,
credentials_t * credentials,
23325 params_t *params,
const char *extra_xml,
23328 return get_one (connection,
"role", credentials, params, extra_xml, NULL,
23346 return get_role (connection, credentials, params, NULL, response_data);
23361 get_roles (openvas_connection_t *connection,
credentials_t * credentials,
23362 params_t *params,
const char *extra_xml,
23365 return get_many (connection,
"role", credentials, params, extra_xml, NULL,
23383 return get_roles (connection, credentials, params, NULL, response_data);
23402 char **content_disposition, gsize *content_length,
23406 content_disposition, content_length, response_data);
23426 char **content_disposition, gsize *content_length,
23429 return export_many (connection,
"role", credentials, params,
content_type,
23430 content_disposition, content_length, response_data);
23448 gchar *html, *response;
23449 const char *no_redirect, *role_id, *name, *comment, *
users;
23467 ret = ompf (connection, credentials,
23471 "<modify_role role_id=\"%s\">" 23473 "<comment>%s</comment>" 23474 "<users>%s</users>" 23489 "Internal error", __FUNCTION__, __LINE__,
23490 "An internal error occurred while saving a role. " 23491 "The role was not saved. " 23492 "Diagnostics: Failure to send command to manager daemon.",
23493 "/omp?cmd=get_roles", response_data);
23497 "Internal error", __FUNCTION__, __LINE__,
23498 "An internal error occurred while saving a role. " 23499 "It is unclear whether the role has been saved or not. " 23500 "Diagnostics: Failure to receive response from manager daemon.",
23501 "/omp?cmd=get_roles", response_data);
23505 "Internal error", __FUNCTION__, __LINE__,
23506 "An internal error occurred while saving a role. " 23507 "It is unclear whether the role has been saved or not. " 23508 "Diagnostics: Internal Error.",
23509 "/omp?cmd=get_roles", response_data);
23512 html = response_from_entity (connection, credentials, params, entity,
23513 (no_redirect && strcmp (no_redirect,
"0")),
23516 "Save Role", response_data);
23517 free_entity (entity);
23544 gchar current_timestamp[30];
23546 if (openvas_connection_sendf (connection,
23554 "Internal error", __FUNCTION__, __LINE__,
23555 "An internal error occurred while getting the feed list. " 23556 "The current list of feeds is not available. " 23557 "Diagnostics: Failure to send command to manager daemon.",
23558 "/omp?cmd=get_tasks", response_data);
23561 if (read_entity_and_text_c (connection, &entity, &text))
23565 "Internal error", __FUNCTION__, __LINE__,
23566 "An internal error occurred while getting the feed. " 23567 "The current list of feeds is not available. " 23568 "Diagnostics: Failure to receive response from manager daemon.",
23569 "/omp?cmd=get_tasks", response_data);
23573 tm = gmtime (&now);
23575 || (strftime (current_timestamp,
23577 "%Y-%m-%dT%H:%M:%S",
23581 current_timestamp[0] =
'\0';
23584 response = g_strdup_printf (
"<get_feeds>" 23586 "<current_time_utc>%s</current_time_utc>" 23589 current_timestamp);
23593 return xsl_transform_omp (connection, credentials, params, response,
23611 sync_feed (openvas_connection_t *connection,
credentials_t * credentials,
23612 params_t *params,
const char *sync_cmd,
const char *action,
23613 const char *feed_name,
23616 const char *no_redirect;
23623 if (openvas_connection_sendf (connection,
23630 msg = g_strdup_printf
23631 (
"An internal error occurred while synchronizing with %s. " 23632 "Feed synchronization is currently not available. " 23633 "Diagnostics: Failure to send command to manager daemon.",
23636 "Internal error", __FUNCTION__, __LINE__,
23637 msg,
"/omp?cmd=get_tasks", response_data);
23642 if (read_entity_and_text_c (connection, &entity, &text))
23646 msg = g_strdup_printf
23647 (
"An internal error occurred while synchronizing with %s. " 23648 "Feed synchronization is currently not available. " 23649 "Diagnostics: Failure to receive response from manager daemon.",
23652 "Internal error", __FUNCTION__, __LINE__,
23653 msg,
"/omp?cmd=get_tasks", response_data);
23658 html = response_from_entity (connection, credentials, params, entity,
23659 (no_redirect && strcmp (no_redirect,
"0")),
23662 action, response_data);
23681 return sync_feed (connection, credentials, params,
23682 "sync_feed",
"Synchronize Feed",
"the NVT feed",
23700 return sync_feed (connection, credentials, params,
23701 "sync_scap",
"Synchronize Feed",
"the SCAP feed",
23719 return sync_feed (connection, credentials, params,
23720 "sync_cert",
"Synchronize CERT Feed",
"the CERT feed",
23739 get_filter (openvas_connection_t *connection,
credentials_t * credentials,
23740 params_t *params,
const char *extra_xml,
23743 return get_one (connection,
"filter", credentials, params, extra_xml,
23744 "alerts=\"1\"", response_data);
23761 return get_filter (connection, credentials, params, NULL, response_data);
23776 get_filters (openvas_connection_t *connection,
credentials_t * credentials,
23777 params_t *params,
const char *extra_xml,
23780 return get_many (connection,
"filter", credentials, params, extra_xml, NULL,
23798 return get_filters (connection, credentials, params, NULL, response_data);
23813 new_filter (openvas_connection_t *connection,
credentials_t *credentials,
23814 params_t *params,
const char *extra_xml,
23818 xml = g_string_new (
"<new_filter>");
23820 g_string_append (xml, extra_xml);
23821 g_string_append (xml,
"</new_filter>");
23822 return xsl_transform_omp (connection, credentials, params,
23823 g_string_free (xml, FALSE), response_data);
23840 gchar *html, *response;
23841 const char *no_redirect, *name, *comment, *term, *type;
23848 type =
params_value (params,
"optional_resource_type");
23855 switch (ompf (connection, credentials,
23861 "<comment>%s</comment>" 23864 "</create_filter>",
23876 "Internal error", __FUNCTION__, __LINE__,
23877 "An internal error occurred while creating a new alert. " 23878 "No new alert was created. " 23879 "Diagnostics: Failure to send command to manager daemon.",
23880 "/omp?cmd=get_alerts", response_data);
23884 "Internal error", __FUNCTION__, __LINE__,
23885 "An internal error occurred while creating a new alert. " 23886 "It is unclear whether the alert has been created or not. " 23887 "Diagnostics: Failure to receive response from manager daemon.",
23888 "/omp?cmd=get_alerts", response_data);
23892 "Internal error", __FUNCTION__, __LINE__,
23893 "An internal error occurred while creating a new alert. " 23894 "It is unclear whether the alert has been created or not. " 23895 "Diagnostics: Internal Error.",
23896 "/omp?cmd=get_alerts", response_data);
23899 if (omp_success (entity))
23901 const char *filter_id;
23903 filter_id = entity_attribute (entity,
"id");
23904 if (filter_id && strlen (filter_id))
23913 if (entity_attribute (entity,
"id"))
23914 params_add (params,
"filter_id", entity_attribute (entity,
"id"));
23915 html = response_from_entity (connection, credentials, params, entity,
23916 (no_redirect && strcmp (no_redirect,
"0")),
23917 NULL,
"get_filters",
23918 NULL,
"new_filter",
23919 "Create Filter", response_data);
23920 free_entity (entity);
23940 return delete_resource (connection,
"filter", credentials, params, 1,
23941 "get_trash", response_data);
23964 if (
id && id->
value && filt_id && filt_id->
value 23965 && (strcmp (id->
value, filt_id->
value) == 0))
23967 filt_id->
value = NULL;
23970 if (
id && id->
value)
23976 g_tree_foreach (credentials->
last_filt_ids, (GTraverseFunc)find_by_value,
23978 if (find.
keys != NULL)
23980 list = g_list_first (find.
keys);
23982 while (list != NULL)
23984 g_debug (
"%s removing filter from last filter ids for %s\n",
23985 __FUNCTION__, (
char *)list->data);
23987 list = g_list_next (find.
keys);
23994 return delete_resource (connection,
"filter", credentials, params, 0,
23995 "get_filters", response_data);
24011 params_t *params,
const char *extra_xml,
24014 return edit_resource (connection,
"filter", credentials, params, NULL,
24015 extra_xml, response_data);
24032 return edit_filter (connection, credentials, params, NULL, response_data);
24079 return export_many (connection,
"filter", credentials, params,
content_type,
24080 content_disposition, content_length, response_data);
24097 return new_filter (connection, credentials, params, NULL, response_data);
24115 gchar *html, *response;
24116 const char *no_redirect, *filter_id, *name, *comment, *term, *type;
24123 type =
params_value (params,
"optional_resource_type");
24136 ret = openvas_connection_sendf_xml (connection,
24137 "<modify_filter filter_id=\"%s\">" 24139 "<comment>%s</comment>" 24142 "</modify_filter>",
24153 "Internal error", __FUNCTION__, __LINE__,
24154 "An internal error occurred while modifying a filter. " 24155 "The filter was not modified. " 24156 "Diagnostics: Failure to send command to manager daemon.",
24157 "/omp?cmd=get_filters", response_data);
24161 if (read_entity_and_text_c (connection, &entity, &response))
24165 "Internal error", __FUNCTION__, __LINE__,
24166 "An internal error occurred while modifying a filter. " 24167 "It is unclear whether the filter has been modified or not. " 24168 "Diagnostics: Failure to receive response from manager daemon.",
24169 "/omp?cmd=get_filters", response_data);
24176 html = response_from_entity (connection, credentials, params, entity,
24177 (no_redirect && strcmp (no_redirect,
"0")),
24178 NULL,
"get_filters",
24179 NULL,
"edit_filter",
24180 "Save Filter", response_data);
24182 free_entity (entity);
24203 params_t *params,
const char *extra_xml,
24206 return edit_resource (connection,
"schedule", credentials, params,
24207 "tasks=\"1\"", extra_xml, response_data);
24225 return edit_schedule (connection, credentials, params, NULL, response_data);
24245 char **content_disposition, gsize *content_length,
24270 char **content_disposition, gsize *content_length,
24273 return export_many (connection,
"schedule", credentials, params,
content_type,
24274 content_disposition, content_length, response_data);
24294 const char *no_redirect, *schedule_id, *name, *comment;
24295 const char *hour, *minute, *day_of_month, *month, *year, *timezone;
24296 const char *period, *period_unit, *duration, *duration_unit;
24307 duration_unit =
params_value (params,
"duration_unit");
24330 switch (ompf (connection, credentials,
24334 "<modify_schedule schedule_id=\"%s\">" 24336 "<comment>%s</comment>" 24339 "<minute>%s</minute>" 24340 "<day_of_month>%s</day_of_month>" 24341 "<month>%s</month>" 24344 "<timezone>%s</timezone>" 24353 "</modify_schedule>",
24356 comment ? comment :
"",
24363 (strcmp (period_unit,
"")
24367 (strcmp (duration_unit,
"")
24378 "Internal error", __FUNCTION__, __LINE__,
24379 "An internal error occurred while saving a schedule. " 24380 "The schedule remains the same. " 24381 "Diagnostics: Failure to send command to manager daemon.",
24382 "/omp?cmd=get_schedules", response_data);
24386 "Internal error", __FUNCTION__, __LINE__,
24387 "An internal error occurred while saving a schedule. " 24388 "It is unclear whether the schedule has been saved or not. " 24389 "Diagnostics: Failure to receive response from manager daemon.",
24390 "/omp?cmd=get_schedules", response_data);
24394 "Internal error", __FUNCTION__, __LINE__,
24395 "An internal error occurred while saving a schedule. " 24396 "It is unclear whether the schedule has been saved or not. " 24397 "Diagnostics: Internal Error.",
24398 "/omp?cmd=get_schedules", response_data);
24401 ret = response_from_entity (connection, credentials, params, entity,
24402 (no_redirect && strcmp (no_redirect,
"0")),
24403 NULL,
"get_schedules",
24404 NULL,
"edit_schedule",
24405 "Save Schedule", response_data);
24406 free_entity (entity);
24426 new_user (openvas_connection_t *connection,
credentials_t *credentials,
24427 params_t *params,
const char *extra_xml,
24432 xml = g_string_new (
"<new_user>");
24434 g_string_append (xml, extra_xml);
24443 switch (omp (connection, credentials, &response, &entity, response_data,
24444 "<describe_auth/>"))
24452 "Internal error", __FUNCTION__, __LINE__,
24453 "An internal error occurred getting the auth list. " 24454 "No new user was created. " 24455 "Diagnostics: Failure to send command to manager daemon.",
24456 "/omp?cmd=get_users", response_data);
24460 "Internal error", __FUNCTION__, __LINE__,
24461 "An internal error occurred getting the auth list. " 24462 "No new user was created. " 24463 "Diagnostics: Failure to receive response from manager daemon.",
24464 "/omp?cmd=get_users", response_data);
24468 "Internal error", __FUNCTION__, __LINE__,
24469 "An internal error occurred getting the auth list. " 24470 "No new user was created. " 24471 "Diagnostics: Internal Error.",
24472 "/omp?cmd=get_users", response_data);
24475 g_string_append (xml, response);
24477 free_entity (entity);
24488 switch (omp (connection, credentials, &response, &entity, response_data,
24489 "<get_groups filter=\"permission=modify_group\"/>"))
24497 "Internal error", __FUNCTION__, __LINE__,
24498 "An internal error occurred getting the group list. " 24499 "No new user was created. " 24500 "Diagnostics: Failure to send command to manager daemon.",
24501 "/omp?cmd=get_users", response_data);
24505 "Internal error", __FUNCTION__, __LINE__,
24506 "An internal error occurred getting the group list. " 24507 "No new user was created. " 24508 "Diagnostics: Failure to receive response from manager daemon.",
24509 "/omp?cmd=get_users", response_data);
24513 "Internal error", __FUNCTION__, __LINE__,
24514 "An internal error occurred getting the group list. " 24515 "No new user was created. " 24516 "Diagnostics: Internal Error.",
24517 "/omp?cmd=get_users", response_data);
24520 g_string_append (xml, response);
24522 free_entity (entity);
24533 switch (omp (connection, credentials, &response, &entity, response_data,
24542 "Internal error", __FUNCTION__, __LINE__,
24543 "An internal error occurred getting the role list. " 24544 "No new user was created. " 24545 "Diagnostics: Failure to send command to manager daemon.",
24546 "/omp?cmd=get_users", response_data);
24550 "Internal error", __FUNCTION__, __LINE__,
24551 "An internal error occurred getting the role list. " 24552 "No new user was created. " 24553 "Diagnostics: Failure to receive response from manager daemon.",
24554 "/omp?cmd=get_users", response_data);
24558 "Internal error", __FUNCTION__, __LINE__,
24559 "An internal error occurred getting the role list. " 24560 "No new user was created. " 24561 "Diagnostics: Internal Error.",
24562 "/omp?cmd=get_users", response_data);
24565 g_string_append (xml, response);
24567 free_entity (entity);
24571 g_string_append (xml,
"</new_user>");
24572 return xsl_transform_omp (connection, credentials, params,
24573 g_string_free (xml, FALSE), response_data);
24590 return new_user (connection, credentials, params, NULL, response_data);
24608 "get_users", response_data);
24623 delete_user_confirm (openvas_connection_t *connection,
24628 gchar *response = NULL;
24629 entity_t entity = NULL;
24633 switch (omp (connection, credentials, &response, &entity, response_data,
24634 "<get_users filter=\"first=1 rows=-1\"/>"))
24642 "Internal error", __FUNCTION__, __LINE__,
24643 "An internal error occurred getting the user list. " 24644 "Diagnostics: Failure to send command to manager daemon.",
24645 "/omp?cmd=get_users", response_data);
24649 "Internal error", __FUNCTION__, __LINE__,
24650 "An internal error occurred getting the user list. " 24651 "Diagnostics: Failure to receive response from manager daemon.",
24652 "/omp?cmd=get_users", response_data);
24656 "Internal error", __FUNCTION__, __LINE__,
24657 "An internal error occurred getting the user list. " 24658 "Diagnostics: Internal Error.",
24659 "/omp?cmd=get_users", response_data);
24663 xml = g_string_new (
"<delete_user>");
24665 g_string_append (xml, extra_xml);
24668 g_string_append (xml, response);
24669 free_entity (entity);
24673 g_string_append (xml, extra_xml);
24675 g_string_append (xml,
"</delete_user>");
24676 return xsl_transform_omp (connection, credentials, params,
24677 g_string_free (xml, FALSE), response_data);
24695 return delete_user_confirm (connection, credentials, params, NULL,
24711 get_user (openvas_connection_t *connection,
credentials_t * credentials,
24712 params_t *params,
const char *extra_xml,
24718 extra = g_string_new (
"");
24720 g_string_append (extra, extra_xml);
24728 switch (omp (connection, credentials, &response, &entity, response_data,
24729 "<describe_auth/>"))
24737 "Internal error", __FUNCTION__, __LINE__,
24738 "An internal error occurred getting the auth list. " 24739 "Diagnostics: Failure to send command to manager daemon.",
24740 "/omp?cmd=get_users", response_data);
24744 "Internal error", __FUNCTION__, __LINE__,
24745 "An internal error occurred getting the auth list. " 24746 "Diagnostics: Failure to receive response from manager daemon.",
24747 "/omp?cmd=get_users", response_data);
24751 "Internal error", __FUNCTION__, __LINE__,
24752 "An internal error occurred getting the auth list. " 24753 "Diagnostics: Internal Error.",
24754 "/omp?cmd=get_users", response_data);
24757 g_string_append (extra, response);
24759 free_entity (entity);
24762 html =
get_one (connection,
"user", credentials, params, extra->str, NULL,
24764 g_string_free (extra, TRUE);
24782 return get_user (connection, credentials, params, NULL, response_data);
24797 get_users (openvas_connection_t *connection,
credentials_t * credentials,
24798 params_t *params,
const char *extra_xml,
24804 extra = g_string_new (
"");
24812 switch (omp (connection, credentials, &response, &entity, response_data,
24813 "<describe_auth/>"))
24821 "Internal error", __FUNCTION__, __LINE__,
24822 "An internal error occurred getting the auth list. " 24823 "Diagnostics: Failure to send command to manager daemon.",
24824 "/omp?cmd=get_users", response_data);
24828 "Internal error", __FUNCTION__, __LINE__,
24829 "An internal error occurred getting the auth list. " 24830 "Diagnostics: Failure to receive response from manager daemon.",
24831 "/omp?cmd=get_users", response_data);
24835 "Internal error", __FUNCTION__, __LINE__,
24836 "An internal error occurred getting the auth list. " 24837 "Diagnostics: Internal Error.",
24838 "/omp?cmd=get_users", response_data);
24841 g_string_append (extra, response);
24843 free_entity (entity);
24847 g_string_append (extra, extra_xml);
24848 html = get_many (connection,
"user", credentials, params, extra->str, NULL,
24850 g_string_free (extra, TRUE);
24868 return get_users (connection, credentials, params, NULL, response_data);
24885 const char *no_redirect;
24886 const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
24887 const char *auth_method;
24890 GString *group_elements, *role_elements, *string;
24891 gchar *buf, *response, *html;
24912 string = g_string_new (
"<create_user>");
24913 buf = g_markup_printf_escaped (
"<name>%s</name>" 24914 "<password>%s</password>",
24918 g_string_append (
string, buf);
24921 group_elements = g_string_new (
"<groups>");
24937 g_string_append_printf (group_elements,
24938 "<group id=\"%s\"/>",
24942 g_string_append (
string, group_elements->str);
24943 g_string_free (group_elements, TRUE);
24944 g_string_append (
string,
"</groups>");
24946 role_elements = g_string_new (
"");
24962 g_string_append_printf (role_elements,
24963 "<role id=\"%s\"/>",
24967 g_string_append (
string, role_elements->str);
24968 g_string_free (role_elements, TRUE);
24970 buf = g_markup_printf_escaped (
"<hosts allow=\"%s\">%s</hosts>" 24971 "<ifaces allow=\"%s\">%s</ifaces>",
24972 hosts_allow, hosts, ifaces_allow, ifaces);
24973 g_string_append (
string, buf);
24975 if (auth_method && !strcmp (auth_method,
"1"))
24977 (
string,
"<sources><source>ldap_connect</source></sources>");
24978 else if (auth_method && !strcmp (auth_method,
"2"))
24980 (
string,
"<sources><source>radius_connect</source></sources>");
24981 g_string_append (
string,
"</create_user>");
24983 buf = g_string_free (
string, FALSE);
24987 ret = omp (connection, credentials, &response, &entity, response_data, buf);
24997 "Internal error", __FUNCTION__, __LINE__,
24998 "An internal error occurred while creating a new user. " 24999 "No new user was created. " 25000 "Diagnostics: Failure to send command to manager daemon.",
25001 "/omp?cmd=get_users", response_data);
25005 "Internal error", __FUNCTION__, __LINE__,
25006 "An internal error occurred while creating a new user. " 25007 "It is unclear whether the user has been created or not. " 25008 "Diagnostics: Failure to receive response from manager daemon.",
25009 "/omp?cmd=get_users", response_data);
25013 "Internal error", __FUNCTION__, __LINE__,
25014 "An internal error occurred while creating a new user. " 25015 "It is unclear whether the user has been created or not. " 25016 "Diagnostics: Internal Error.",
25017 "/omp?cmd=get_users", response_data);
25020 if (entity_attribute (entity,
"id"))
25021 params_add (params,
"user_id", entity_attribute (entity,
"id"));
25022 html = response_from_entity (connection, credentials, params, entity,
25023 (no_redirect && strcmp (no_redirect,
"0")),
25026 "Create User", response_data);
25027 free_entity (entity);
25045 params_t *params,
const char *extra_xml,
25051 extra = g_string_new (
"");
25059 switch (omp (connection, credentials, &response, &entity, response_data,
25060 "<describe_auth/>"))
25068 "Internal error", __FUNCTION__, __LINE__,
25069 "An internal error occurred getting the auth list. " 25070 "Diagnostics: Failure to send command to manager daemon.",
25071 "/omp?cmd=get_users", response_data);
25075 "Internal error", __FUNCTION__, __LINE__,
25076 "An internal error occurred getting the auth list. " 25077 "Diagnostics: Failure to receive response from manager daemon.",
25078 "/omp?cmd=get_users", response_data);
25082 "Internal error", __FUNCTION__, __LINE__,
25083 "An internal error occurred getting the auth list. " 25084 "Diagnostics: Internal Error.",
25085 "/omp?cmd=get_users", response_data);
25088 g_string_append (extra, response);
25090 free_entity (entity);
25101 switch (omp (connection, credentials, &response, &entity, response_data,
25102 "<get_groups filter=\"permission=modify_group\"/>"))
25110 "Internal error", __FUNCTION__, __LINE__,
25111 "An internal error occurred getting the group list. " 25112 "Diagnostics: Failure to send command to manager daemon.",
25113 "/omp?cmd=get_users", response_data);
25117 "Internal error", __FUNCTION__, __LINE__,
25118 "An internal error occurred getting the group list. " 25119 "Diagnostics: Failure to receive response from manager daemon.",
25120 "/omp?cmd=get_users", response_data);
25124 "Internal error", __FUNCTION__, __LINE__,
25125 "An internal error occurred getting the group list. " 25126 "Diagnostics: Internal Error.",
25127 "/omp?cmd=get_users", response_data);
25130 g_string_append (extra, response);
25132 free_entity (entity);
25143 switch (omp (connection, credentials, &response, &entity, response_data,
25152 "Internal error", __FUNCTION__, __LINE__,
25153 "An internal error occurred getting the role list. " 25154 "No new user was created. " 25155 "Diagnostics: Failure to send command to manager daemon.",
25156 "/omp?cmd=get_users", response_data);
25160 "Internal error", __FUNCTION__, __LINE__,
25161 "An internal error occurred getting the role list. " 25162 "No new user was created. " 25163 "Diagnostics: Failure to receive response from manager daemon.",
25164 "/omp?cmd=get_users", response_data);
25168 "Internal error", __FUNCTION__, __LINE__,
25169 "An internal error occurred getting the role list. " 25170 "No new user was created. " 25171 "Diagnostics: Internal Error.",
25172 "/omp?cmd=get_users", response_data);
25175 g_string_append (extra, response);
25177 free_entity (entity);
25182 g_string_append (extra, extra_xml);
25183 html =
edit_resource (connection,
"user", credentials, params, NULL,
25184 extra->str, response_data);
25185 g_string_free (extra, TRUE);
25203 return edit_user (connection, credentials, params, NULL, response_data);
25219 xml = g_string_new (
"");
25220 buf = g_markup_printf_escaped (
"<auth_settings name=\"%s\">", name);
25221 g_string_append (xml, buf);
25226 gchar * response = NULL;
25227 entity_t entity = NULL;
25229 switch (omp (connection, credentials, &response, &entity, response_data,
25230 "<describe_auth/>"))
25238 "Internal error", __FUNCTION__, __LINE__,
25239 "An internal error occurred getting the auth list. " 25240 "Diagnostics: Failure to send command to manager daemon.",
25241 "/omp?cmd=get_users", response_data);
25245 "Internal error", __FUNCTION__, __LINE__,
25246 "An internal error occurred getting the auth list. " 25247 "Diagnostics: Failure to receive response from manager daemon.",
25248 "/omp?cmd=get_users", response_data);
25252 "Internal error", __FUNCTION__, __LINE__,
25253 "An internal error occurred getting the auth list. " 25254 "Diagnostics: Internal Error.",
25255 "/omp?cmd=get_users", response_data);
25259 g_string_append (xml, response);
25260 free_entity (entity);
25264 g_string_append (xml,
"</auth_settings>");
25266 return xsl_transform_omp (connection, credentials, params,
25267 g_string_free (xml, FALSE), response_data);
25286 char ctime_now[200];
25288 const char* xml_flag;
25291 if (credentials->
token == NULL)
25301 xml =
login_xml (message, NULL, ctime_now, NULL, NULL, NULL);
25303 if (xml_flag && strcmp (xml_flag,
"0"))
25326 params_t *params,
char **password_return,
char **modified_user,
25330 gchar *html, *response, *buf;
25331 const char *no_redirect;
25332 const char *user_id, *login, *old_login, *modify_password, *password;
25333 const char *hosts, *hosts_allow, *ifaces, *ifaces_allow;
25335 GString *command, *group_elements, *role_elements;
25337 const char *status;
25339 *password_return = NULL;
25340 *modified_user = NULL;
25353 modify_password =
params_value (params,
"modify_password");
25374 command = g_string_new (
"");
25375 buf = g_markup_printf_escaped (
"<modify_user user_id=\"%s\">" 25376 "<password modify=\"%s\">" 25381 g_string_append (command, buf);
25386 buf = g_markup_printf_escaped (
"<new_name>%s</new_name>",
25388 g_string_append (command, buf);
25392 buf = g_markup_printf_escaped (
"<hosts allow=\"%s\">%s</hosts>" 25393 "<ifaces allow=\"%s\">%s</ifaces>",
25394 hosts_allow, hosts, ifaces_allow, ifaces);
25395 g_string_append (command, buf);
25398 if (modify_password && !strcmp (modify_password,
"2"))
25399 g_string_append (command,
"<sources><source>ldap_connect</source></sources>");
25400 else if (modify_password && !strcmp (modify_password,
"3"))
25401 g_string_append (command,
"<sources><source>radius_connect</source></sources>");
25403 g_string_append (command,
"<sources><source>file</source></sources>");
25405 group_elements = g_string_new (
"<groups>");
25421 g_string_append_printf (group_elements,
25422 "<group id=\"%s\"/>",
25426 g_string_append (command, group_elements->str);
25427 g_string_free (group_elements, TRUE);
25428 g_string_append (command,
"</groups>");
25430 role_elements = g_string_new (
"");
25446 g_string_append_printf (role_elements,
25447 "<role id=\"%s\"/>",
25452 g_string_append_printf (role_elements,
"<role id=\"0\"/>");
25454 g_string_append (command, role_elements->str);
25455 g_string_free (role_elements, TRUE);
25457 g_string_append (command,
"</modify_user>");
25461 ret = omp (connection, credentials,
25466 g_string_free (command, TRUE);
25470 status = entity_attribute (entity,
"status");
25471 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
25474 = g_strdup (old_login ? old_login : credentials->
username);
25476 if (strcmp (modify_password,
"0")
25477 || (login && *modified_user && strcmp (*modified_user, login)))
25480 if (strcmp (modify_password,
"0")
25481 && strcmp (modify_password,
"2")
25482 && strcmp (modify_password,
"3")
25486 credentials->
password = g_strdup (password);
25487 *password_return = g_strdup (password);
25496 "Internal error", __FUNCTION__, __LINE__,
25497 "An internal error occurred while saving a user. " 25498 "The user was not saved. " 25499 "Diagnostics: Failure to send command to manager daemon.",
25500 "/omp?cmd=get_users", response_data);
25504 "Internal error", __FUNCTION__, __LINE__,
25505 "An internal error occurred while saving a user. " 25506 "It is unclear whether the user has been saved or not. " 25507 "Diagnostics: Failure to receive response from manager daemon.",
25508 "/omp?cmd=get_users", response_data);
25512 "Internal error", __FUNCTION__, __LINE__,
25513 "An internal error occurred while saving a user. " 25514 "It is unclear whether the user has been saved or not. " 25515 "Diagnostics: Internal Error.",
25516 "/omp?cmd=get_users", response_data);
25519 if (omp_success (entity)
25520 && (!strcmp (modify_password,
"2")
25521 || !strcmp (modify_password,
"3"))
25524 free_entity (entity);
25526 html =
logout (credentials,
25527 "Authentication method changed." 25528 " Please login with LDAP password.",
25532 html = response_from_entity (connection, credentials, params, entity,
25533 (no_redirect && strcmp (no_redirect,
"0")),
25536 "Save User", response_data);
25537 free_entity (entity);
25558 char **content_disposition, gsize *content_length,
25562 content_disposition, content_length, response_data);
25582 char **content_disposition, gsize *content_length,
25585 return export_many (connection,
"user", credentials, params,
content_type,
25586 content_disposition, content_length, response_data);
25594 const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
25595 const char *cvss_vector, *name;
25606 xml = g_string_new (
"<cvss_calculator>");
25609 if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
25611 char *vector = g_strdup_printf
25612 (
"AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c",
25613 *cvss_av, *cvss_ac, *cvss_au, *cvss_c, *cvss_i, *cvss_a);
25615 g_string_append_printf (xml,
25616 "<cvss_vector>%s</cvss_vector>" 25617 "<cvss_score>%.1f</cvss_score>",
25619 get_cvss_score_from_base_metrics (vector));
25621 g_string_append_printf
25623 "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>" 25624 "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>" 25625 "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
25626 *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a);
25630 else if (cvss_vector)
25632 double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
25634 g_string_append_printf (xml,
25635 "<cvss_vector>%s</cvss_vector>" 25636 "<cvss_score>%.1f</cvss_score>",
25640 if (cvss_score != -1.0)
25642 cvss_av = strstr (cvss_vector,
"AV:");
25643 cvss_ac = strstr (cvss_vector,
"/AC:");
25644 cvss_au = strstr (cvss_vector,
"/Au:");
25645 if (cvss_au == NULL)
25646 cvss_au = strstr (cvss_vector,
"/AU:");
25647 cvss_c = strstr (cvss_vector,
"/C:");
25648 cvss_i = strstr (cvss_vector,
"/I:");
25649 cvss_a = strstr (cvss_vector,
"/A:");
25651 if (cvss_av && cvss_ac && cvss_au && cvss_c
25652 && cvss_i && cvss_a)
25653 g_string_append_printf
25655 "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>" 25656 "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>" 25657 "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
25658 *(cvss_av + 3), *(cvss_ac + 4), *(cvss_au + 4),
25659 *(cvss_c + 3), *(cvss_i + 3), *(cvss_a + 3));
25662 else if (name && !strcmp (
"vector", name))
25664 g_string_append_printf (xml,
25665 "<cvss_score>%.1f</cvss_score>",
25669 g_string_append (xml,
"</cvss_calculator>");
25670 return xsl_transform_omp (connection, credentials, params,
25671 g_string_free (xml, FALSE), response_data);
25693 int may_get_aggregates, may_get_info, may_get_tasks;
25695 may_get_aggregates =
command_enabled (credentials,
"GET_AGGREGATES");
25701 if (credentials->
guest 25702 && may_get_aggregates && may_get_info)
25704 else if (may_get_aggregates && may_get_info && may_get_tasks)
25706 else if (may_get_aggregates && may_get_tasks)
25708 else if (may_get_aggregates && may_get_info)
25712 gchar *redirect_url;
25713 redirect_url = g_strdup_printf (
"/omp?cmd=get_system_reports&token=%s",
25714 credentials->
token);
25715 response_data->
redirect = redirect_url;
25716 return g_strdup_printf (
"redirecting to %s", redirect_url);
25720 gchar *redirect_url;
25721 redirect_url = g_strdup_printf (
"/help/about.html?token=%s",
25722 credentials->
token);
25723 response_data->
redirect = redirect_url;
25724 return g_strdup_printf (
"redirecting to %s", redirect_url);
25728 xml = g_string_new (
"<dashboard>");
25729 g_string_append_printf (xml,
"<name>%s</name>", name);
25735 if (strcasecmp (name,
"") == 0
25736 || strcasecmp (name,
"Main") == 0
25737 || strcasecmp (name,
"SecInfo") == 0)
25739 ret = ompf (connection,
25744 "<get_info type=\"cve\" info_id=\"--\"/>");
25752 g_string_free (xml, TRUE);
25755 "Internal error", __FUNCTION__, __LINE__,
25756 "An internal error occurred while " 25757 "testing SecInfo database availability. " 25758 "Diagnostics: Failure to send command to " 25760 "/omp?cmd=dashboard", response_data);
25762 g_string_free (xml, TRUE);
25765 "Internal error", __FUNCTION__, __LINE__,
25766 "An internal error occurred while " 25767 "testing SecInfo database availability. " 25768 "Diagnostics: Failure to receive response from " 25770 "/omp?cmd=dashboard", response_data);
25772 g_string_free (xml, TRUE);
25775 "Internal error", __FUNCTION__, __LINE__,
25776 "An internal error occurred while " 25777 "testing SecInfo database availability. " 25778 "Diagnostics: Internal Error.",
25779 "/omp?cmd=dashboard", response_data);
25781 g_string_append_printf (xml,
25782 "<secinfo_test>%s</secinfo_test>",
25785 free_entity (entity);
25788 if (strcasecmp (name,
"SecInfo") == 0)
25789 ret = ompf (connection,
25794 "<get_filters filter=\"type=info or type= first=1 rows=-1\"/>");
25796 ret = ompf (connection,
25801 "<get_filters filter=\"first=1 rows=-1\"/>");
25809 g_string_free (xml, TRUE);
25812 "Internal error", __FUNCTION__, __LINE__,
25813 "An internal error occurred while getting the " 25815 "Diagnostics: Failure to send command to " 25817 "/omp?cmd=dashboard", response_data);
25819 g_string_free (xml, TRUE);
25822 "Internal error", __FUNCTION__, __LINE__,
25823 "An internal error occurred while getting the " 25825 "Diagnostics: Failure to receive response from " 25827 "/omp?cmd=dashboard", response_data);
25829 g_string_free (xml, TRUE);
25832 "Internal error", __FUNCTION__, __LINE__,
25833 "An internal error occurred while getting the " 25835 "Diagnostics: Internal Error.",
25836 "/omp?cmd=dashboard", response_data);
25839 g_string_append (xml, response);
25841 free_entity (entity);
25843 g_string_append (xml,
"</dashboard>");
25844 return xsl_transform_omp (connection, credentials, params,
25845 g_string_free (xml, FALSE), response_data);
25851 #define AUTH_CONF_SETTING(key, value) \ 25852 "<auth_conf_setting>" \ 25853 "<key>" key "</key>" \ 25854 "<value>" value "</value>" \ 25855 "</auth_conf_setting>" 25872 entity_t entity = NULL;
25873 char *html, *response = NULL, *truefalse;
25874 const char *no_redirect, *method;
25877 && (strcmp (
params_value (params,
"enable"),
"1") == 0))
25878 truefalse =
"true";
25880 truefalse =
"false";
25885 if (!strcmp (method,
"method:ldap_connect"))
25887 const char *ldaphost, *authdn, *certificate;
25894 if (
params_given (params,
"certificate") && strcmp (certificate,
""))
25898 ret = ompf (connection, credentials, &response, &entity,
25901 "<group name=\"%s\">" 25907 "</modify_auth>", method, truefalse, ldaphost, authdn,
25912 ret = ompf (connection, credentials, &response, &entity, response_data,
25914 "<group name=\"%s\">" 25919 "</modify_auth>", method, truefalse, ldaphost, authdn);
25921 else if (!strcmp (method,
"method:radius_connect"))
25923 const char *radiushost, *radiuskey;
25930 ret = ompf (connection, credentials, &response, &entity, response_data,
25932 "<group name=\"%s\">" 25937 "</modify_auth>", method, truefalse, radiushost, radiuskey);
25940 return get_users (connection, credentials, params,
25942 (
"Save Authentication Configuration"),
25953 "Internal error", __FUNCTION__, __LINE__,
25954 "An internal error occurred while saving the auth settings. " 25955 "The settings were not saved. " 25956 "Diagnostics: Failure to send command to manager daemon.",
25957 "/omp?cmd=get_users", response_data);
25961 "Internal error", __FUNCTION__, __LINE__,
25962 "An internal error occurred while saving the auth settings. " 25963 "It is unclear whether the settings have been saved or not. " 25964 "Diagnostics: Failure to receive response from manager daemon.",
25965 "/omp?cmd=get_users", response_data);
25969 "Internal error", __FUNCTION__, __LINE__,
25970 "An internal error occurred while saving the auth settings. " 25971 "It is unclear whether the settings have been saved or not. " 25972 "Diagnostics: Internal Error.",
25973 "/omp?cmd=get_users", response_data);
25976 html = response_from_entity (connection, credentials, params, entity,
25977 (no_redirect && strcmp (no_redirect,
"0")),
25979 NULL,
"modify_auth",
25980 "Save Authentication Configuration",
25982 free_entity (entity);
26002 gchar **pref_id, gchar **pref_value,
26005 *pref_id = g_strdup (
params_value (params,
"chart_preference_id"));
26006 *pref_value = g_strdup (
params_value (params,
"chart_preference_value"));
26008 gchar* value_64 = g_base64_encode ((guchar*)*pref_value,
26009 strlen (*pref_value));
26014 if (*pref_id == NULL)
26017 return (
"<save_chart_preference_response" 26018 " status=\"400\" status_text=\"Invalid or missing name\"/>");
26020 if (*pref_value == NULL)
26023 return (
"<save_chart_preference_response" 26024 " status=\"400\" status_text=\"Invalid or missing value\"/>");
26029 ret = ompf (connection, credentials, &response, &entity, response_data,
26030 "<modify_setting setting_id=\"%s\">" 26031 "<value>%s</value>" 26032 "</modify_setting>",
26033 *pref_id, value_64);
26043 "Internal error", __FUNCTION__, __LINE__,
26044 "An internal error occurred while saving settings. " 26045 "It is unclear whether all the settings were saved. " 26046 "Diagnostics: Failure to send command to manager daemon.",
26047 "/omp?cmd=get_my_settings", response_data);
26051 "Internal error", __FUNCTION__, __LINE__,
26052 "An internal error occurred while saving settings. " 26053 "It is unclear whether all the settings were saved. " 26054 "Diagnostics: Failure to receive response from manager daemon.",
26055 "/omp?cmd=get_my_settings", response_data);
26059 "Internal error", __FUNCTION__, __LINE__,
26060 "An internal error occurred while saving settings. " 26061 "It is unclear whether all the settings were saved. " 26062 "Diagnostics: Internal Error.",
26063 "/omp?cmd=get_my_settings", response_data);
26066 if (omp_success (entity))
26068 free_entity (entity);
26070 return (
"<save_chart_preference_response" 26071 " status=\"200\" status_text=\"OK\"/>");
26076 gchar* ret_response
26077 = g_strdup_printf(
"<save_chart_preference_response" 26078 " status=\"%s\" status_text=\"%s\"/>",
26079 entity_attribute (entity,
"status"),
26080 entity_attribute (entity,
"status_text"));
26081 free_entity (entity);
26083 return ret_response;
26102 wizard (openvas_connection_t *connection,
credentials_t *credentials,
26103 params_t *params,
const char *extra_xml,
26113 "Internal error", __FUNCTION__, __LINE__,
26114 "An internal error occurred while getting the wizard. " 26115 "Given name was invalid",
26116 "/omp?cmd=get_tasks", response_data);
26119 xml = g_string_new (
"");
26120 g_string_append_printf (xml,
26122 extra_xml ? extra_xml :
"",
26126 if (openvas_connection_sendf_xml (connection,
26127 "<run_wizard read_only=\"1\">" 26129 "<mode>init</mode>" 26134 g_string_free (xml, TRUE);
26137 "Internal error", __FUNCTION__, __LINE__,
26138 "An internal error occurred while getting the wizard. " 26139 "Diagnostics: Failure to send command to manager daemon.",
26140 "/omp?cmd=get_tasks", response_data);
26143 if (read_string_c (connection, &xml))
26145 g_string_free (xml, TRUE);
26148 "Internal error", __FUNCTION__, __LINE__,
26149 "An internal error occurred while getting the" 26151 "Diagnostics: Failure to receive response from" 26152 " manager daemon.",
26153 "/omp?cmd=get_tasks", response_data);
26158 if (openvas_connection_sendf_xml (connection,
26160 " setting_id=\"20f3034c-e709-11e1-87e7-406186ea4fc5\"/>")
26163 g_string_free (xml, TRUE);
26166 "Internal error", __FUNCTION__, __LINE__,
26167 "An internal error occurred while getting the wizard. " 26168 "Diagnostics: Failure to send command to manager daemon.",
26169 "/omp?cmd=get_tasks", response_data);
26172 if (read_string_c (connection, &xml))
26174 g_string_free (xml, TRUE);
26177 "Internal error", __FUNCTION__, __LINE__,
26178 "An internal error occurred while the wizard. " 26179 "Diagnostics: Failure to receive response from manager daemon.",
26180 "/omp?cmd=get_tasks", response_data);
26185 g_string_append_printf (xml,
"</wizard>");
26186 return xsl_transform_omp (connection, credentials, params,
26187 g_string_free (xml, FALSE), response_data);
26204 return wizard (connection, credentials, params, NULL, response_data);
26219 wizard_get (openvas_connection_t *connection,
credentials_t *credentials,
26220 params_t *params,
const char *extra_xml,
26227 gchar *param_name, *response;
26242 "Internal error", __FUNCTION__, __LINE__,
26243 "An internal error occurred while trying to start a wizard. " 26244 "Diagnostics: Required parameter 'get_name' was NULL.",
26245 "/omp?cmd=get_tasks", response_data);
26248 run = g_string_new (
"<run_wizard read_only=\"1\">");
26250 g_string_append_printf (run,
26260 xml_string_append (run,
26263 "<value>%s</value>" 26269 g_string_append (run,
"</params></run_wizard>");
26273 ret = omp (connection, credentials, &response, &entity, response_data,
26275 g_string_free (run, TRUE);
26284 "Internal error", __FUNCTION__, __LINE__,
26285 "An internal error occurred while running a wizard. " 26286 "The wizard did not start. " 26287 "Diagnostics: Failure to send command to manager daemon.",
26288 "/omp?cmd=get_tasks", response_data);
26292 "Internal error", __FUNCTION__, __LINE__,
26293 "An internal error occurred while running a wizard. " 26294 "It is unclear whether the wizard started or not. " 26295 "Diagnostics: Failure to receive response from manager daemon.",
26296 "/omp?cmd=get_tasks", response_data);
26300 "Internal error", __FUNCTION__, __LINE__,
26301 "An internal error occurred while running a wizard. " 26302 "It is unclear whether the wizard started or not. " 26303 "Diagnostics: Internal Error.",
26304 "/omp?cmd=get_tasks", response_data);
26307 wizard_xml = g_strdup_printf (
"<wizard><%s/>%s%s</wizard>",
26309 extra_xml ? extra_xml :
"",
26312 return xsl_transform_omp (connection, credentials, params, wizard_xml,
26330 return wizard_get (connection, credentials, params, NULL, response_data);
26349 char **content_disposition, gsize *content_length,
26352 GString *bulk_string;
26353 const char *type, *subtype, *action;
26364 "Internal error", __FUNCTION__, __LINE__,
26365 "An internal error occurred while performing a bulk action. " 26366 "Diagnostics: Required parameter 'resource_type' was NULL.",
26367 "/omp?cmd=get_tasks", response_data);
26369 if (strcmp (type,
"info") == 0)
26372 if (subtype == NULL)
26376 "Internal error", __FUNCTION__, __LINE__,
26377 "An internal error occurred while performing a bulk action. " 26378 "Diagnostics: Required parameter 'info_type' was NULL.",
26379 "/omp?cmd=get_tasks", response_data);
26397 "Internal error", __FUNCTION__, __LINE__,
26398 "An internal error occurred while performing a bulk action. " 26399 "Diagnostics: Could not determine the action.",
26400 "/omp?cmd=get_tasks", response_data);
26403 if (strcmp (action,
"create") == 0)
26406 && strcmp (
params_value (params,
"bulk_select"),
"1") == 0)
26408 bulk_string = g_string_new (
"first=1 rows=-1");
26415 xml_string_append (bulk_string,
26421 && strcmp (
params_value (params,
"bulk_select"),
"2") == 0)
26423 bulk_string = g_string_new (
"first=1 rows=-1 ");
26424 g_string_append (bulk_string,
params_value (params,
"filter") ? :
"");
26428 bulk_string = g_string_new (
params_value (params,
"filter") ? :
"");
26433 g_string_free (bulk_string, TRUE);
26435 return new_target (connection, credentials, params, NULL, response_data);
26438 if (strcmp (action,
"export") == 0)
26441 && strcmp (
params_value (params,
"bulk_select"),
"1") == 0)
26444 = g_string_new (
"first=1 rows=-1 uuid=");
26451 xml_string_append (bulk_string,
26457 && strcmp (
params_value (params,
"bulk_select"),
"2") == 0)
26460 = g_string_new (
"first=1 rows=-1 ");
26461 g_string_append (bulk_string,
params_value (params,
"filter") ? :
"");
26466 = g_string_new (
params_value (params,
"filter") ? :
"");
26468 params_add (params,
"filter", g_string_free (bulk_string, FALSE));
26470 return export_many (connection, type, credentials, params,
content_type,
26471 content_disposition, content_length, response_data);
26474 bulk_string = g_string_new (
"<process_bulk>");
26476 g_string_append_printf (bulk_string,
26478 "<action>%s</action>",
26482 g_string_append (bulk_string,
"<selections>");
26485 && strcmp (
params_value (params,
"bulk_select"),
"2") == 0)
26491 ret = ompf (connection, credentials, &response, &entity, response_data,
26492 "<get_%ss filter=\"first=1 rows=-1 %s\"/>",
26498 free_entity (entity);
26500 g_string_free (bulk_string, TRUE);
26510 "Internal error", __FUNCTION__, __LINE__,
26511 "An internal error occurred while getting a" 26512 " resources list. " 26513 "Diagnostics: Failure to send command to" 26514 " manager daemon.",
26515 "/omp?cmd=get_my_settings", response_data);
26519 "Internal error", __FUNCTION__, __LINE__,
26520 "An internal error occurred while getting a" 26521 " resources list. " 26522 "Diagnostics: Failure to receive response from" 26523 " manager daemon.",
26524 "/omp?cmd=get_my_settings", response_data);
26528 "Internal error", __FUNCTION__, __LINE__,
26529 "An internal error occurred while getting a" 26530 " resources list. " 26531 "Diagnostics: Internal Error.",
26532 "/omp?cmd=get_my_settings", response_data);
26535 entities_t entities = entity->entities;
26536 entity_t child_entity;
26538 while ((child_entity = first_entity (entities)))
26540 if (strcmp (entity_name (child_entity), type) == 0)
26542 const char *resource_id
26543 = entity_attribute (child_entity,
"id");
26546 xml_string_append (bulk_string,
26547 "<selection id=\"%s\" />",
26550 entities = next_entities (entities);
26560 xml_string_append (bulk_string,
26561 "<selection id=\"%s\" />",
26565 g_string_append (bulk_string,
"</selections>");
26567 if (strcmp (action,
"delete") == 0 && strcmp (type,
"user") == 0)
26573 ret = ompf (connection, credentials, &response, &entity, response_data,
26574 "<get_users filter=\"first=1 rows=-1\"/>",
26580 free_entity (entity);
26582 g_string_free (bulk_string, TRUE);
26592 "Internal error", __FUNCTION__, __LINE__,
26593 "An internal error occurred while getting a" 26594 " resources list. " 26595 "Diagnostics: Failure to send command to" 26596 " manager daemon.",
26597 "/omp?cmd=get_my_settings", response_data);
26601 "Internal error", __FUNCTION__, __LINE__,
26602 "An internal error occurred while getting a" 26603 " resources list. " 26604 "Diagnostics: Failure to receive response from" 26605 " manager daemon.",
26606 "/omp?cmd=get_my_settings", response_data);
26610 "Internal error", __FUNCTION__, __LINE__,
26611 "An internal error occurred while getting a" 26612 " resources list. " 26613 "Diagnostics: Internal Error.",
26614 "/omp?cmd=get_my_settings", response_data);
26617 g_string_append (bulk_string, response);
26618 free_entity (entity);
26622 g_string_append (bulk_string,
"</process_bulk>");
26624 return xsl_transform_omp (connection, credentials, params,
26625 g_string_free (bulk_string, FALSE), response_data);
26642 const char *no_redirect, *type;
26643 GString *commands_xml;
26648 gchar *html, *response;
26650 gchar *extra_attribs;
26658 "Internal error", __FUNCTION__, __LINE__,
26659 "An internal error occurred while deleting resources. " 26660 "The resources were not deleted. " 26661 "Diagnostics: Required parameter 'resource_type' was NULL.",
26662 "/omp?cmd=get_tasks", response_data);
26666 extra_attribs = NULL;
26669 if (strcmp (type,
"user") == 0)
26671 const char* inheritor_id;
26674 extra_attribs = g_strdup_printf (
"inheritor_id=\"%s\"", inheritor_id);
26677 commands_xml = g_string_new (
"<commands>");
26685 xml_string_append (commands_xml,
26686 "<delete_%s %s_id=\"%s\" ultimate=\"0\"",
26691 g_string_append_printf (commands_xml,
" %s/>", extra_attribs);
26693 g_string_append (commands_xml,
"/>");
26697 g_string_append (commands_xml,
"</commands>");
26701 if (openvas_connection_sendf_xml (connection,
26705 g_string_free (commands_xml, TRUE);
26708 "Internal error", __FUNCTION__, __LINE__,
26709 "An internal error occurred while deleting resources. " 26710 "The resources were not deleted. " 26711 "Diagnostics: Failure to send command to manager daemon.",
26712 "/omp?cmd=get_tasks", response_data);
26714 g_string_free (commands_xml, TRUE);
26717 if (read_entity_and_text_c (connection, &entity, &response))
26721 "Internal error", __FUNCTION__, __LINE__,
26722 "An internal error occurred while deleting resources. " 26723 "It is unclear whether the resources have been deleted or not. " 26724 "Diagnostics: Failure to read response from manager daemon.",
26725 "/omp?cmd=get_tasks", response_data);
26733 next = g_strdup_printf (
"get_%ss", type);
26737 html = response_from_entity (connection, credentials, params, entity,
26738 (no_redirect && strcmp (no_redirect,
"0")),
26741 "Bulk Delete", response_data);
26743 free_entity (entity);
26763 new_host (openvas_connection_t *connection,
credentials_t *credentials,
26764 params_t *params,
const char *extra_xml,
26768 xml = g_string_new (
"<new_host>");
26770 g_string_append (xml, extra_xml);
26771 g_string_append (xml,
"</new_host>");
26772 return xsl_transform_omp (connection, credentials, params,
26773 g_string_free (xml, FALSE), response_data);
26790 return new_host (connection, credentials, params, NULL, response_data);
26808 gchar *html, *response;
26809 const char *no_redirect, *name, *comment;
26823 xml = g_string_new (
"");
26825 xml_string_append (xml,
26828 "<type>host</type>" 26830 "<comment>%s</comment>" 26836 ret = omp (connection, credentials,
26841 g_string_free (xml, TRUE);
26850 "Internal error", __FUNCTION__, __LINE__,
26851 "An internal error occurred while creating a new host. " 26852 "No new host was created. " 26853 "Diagnostics: Failure to send command to manager daemon.",
26854 "/omp?cmd=get_assets", response_data);
26858 "Internal error", __FUNCTION__, __LINE__,
26859 "An internal error occurred while creating a new host. " 26860 "It is unclear whether the host has been created or not. " 26861 "Diagnostics: Failure to receive response from manager daemon.",
26862 "/omp?cmd=get_assets", response_data);
26866 "Internal error", __FUNCTION__, __LINE__,
26867 "An internal error occurred while creating a new host. " 26868 "It is unclear whether the host has been created or not. " 26869 "Diagnostics: Internal Error.",
26870 "/omp?cmd=get_assets", response_data);
26873 if (entity_attribute (entity,
"id"))
26874 params_add (params,
"asset_id", entity_attribute (entity,
"id"));
26875 html = response_from_entity (connection, credentials, params, entity,
26876 (no_redirect && strcmp (no_redirect,
"0")),
26877 NULL,
"get_assets",
26879 "Create Host", response_data);
26880 free_entity (entity);
26897 get_asset (openvas_connection_t *connection,
credentials_t *credentials,
26898 params_t *params,
const char *extra_xml,
26902 GString *extra_attribs, *extra_response;
26903 const char *asset_type;
26906 if (asset_type == NULL)
26915 if (strcmp (asset_type,
"host")
26916 && strcmp (asset_type,
"os"))
26920 "Internal error", __FUNCTION__, __LINE__,
26921 "An internal error occurred while getting an asset. " 26922 "Diagnostics: Invalid asset_type parameter value",
26923 "/omp?cmd=get_asset", response_data);
26931 "Internal error", __FUNCTION__, __LINE__,
26932 "An internal error occurred while getting an asset. " 26933 "Diagnostics: Both ID and Name set.",
26934 "/omp?cmd=get_asset", response_data);
26937 extra_response = g_string_new (extra_xml ? extra_xml :
"");
26939 extra_attribs = g_string_new (
"");
26940 g_string_append_printf (extra_attribs,
"type=\"%s\"",
26943 g_string_append_printf (extra_attribs,
26947 g_string_append_printf (extra_attribs,
26948 " asset_id=\"%s\"",
26951 g_string_append_printf (extra_attribs,
26955 ret =
get_one (connection,
"asset", credentials, params, extra_response->str,
26956 extra_attribs->str, response_data);
26958 g_string_free (extra_response, TRUE);
26959 g_string_free (extra_attribs, TRUE);
26978 return get_asset (connection, credentials, params, NULL, response_data);
26993 get_assets (openvas_connection_t *connection,
credentials_t *credentials,
26994 params_t *params,
const char *extra_xml,
26998 GString *extra_attribs, *extra_response;
26999 const char *asset_type;
27002 if (asset_type == NULL)
27011 if (strcmp (asset_type,
"host")
27012 && strcmp (asset_type,
"os"))
27016 "Internal error", __FUNCTION__, __LINE__,
27017 "An internal error occurred while getting Assets. " 27018 "Diagnostics: Invalid asset_type parameter value",
27019 "/omp?cmd=get_assets", response_data);
27022 extra_response = g_string_new (extra_xml ? extra_xml :
"");
27024 extra_attribs = g_string_new(
"");
27025 g_string_append_printf (extra_attribs,
"type=\"%s\" ignore_pagination=\"%s\"",
27031 g_string_append_printf (extra_attribs,
27034 ret = get_many (connection,
"asset", credentials, params, extra_response->str,
27035 extra_attribs->str, response_data);
27037 g_string_free (extra_response, TRUE);
27038 g_string_free (extra_attribs, TRUE);
27057 return get_assets (connection, credentials, params, NULL, response_data);
27076 const char *no_redirect, *report_id, *filter;
27088 switch (ompf (connection, credentials,
27093 "<report id=\"%s\">" 27094 "<filter><term>%s</term></filter>" 27106 "Internal error", __FUNCTION__, __LINE__,
27107 "An internal error occurred while creating an asset. " 27108 "No new asset was created. " 27109 "Diagnostics: Failure to send command to manager daemon.",
27110 "/omp?cmd=get_tasks", response_data);
27114 "Internal error", __FUNCTION__, __LINE__,
27115 "An internal error occurred while creating an asset. " 27116 "It is unclear whether the asset has been created or not. " 27117 "Diagnostics: Failure to receive response from manager daemon.",
27118 "/omp?cmd=get_tasks", response_data);
27122 "Internal error", __FUNCTION__, __LINE__,
27123 "An internal error occurred while creating an asset. " 27124 "It is unclear whether the asset has been created or not. " 27125 "Diagnostics: Internal Error.",
27126 "/omp?cmd=get_tasks", response_data);
27129 ret = response_from_entity (connection, credentials, params, entity,
27130 (no_redirect && strcmp (no_redirect,
"0")),
27131 NULL,
"get_report_section",
27132 NULL,
"get_report_section",
27133 "Create Asset", response_data);
27134 free_entity (entity);
27153 gchar *html, *response, *resource_id;
27154 const char *next_id, *no_redirect;
27159 resource_id = g_strdup (
params_value (params,
"asset_id"));
27161 resource_id = g_strdup (
params_value (params,
"report_id"));
27166 "Internal error", __FUNCTION__, __LINE__,
27167 "An internal error occurred while deleting an asset. " 27168 "The asset was not deleted. " 27169 "Diagnostics: Required parameter was NULL.",
27170 "/omp?cmd=get_tasks", response_data);
27188 if (openvas_connection_sendf (connection,
27189 "<delete_asset %s_id=\"%s\"/>",
27191 ?
"asset" :
"report",
27195 g_free (resource_id);
27198 "Internal error", __FUNCTION__, __LINE__,
27199 "An internal error occurred while deleting an asset. " 27200 "The asset is not deleted. " 27201 "Diagnostics: Failure to send command to manager daemon.",
27202 "/omp?cmd=get_tasks", response_data);
27205 g_free (resource_id);
27208 if (read_entity_and_text_c (connection, &entity, &response))
27212 "Internal error", __FUNCTION__, __LINE__,
27213 "An internal error occurred while deleting an asset. " 27214 "It is unclear whether the asset has been deleted or not. " 27215 "Diagnostics: Failure to read response from manager daemon.",
27216 "/omp?cmd=get_tasks", response_data);
27225 if (no_redirect && strcmp (no_redirect,
"0"))
27227 html = next_page (connection, credentials, params, response,
27233 "Internal error", __FUNCTION__, __LINE__,
27234 "An internal error occurred while deleting an " 27235 "asset. Diagnostics: Error in parameter next.",
27236 "/omp?cmd=get_tasks", response_data);
27241 next_url = next_page_url (credentials, params,
27242 NULL,
"get_asset",
"delete_asset",
27243 entity_attribute (entity,
"status"),
27244 entity_attribute (entity,
"status_text"));
27245 response_data->
redirect = next_url;
27251 free_entity (entity);
27271 char **content_disposition, gsize *content_length,
27299 return export_many (connection,
"asset", credentials, params,
content_type,
27300 content_disposition, content_length, response_data);
27316 params_t *params,
const char *extra_xml,
27320 const char *asset_id;
27325 if (asset_id == NULL)
27329 "Internal error", __FUNCTION__, __LINE__,
27330 "An internal error occurred while editing a asset. " 27331 "The asset remains as it was. " 27332 "Diagnostics: Required ID parameter was NULL.",
27333 "/omp?cmd=get_tasks", response_data);
27336 xml = g_string_new (
"");
27338 g_string_append_printf (xml,
"<edit_asset>");
27341 g_string_append (xml, extra_xml);
27345 switch (ompf (connection, credentials,
27352 " details=\"1\"/>",
27360 g_string_free (xml, TRUE);
27362 "Internal error", __FUNCTION__, __LINE__,
27363 "An internal error occurred while getting the asset. " 27364 "Diagnostics: Failure to send command to manager daemon.",
27365 "/omp?cmd=get_assets", response_data);
27368 g_string_free (xml, TRUE);
27370 "Internal error", __FUNCTION__, __LINE__,
27371 "An internal error occurred while getting the asset. " 27372 "Diagnostics: Failure to receive response from manager daemon.",
27373 "/omp?cmd=get_assets", response_data);
27376 g_string_free (xml, TRUE);
27378 "Internal error", __FUNCTION__, __LINE__,
27379 "An internal error occurred while getting the asset. " 27380 "Diagnostics: Internal Error.",
27381 "/omp?cmd=get_assets", response_data);
27384 g_string_append (xml, response);
27385 g_string_append_printf (xml,
"</edit_asset>");
27386 free_entity (entity);
27388 return xsl_transform_omp (connection, credentials, params,
27389 g_string_free (xml, FALSE), response_data);
27407 return edit_asset (connection, credentials, params, NULL, response_data);
27426 gchar *html, *response;
27427 const char *no_redirect, *asset_id, *comment;
27441 ret = ompf (connection, credentials,
27445 "<modify_asset asset_id=\"%s\">" 27446 "<comment>%s</comment>" 27459 "Internal error", __FUNCTION__, __LINE__,
27460 "An internal error occurred while saving an asset. " 27461 "The asset was not saved. " 27462 "Diagnostics: Failure to send command to manager daemon.",
27463 "/omp?cmd=get_assets", response_data);
27467 "Internal error", __FUNCTION__, __LINE__,
27468 "An internal error occurred while saving an asset. " 27469 "It is unclear whether the asset has been saved or not. " 27470 "Diagnostics: Failure to receive response from manager daemon.",
27471 "/omp?cmd=get_assets", response_data);
27475 "Internal error", __FUNCTION__, __LINE__,
27476 "An internal error occurred while saving an asset. " 27477 "It is unclear whether the asset has been saved or not. " 27478 "Diagnostics: Internal Error.",
27479 "/omp?cmd=get_assets", response_data);
27482 html = response_from_entity (connection, credentials, params, entity,
27483 (no_redirect && strcmp (no_redirect,
"0")),
27484 NULL,
"get_assets",
27485 NULL,
"edit_asset",
27486 "Save Asset", response_data);
27487 free_entity (entity);
27504 get_assets_chart (openvas_connection_t *connection,
credentials_t *credentials,
27505 params_t *params,
const char *extra_xml,
27508 return xsl_transform_omp (connection, credentials, params,
27509 g_strdup (
"<get_assets_chart/>"), response_data);
27527 return get_assets_chart (connection, credentials, params, NULL,
27544 struct sockaddr_un address;
27549 sock = socket (AF_UNIX, SOCK_STREAM, 0);
27552 g_warning (
"Failed to create server socket");
27558 address.sun_family = AF_UNIX;
27559 strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
27560 if (connect (sock, (
struct sockaddr *) &address,
sizeof (address)) == -1)
27562 g_warning (
"Failed to connect to server: %s", strerror (errno));
27581 const gchar *address,
27584 if (address == NULL)
27591 connection->socket = openvas_server_open (&connection->session,
27594 connection->credentials = NULL;
27599 if (connection->socket == -1)
27623 gchar **role, gchar **timezone, gchar **severity,
27624 gchar **capabilities, gchar **language, gchar **pw_warning,
27625 GTree **chart_prefs, gchar **autorefresh)
27627 openvas_connection_t connection;
27629 omp_authenticate_info_opts_t auth_opts;
27635 g_debug (
"%s failed to acquire socket!\n", __FUNCTION__);
27647 g_debug (
"Sleeping!");
27651 auth_opts = omp_authenticate_info_opts_defaults;
27652 auth_opts.username = username;
27653 auth_opts.password = password;
27654 auth_opts.role = role;
27655 auth_opts.severity = severity;
27656 auth_opts.timezone = timezone;
27657 auth_opts.pw_warning = pw_warning;
27659 auth = omp_authenticate_info_ext_c (&connection, auth_opts);
27663 const char* status;
27670 ret = setting_get_value (&connection,
27671 "6765549a-934e-11e3-b358-406186ea4fc5",
27681 openvas_connection_close (&connection);
27684 openvas_connection_close (&connection);
27690 ret = openvas_connection_sendf (&connection,
27691 "<help format=\"XML\" type=\"brief\"/>");
27694 openvas_connection_close (&connection);
27701 if (read_entity_and_text_c (&connection, &entity, &response))
27703 openvas_connection_close (&connection);
27709 status = entity_attribute (entity,
"status");
27711 || strlen (status) == 0)
27714 free_entity (entity);
27718 free_entity (entity);
27721 *capabilities = response;
27725 openvas_connection_close (&connection);
27732 ret = openvas_connection_sendf (&connection,
27734 " filter='name~\"Dashboard\"'/>");
27737 openvas_connection_close (&connection);
27743 if (read_entity_and_text_c (&connection, &entity, &response))
27745 openvas_connection_close (&connection);
27750 status = entity_attribute (entity,
"status");
27752 || strlen (status) == 0)
27755 free_entity (entity);
27761 entities_t entities = entity->entities;
27762 entity_t child_entity;
27763 *chart_prefs = g_tree_new_full ((GCompareDataFunc) g_strcmp0,
27764 NULL, g_free, g_free);
27766 while ((child_entity = first_entity (entities)))
27768 if (strcmp (entity_name (child_entity),
"setting") == 0)
27770 const char *setting_id
27771 = entity_attribute (child_entity,
"id");
27772 const char *setting_value
27773 = entity_text (entity_child (child_entity,
"value"));
27775 if (setting_id && setting_value)
27776 g_tree_insert (*chart_prefs,
27777 g_strdup (setting_id),
27778 g_strdup (setting_value));
27780 entities = next_entities (entities);
27782 free_entity (entity);
27787 free_entity (entity);
27789 openvas_connection_close (&connection);
27795 ret = setting_get_value (&connection,
27796 "578a1c14-e2dc-45ef-a591-89d31391d007",
27806 openvas_connection_close (&connection);
27809 openvas_connection_close (&connection);
27813 openvas_connection_close (&connection);
27818 openvas_connection_close (&connection);
27838 omp_authenticate_info_opts_t auth_opts;
27849 g_debug (
"in manager_connect: Trying to authenticate with %s/%s\n",
27855 auth_opts = omp_authenticate_info_opts_defaults;
27856 auth_opts.username = credentials->
username;
27857 auth_opts.password = credentials->
password;
27858 if (omp_authenticate_info_ext_c (connection, auth_opts))
27860 g_debug (
"authenticate failed!\n");
27861 openvas_connection_close (connection);
27872 g_debug (
"Sleeping!");
char * new_container_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new task.
char * save_container_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save container task, get next page, XSL transform the result.
char * create_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a permission, get all permissions, XSL transform the result.
char * delete_port_range_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a port range, get the port list, XSL transform the result.
char * save_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save details of an NVT for a config and return the next page.
char * delete_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete report format, get report formats, XSL transform the result.
int download_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *result_len, char **html, char **login, cmd_response_data_t *response_data)
Export a Credential in a defined format.
char * new_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new scanner page.
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
char * export_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a filter.
char * export_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a user.
char * edit_agent(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_agent XML, XSL transform the result.
char * import_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import report format, get all report formats, XSL transform result.
char * edit_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_alert XML, XSL transform the result.
char * export_agents_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of agents.
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
char * edit_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit override, get next page, XSL transform the result.
params_t * params_values(params_t *params, const char *name)
Get values of param.
int authenticate_omp(const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning, GTree **chart_prefs, gchar **autorefresh)
Check authentication credentials.
char * edit_my_settings_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page with user's settings, for editing.
char * export_report_formats_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of Report Formats.
char * download_ssl_cert(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
Get an SSL Certificate.
char * upload_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the upload scan config page.
char * wizard_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns a wizard page.
char * create_asset_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an asset, get report, XSL transform the result.
char * export_permissions_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of permissions.
char * delete_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete agent, get all agents, XSL transform result.
char * edit_filter(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_filter XML, XSL transform the result.
char * export_asset_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export an asset.
char * export_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a permission.
char * get_permissions_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all permissions, XSL transform the result.
char * resource_action(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, XSL transform result.
char * save_config_family_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of an NVT for a config, XSL transform the result.
char * save_my_settings_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *accept_language, char **timezone, char **password, char **severity, char **language, cmd_response_data_t *response_data)
Returns page with user's settings, for editing.
void cmd_response_data_init(cmd_response_data_t *data)
Initializes a cmd_response_data_t struct.
char * create_port_range_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Add a range to a port list, XSL transform the result.
char * delete_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a scanner, get all scanners, XSL transform the result.
char * get_filters_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all filters, XSL transform the result.
char * sync_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Sync config, get configs, XSL transform the result.
char * new_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new notes page.
char * delete_trash_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash report format, get all trash, XSL transform the result.
char * edit_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_port_list XML, XSL transform the result.
char * capabilities
Capabilites of manager.
char * import_report_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import report, get all reports, XSL transform the result.
char * create_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a task, get all tasks, XSL transform the result.
char * get_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one tag, XSL transform the result.
param_t * params_get(params_t *params, const char *name)
Get param.
char * save_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save note, get next page, XSL transform the result.
char * timezone
User's timezone.
content_type
Content types.
char * get_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one target, XSL transform the result.
char * export_users_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of users.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
char * edit_scanner(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_scanner XML, XSL transform the result.
char * delete_trash_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash config, get all trash, XSL transform the result.
char * export_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a agent.
char * edit_asset(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit XML, XSL transform the result.
gchar * format_file_name(gchar *fname_format, credentials_t *credentials, const char *type, const char *uuid, entity_t resource_entity)
Generates a file name for exporting.
char * get_result_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one result, XSL transform the result.
char * delete_trash_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a filter, get all filters, XSL transform the result.
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
char * save_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, char **password_return, char **modified_user, int *logout_user, cmd_response_data_t *response_data)
Modify a user, get all users, XSL transform the result.
char * restore_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Restore a resource, get all trash, XSL transform the result.
char * create_permissions_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create multiple permission, get next page, XSL transform the result.
char * export_roles_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of roles.
char * export_preference_file_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a file preference.
gchar * manager_address
The address the manager is on.
char * caller
Caller URL, for POST relogin.
char * export_tags_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of tags.
char * export_results_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of results.
char * get_assets_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get assets, XSL transform the result.
char * new_permissions_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
char * delete_trash_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a permission, get all permissions, XSL transform the result.
Response information for commands.
char * get_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one credential, XSL transform the result.
void omp_init(const gchar *manager_address_unix, const gchar *manager_address_tls, int port_manager)
Init the GSA OMP library.
char * logout(credentials_t *credentials, const gchar *message, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
char * save_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a port list, get all port list, XSL transform the result.
char * run_wizard_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Run a wizard and XSL transform the result.
const char * params_filename(params_t *params, const char *name)
Get filename of param.
char * sync_feed_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with an NVT feed and XSL transform the result.
char * download_key_pub(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
Get a Scanner's Certificate.
char * delete_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a filter, get all filters, XSL transform the result.
char * dashboard(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Show a dashboard.
char * resume_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Resume a task, get all tasks, XSL transform the result.
char * new_permissions(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permissions XML, XSL transform the result.
char * cvss_calculator(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
char * toggle_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Set tag enabled status.
char * new_override(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new overrides page.
char * delete_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a task, get all tasks, XSL transform the result.
void set_language_code(gchar **lang, const gchar *language)
Set language code of user.
char * create_report_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a report, get all tasks, XSL transform the result.
int token_user_remove(const char *)
Remove a user from the session "database", releasing the user_t too.
char * delete_trash_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash scanner, get all scanners, XSL transform the result.
char * delete_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a target, get all targets, XSL transform the result.
char * new_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new target.
char * get_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one permission, XSL transform the result.
char * new_port_range_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new Port Range page.
char * sync_scap_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with a SCAP feed and XSL transform the result.
char * edit_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_credential XML, XSL transform the result.
char * get_tasks_chart_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a tasks chart, XSL transform the result.
#define RESULTS_PER_PAGE
Initial filtered results per page on the report summary.
char * get_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one port_list, XSL transform the result.
char * sync_cert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with a CERT feed and XSL transform the result.
char * get_roles_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all roles, XSL transform the result.
void cmd_response_data_reset(cmd_response_data_t *data)
Clears a cmd_response_data_t struct.
char * edit_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_task XML, XSL transform the result.
char * auth_settings_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
char * new_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new report format page.
char * edit_schedule(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_schedule XML, XSL transform the result.
char * get_system_reports_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all system reports, XSL transform the result.
char * export_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a task.
gchar * message_invalid(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
char * get_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a task, XSL transform the result.
Structure of credential related information.
int manager_use_tls
Whether to use TLS for Manager connections.
char * delete_trash_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a role from trash, get all roles, XSL transform the result.
char * export_configs_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of scan configs.
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
char * get_my_settings_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page with user's settings.
char * create_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a schedule, get all schedules, XSL transform the result.
char * delete_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete an alert, get all alerts, XSL transform the result.
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
char * get_one(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, const char *extra_attribs, cmd_response_data_t *response_data)
Get one resource, XSL transform the result.
char * get_trash_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all trash, XSL transform the result.
char * get_report_formats_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all Report Formats, XSL transform the result.
char * edit_tag(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
gchar * accept_language_to_env_fmt(const char *accept_language)
Convert an Accept-Language string to the LANGUAGE env variable form.
char * start_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Start a task, get all tasks, XSL transform the result.
char * username
Name of user.
char * create_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an agent, get all agents, XSL transform result.
char * import_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import port list, get all port_lists, XSL transform the result.
char * get_system_report_omp(openvas_connection_t *connection, credentials_t *credentials, const char *url, params_t *params, enum content_type *content_type, gsize *content_length, cmd_response_data_t *response_data)
Return system report image.
char * get_results_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all results, XSL transform the result.
char * new_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new target.
char * get_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one scanner, XSL transform the result.
char * new_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new agent page.
char * new_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new user.
char * get_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one agent, XSL transform the result.
char * export_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a Port List.
char * edit_user(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
char * delete_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete config, get all configs, XSL transform the result.
char * save_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a tag, get all tags, XSL transform the result.
char * get_tags_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tags, XSL transform the result.
char * export_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a config.
char * process_bulk_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Returns a process_bulk page.
char * get_notes_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all notes, XSL transform the result.
char * export_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a report format.
int user_set_autorefresh(const gchar *token, const gchar *autorefresh)
Set default autorefresh interval of user.
char * edit_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
char * edit_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit note, get next page, XSL transform the result.
char * edit_alert(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_alert XML, XSL transform the result.
char * delete_trash_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a override, get all overrides, XSL transform the result.
char * edit_note(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Edit note, get next page, XSL transform the result.
char * delete_report_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete report, get task status, XSL transform the result.
char * autorefresh
Auto-refresh interval.
char * get_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one report format, XSL transform the result.
GTree * last_filt_ids
Last filter ids.
char * edit_asset_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_asset XML, XSL transform the result.
char * client_address
Client's address.
char * save_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a role, return the next page.
char * get_scanners_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all scanners, XSL transform the result.
char * get_report_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *report_len, gchar **content_type, char **content_disposition, cmd_response_data_t *response_data)
Get a report and XSL transform the result.
char * edit_override(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Edit override, get next page, XSL transform the result.
#define PARAM_OR_SETTING(value, param, setting_id, cleanup)
Get a value from a param or fall back to a setting.
char * wizard_get_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns a wizard_get page.
char * delete_trash_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash port list, get all trash, XSL transform the result.
char * get_credentials_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one or all credentials, XSL transform the result.
char * export_alerts_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of alerts.
char * save_auth_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save authentication settings.
void init_find_by_value(find_by_value_t *find, gchar *value)
char * get_aggregate_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an aggregate of resources.
char * export_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a Credential.
Headers/structs used generally in GSA.
#define CHECK(name)
Check a param.
char * upload_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the upload port list page.
char * export_schedules_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of schedules.
Structure to search a key by value.
char * edit_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_filter XML, XSL transform the result.
char * new_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new group.
char * get_targets_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all targets, XSL transform the result.
char * new_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new overrides page.
char * get_protocol_doc_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get OMP doc.
char * save_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a permission, get all permissions, XSL transform the result.
struct timeval cmd_start
Seconds since command page handler started.
gchar * login_xml(const gchar *message, const gchar *token, const gchar *time, const gchar *url, const gchar *i18n, const gchar *guest)
Generate XML for login page.
char * save_asset_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify an asset, get all assets, XSL transform the result.
char * create_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an override, get report, XSL transform the result.
char * create_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create config, get all configs, XSL transform the result.
char * get_feeds_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get descriptions of the feeds connected to the manager.
char * save_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify an alert, get all alerts, XSL transform the result.
char * create_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a credential, get all credentials, XSL transform result.
int download_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *result_len, char **html, char **filename, cmd_response_data_t *response_data)
Get an agent, XSL transform the result.
char * get_config_nvt_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of an NVT for a config, XSL transform the result.
char * stop_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Stop a task, get all tasks, XSL transform the result.
char * export_tasks_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of tasks.
char * export_credentials_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of Credentials.
char * get_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one filter, XSL transform the result.
char * bulk_delete_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete multiple resources, get next page, XSL transform the result.
char * get_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a config, XSL transform the result.
char * save_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save task, get next page, XSL transform the result.
char * delete_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete override, get next page, XSL transform the result.
char * save_chart_preference_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gchar **pref_id, gchar **pref_value, cmd_response_data_t *response_data)
Save chart preferences.
char * get_info_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get info, XSL transform the result.
char * create_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an alert, get all alerts, XSL transform the result.
char * export_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a note.
char * create_host_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a host, serve next page.
char * delete_trash_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash schedule, get all trash, XSL transform the result.
char * export_port_lists_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of Port Lists.
char * get_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an override, XSL transform the result.
char * edit_config_family_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of a family for editing a config, XSL transform result.
char * new_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new schedule page.
char * new_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new Credential.
char * get_info(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Requests SecInfo.
char * export_groups_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of groups.
char * new_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new Port List page.
char * delete_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a group, get all groups, XSL transform the result.
char * create_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a group, get all groups, XSL transform the result.
char * delete_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete note, get next page, XSL transform the result.
char * export_targets_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of targets.
char * edit_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_report_format XML, XSL transform the result.
char * get_overrides_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all overrides, XSL transform the result.
char * save_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a agent, get all agents, XSL transform the result.
#define GET_TRASH_RESOURCE(capability, command, name)
char * get_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one group, XSL transform the result.
char * create_container_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a container task, serve next page.
char * delete_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a role, get all roles, XSL transform the result.
char * create_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a filter, get all filters, XSL transform the result.
char * get_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one user, XSL transform the result.
char * get_port_lists_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all port_lists, XSL transform the result.
GPtrArray * users
User session data.
char * delete_trash_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash agent, get all agents, XSL transform the result.
char * delete_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete note, get next page, XSL transform the result.
int guest
Whether the user is a guest user.
char * save_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save credential, get next page, XSL transform the result.
char * save_config_nvt_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save NVT prefs for a config, get NVT details, XSL transform result.
char * export_assets_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of assets.
char * get_users_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all users, XSL transform the result.
char * import_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import config, get all configs, XSL transform the result.
int manager_port
The port the manager is on.
char * verify_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify agent, get agents, XSL transform the result.
char * token
Session token.
char * export_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export an override.
const char * params_value(params_t *params, const char *name)
Get value of param.
char * delete_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a user, get all users, XSL transform the result.
char * get_config_family_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of a family for a config, XSL transform the result.
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
char * get_assets_chart_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an assets chart, XSL transform the result.
char * new_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new filter.
char * export_scanners_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of scanners.
char * export_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export an alert.
char * download_ca_pub(openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
Get a Scanner's CA Certificate.
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
char * delete_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a schedule, get all schedules, XSL transform the result.
char * edit_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
char * delete_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a port list, get all port lists, XSL transform the result.
#define GSAD_MESSAGE_INVALID
Answer for invalid input.
char * delete_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete credential, get all credentials, XSL transform result.
char * save_filter_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a filter, get all filters, XSL transform the result.
char * get_reports_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all reports, XSL transform the result.
char * edit_config_nvt_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit details of an NVT for a config, XSL transform the result.
char * edit_target(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_target XML, XSL transform the result.
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
char * edit_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a config, XSL transform the result.
char * save_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a target, get all targets, XSL transform the result.
const gchar * vendor_version_get()
Get the vendor version.
char * new_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new role.
int charts
Whether to show charts for this user.
char * edit_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_group XML, XSL transform the result.
char * delete_trash_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a group from trash, get all groups, XSL transform the result.
char * delete_trash_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash alert, get all trash, XSL transform the result.
char * save_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a group, return the next page.
char * get_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one role, XSL transform the result.
char * export_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a scanner.
char * pw_warning
Password policy warning message.
char * get_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one alert, XSL transform the result.
gchar * redirect
HTTP status code.
char * save_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save report_format, get next page, XSL transform the result.
char * export_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a schedule.
char * export_omp_doc_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Download the OMP doc.
char * verify_report_format_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify report format, get report formats, XSL transform the result.
char * get_alerts_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all alerts, XSL transform the result.
char * edit_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_permission XML, XSL transform the result.
char * export_group_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a group.
char * xsl_transform(const char *xml_text, cmd_response_data_t *response_data)
XSL Transformation.
char * new_host_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new host page.
GTree * chart_prefs
Chart preferences.
char * get_tasks_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tasks, XSL transform the result.
char * new_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
char * new_note(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new notes page.
char * delete_asset_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete an asset, go to the next page.
char * get_report_section_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a report section, XSL transform the result.
char * empty_trashcan_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Empty the trashcan, get all trash, XSL transform the result.
char * severity
Severity class.
char * get_groups_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all groups, XSL transform the result.
char * delete_user_confirm_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Show confirmation deleting a user, XSL transform the result.
char * export_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a target.
char * edit_agent_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_agent XML, XSL transform the result.
char * get_asset_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get asset, XSL transform the result.
void free_find_by_value(find_by_value_t *find)
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
char * get_configs_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all scan configs, XSL transform the result.
char * new_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new alert.
char * create_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a scanner, get all scanners, XSL transform the result.
char * test_alert_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Test an alert, get all alerts XSL transform the result.
#define params_iterator_init
char * current_page
Current page URL, for refresh.
char * move_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Reassign a task to a new OMP slave.
char * get_schedules_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all schedules, XSL transform the result.
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
char * get_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a note, XSL transform the result.
char * new_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new task.
char * language
Accept-Language browser header.
char * new_config_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new scan config page.
char * save_override_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save override, get next page, XSL transform the result.
char * save_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save scanner, get next page, XSL transform the result.
char * edit_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_get_attribs, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit XML, XSL transform the result.
char * new_permission(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
char * export_filters_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of filters.
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_omp.
char * create_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a note, get report, XSL transform the result.
char * clone_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Clone a resource, XSL transform the result.
int manager_connect(credentials_t *credentials, openvas_connection_t *connection, cmd_response_data_t *response_data)
Connect to OpenVAS Manager daemon.
int openvas_connection_open(openvas_connection_t *connection, const gchar *address, int port)
Connect to an address.
char * delete_trash_note_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a note, get all notes, XSL transform the result.
char * edit_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_target XML, XSL transform the result.
params_t * params
Request parameters.
char * ctime_r_strip_newline(time_t *time, char *string)
Return string from ctime_r with newline replaces with terminator.
char * export_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a role.
#define params_iterator_t
Headers for GSA's OMP communication module.
char * export_result_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a result.
void buffer_languages_xml(GString *buffer)
Write the list of installed languages to a buffer as XML.
char * create_user_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a user, get all users, XSL transform the result.
char * delete_permission_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a permission, get all permissions, XSL transform the result.
char * edit_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_schedule XML, XSL transform the result.
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
char * delete_trash_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a note, get all notes, XSL transform the result.
char * edit_group(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_group XML, XSL transform the result.
char * edit_permission(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_permission XML, XSL transform the result.
char * create_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a tag, get report, XSL transform the result.
char * get_agents_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all agents, XSL transform the result.
char * verify_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify scanner, get scanners, XSL transform the result.
char * save_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save schedule, get next page, XSL transform the result.
char * password
User's password.
char * upload_report_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the upload report page.
char * export_notes_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of notes.
char * edit_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_role XML, XSL transform the result.
char * get_nvts_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Requests NVT details, accepting extra commands.
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
char * delete_trash_credential_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash credential, get all trash, XSL transform the result.
char * export_tag_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a tag.
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
char * create_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a target, get all targets, XSL transform the result.
char * edit_scanner_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_scanner XML, XSL transform the result.
char * export_overrides_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a list of overrides.
char * get_schedule_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one schedule, XSL transform the result.
char * create_port_list_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a port list, get all port lists, XSL transform the result.
char * delete_trash_target_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash target, get all trash, XSL transform the result.
int connect_unix(const gchar *path)
Connect to OpenVAS Manager daemon.
char * delete_trash_task_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash task, get all trash, XSL transform the result.
char * create_role_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a role, get all roles, XSL transform the result.