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"
227 gchar **,
char **,
const char *,
int *,
280 static int omp_success (entity_t entity);
283 const char *,
const char *,
const char *,
287 const char*,
const char*,
const char*,
291 entity_t,
int,
const char*,
const char *,
292 const char*,
const char*,
const char*,
307 return strstr (credentials->
capabilities, name) ? 1 : 0;
318 omp_init (
const gchar *manager_address_unix,
const gchar *manager_address_tls,
321 if (manager_address_unix)
326 else if (manager_address_tls)
374 print_chart_pref (gchar *
id, gchar *
value, GString* buffer)
376 g_string_append_printf (buffer,
377 "<chart_preference id=\"%s\">"
379 "</chart_preference>",
404 g_list_free (find->
keys);
420 if (strcmp (value, data->
value) == 0)
422 g_debug (
"%s found key %s for value %s\n",
423 __FUNCTION__, key, value);
424 data->
keys = g_list_append (data->
keys, key);
438 filter_exists (openvas_connection_t *connection,
const char *filt_id)
443 || strcmp (filt_id,
"0")
444 || strcmp (filt_id,
"-2"))
448 if (openvas_connection_sendf (connection,
"<get_filters filter_id='%s'/>",
454 if (read_entity_c (connection, &entity))
459 return omp_success (entity);
482 const char *refresh_interval, *xml_flag;
485 assert (credentials);
490 string = g_string_new (
"");
492 gettimeofday (&tv, NULL);
493 res = g_markup_printf_escaped (
"<envelope>"
494 "<version>%s</version>"
495 "<vendor_version>%s</vendor_version>"
497 "<caller>%s</caller>"
498 "<current_page>%s</current_page>"
500 "<timezone>%s</timezone>"
503 "<severity>%s</severity>"
505 "<charts>%d</charts>"
507 "<client_address>%s</client_address>"
508 "<backend_operation>%.2f</backend_operation>",
534 g_string_append (
string, res);
537 g_string_append (
string,
"<chart_preferences>");
539 (GTraverseFunc)print_chart_pref,
541 g_string_append (
string,
"</chart_preferences>");
546 warning_elem = g_markup_printf_escaped (
"<password_warning>"
548 "</password_warning>",
550 g_string_append (
string, warning_elem);
551 g_free (warning_elem);
555 if ((refresh_interval == NULL) || (strcmp (refresh_interval,
"") == 0))
556 g_string_append_printf (
string,
557 "<autorefresh interval=\"%s\"/>",
562 gchar *interval_64, *response;
565 interval_64 = (refresh_interval
566 ? g_base64_encode ((guchar*) refresh_interval,
567 strlen (refresh_interval))
569 ret = ompf (credentials, &response, &entity, response_data,
571 " setting_id=\"578a1c14-e2dc-45ef-a591-89d31391d007\">"
575 g_free (interval_64);
584 "Internal error", __FUNCTION__, __LINE__,
585 "An internal error occurred while modifying the"
586 " autorefresh setting for the settings. "
587 "Diagnostics: Failure to send command to"
589 "/omp?cmd=get_my_settings", response_data);
593 "Internal error", __FUNCTION__, __LINE__,
594 "An internal error occurred while modifying the"
595 " autorefresh setting for the settings. "
596 "Diagnostics: Failure to receive response from"
598 "/omp?cmd=get_my_settings", response_data);
602 "Internal error", __FUNCTION__, __LINE__,
603 "An internal error occurred while modifying the"
604 " autorefresh setting for the settings. "
605 "Diagnostics: Internal Error.",
606 "/omp?cmd=get_my_settings", response_data);
609 free_entity (entity);
611 credentials->
autorefresh = g_strdup (refresh_interval);
614 g_string_append_printf (
string,
615 "<autorefresh interval=\"%s\"/>",
619 g_string_append (
string,
"<params>");
623 if (name && strcmp (name,
""))
625 if ((name[strlen (name) - 1] ==
':') && param->
values)
634 if (child_param->
value
635 && child_param->
valid
637 xml_string_append (
string,
639 "<name>%s%s</name><value>%s</value>"
641 name, child_name, child_param->
value);
645 && strcmp (name,
"xml_file") && strcmp (name,
"installer"))
646 xml_string_append (
string,
"<%s>%s</%s>", name, param->
value, name);
649 g_warning (
"%s: Param without name found", __FUNCTION__);
651 g_string_append (
string,
"</params>");
653 g_string_append_printf (
string,
654 "<capabilities>%s</capabilities>"
662 if (xml_flag && strcmp (xml_flag,
"0"))
663 return g_string_free (
string, FALSE);
666 g_string_free (
string, TRUE);
670 res = g_strdup_printf (
"<gsad_response>"
671 "<title>Internal Error</title>"
673 "An internal server error has occurred during XSL"
676 "<backurl>/omp?cmd=get_tasks</backurl>"
680 html = g_strdup (
"<html>"
682 "An internal server error has occurred during XSL"
700 member (
params_t *params,
const char *
string)
708 if (strcmp (name,
string) == 0)
return 1;
730 && param->
value[0] ==
'1'
731 && strcmp (name,
string) == 0)
751 openvas_connection_t *connection,
params_t *params,
752 const char* next,
const char* fail_next,
int* success,
757 const char *no_redirect, *status_text;
768 if (read_entity_c (connection, &entity))
772 "Internal error", __FUNCTION__, __LINE__,
773 "An internal error occurred while saving a config. "
774 "It is unclear whether the entire config has been saved. "
775 "Diagnostics: Failure to read command to manager daemon.",
776 "/omp?cmd=get_configs", response_data);
781 status_text = entity_attribute (entity,
"status_text");
782 if (status_text == NULL)
784 free_entity (entity);
787 "Internal error", __FUNCTION__, __LINE__,
788 "An internal error occurred while saving a config. "
789 "It is unclear whether the entire config has been saved. "
790 "Diagnostics: Failure to parse status_text from response.",
791 "/omp?cmd=get_configs", response_data);
794 if (strcmp (status_text,
"Config is in use") == 0)
796 const char* message =
"The config is now in use by a task,"
797 " so only name and comment can be modified.";
798 gchar *next_url = next_page_url (credentials, params,
801 entity_attribute (entity,
"status"),
806 = action_result_page (credentials, response_data,
"Save Config",
807 entity_attribute (entity,
"status"),
811 free_entity (entity);
814 else if (strcmp (status_text,
"MODIFY_CONFIG name must be unique") == 0)
816 const char* message =
"A config with the given name exists already.";
817 gchar *next_url = next_page_url (credentials, params,
820 entity_attribute (entity,
"status"),
825 = action_result_page (credentials, response_data,
"Save Config",
826 entity_attribute (entity,
"status"),
830 free_entity (entity);
833 else if (success && omp_success (entity))
839 = response_from_entity (credentials, params, entity,
840 (no_redirect && strcmp (no_redirect,
"0")),
843 "Save Config", response_data);
844 free_entity (entity);
857 omp_success (entity_t entity)
864 status = entity_attribute (entity,
"status");
866 || (strlen (status) == 0))
869 return status[0] ==
'2';
884 else if (strcmp (entity_attribute (entity,
"status_text"),
888 else if (strcmp (entity_attribute (entity,
"status"),
"404") == 0)
907 omp (
credentials_t *credentials, gchar **response, entity_t *entity_return,
910 openvas_connection_t connection;
915 *entity_return = NULL;
917 switch (
manager_connect (credentials, &connection, response, response_data))
928 "Internal error", __FUNCTION__, __LINE__,
929 "An internal error occurred. "
930 "Diagnostics: Failure to connect to manager daemon.",
931 "/omp?cmd=get_tasks", response_data);
935 ret = openvas_connection_sendf (&connection,
"%s", command);
938 openvas_connection_close (&connection);
943 if (read_entity_and_text_c (&connection, &entity, response))
945 openvas_connection_close (&connection);
949 *entity_return = entity;
951 free_entity (entity);
952 openvas_connection_close (&connection);
970 simple_ompf (
const gchar *message_operation,
credentials_t *credentials,
972 const char *format, ...)
979 va_start (args, format);
980 command = g_markup_vprintf_escaped (format, args);
983 ret = omp (credentials, response, &entity, response_data, command);
998 message = g_strdup_printf
999 (
"An internal error occurred while %s. "
1000 " The operation was not started."
1001 " Diagnostics: Failure to send command to manager"
1005 :
"performing an operation");
1006 *response =
gsad_message (credentials,
"Internal error",
1007 __FUNCTION__, __LINE__,
1008 message,
"/omp?cmd=get_tasks",
1019 message = g_strdup_printf
1020 (
"An internal error occurred while %s."
1021 " It is unclear whether the operation succeeded."
1022 " Diagnostics: Failure to receive response from manager"
1026 :
"performing an operation");
1027 *response =
gsad_message (credentials,
"Internal error",
1028 __FUNCTION__, __LINE__,
1029 message,
"/omp?cmd=get_tasks",
1040 message = g_strdup_printf
1041 (
"An internal error occurred while %s."
1042 " It is unclear whether the operation succeeded."
1043 " Diagnostics: Internal Error.",
1046 :
"performing an operation");
1047 *response =
gsad_message (credentials,
"Internal error",
1048 __FUNCTION__, __LINE__,
1049 message,
"/omp?cmd=get_tasks",
1056 switch (omp_success (entity))
1069 free_entity (entity);
1087 ompf (
credentials_t *credentials, gchar **response, entity_t *entity_return,
1094 va_start (args, format);
1095 command = g_markup_vprintf_escaped (format, args);
1098 ret = omp (credentials, response, entity_return, response_data, command);
1114 setting_get_value (openvas_connection_t *connection,
const char *setting_id,
1124 ret = openvas_connection_sendf
1126 "<get_settings setting_id=\"%s\"/>",
1132 if (read_entity_and_text_c (connection, &entity, &response))
1135 status = entity_attribute (entity,
"status");
1137 || strlen (status) == 0)
1140 free_entity (entity);
1144 if (status[0] ==
'2')
1147 setting = entity_child (entity,
"setting");
1148 if (setting == NULL)
1150 free_entity (entity);
1154 setting = entity_child (setting,
"value");
1155 if (setting == NULL)
1157 free_entity (entity);
1161 *value = g_strdup (entity_text (setting));
1163 free_entity (entity);
1169 free_entity (entity);
1184 #define CHECK_PARAM(name, op_name, ret_func) \
1187 gchar *msg, *ret_html; \
1188 msg = g_strdup_printf (GSAD_MESSAGE_INVALID, \
1189 "Given " G_STRINGIFY (name) " was invalid", \
1191 ret_html = ret_func (credentials, params, msg, response_data); \
1193 response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \
1204 #define CHECK_PARAM_INVALID(name, op_name, next_cmd) \
1207 return message_invalid (credentials, params, response_data, \
1208 "Given " G_STRINGIFY (name) " was invalid", \
1209 G_STRINGIFY (MHD_HTTP_BAD_REQUEST), \
1210 op_name, next_cmd); \
1228 url = g_string_new (
"");
1230 if (credentials->
caller && strlen (credentials->
caller))
1232 gchar **split_question, *page, *params;
1234 split_question = g_strsplit (credentials->
caller,
"?", 2);
1236 page = *split_question;
1240 g_string_append_printf (url,
"%s?cmd=%s", page, cmd);
1241 params = split_question[1];
1245 g_string_append_printf (url,
"cmd=%s", cmd);
1246 params = credentials->
caller;
1250 gchar **split_amp, **point;
1252 point = split_amp = g_strsplit (params,
"&", 0);
1261 if (strstr (param,
"cmd=") == param)
1267 g_string_append_printf (url,
"&%s", param);
1271 g_strfreev (split_amp);
1273 g_strfreev (split_question);
1276 g_string_append_printf (url,
"?cmd=%s", cmd);
1278 return g_string_free (url, FALSE);
1289 capitalize (
const char* input)
1296 int first_letter = 1;
1298 output = g_strdup (input);
1302 if (g_ascii_isalpha (output[pos]) && first_letter)
1304 output[pos] = g_ascii_toupper (output[pos]);
1307 else if (output[pos] ==
'_')
1336 const char* override_next,
const char *default_next,
1337 const char* prev_action,
const char* action_status,
1338 const char* action_message)
1341 const char *next_cmd, *xml_param, *next_xml_param;
1346 if (action_status && strcmp (action_status,
"") && action_status[0] !=
'2')
1351 url = g_string_new (
"/omp?cmd=");
1354 next_cmd = override_next;
1359 else if (default_next)
1360 next_cmd = default_next;
1362 next_cmd =
"get_tasks";
1367 g_string_append (url, next_cmd);
1372 if (strcmp (param_name,
"asset_type") == 0
1373 || strcmp (param_name,
"filter") == 0
1374 || strcmp (param_name,
"filt_id") == 0
1375 || (strstr (param_name,
"_id")
1376 == param_name + strlen (param_name) - strlen (
"_id"))
1377 || (strcmp (param_name,
"name") == 0
1378 && strcasecmp (prev_action,
"Run Wizard") == 0)
1379 || (strcmp (param_name,
"get_name") == 0
1380 && strcasecmp (next_cmd,
"wizard_get") == 0))
1382 g_string_append_printf (url,
"&%s=%s",
1384 current_param->
value
1385 ? current_param->
value
1392 g_string_append_printf (url,
"&xml=%s", next_xml_param);
1396 g_string_append_printf (url,
"&xml=%s", xml_param);
1401 gchar *escaped = g_uri_escape_string (action_status, NULL, FALSE);
1402 g_string_append_printf (url,
"&action_status=%s", escaped);
1408 gchar *escaped = g_uri_escape_string (action_message, NULL, FALSE);
1409 g_string_append_printf (url,
"&action_message=%s", escaped);
1415 gchar *escaped = g_uri_escape_string (prev_action, NULL, FALSE);
1416 g_string_append_printf (url,
"&prev_action=%s", escaped);
1421 g_string_append_printf (url,
"&token=%s", credentials->
token);
1423 return g_string_free (url, FALSE);
1441 const char* action,
const char* status,
1442 const char* message,
const char* next_url)
1445 xml = g_markup_printf_escaped (
"<action_result>"
1446 "<action>%s</action>"
1447 "<status>%s</status>"
1448 "<message>%s</message>"
1451 action ? action :
"",
1452 status ? status :
"",
1453 message ? message :
"",
1454 next_url ? next_url :
"");
1455 return xsl_transform_omp (credentials, xml, response_data);
1474 const char *status,
const char *op_name,
const char *next_cmd)
1479 next_url = next_page_url (credentials, params, next_cmd, NULL, op_name,
1481 ret = action_result_page (credentials, response_data, op_name,
1482 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
1495 entity_t entity,
int no_redirect,
1496 const char* override_next,
const char *default_next,
1497 const char* override_fail_next,
1498 const char* default_fail_next,
1501 gchar *res, *next_url;
1503 success = omp_success (entity);
1507 next_url = next_page_url (credentials, params,
1508 override_next, default_next,
1510 entity_attribute (entity,
"status"),
1511 entity_attribute (entity,
"status_text"));
1516 next_url = next_page_url (credentials, params,
1517 override_fail_next, default_fail_next,
1519 entity_attribute (entity,
"status"),
1520 entity_attribute (entity,
"status_text"));
1523 if (no_redirect || success == 0)
1525 res = action_result_page (credentials, response_data, action,
1526 entity_attribute (entity,
"status"),
1527 entity_attribute (entity,
"status_text"),
1534 response_data->
redirect = next_url;
1554 credentials->
current_page = page_url (credentials, next);
1555 if (g_utf8_validate (credentials->
current_page, -1, NULL) == FALSE)
1558 g_warning (
"%s - current_page is not valid UTF-8", __FUNCTION__);
1562 if (strcmp (next,
"edit_role") == 0)
1563 return edit_role (credentials, params, response, response_data);
1565 if (strcmp (next,
"edit_task") == 0)
1566 return edit_task (credentials, params, response, response_data);
1568 if (strcmp (next,
"get_alerts") == 0)
1569 return get_alerts (credentials, params, response, response_data);
1571 if (strcmp (next,
"get_alert") == 0)
1572 return get_alert (credentials, params, response, response_data);
1574 if (strcmp (next,
"edit_port_list") == 0)
1575 return edit_port_list (credentials, params, response, response_data);
1577 if (strcmp (next,
"get_agents") == 0)
1578 return get_agents (credentials, params, response, response_data);
1580 if (strcmp (next,
"get_agent") == 0)
1581 return get_agent (credentials, params, response, response_data);
1583 if (strcmp (next,
"get_asset") == 0)
1584 return get_asset (credentials, params, response, response_data);
1586 if (strcmp (next,
"get_assets") == 0)
1587 return get_assets (credentials, params, response, response_data);
1589 if (strcmp (next,
"get_assets_chart") == 0)
1590 return get_assets_chart (credentials, params, response, response_data);
1592 if (strcmp (next,
"get_config") == 0)
1593 return get_config (credentials, params, response, 0, response_data);
1595 if (strcmp (next,
"get_configs") == 0)
1596 return get_configs (credentials, params, response, response_data);
1598 if (strcmp (next,
"get_filter") == 0)
1599 return get_filter (credentials, params, response, response_data);
1601 if (strcmp (next,
"get_filters") == 0)
1602 return get_filters (credentials, params, response, response_data);
1604 if (strcmp (next,
"get_group") == 0)
1605 return get_group (credentials, params, response, response_data);
1607 if (strcmp (next,
"get_groups") == 0)
1608 return get_groups (credentials, params, response, response_data);
1610 if (strcmp (next,
"get_credential") == 0)
1611 return get_credential (credentials, params, response, response_data);
1613 if (strcmp (next,
"get_credentials") == 0)
1614 return get_credentials (credentials, params, response, response_data);
1616 if (strcmp (next,
"get_note") == 0)
1617 return get_note (credentials, params, response, response_data);
1619 if (strcmp (next,
"get_notes") == 0)
1620 return get_notes (credentials, params, response, response_data);
1622 if (strcmp (next,
"get_nvts") == 0)
1623 return get_nvts (credentials, params, NULL, response, response_data);
1625 if (strcmp (next,
"get_override") == 0)
1626 return get_override (credentials, params, response, response_data);
1628 if (strcmp (next,
"get_overrides") == 0)
1629 return get_overrides (credentials, params, response, response_data);
1631 if (strcmp (next,
"get_permission") == 0)
1632 return get_permission (credentials, params, response, response_data);
1634 if (strcmp (next,
"get_permissions") == 0)
1635 return get_permissions (credentials, params, response, response_data);
1637 if (strcmp (next,
"get_port_list") == 0)
1638 return get_port_list (credentials, params, response, response_data);
1640 if (strcmp (next,
"get_port_lists") == 0)
1641 return get_port_lists (credentials, params, response, response_data);
1643 if (strcmp (next,
"get_tag") == 0)
1644 return get_tag (credentials, params, response, response_data);
1646 if (strcmp (next,
"get_tags") == 0)
1647 return get_tags (credentials, params, response, response_data);
1649 if (strcmp (next,
"get_target") == 0)
1650 return get_target (credentials, params, response, response_data);
1652 if (strcmp (next,
"get_targets") == 0)
1653 return get_targets (credentials, params, response, response_data);
1655 if (strcmp (next,
"get_task") == 0)
1656 return get_task (credentials, params, response, response_data);
1658 if (strcmp (next,
"get_tasks") == 0)
1659 return get_tasks (credentials, params, response, response_data);
1661 if (strcmp (next,
"get_tasks_chart") == 0)
1662 return get_tasks_chart (credentials, params, response, response_data);
1664 if (strcmp (next,
"get_report") == 0)
1669 result = get_report (credentials, params, NULL, NULL, NULL,
1670 NULL, response, &error, response_data);
1672 return error ? result : xsl_transform_omp (credentials, result,
1676 if (strcmp (next,
"get_report_format") == 0)
1677 return get_report_format (credentials, params, response, response_data);
1679 if (strcmp (next,
"get_report_formats") == 0)
1680 return get_report_formats (credentials, params, response, response_data);
1682 if (strcmp (next,
"get_report_section") == 0)
1683 return get_report_section (credentials, params, response, response_data);
1685 if (strcmp (next,
"get_reports") == 0)
1686 return get_reports (credentials, params, response, response_data);
1688 if (strcmp (next,
"get_results") == 0)
1689 return get_results (credentials, params, response, response_data);
1691 if (strcmp (next,
"get_result") == 0)
1692 return get_result_page (credentials, params, response, response_data);
1694 if (strcmp (next,
"get_role") == 0)
1695 return get_role (credentials, params, response, response_data);
1697 if (strcmp (next,
"get_roles") == 0)
1698 return get_roles (credentials, params, response, response_data);
1700 if (strcmp (next,
"get_scanner") == 0)
1701 return get_scanner (credentials, params, response, response_data);
1703 if (strcmp (next,
"get_scanners") == 0)
1704 return get_scanners (credentials, params, response, response_data);
1706 if (strcmp (next,
"get_schedule") == 0)
1707 return get_schedule (credentials, params, response, response_data);
1709 if (strcmp (next,
"get_schedules") == 0)
1710 return get_schedules (credentials, params, response, response_data);
1712 if (strcmp (next,
"get_user") == 0)
1713 return get_user (credentials, params, response, response_data);
1715 if (strcmp (next,
"get_users") == 0)
1716 return get_users (credentials, params, response, response_data);
1718 if (strcmp (next,
"get_info") == 0)
1719 return get_info (credentials, params, response, response_data);
1721 if (strcmp (next,
"wizard") == 0)
1722 return wizard (credentials, params, response, response_data);
1724 if (strcmp (next,
"wizard_get") == 0)
1725 return wizard_get (credentials, params, response, response_data);
1750 return generate_page (credentials, params, response, next, response_data);
1767 const char *extra_xml,
const char *extra_attribs,
1771 openvas_connection_t connection;
1773 gchar *html, *end, *id_name;
1774 const char *id, *sort_field, *sort_order, *filter, *first, *max;
1776 id_name = g_strdup_printf (
"%s_id", type);
1786 "Internal error", __FUNCTION__, __LINE__,
1787 "An internal error occurred while getting a resource. "
1788 "Diagnostics: missing ID.",
1789 "/omp?cmd=get_tasks", response_data);
1792 switch (
manager_connect (credentials, &connection, &html, response_data))
1803 "Internal error", __FUNCTION__, __LINE__,
1804 "An internal error occurred while getting a resource. "
1805 "The resource is currently not available. "
1806 "Diagnostics: Failure to connect to manager daemon.",
1807 "/omp?cmd=get_tasks", response_data);
1810 xml = g_string_new (
"");
1811 g_string_append_printf (xml,
"<get_%s>", type);
1813 if (strcmp (type,
"role") == 0
1822 switch (ompf (credentials, &response, &entity, response_data,
1824 " filter=\"rows=-1 subject_type=role and subject_uuid=%s\"/>",
1833 "Internal error", __FUNCTION__, __LINE__,
1834 "An internal error occurred getting permissions. "
1835 "Diagnostics: Failure to send command to manager daemon.",
1836 "/omp?cmd=get_roles", response_data);
1840 "Internal error", __FUNCTION__, __LINE__,
1841 "An internal error occurred getting permissions. "
1842 "Diagnostics: Failure to receive response from manager daemon.",
1843 "/omp?cmd=get_roles", response_data);
1847 "Internal error", __FUNCTION__, __LINE__,
1848 "An internal error occurred getting permissins. "
1849 "Diagnostics: Internal Error.",
1850 "/omp?cmd=get_roles", response_data);
1853 g_string_append (xml, response);
1855 if (!omp_success (entity))
1858 free_entity (entity);
1866 end = g_markup_printf_escaped (
"<filters><term>%s</term></filters>"
1867 "<%ss start=\"%s\" max=\"%s\"/>",
1868 filter ? filter :
"",
1872 g_string_append (xml, end);
1876 g_string_append (xml, extra_xml);
1880 if (openvas_connection_sendf (&connection,
1883 " sort_field=\"%s\""
1884 " sort_order=\"%s\""
1890 sort_field ? sort_field :
"name",
1891 sort_order ? sort_order :
"ascending",
1892 extra_attribs ? extra_attribs :
"")
1895 g_string_free (xml, TRUE);
1896 openvas_connection_close (&connection);
1899 "Internal error", __FUNCTION__, __LINE__,
1900 "An internal error occurred while getting resources list. "
1901 "The current list of resources is not available. "
1902 "Diagnostics: Failure to send command to manager daemon.",
1903 "/omp?cmd=get_resources", response_data);
1906 if (read_string_c (&connection, &xml))
1908 g_string_free (xml, TRUE);
1909 openvas_connection_close (&connection);
1912 "Internal error", __FUNCTION__, __LINE__,
1913 "An internal error occurred while getting resources list. "
1914 "The current list of resources is not available. "
1915 "Diagnostics: Failure to receive response from manager daemon.",
1916 "/omp?cmd=get_resources", response_data);
1921 if (openvas_connection_sendf (&connection,
1923 " filter=\"resource_type=%s"
1931 g_string_free (xml, TRUE);
1932 openvas_connection_close (&connection);
1935 "Internal error", __FUNCTION__, __LINE__,
1936 "An internal error occurred while getting tag names list. "
1937 "The current list of resources is not available. "
1938 "Diagnostics: Failure to send command to manager daemon.",
1939 "/omp?cmd=get_resources", response_data);
1942 if (read_string_c (&connection, &xml))
1944 g_string_free (xml, TRUE);
1945 openvas_connection_close (&connection);
1948 "Internal error", __FUNCTION__, __LINE__,
1949 "An internal error occurred while getting tag names list. "
1950 "The current list of resources is not available. "
1951 "Diagnostics: Failure to receive response from manager daemon.",
1952 "/omp?cmd=get_resources", response_data);
1957 g_string_append (xml,
"<permissions>");
1959 if ((strcmp (type,
"user") == 0)
1960 || (strcmp (type,
"group") == 0)
1961 || (strcmp (type,
"role") == 0))
1962 ret = openvas_connection_sendf (&connection,
1964 " filter=\"subject_uuid=%s"
1965 " and not resource_uuid="""
1966 " or resource_uuid=%s"
1967 " first=1 rows=-1\"/>",
1971 ret = openvas_connection_sendf (&connection,
1973 " filter=\"resource_uuid=%s"
1974 " first=1 rows=-1\"/>",
1978 g_string_free (xml, TRUE);
1979 openvas_connection_close (&connection);
1982 "Internal error", __FUNCTION__, __LINE__,
1983 "An internal error occurred while getting permissions list. "
1984 "The current list of resources is not available. "
1985 "Diagnostics: Failure to send command to manager daemon.",
1986 "/omp?cmd=get_resources", response_data);
1989 if (read_string_c (&connection, &xml))
1991 g_string_free (xml, TRUE);
1992 openvas_connection_close (&connection);
1995 "Internal error", __FUNCTION__, __LINE__,
1996 "An internal error occurred while getting permissions list. "
1997 "The current list of resources is not available. "
1998 "Diagnostics: Failure to receive response from manager daemon.",
1999 "/omp?cmd=get_resources", response_data);
2002 g_string_append (xml,
"</permissions>");
2006 g_string_append_printf (xml,
"</get_%s>", type);
2007 openvas_connection_close (&connection);
2008 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
2026 const char *extra_xml,
const char *extra_attribs,
2031 openvas_connection_t connection;
2032 gchar *filter_type, *html, *request, *built_filter;
2033 int no_filter_history;
2034 const char *build_filter, *given_filt_id, *filt_id, *filter, *filter_extra;
2035 const char *first, *max, *sort_field, *sort_order, *owner, *permission;
2036 const char *replace_task_id;
2037 const char *overrides, *autofp, *autofp_value, *min_qod;
2038 const char *level_high, *level_medium, *level_low, *level_log;
2039 const char *level_false_positive;
2041 no_filter_history =
params_value(params,
"no_filter_history")
2050 replace_task_id =
params_value (params,
"replace_task_id");
2063 level_false_positive =
params_value (params,
"level_false_positive");
2065 if (strcasecmp (type,
"info") == 0)
2066 filter_type = g_strdup (
params_value (params,
"info_type"));
2068 filter_type = g_strdup (type);
2072 if (no_filter_history == 0 && strcmp (given_filt_id,
"0"))
2074 g_strdup (given_filt_id));
2075 filt_id = given_filt_id;
2079 if (no_filter_history == 0
2080 && (filter == NULL || strcmp (filter,
"") == 0))
2081 filt_id = g_tree_lookup (credentials->
last_filt_ids, filter_type);
2084 g_free (filter_type);
2087 switch (
manager_connect (credentials, &connection, &html, response_data))
2098 "Internal error", __FUNCTION__, __LINE__,
2099 "An internal error occurred while getting a resource list. "
2100 "The current list of resources is not available. "
2101 "Diagnostics: Failure to connect to manager daemon.",
2102 "/omp?cmd=get_tasks", response_data);
2106 switch (filter_exists (&connection, filt_id))
2111 g_debug (
"%s filter doesn't exist anymore %s!\n", __FUNCTION__,
2116 g_debug (
"%s filter response didn't contain a status!\n", __FUNCTION__);
2120 g_debug (
"%s could not send filter request!\n", __FUNCTION__);
2124 g_debug (
"%s could not read entity from filter response!\n",
2132 xml = g_string_new (
"");
2133 type_many = g_string_new (type);
2136 if (strcmp (type,
"info") != 0)
2137 g_string_append (type_many,
"s");
2139 g_string_append_printf (xml,
"<get_%s>", type_many->str);
2142 g_string_append (xml, extra_xml);
2144 built_filter = NULL;
2146 || (strcmp (filt_id,
"") == 0)
2147 || (strcmp (filt_id,
"--") == 0))
2149 if ((build_filter && (strcmp (build_filter,
"1") == 0))
2150 || ((filter == NULL || strcmp (filter,
"") == 0)
2151 && (filter_extra == NULL || strcmp (filter_extra,
"") == 0)))
2153 if (build_filter && (strcmp (build_filter,
"1") == 0))
2156 const char *search_phrase, *task_id;
2158 if (strcmp (type,
"report") == 0
2159 || strcmp (type,
"task") == 0)
2161 task = g_strdup_printf (
"apply_overrides=%i min_qod=%s ",
2163 && strcmp (overrides,
"0"),
2164 min_qod ? min_qod :
"");
2166 else if (strcmp (type,
"result") == 0)
2169 = g_strdup_printf (
"%s%s%s%s%s",
2170 level_high ?
"h" :
"",
2171 level_medium ?
"m" :
"",
2172 level_low ?
"l" :
"",
2173 level_log ?
"g" :
"",
2174 level_false_positive ?
"f" :
"");
2175 task = g_strdup_printf (
"apply_overrides=%i min_qod=%s"
2176 " autofp=%s levels=%s ",
2178 && strcmp (overrides,
"0")),
2179 min_qod ? min_qod :
"",
2180 (autofp && autofp_value)
2181 ? autofp_value :
"0",
2188 search_phrase =
params_value (params,
"search_phrase");
2190 built_filter = g_strdup_printf
2191 (
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
2193 task_id ?
"task_id=" :
"",
2194 task_id ? task_id :
"",
2196 first ?
"first=" :
"",
2203 ? ((sort_order && strcmp (sort_order,
2208 sort_field ? sort_field :
"",
2209 sort_field ?
" " :
"",
2210 permission ?
"permission=" :
"",
2211 permission ? permission :
"",
2212 permission ?
" " :
"",
2213 owner ?
"owner=" :
"",
2216 (filter && search_phrase) ?
" " :
"",
2217 filter ? filter :
"",
2218 search_phrase ?
" " :
"",
2225 else if (strcmp (type,
"info") == 0
2228 if (strcmp (
params_value (params,
"info_type"),
"cve") == 0)
2229 filter =
"sort-reverse=published rows=-2";
2231 filter =
"sort-reverse=created rows=-2";
2233 else if (strcmp (type,
"user") == 0)
2234 filter =
"sort=roles rows=-2";
2235 else if (strcmp (type,
"report") == 0)
2237 const char *task_id;
2240 built_filter = g_strdup_printf (
"task_id=%s apply_overrides=1"
2241 " rows=-2 sort-reverse=date",
2244 filter =
"apply_overrides=1 rows=-2 sort-reverse=date";
2246 else if (strcmp (type,
"result") == 0)
2249 = g_strdup_printf(
"apply_overrides=%d autofp=%s rows=-2"
2250 " sort-reverse=created",
2252 || strcmp (overrides,
"0")),
2253 (autofp && strcmp (autofp,
"0"))
2257 else if (strcmp (type,
"task"))
2260 filter =
"apply_overrides=1 rows=-2";
2261 if (filt_id && strcmp (filt_id,
""))
2267 else if ((strcmp (filter,
"sort=nvt") == 0)
2268 && ((strcmp (type,
"note") == 0)
2269 || (strcmp (type,
"override") == 0)))
2271 else if ((strcmp (filter,
"apply_overrides=1") == 0)
2272 && (strcmp (type,
"task") == 0))
2275 else if (replace_task_id)
2277 const char *task_id;
2280 built_filter = g_strdup_printf (
"task_id=%s %s",
2282 filter ? filter :
"");
2287 request = g_markup_printf_escaped (
" %sfilt_id=\"%s\""
2288 " %sfilter=\"%s%s%s%s\""
2289 " filter_replace=\"%s\""
2292 " sort_field=\"%s\""
2293 " sort_order=\"%s\"",
2294 strcmp (type,
"report") ?
"" :
"report_",
2295 filt_id ? filt_id :
"0",
2296 strcmp (type,
"report") ?
"" :
"report_",
2299 : (filter ? filter :
""),
2300 filter_extra ?
" " :
"",
2301 filter_extra ? filter_extra :
"",
2302 filter_extra ?
" " :
"",
2303 replace_task_id ?
"task_id" :
"",
2304 first ? first :
"1",
2306 sort_field ? sort_field :
"name",
2307 sort_order ? sort_order :
"ascending");
2309 g_free (built_filter);
2310 if (openvas_connection_sendf (&connection,
2313 strcmp (type,
"report") ?
"" :
" details=\"0\"",
2315 extra_attribs ? extra_attribs :
"")
2319 g_string_free (xml, TRUE);
2320 g_string_free (type_many, TRUE);
2321 openvas_connection_close (&connection);
2324 "Internal error", __FUNCTION__, __LINE__,
2325 "An internal error occurred while getting a resource list. "
2326 "The current list of resources is not available. "
2327 "Diagnostics: Failure to send command to manager daemon.",
2328 "/omp?cmd=get_tasks", response_data);
2331 if (read_string_c (&connection, &xml))
2333 g_string_free (xml, TRUE);
2334 g_string_free (type_many, TRUE);
2335 openvas_connection_close (&connection);
2338 "Internal error", __FUNCTION__, __LINE__,
2339 "An internal error occurred while getting resources list. "
2340 "The current list of resources is not available. "
2341 "Diagnostics: Failure to receive response from manager daemon.",
2342 "/omp?cmd=get_tasks", response_data);
2351 g_string_append (xml,
"<filters>");
2353 if (openvas_connection_sendf_xml
2356 " filter=\"rows=-1 type=%s or type=\"/>",
2360 g_string_free (xml, TRUE);
2361 g_string_free (type_many, TRUE);
2362 openvas_connection_close (&connection);
2365 "Internal error", __FUNCTION__, __LINE__,
2366 "An internal error occurred while getting the filter list. "
2367 "The current list of filters is not available. "
2368 "Diagnostics: Failure to send command to manager daemon.",
2369 "/omp?cmd=get_tasks", response_data);
2372 if (read_string_c (&connection, &xml))
2374 g_string_free (xml, TRUE);
2375 g_string_free (type_many, TRUE);
2376 openvas_connection_close (&connection);
2379 "Internal error", __FUNCTION__, __LINE__,
2380 "An internal error occurred while getting the filter list. "
2381 "The current list of filters is not available. "
2382 "Diagnostics: Failure to receive response from manager daemon.",
2383 "/omp?cmd=get_tasks", response_data);
2386 g_string_append (xml,
"</filters>");
2393 if (openvas_connection_sendf_xml
2396 " setting_id=\"20f3034c-e709-11e1-87e7-406186ea4fc5\"/>",
2400 g_string_free (xml, TRUE);
2401 g_string_free (type_many, TRUE);
2402 openvas_connection_close (&connection);
2405 "Internal error", __FUNCTION__, __LINE__,
2406 "An internal error occurred while getting the filter list. "
2407 "The current list of filters is not available. "
2408 "Diagnostics: Failure to send command to manager daemon.",
2409 "/omp?cmd=get_tasks", response_data);
2412 if (read_string_c (&connection, &xml))
2414 g_string_free (xml, TRUE);
2415 g_string_free (type_many, TRUE);
2416 openvas_connection_close (&connection);
2419 "Internal error", __FUNCTION__, __LINE__,
2420 "An internal error occurred while getting the filter list. "
2421 "The current list of filters is not available. "
2422 "Diagnostics: Failure to receive response from manager daemon.",
2423 "/omp?cmd=get_tasks", response_data);
2432 if (openvas_connection_sendf (&connection,
2434 " filter=\"resource_type=%s"
2439 strcmp (type,
"info")
2444 g_string_free (xml, TRUE);
2445 openvas_connection_close (&connection);
2448 "Internal error", __FUNCTION__, __LINE__,
2449 "An internal error occurred while getting tag names list. "
2450 "The current list of resources is not available. "
2451 "Diagnostics: Failure to send command to manager daemon.",
2452 "/omp?cmd=get_resources", response_data);
2455 if (read_string_c (&connection, &xml))
2457 g_string_free (xml, TRUE);
2458 openvas_connection_close (&connection);
2461 "Internal error", __FUNCTION__, __LINE__,
2462 "An internal error occurred while getting tag names list. "
2463 "The current list of resources is not available. "
2464 "Diagnostics: Failure to receive response from manager daemon.",
2465 "/omp?cmd=get_resources", response_data);
2470 g_string_append_printf (xml,
"</get_%s>", type_many->str);
2471 openvas_connection_close (&connection);
2472 g_string_free (type_many, TRUE);
2473 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
2491 const char *extra_get_attribs,
const char *extra_xml,
2495 openvas_connection_t connection;
2496 gchar *html, *id_name;
2497 const char *resource_id;
2499 id_name = g_strdup_printf (
"%s_id", type);
2503 if (resource_id == NULL)
2507 "Internal error", __FUNCTION__, __LINE__,
2508 "An internal error occurred while editing a resource. "
2509 "The resource remains as it was. "
2510 "Diagnostics: Required ID parameter was NULL.",
2511 "/omp?cmd=get_tasks", response_data);
2526 "Internal error", __FUNCTION__, __LINE__,
2527 "An internal error occurred while editing a resource. "
2528 "The resource remains as it was. "
2529 "Diagnostics: Failure to connect to manager daemon.",
2530 "/omp?cmd=get_tasks", response_data);
2533 if (openvas_connection_sendf (&connection,
2542 extra_get_attribs ? extra_get_attribs :
"",
2547 openvas_connection_close (&connection);
2550 "Internal error", __FUNCTION__, __LINE__,
2551 "An internal error occurred while getting a resource. "
2552 "Diagnostics: Failure to send command to manager daemon.",
2553 "/omp?cmd=get_tasks", response_data);
2556 xml = g_string_new (
"");
2558 g_string_append_printf (xml,
"<edit_%s>", type);
2561 g_string_append (xml, extra_xml);
2563 if (read_string_c (&connection, &xml))
2565 g_string_free (xml, TRUE);
2566 openvas_connection_close (&connection);
2569 "Internal error", __FUNCTION__, __LINE__,
2570 "An internal error occurred while getting a resource. "
2571 "Diagnostics: Failure to receive response from manager daemon.",
2572 "/omp?cmd=get_tasks", response_data);
2577 g_string_append_printf (xml,
"</edit_%s>", type);
2578 openvas_connection_close (&connection);
2579 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
2596 const char* type,
const char* uuid,
2597 entity_t resource_entity)
2599 gchar *creation_time, *modification_time, *name, *format_name;
2602 if (resource_entity)
2604 entity_t creation_time_entity, modification_time_entity;
2605 entity_t task_entity, format_entity, format_name_entity, name_entity;
2607 creation_time_entity = entity_child (resource_entity,
2610 if (creation_time_entity)
2611 creation_time = entity_text (creation_time_entity);
2613 creation_time = NULL;
2615 modification_time_entity = entity_child (resource_entity,
2616 "modification_time");
2618 if (modification_time_entity)
2619 modification_time = entity_text (modification_time_entity);
2621 modification_time = NULL;
2623 if (strcasecmp (type,
"report") == 0)
2625 task_entity = entity_child (resource_entity,
"task");
2627 name_entity = entity_child (task_entity,
"name");
2631 format_entity = entity_child (resource_entity,
"report_format");
2634 format_name_entity = entity_child (format_entity,
"name");
2637 format_name_entity = NULL;
2639 if (format_name_entity && strlen (entity_text (format_name_entity)))
2640 format_name = entity_text (format_name_entity);
2646 name_entity = entity_child (resource_entity,
"name");
2651 name = entity_text (name_entity);
2657 creation_time = NULL;
2658 modification_time = NULL;
2663 ret = openvas_export_file_name (fname_format, credentials->
username,
2664 type, uuid, creation_time, modification_time,
2686 char **content_disposition, gsize *content_length,
2691 entity_t resource_entity;
2692 openvas_connection_t connection;
2693 char *content = NULL;
2694 gchar *html, *id_name;
2695 gchar *fname_format, *file_name;
2697 const char *resource_id, *subtype;
2699 *content_length = 0;
2713 "Internal error", __FUNCTION__, __LINE__,
2714 "An internal error occurred while getting a resource. "
2715 "The resource could not be delivered. "
2716 "Diagnostics: Failure to connect to manager daemon.",
2717 "/omp?cmd=get_tasks", response_data);
2720 xml = g_string_new (
"");
2722 id_name = g_strdup_printf (
"%s_id", type);
2726 if (resource_id == NULL)
2729 openvas_connection_close (&connection);
2730 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
2736 if (openvas_connection_sendf (&connection,
2745 subtype ?
" type=\"" :
"",
2746 subtype ? subtype :
"",
2747 subtype ?
"\"" :
"")
2750 g_string_free (xml, TRUE);
2751 openvas_connection_close (&connection);
2754 "Internal error", __FUNCTION__, __LINE__,
2755 "An internal error occurred while getting a resource. "
2756 "The resource could not be delivered. "
2757 "Diagnostics: Failure to send command to manager daemon.",
2758 "/omp?cmd=get_tasks", response_data);
2762 if (read_entity_and_text_c (&connection, &entity, &content))
2764 g_string_free (xml, TRUE);
2765 openvas_connection_close (&connection);
2768 "Internal error", __FUNCTION__, __LINE__,
2769 "An internal error occurred while getting a resource. "
2770 "The resource could not be delivered. "
2771 "Diagnostics: Failure to receive response from manager daemon.",
2772 "/omp?cmd=get_tasks", response_data);
2775 if (!omp_success (entity))
2778 resource_entity = entity_child (entity, type);
2780 if (resource_entity == NULL)
2783 free_entity (entity);
2784 g_string_free (xml, TRUE);
2785 openvas_connection_close (&connection);
2788 "Internal error", __FUNCTION__, __LINE__,
2789 "An internal error occurred while getting a resource. "
2790 "The resource could not be delivered. "
2791 "Diagnostics: Failure to receive resource from manager daemon.",
2792 "/omp?cmd=get_tasks", response_data);
2795 ret = setting_get_value (&connection,
2796 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2",
2802 free_entity (entity);
2803 g_string_free (xml, TRUE);
2804 openvas_connection_close (&connection);
2810 "Internal error", __FUNCTION__, __LINE__,
2811 "An internal error occurred while getting a setting. "
2812 "The setting could not be delivered. "
2813 "Diagnostics: Failure to send command to manager daemon.",
2814 "/omp?cmd=get_tasks", response_data);
2818 "Internal error", __FUNCTION__, __LINE__,
2819 "An internal error occurred while getting a setting. "
2820 "The setting could not be delivered. "
2821 "Diagnostics: Failure to receive response from manager daemon.",
2822 "/omp?cmd=get_tasks", response_data);
2826 "Internal error", __FUNCTION__, __LINE__,
2827 "An internal error occurred while getting a setting. "
2828 "The setting could not be delivered. "
2829 "Diagnostics: Internal error.",
2830 "/omp?cmd=get_tasks", response_data);
2834 if (fname_format == NULL)
2836 g_warning (
"%s : File name format setting not found.", __FUNCTION__);
2837 fname_format =
"%T-%U";
2840 file_name =
format_file_name (fname_format, credentials, type, resource_id,
2842 if (file_name == NULL)
2843 file_name = g_strdup_printf (
"%s-%s", type, resource_id);
2846 *content_disposition = g_strdup_printf (
"attachment; filename=\"%s.xml\"",
2848 *content_length = strlen (content);
2849 free_entity (entity);
2851 g_string_free (xml, TRUE);
2852 openvas_connection_close (&connection);
2874 openvas_connection_t connection;
2875 char *content = NULL;
2878 gchar *filter_escaped;
2880 gchar *fname_format, *file_name;
2883 *content_length = 0;
2897 "Internal error", __FUNCTION__, __LINE__,
2898 "An internal error occurred while getting a list. "
2899 "The list could not be delivered. "
2900 "Diagnostics: Failure to connect to manager daemon.",
2901 "/omp?cmd=get_tasks", response_data);
2906 filter_escaped = g_markup_escape_text (filter, -1);
2908 if (strcmp (type,
"info") == 0)
2910 if (openvas_connection_sendf (&connection,
2917 filter_escaped ? filter_escaped :
"")
2920 openvas_connection_close (&connection);
2921 g_free (filter_escaped);
2924 "Internal error", __FUNCTION__, __LINE__,
2925 "An internal error occurred while getting a list. "
2926 "The list could not be delivered. "
2927 "Diagnostics: Failure to send command to manager daemon.",
2928 "/omp?cmd=get_tasks", response_data);
2931 else if (strcmp (type,
"asset") == 0)
2933 if (openvas_connection_sendf (&connection,
2940 filter_escaped ? filter_escaped :
"")
2943 openvas_connection_close (&connection);
2944 g_free (filter_escaped);
2947 "Internal error", __FUNCTION__, __LINE__,
2948 "An internal error occurred while getting a list. "
2949 "The list could not be delivered. "
2950 "Diagnostics: Failure to send command to manager daemon.",
2951 "/omp?cmd=get_tasks", response_data);
2956 if (openvas_connection_sendf (&connection,
2962 filter_escaped ? filter_escaped :
"")
2965 openvas_connection_close (&connection);
2966 g_free (filter_escaped);
2969 "Internal error", __FUNCTION__, __LINE__,
2970 "An internal error occurred while getting a list. "
2971 "The list could not be delivered. "
2972 "Diagnostics: Failure to send command to manager daemon.",
2973 "/omp?cmd=get_tasks", response_data);
2976 g_free (filter_escaped);
2979 if (read_entity_and_text_c (&connection, &entity, &content))
2981 openvas_connection_close (&connection);
2984 "Internal error", __FUNCTION__, __LINE__,
2985 "An internal error occurred while getting a list. "
2986 "The list could not be delivered. "
2987 "Diagnostics: Failure to receive response from manager daemon.",
2988 "/omp?cmd=get_tasks", response_data);
2991 if (!omp_success (entity))
2994 ret = setting_get_value (&connection,
2995 "0872a6ed-4f85-48c5-ac3f-a5ef5e006745",
3001 free_entity (entity);
3002 openvas_connection_close (&connection);
3008 "Internal error", __FUNCTION__, __LINE__,
3009 "An internal error occurred while getting a setting. "
3010 "The setting could not be delivered. "
3011 "Diagnostics: Failure to send command to manager daemon.",
3012 "/omp?cmd=get_tasks", response_data);
3016 "Internal error", __FUNCTION__, __LINE__,
3017 "An internal error occurred while getting a setting. "
3018 "The setting could not be delivered. "
3019 "Diagnostics: Failure to receive response from manager daemon.",
3020 "/omp?cmd=get_tasks", response_data);
3024 "Internal error", __FUNCTION__, __LINE__,
3025 "An internal error occurred while getting a setting. "
3026 "The setting could not be delivered. "
3027 "Diagnostics: Internal error.",
3028 "/omp?cmd=get_tasks", response_data);
3032 if (fname_format == NULL)
3034 g_warning (
"%s : File name format setting not found.", __FUNCTION__);
3035 fname_format =
"%T-%D";
3038 if (strcmp (type,
"info") == 0)
3039 type_many = g_strdup (type);
3041 type_many = g_strdup_printf (
"%ss", type);
3043 file_name =
format_file_name (fname_format, credentials, type_many,
"list",
3045 if (file_name == NULL)
3046 file_name = g_strdup_printf (
"%s-%s", type_many,
"list");
3051 *content_disposition = g_strdup_printf (
"attachment; filename=\"%s.xml\"",
3053 *content_length = strlen (content);
3054 free_entity (entity);
3056 openvas_connection_close (&connection);
3077 openvas_connection_t connection;
3078 gchar *html, *response, *id_name, *resource_id, *extra_attribs;
3079 const char *no_redirect, *next_id;
3081 gchar *cap_type, *default_next, *prev_action;
3084 id_name = g_strdup_printf (
"%s_id", type);
3086 resource_id = g_strdup (
params_value (params, id_name));
3092 "Internal error", __FUNCTION__, __LINE__,
3093 "An internal error occurred while deleting a resource. "
3094 "The resource was not deleted. "
3095 "Diagnostics: Required parameter resource_id was NULL.",
3096 "/omp?cmd=get_tasks", response_data);
3106 g_free (param->
value);
3107 param->
value = g_strdup (next_id);
3122 g_free (resource_id);
3127 g_free (resource_id);
3130 "Internal error", __FUNCTION__, __LINE__,
3131 "An internal error occurred while deleting a resource. "
3132 "The resource is not deleted. "
3133 "Diagnostics: Failure to connect to manager daemon.",
3134 "/omp?cmd=get_tasks", response_data);
3138 extra_attribs = NULL;
3141 if (strcmp (type,
"user") == 0)
3143 const char* inheritor_id;
3146 extra_attribs = g_strdup_printf (
"inheritor_id=\"%s\"", inheritor_id);
3151 if (openvas_connection_sendf (&connection,
3152 "<delete_%s %s_id=\"%s\" ultimate=\"%i\"%s%s/>",
3157 extra_attribs ?
" " :
"",
3158 extra_attribs ? extra_attribs :
"")
3161 openvas_connection_close (&connection);
3162 g_free (resource_id);
3163 g_free (extra_attribs);
3166 "Internal error", __FUNCTION__, __LINE__,
3167 "An internal error occurred while deleting a resource. "
3168 "The resource is not deleted. "
3169 "Diagnostics: Failure to send command to manager daemon.",
3170 "/omp?cmd=get_tasks", response_data);
3173 g_free (resource_id);
3174 g_free (extra_attribs);
3177 if (read_entity_and_text_c (&connection, &entity, &response))
3179 openvas_connection_close (&connection);
3182 "Internal error", __FUNCTION__, __LINE__,
3183 "An internal error occurred while deleting a resource. "
3184 "It is unclear whether the resource has been deleted or not. "
3185 "Diagnostics: Failure to read response from manager daemon.",
3186 "/omp?cmd=get_tasks", response_data);
3189 if (!omp_success (entity))
3191 openvas_connection_close (&connection);
3193 cap_type = capitalize (type);
3194 default_next = g_strdup_printf (
"get_%ss", type);
3195 prev_action = g_strdup_printf (
"Delete %s", cap_type);
3197 html = response_from_entity (credentials, params, entity,
3198 (no_redirect && strcmp (no_redirect,
"0")),
3201 prev_action, response_data);
3204 free_entity (entity);
3206 g_free (default_next);
3207 g_free (prev_action);
3227 gchar *html, *response, *param_name;
3228 const char *no_redirect, *resource_id;
3229 gchar *cap_action, *cap_type, *get_cmd, *prev_action;
3236 param_name = g_strdup_printf (
"%s_id", type);
3240 if (resource_id == NULL)
3243 message = g_strdup_printf
3244 (
"An internal error occurred while performing an action. "
3245 "The resource remains the same. "
3246 "Diagnostics: Required parameter %s was NULL.",
3248 g_free (param_name);
3251 "Internal error", __FUNCTION__, __LINE__,
3253 "/omp?cmd=get_tasks", response_data);
3257 g_free (param_name);
3261 ret = ompf (credentials, &response, &entity, response_data,
3262 "<%s_%s %s_id=\"%s\"/>",
3275 "Internal error", __FUNCTION__, __LINE__,
3276 "An internal error occurred while performing an action. "
3277 "The resource remains the same. "
3278 "Diagnostics: Failure to send command to manager daemon.",
3279 "/omp?cmd=get_tasks", response_data);
3283 "Internal error", __FUNCTION__, __LINE__,
3284 "An internal error occurred while performing an action. "
3285 "It is unclear whether the resource has been affected. "
3286 "Diagnostics: Failure to receive response from manager daemon.",
3287 "/omp?cmd=get_tasks", response_data);
3291 "Internal error", __FUNCTION__, __LINE__,
3292 "An internal error occurred while performing an action. "
3293 "It is unclear whether the resource has been affected. "
3294 "Diagnostics: Internal Error.",
3295 "/omp?cmd=get_tasks", response_data);
3298 if (!omp_success (entity))
3301 cap_action = capitalize (action);
3302 cap_type = capitalize (type);
3303 get_cmd = g_strdup_printf (
"get_%ss", type);
3304 prev_action = g_strdup_printf (
"%s %s", cap_action, cap_type);
3305 html = response_from_entity (credentials, params, entity,
3306 (no_redirect && strcmp (no_redirect,
"0")),
3309 prev_action, response_data);
3312 free_entity (entity);
3313 g_free (cap_action);
3316 g_free (prev_action);
3374 openvas_connection_t *connection,
3375 const gchar *setting_id,
3379 switch (setting_get_value (connection, setting_id, value, response_data))
3386 "Internal error", __FUNCTION__, __LINE__,
3387 "An internal error occurred while getting a setting. "
3388 "The setting could not be delivered. "
3389 "Diagnostics: Failure to send command to manager daemon.",
3390 "/omp?cmd=get_tasks", response_data);
3394 "Internal error", __FUNCTION__, __LINE__,
3395 "An internal error occurred while getting a setting. "
3396 "The setting could not be delivered. "
3397 "Diagnostics: Failure to receive response from manager daemon.",
3398 "/omp?cmd=get_tasks", response_data);
3402 "Internal error", __FUNCTION__, __LINE__,
3403 "An internal error occurred while getting a setting. "
3404 "The setting could not be delivered. "
3405 "Diagnostics: Internal error.",
3406 "/omp?cmd=get_tasks", response_data);
3418 #define PARAM_OR_SETTING(value, param, setting_id, cleanup) \
3419 if (params_valid (params, param)) \
3420 value = g_strdup (params_value (params, param)); \
3424 message = setting_get_value_error (credentials, &connection, setting_id,\
3425 &value, response_data); \
3449 openvas_connection_t connection;
3451 int apply_overrides;
3452 const char *alerts, *overrides;
3454 gchar *alert, *schedule, *target;
3455 gchar *openvas_config, *osp_config, *openvas_scanner, *osp_scanner;
3460 apply_overrides = overrides ? strcmp (overrides,
"0") : 0;
3474 "Internal error", __FUNCTION__, __LINE__,
3475 "An internal error occurred while getting targets list. "
3476 "The current list of targets is not available. "
3477 "Diagnostics: Failure to connect to manager daemon.",
3478 "/omp?cmd=get_tasks", response_data);
3481 ret = setting_get_value (&connection,
3482 "f9f5a546-8018-48d0-bef5-5ad4926ea899",
3487 openvas_connection_close (&connection);
3493 "Internal error", __FUNCTION__, __LINE__,
3494 "An internal error occurred while getting a setting. "
3495 "The setting could not be delivered. "
3496 "Diagnostics: Failure to send command to manager daemon.",
3497 "/omp?cmd=get_tasks", response_data);
3501 "Internal error", __FUNCTION__, __LINE__,
3502 "An internal error occurred while getting a setting. "
3503 "The setting could not be delivered. "
3504 "Diagnostics: Failure to receive response from manager daemon.",
3505 "/omp?cmd=get_tasks", response_data);
3509 "Internal error", __FUNCTION__, __LINE__,
3510 "An internal error occurred while getting a setting. "
3511 "The setting could not be delivered. "
3512 "Diagnostics: Internal error.",
3513 "/omp?cmd=get_tasks", response_data);
3518 "778eedad-5550-4de0-abb6-1320d13b5e18",
3519 openvas_connection_close (&connection);
3523 "23409203-940a-4b4a-b70c-447475f18323",
3524 openvas_connection_close (&connection);
3529 "fe7ea321-e3e3-4cc6-9952-da836aae83ce",
3530 openvas_connection_close (&connection);
3536 "fb19ac4b-614c-424c-b046-0bc32bf1be73",
3537 openvas_connection_close (&connection);
3541 g_free (openvas_config));
3544 "f7d0f6ed-6f9e-45dc-8bd9-05cced84e80d",
3545 openvas_connection_close (&connection);
3549 g_free (openvas_config);
3550 g_free (osp_config));
3553 "b20697c9-be0a-4cd4-8b4d-5fe7841ebb03",
3554 openvas_connection_close (&connection);
3558 g_free (openvas_config);
3559 g_free (osp_config);
3560 g_free (openvas_scanner));
3562 xml = g_string_new (
"<new_task>");
3564 g_string_append_printf (xml,
3565 "<alert_id>%s</alert_id>"
3566 "<config_id>%s</config_id>"
3567 "<osp_config_id>%s</osp_config_id>"
3568 "<scanner_id>%s</scanner_id>"
3569 "<osp_scanner_id>%s</osp_scanner_id>"
3570 "<schedule_id>%s</schedule_id>"
3571 "<target_id>%s</target_id>",
3573 (openvas_config && strlen (openvas_config))
3575 :
"daba56c8-73ec-11df-a475-002264764cea",
3576 osp_config ? osp_config :
"",
3577 openvas_scanner ? openvas_scanner :
"",
3578 osp_scanner ? osp_scanner :
"",
3579 schedule ? schedule :
"",
3580 (target && strlen (target))
3582 :
"b493b7a8-7489-11df-a3ec-002264764cea");
3586 g_free (openvas_config);
3587 g_free (osp_config);
3588 g_free (openvas_scanner);
3589 g_free (osp_scanner);
3592 if (openvas_connection_sendf (&connection,
3594 " filter=\"rows=-1 sort=name\"/>")
3597 g_string_free (xml, TRUE);
3598 openvas_connection_close (&connection);
3601 "Internal error", __FUNCTION__, __LINE__,
3602 "An internal error occurred while getting targets list. "
3603 "The current list of targets is not available. "
3604 "Diagnostics: Failure to send command to manager daemon.",
3605 "/omp?cmd=get_tasks", response_data);
3608 if (read_string_c (&connection, &xml))
3610 g_string_free (xml, TRUE);
3611 openvas_connection_close (&connection);
3614 "Internal error", __FUNCTION__, __LINE__,
3615 "An internal error occurred while getting targets list. "
3616 "The current list of targets is not available. "
3617 "Diagnostics: Failure to receive response from manager daemon.",
3618 "/omp?cmd=get_tasks", response_data);
3622 if (openvas_connection_sendf (&connection,
3624 " filter=\"rows=-1 sort=name\"/>")
3627 g_string_free (xml, TRUE);
3628 openvas_connection_close (&connection);
3631 "Internal error", __FUNCTION__, __LINE__,
3632 "An internal error occurred while getting config list. "
3633 "The current list of configs is not available. "
3634 "Diagnostics: Failure to send command to manager daemon.",
3635 "/omp?cmd=get_tasks", response_data);
3638 if (read_string_c (&connection, &xml))
3640 g_string_free (xml, TRUE);
3641 openvas_connection_close (&connection);
3644 "Internal error", __FUNCTION__, __LINE__,
3645 "An internal error occurred while getting config list. "
3646 "The current list of configs is not available. "
3647 "Diagnostics: Failure to receive response from manager daemon.",
3648 "/omp?cmd=get_tasks", response_data);
3654 if (openvas_connection_sendf (&connection,
3656 " filter=\"rows=-1 sort=name\"/>")
3659 g_string_free (xml, TRUE);
3660 openvas_connection_close (&connection);
3663 "Internal error", __FUNCTION__, __LINE__,
3664 "An internal error occurred while getting alert list. "
3665 "The current list of alerts is not available. "
3666 "Diagnostics: Failure to send command to manager daemon.",
3667 "/omp?cmd=get_tasks", response_data);
3670 if (read_string_c (&connection, &xml))
3672 g_string_free (xml, TRUE);
3673 openvas_connection_close (&connection);
3676 "Internal error", __FUNCTION__, __LINE__,
3677 "An internal error occurred while getting alert list. "
3678 "The current list of alerts is not available. "
3679 "Diagnostics: Failure to receive response from manager daemon.",
3680 "/omp?cmd=get_tasks", response_data);
3687 if (openvas_connection_sendf
3690 " filter=\"rows=-1 sort=name\"/>")
3693 g_string_free (xml, TRUE);
3694 openvas_connection_close (&connection);
3697 "Internal error", __FUNCTION__, __LINE__,
3698 "An internal error occurred while getting the schedule list. "
3699 "The current list of schedules is not available. "
3700 "Diagnostics: Failure to send command to manager daemon.",
3701 "/omp?cmd=get_tasks", response_data);
3704 if (read_string_c (&connection, &xml))
3706 g_string_free (xml, TRUE);
3707 openvas_connection_close (&connection);
3710 "Internal error", __FUNCTION__, __LINE__,
3711 "An internal error occurred while getting the schedule list. "
3712 "The current list of schedules is not available. "
3713 "Diagnostics: Failure to receive response from manager daemon.",
3714 "/omp?cmd=get_tasks", response_data);
3721 if (openvas_connection_sendf (&connection,
3723 " filter=\"rows=-1\"/>")
3726 g_string_free (xml, TRUE);
3727 openvas_connection_close (&connection);
3730 "Internal error", __FUNCTION__, __LINE__,
3731 "An internal error occurred while getting the"
3733 "The current list of scanners is not available. "
3734 "Diagnostics: Failure to send command to manager"
3736 "/omp?cmd=get_tasks", response_data);
3739 if (read_string_c (&connection, &xml))
3741 g_string_free (xml, TRUE);
3742 openvas_connection_close (&connection);
3745 "Internal error", __FUNCTION__, __LINE__,
3746 "An internal error occurred while getting"
3747 " the scanner list."
3748 "The current list of scanners is not available. "
3749 "Diagnostics: Failure to receive response from"
3751 "/omp?cmd=get_tasks", response_data);
3759 if (openvas_connection_sendf (&connection,
3763 g_string_free (xml, TRUE);
3764 openvas_connection_close (&connection);
3767 "Internal error", __FUNCTION__, __LINE__,
3768 "An internal error occurred while getting group list. "
3769 "The current list of groups is not available. "
3770 "Diagnostics: Failure to send command to manager daemon.",
3771 "/omp?cmd=get_tasks", response_data);
3774 if (read_string_c (&connection, &xml))
3776 g_string_free (xml, TRUE);
3777 openvas_connection_close (&connection);
3780 "Internal error", __FUNCTION__, __LINE__,
3781 "An internal error occurred while getting group list. "
3782 "The current list of groups is not available. "
3783 "Diagnostics: Failure to receive response from manager daemon.",
3784 "/omp?cmd=get_tasks", response_data);
3792 if (openvas_connection_sendf (&connection,
3793 "<get_tags names_only=\"1\""
3794 " filter=\"resource_type=task rows=-1\"/>")
3797 g_string_free (xml, TRUE);
3798 openvas_connection_close (&connection);
3801 "Internal error", __FUNCTION__, __LINE__,
3802 "An internal error occurred while getting tag list. "
3803 "The current list of tags is not available. "
3804 "Diagnostics: Failure to send command to manager daemon.",
3805 "/omp?cmd=get_tasks", response_data);
3808 if (read_string_c (&connection, &xml))
3810 g_string_free (xml, TRUE);
3811 openvas_connection_close (&connection);
3814 "Internal error", __FUNCTION__, __LINE__,
3815 "An internal error occurred while getting tag list. "
3816 "The current list of tags is not available. "
3817 "Diagnostics: Failure to receive response from manager daemon.",
3818 "/omp?cmd=get_tasks", response_data);
3823 g_string_append (xml, extra_xml);
3826 g_string_append_printf (xml,
3828 "<apply_overrides>%i</apply_overrides>"
3829 "<alerts>%s</alerts>"
3833 alerts ? alerts :
"1");
3835 openvas_connection_close (&connection);
3836 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
3853 return new_task (credentials, NULL, params, NULL, response_data);
3868 new_container_task (
credentials_t * credentials,
const char *message,
3869 params_t *params,
const char *extra_xml,
3874 xml = g_string_new (
"<new_container_task>");
3877 g_string_append (xml, extra_xml);
3882 g_string_append_printf (xml,
"</new_container_task>");
3884 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
3901 return new_container_task (credentials, NULL, params, NULL, response_data);
3920 xml = g_string_new (
"<upload_report>");
3922 g_string_append (xml, extra_xml);
3928 if (simple_ompf (
"getting Tasks", credentials, &response, response_data,
3931 " filter=\"target= rows=-1 owner=any permission=any\"/>"))
3933 g_string_free (xml, TRUE);
3937 g_string_append (xml, response);
3940 g_string_append (xml,
"</upload_report>");
3942 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
3959 return upload_report (credentials, params, NULL, response_data);
3977 gchar *command, *html, *response;
3978 const char *no_redirect, *cmd, *task_id, *name, *comment, *xml_file;
3979 const char *in_assets;
3988 if (task_id == NULL)
3998 if (strlen (xml_file) == 0)
4003 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
4004 "Create Report",
"new_container_task");
4008 command = g_strdup_printf (
"<create_task>"
4009 "<target id=\"0\"/>"
4011 "<comment>%s</comment>"
4018 gchar **xml_file_array, *xml_file_escaped;
4020 xml_file_array = g_strsplit (xml_file,
"%", -1);
4021 if (xml_file_array != NULL && xml_file_array[0] != NULL)
4022 xml_file_escaped = g_strjoinv (
"%%", xml_file_array);
4024 xml_file_escaped = g_strdup (xml_file);
4025 g_strfreev (xml_file_array);
4028 command = g_strdup_printf (
"<create_report>"
4029 "<in_assets>%s</in_assets>"
4033 in_assets ? in_assets :
"0",
4034 task_id ? task_id :
"0",
4035 xml_file_escaped ? xml_file_escaped :
"");
4037 command = g_strdup_printf (
"<create_report>"
4038 "<in_assets>%s</in_assets>"
4041 "<comment>%s</comment>"
4045 in_assets ? in_assets :
"",
4049 g_free (xml_file_escaped);
4052 ret = omp (credentials,
4069 "Internal error", __FUNCTION__, __LINE__,
4070 "An internal error occurred while creating a new report. "
4071 "No new report was created. "
4072 "Diagnostics: Failure to send command to manager daemon.",
4073 "/omp?cmd=get_tasks", response_data);
4077 "Internal error", __FUNCTION__, __LINE__,
4078 "An internal error occurred while creating a new report. "
4079 "It is unclear whether the report has been created or not. "
4080 "Diagnostics: Failure to receive response from manager daemon.",
4081 "/omp?cmd=get_tasks", response_data);
4085 "Internal error", __FUNCTION__, __LINE__,
4086 "An internal error occurred while creating a new report. "
4087 "It is unclear whether the report has been created or not. "
4088 "Diagnostics: Internal Error.",
4089 "/omp?cmd=get_tasks", response_data);
4093 html = response_from_entity (credentials, params, entity,
4094 (no_redirect && strcmp (no_redirect,
"0")),
4097 (cmd && strcmp (cmd,
"import_report"))
4098 ?
"new_container_task" :
"upload_report",
4099 "Import Report", response_data);
4100 free_entity (entity);
4121 #define CHECK(name) \
4122 CHECK_PARAM_INVALID (name, "Create Task", "new_task")
4139 gchar *command, *html, *response;
4140 const char *no_redirect, *name, *comment;
4148 command = g_strdup_printf (
"<create_task>"
4149 "<target id=\"0\"/>"
4151 "<comment>%s</comment>"
4155 ret = omp (credentials,
4172 "Internal error", __FUNCTION__, __LINE__,
4173 "An internal error occurred while creating a container task. "
4174 "No task was created. "
4175 "Diagnostics: Failure to send command to manager daemon.",
4176 "/omp?cmd=get_tasks", response_data);
4180 "Internal error", __FUNCTION__, __LINE__,
4181 "An internal error occurred while creating a container task. "
4182 "It is unclear whether the task has been created or not. "
4183 "Diagnostics: Failure to receive response from manager daemon.",
4184 "/omp?cmd=get_tasks", response_data);
4188 "Internal error", __FUNCTION__, __LINE__,
4189 "An internal error occurred while creating a container task. "
4190 "It is unclear whether the task has been created or not. "
4191 "Diagnostics: Internal Error.",
4192 "/omp?cmd=get_tasks", response_data);
4195 if (entity_attribute (entity,
"id"))
4196 params_add (params,
"task_id", entity_attribute (entity,
"id"));
4197 html = response_from_entity (credentials, params, entity,
4198 (no_redirect && strcmp (no_redirect,
"0")),
4200 NULL,
"new_container_task",
4201 "Create Container Task", response_data);
4202 free_entity (entity);
4222 gchar *schedule_element, *command;
4223 gchar *response, *html;
4224 const char *no_redirect;
4225 const char *name, *comment, *config_id, *target_id, *scanner_type;
4226 const char *scanner_id, *schedule_id, *schedule_periods;
4227 const char *max_checks, *max_hosts;
4228 const char *in_assets, *hosts_ordering, *alterable, *source_iface;
4229 const char *add_tag, *tag_name, *tag_value, *auto_delete, *auto_delete_data;
4230 const char *apply_overrides, *min_qod;
4232 GString *alert_element;
4239 hosts_ordering =
params_value (params,
"hosts_ordering");
4241 schedule_periods =
params_value (params,
"schedule_periods");
4245 apply_overrides =
params_value (params,
"apply_overrides");
4250 auto_delete_data =
params_value (params,
"auto_delete_data");
4256 CHECK (scanner_type);
4257 if (!strcmp (scanner_type,
"1"))
4259 hosts_ordering =
"";
4264 else if (!strcmp (scanner_type,
"3"))
4267 hosts_ordering =
"";
4277 CHECK (hosts_ordering);
4279 CHECK (schedule_id);
4282 CHECK (schedule_periods);
4285 schedule_periods =
"0";
4287 if (!strcmp (in_assets,
"1"))
4289 CHECK (apply_overrides);
4296 apply_overrides =
"";
4303 CHECK (source_iface);
4304 CHECK (auto_delete);
4305 CHECK (auto_delete_data);
4315 if (schedule_id == NULL || strcmp (schedule_id,
"0") == 0)
4316 schedule_element = g_strdup (
"");
4318 schedule_element = g_strdup_printf (
"<schedule id=\"%s\"/>", schedule_id);
4320 alert_element = g_string_new (
"");
4334 if (param->
value && strcmp (param->
value,
"0"))
4335 g_string_append_printf (alert_element,
4336 "<alert id=\"%s\"/>",
4340 command = g_strdup_printf (
"<create_task>"
4341 "<config id=\"%s\"/>"
4342 "<schedule_periods>%s</schedule_periods>"
4344 "<target id=\"%s\"/>"
4345 "<scanner id=\"%s\"/>"
4346 "<hosts_ordering>%s</hosts_ordering>"
4348 "<comment>%s</comment>"
4351 "<scanner_name>max_checks</scanner_name>"
4355 "<scanner_name>max_hosts</scanner_name>"
4359 "<scanner_name>in_assets</scanner_name>"
4364 "assets_apply_overrides"
4369 "<scanner_name>assets_min_qod</scanner_name>"
4373 "<scanner_name>source_iface</scanner_name>"
4377 "<scanner_name>auto_delete</scanner_name>"
4381 "<scanner_name>auto_delete_data</scanner_name>"
4385 "<alterable>%i</alterable>"
4398 strcmp (in_assets,
"0") ?
"yes" :
"no",
4399 strcmp (apply_overrides,
"0") ?
"yes" :
"no",
4404 alterable ? strcmp (alterable,
"0") : 0);
4406 ret = omp (credentials,
4413 g_free (schedule_element);
4414 g_string_free (alert_element, TRUE);
4426 "Internal error", __FUNCTION__, __LINE__,
4427 "An internal error occurred while creating a new task. "
4428 "No new task was created. "
4429 "Diagnostics: Failure to send command to manager daemon.",
4430 "/omp?cmd=get_tasks", response_data);
4434 "Internal error", __FUNCTION__, __LINE__,
4435 "An internal error occurred while creating a new task. "
4436 "It is unclear whether the task has been created or not. "
4437 "Diagnostics: Failure to receive response from manager daemon.",
4438 "/omp?cmd=get_tasks", response_data);
4442 "Internal error", __FUNCTION__, __LINE__,
4443 "An internal error occurred while creating a new task. "
4444 "It is unclear whether the task has been created or not. "
4445 "Diagnostics: Internal Error.",
4446 "/omp?cmd=get_tasks", response_data);
4449 if (omp_success (entity))
4451 if (add_tag && strcmp (add_tag,
"0"))
4453 const char *new_task_id = entity_attribute (entity,
"id");
4454 gchar *tag_command, *tag_response;
4455 entity_t tag_entity;
4457 if (tag_value && strcmp (tag_value,
""))
4459 = g_markup_printf_escaped (
"<create_tag>"
4461 "<resource id=\"%s\">"
4471 = g_markup_printf_escaped (
"<create_tag>"
4473 "<resource id=\"%s\">"
4480 ret = omp (credentials,
4492 free_entity (entity);
4495 = MHD_HTTP_INTERNAL_SERVER_ERROR;
4497 "Internal error", __FUNCTION__, __LINE__,
4498 "An internal error occurred while creating a new tag. "
4499 "No new tag was created. "
4500 "Diagnostics: Failure to send command to manager daemon.",
4501 "/omp?cmd=get_tasks", response_data);
4503 free_entity (entity);
4506 = MHD_HTTP_INTERNAL_SERVER_ERROR;
4508 "Internal error", __FUNCTION__, __LINE__,
4509 "An internal error occurred while creating a new tag. "
4510 "It is unclear whether the tag has been created or not. "
4511 "Diagnostics: Failure to receive response from manager daemon.",
4512 "/omp?cmd=get_tasks", response_data);
4514 free_entity (entity);
4517 = MHD_HTTP_INTERNAL_SERVER_ERROR;
4519 "Internal error", __FUNCTION__, __LINE__,
4520 "An internal error occurred while creating a new task. "
4521 "It is unclear whether the tag has been created or not. "
4522 "Diagnostics: Internal Error.",
4523 "/omp?cmd=get_tasks", response_data);
4526 if (entity_attribute (entity,
"id"))
4527 params_add (params,
"task_id", entity_attribute (entity,
"id"));
4529 = response_from_entity (credentials, params, tag_entity,
4530 (no_redirect && strcmp (no_redirect,
"0")),
4533 "Create Task and Tag", response_data);
4534 free_entity (tag_entity);
4535 g_free (tag_response);
4539 if (entity_attribute (entity,
"id"))
4540 params_add (params,
"task_id", entity_attribute (entity,
"id"));
4542 = response_from_entity (credentials, params, entity,
4543 (no_redirect && strcmp (no_redirect,
"0")),
4546 "Create Task", response_data);
4551 html = response_from_entity (credentials, params, entity,
4552 (no_redirect && strcmp (no_redirect,
"0")),
4555 "Create Task", response_data);
4557 free_entity (entity);
4576 return delete_resource (
"task", credentials, params, 0, NULL, response_data);
4594 openvas_connection_t connection;
4596 const char *task_id, *next, *refresh_interval, *sort_field, *sort_order;
4597 const char *overrides, *alerts;
4598 int apply_overrides;
4602 refresh_interval =
params_value (params,
"refresh_interval");
4608 apply_overrides = overrides ? strcmp (overrides,
"0") : 1;
4610 if (task_id == NULL)
4614 "Internal error", __FUNCTION__, __LINE__,
4615 "An internal error occurred while editing a task. "
4616 "The task remains as it was. "
4617 "Diagnostics: Required parameter was NULL.",
4618 "/omp?cmd=get_tasks", response_data);
4636 "Internal error", __FUNCTION__, __LINE__,
4637 "An internal error occurred while editing a task. "
4638 "The task remains as it was. "
4639 "Diagnostics: Failure to connect to manager daemon.",
4640 "/omp?cmd=get_tasks", response_data);
4643 if (openvas_connection_sendf (&connection,
4645 "<get_tasks task_id=\"%s\" details=\"1\" />"
4647 " filter=\"rows=-1 sort=name\"/>"
4649 " filter=\"rows=-1 sort=name\"/>"
4658 " filter=\"rows=-1 sort=name\"/>"
4662 " filter=\"rows=-1 sort=name\"/>"
4666 " filter=\"rows=-1\"/>"
4673 openvas_connection_close (&connection);
4676 "Internal error", __FUNCTION__, __LINE__,
4677 "An internal error occurred while getting task info. "
4678 "Diagnostics: Failure to send command to manager daemon.",
4679 "/omp?cmd=get_tasks", response_data);
4682 xml = g_string_new (
"");
4685 g_string_append (xml, extra_xml);
4687 g_string_append_printf (xml,
4691 "<alerts>%s</alerts>"
4695 "<refresh_interval>%s</refresh_interval>"
4696 "<sort_field>%s</sort_field>"
4697 "<sort_order>%s</sort_order>"
4698 "<apply_overrides>%i</apply_overrides>",
4701 alerts ? alerts :
"1",
4703 refresh_interval ? refresh_interval :
"",
4708 if (read_string_c (&connection, &xml))
4710 g_string_free (xml, TRUE);
4711 openvas_connection_close (&connection);
4714 "Internal error", __FUNCTION__, __LINE__,
4715 "An internal error occurred while getting task info. "
4716 "Diagnostics: Failure to receive response from manager daemon.",
4717 "/omp?cmd=get_tasks", response_data);
4722 g_string_append (xml,
"</edit_task>");
4723 openvas_connection_close (&connection);
4724 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
4741 return edit_task (credentials, params, NULL, response_data);
4757 gchar *html, *response, *format;
4758 const char *no_redirect;
4759 const char *comment, *name, *schedule_id, *in_assets;
4760 const char *scanner_id, *task_id, *max_checks, *max_hosts;
4761 const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
4762 const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
4763 const char *apply_overrides, *min_qod;
4766 GString *alert_element;
4774 apply_overrides =
params_value (params,
"apply_overrides");
4778 hosts_ordering =
params_value (params,
"hosts_ordering");
4781 schedule_periods =
params_value (params,
"schedule_periods");
4786 auto_delete_data =
params_value (params,
"auto_delete_data");
4790 if (!strcmp (scanner_type,
"1"))
4792 hosts_ordering =
"";
4797 else if (!strcmp (scanner_type,
"3"))
4800 hosts_ordering =
"";
4814 CHECK (schedule_periods);
4817 schedule_periods =
"0";
4827 if (!strcmp (in_assets,
"1"))
4836 apply_overrides =
"";
4843 alert_element = g_string_new (
"");
4858 if (param->
value && strcmp (param->
value,
"0"))
4859 g_string_append_printf (alert_element,
4860 "<alert id=\"%s\"/>",
4866 if (strcmp (alert_element->str,
"") == 0)
4867 g_string_append_printf (alert_element,
"<alert id=\"0\"/>");
4869 format = g_strdup_printf (
"<modify_task task_id=\"%%s\">"
4871 "<comment>%%s</comment>"
4872 "<hosts_ordering>%s</hosts_ordering>"
4874 "<target id=\"%%s\"/>"
4875 "<config id=\"%%s\"/>"
4876 "<schedule id=\"%%s\"/>"
4877 "<schedule_periods>%%s</schedule_periods>"
4878 "<scanner id=\"%%s\"/>"
4881 "<scanner_name>max_checks</scanner_name>"
4882 "<value>%%s</value>"
4885 "<scanner_name>max_hosts</scanner_name>"
4886 "<value>%%s</value>"
4889 "<scanner_name>in_assets</scanner_name>"
4890 "<value>%%s</value>"
4893 "<scanner_name>assets_apply_overrides</scanner_name>"
4894 "<value>%%s</value>"
4897 "<scanner_name>assets_min_qod</scanner_name>"
4898 "<value>%%s</value>"
4901 "<scanner_name>source_iface</scanner_name>"
4902 "<value>%%s</value>"
4905 "<scanner_name>auto_delete</scanner_name>"
4906 "<value>%%s</value>"
4909 "<scanner_name>auto_delete_data</scanner_name>"
4910 "<value>%%s</value>"
4917 alterable ?
"<alterable>" :
"",
4918 alterable ? strcmp (alterable,
"0") : 0,
4919 alterable ?
"</alterable>" :
"");
4922 ret = ompf (credentials,
4937 strcmp (in_assets,
"0") ?
"yes" :
"no",
4938 strcmp (apply_overrides,
"0") ?
"yes" :
"no",
4945 g_string_free (alert_element, TRUE);
4955 "Internal error", __FUNCTION__, __LINE__,
4956 "An internal error occurred while saving a task. "
4957 "The task was not saved. "
4958 "Diagnostics: Failure to send command to manager daemon.",
4959 "/omp?cmd=get_tasks", response_data);
4963 "Internal error", __FUNCTION__, __LINE__,
4964 "An internal error occurred while saving a task. "
4965 "It is unclear whether the task has been saved or not. "
4966 "Diagnostics: Failure to receive response from manager daemon.",
4967 "/omp?cmd=get_tasks", response_data);
4971 "Internal error", __FUNCTION__, __LINE__,
4972 "An internal error occurred while saving a task. "
4973 "It is unclear whether the task has been saved or not. "
4974 "Diagnostics: Internal Error.",
4975 "/omp?cmd=get_tasks", response_data);
4978 html = response_from_entity (credentials, params, entity,
4979 (no_redirect && strcmp (no_redirect,
"0")),
4982 "Save Task", response_data);
4983 free_entity (entity);
5003 gchar *format, *response, *html;
5004 const char *no_redirect, *comment, *name, *task_id;
5005 const char *in_assets, *auto_delete, *auto_delete_data;
5015 auto_delete_data =
params_value (params,
"auto_delete_data");
5023 format = g_strdup_printf (
"<modify_task task_id=\"%%s\">"
5025 "<comment>%%s</comment>"
5028 "<scanner_name>in_assets</scanner_name>"
5029 "<value>%%s</value>"
5032 "<scanner_name>auto_delete</scanner_name>"
5033 "<value>%%s</value>"
5036 "<scanner_name>auto_delete_data</scanner_name>"
5037 "<value>%%s</value>"
5044 ret = ompf (credentials, &response, &entity, response_data,
5045 format, task_id, name, comment,
5046 strcmp (in_assets,
"0") ?
"yes" :
"no",
5058 "Internal error", __FUNCTION__, __LINE__,
5059 "An internal error occurred while saving a task. "
5060 "No new task was created. "
5061 "Diagnostics: Failure to send command to manager daemon.",
5062 "/omp?cmd=get_tasks", response_data);
5066 "Internal error", __FUNCTION__, __LINE__,
5067 "An internal error occurred while saving a task. "
5068 "It is unclear whether the task has been created or not. "
5069 "Diagnostics: Failure to receive response from manager daemon.",
5070 "/omp?cmd=get_tasks", response_data);
5074 "Internal error", __FUNCTION__, __LINE__,
5075 "An internal error occurred while saving a task. "
5076 "It is unclear whether the task has been created or not. "
5077 "Diagnostics: Internal Error.",
5078 "/omp?cmd=get_tasks", response_data);
5081 html = response_from_entity (credentials, params, entity,
5082 (no_redirect && strcmp (no_redirect,
"0")),
5085 "Save Container Task", response_data);
5086 free_entity (entity);
5105 enum content_type * content_type,
char **content_disposition,
5109 content_disposition, content_length, response_data);
5127 enum content_type * content_type,
char **content_disposition,
5130 return export_many (
"task", credentials, params, content_type,
5131 content_disposition, content_length, response_data);
5147 return resource_action (credentials, params,
"task",
"stop", response_data);
5163 return resource_action (credentials, params,
"task",
"resume", response_data);
5179 return resource_action (credentials, params,
"task",
"start", response_data);
5195 gchar *command, *response, *html;
5196 const char *no_redirect, *task_id, *slave_id;
5204 command = g_strdup_printf (
"<move_task task_id=\"%s\" slave_id=\"%s\"/>",
5205 task_id ? task_id :
"",
5206 slave_id ? slave_id :
"");
5210 ret = omp (credentials, &response, &entity, response_data, command);
5222 "Internal error", __FUNCTION__, __LINE__,
5223 "An internal error occurred while moving a task. "
5224 "The task was not moved. "
5225 "Diagnostics: Failure to send command to manager daemon.",
5226 "/omp?cmd=get_tasks", response_data);
5230 "Internal error", __FUNCTION__, __LINE__,
5231 "An internal error occurred while moving a task. "
5232 "It is unclear whether the task has been moved or not. "
5233 "Diagnostics: Failure to receive response from manager daemon.",
5234 "/omp?cmd=get_tasks", response_data);
5238 "Internal error", __FUNCTION__, __LINE__,
5239 "An internal error occurred while moving a task. "
5240 "It is unclear whether the task has been moved or not. "
5241 "Diagnostics: Internal Error.",
5242 "/omp?cmd=get_tasks", response_data);
5245 html = response_from_entity (credentials, params, entity,
5246 (no_redirect && strcmp (no_redirect,
"0")),
5249 "Move Task", response_data);
5251 free_entity (entity);
5271 GString *xml = NULL;
5272 openvas_connection_t connection;
5281 "Internal error", __FUNCTION__, __LINE__,
5282 "An internal error occurred while getting an NVT. "
5283 "Diagnostics: Required parameter was NULL.",
5284 "/omp?cmd=get_tasks", response_data);
5298 "Internal error", __FUNCTION__, __LINE__,
5299 "An internal error occurred while getting nvt details. "
5300 "Diagnostics: Failure to connect to manager daemon.",
5301 "/omp?cmd=get_tasks", response_data);
5304 if (openvas_connection_sendf (&connection,
5310 " preferences=\"1\"/>"
5313 " sort_field=\"notes.text\"/>"
5316 " sort_field=\"overrides.text\"/>"
5318 commands ? commands :
"",
5324 openvas_connection_close (&connection);
5327 "Internal error", __FUNCTION__, __LINE__,
5328 "An internal error occurred while getting nvt details. "
5329 "Diagnostics: Failure to send command to manager daemon.",
5330 "/omp?cmd=get_tasks", response_data);
5333 xml = g_string_new (
"<get_nvts>");
5334 if (read_string_c (&connection, &xml))
5336 openvas_connection_close (&connection);
5337 g_string_free (xml, TRUE);
5340 "Internal error", __FUNCTION__, __LINE__,
5341 "An internal error occurred while getting nvt details. "
5342 "Diagnostics: Failure to receive response from manager daemon.",
5343 "/omp?cmd=get_tasks", response_data);
5348 g_string_append (xml, extra_xml);
5352 if (openvas_connection_sendf (&connection,
5354 " filter=\"resource_type=nvt"
5361 g_string_free (xml, TRUE);
5362 openvas_connection_close (&connection);
5365 "Internal error", __FUNCTION__, __LINE__,
5366 "An internal error occurred while getting tag names list. "
5367 "The current list of resources is not available. "
5368 "Diagnostics: Failure to send command to manager daemon.",
5369 "/omp?cmd=get_resources", response_data);
5372 if (read_string_c (&connection, &xml))
5374 g_string_free (xml, TRUE);
5375 openvas_connection_close (&connection);
5378 "Internal error", __FUNCTION__, __LINE__,
5379 "An internal error occurred while getting tag names list. "
5380 "The current list of resources is not available. "
5381 "Diagnostics: Failure to receive response from manager daemon.",
5382 "/omp?cmd=get_resources", response_data);
5385 g_string_append (xml,
"</get_nvts>");
5387 openvas_connection_close (&connection);
5388 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
5407 GString *extra_attribs, *extra_response;
5408 const char *info_type;
5411 if (info_type == NULL)
5414 param =
params_add (params,
"info_type",
"nvt");
5420 if (strcmp (info_type,
"nvt")
5421 && strcmp (info_type,
"cve")
5422 && strcmp (info_type,
"cpe")
5423 && strcmp (info_type,
"ovaldef")
5424 && strcmp (info_type,
"cert_bund_adv")
5425 && strcmp (info_type,
"dfn_cert_adv")
5426 && strcmp (info_type,
"allinfo")
5427 && strcmp (info_type,
"NVT")
5428 && strcmp (info_type,
"CVE")
5429 && strcmp (info_type,
"CPE")
5430 && strcmp (info_type,
"OVALDEF")
5431 && strcmp (info_type,
"CERT_BUND_ADV")
5432 && strcmp (info_type,
"DFN_CERT_ADV")
5433 && strcmp (info_type,
"ALLINFO"))
5437 "Internal error", __FUNCTION__, __LINE__,
5438 "An internal error occurred while getting SecInfo. "
5439 "Diagnostics: Invalid info_type parameter value",
5440 "/omp?cmd=get_info", response_data);
5448 "Internal error", __FUNCTION__, __LINE__,
5449 "An internal error occurred while getting SecInfo. "
5450 "Diagnostics: Both ID and Name set.",
5451 "/omp?cmd=get_info", response_data);
5453 extra_response = g_string_new (extra_xml ? extra_xml :
"");
5456 && (strcasecmp (info_type,
"NVT") == 0)
5461 if (simple_ompf (
"getting SecInfo", credentials, &response, response_data,
5464 " sort_field=\"notes.text\"/>",
5467 g_string_free (extra_response, TRUE);
5471 g_string_append (extra_response, response);
5475 && (strcasecmp (info_type,
"NVT") == 0)
5480 if (simple_ompf (
"getting SecInfo", credentials, &response, response_data,
5483 " sort_field=\"overrides.text\"/>",
5486 g_string_free (extra_response, TRUE);
5490 g_string_append (extra_response, response);
5493 extra_attribs = g_string_new(
"");
5494 g_string_append_printf (extra_attribs,
"type=\"%s\"",
5497 g_string_append_printf (extra_attribs,
5501 g_string_append_printf (extra_attribs,
5505 g_string_append_printf (extra_attribs,
5508 ret = get_many (
"info", credentials, params, extra_response->str,
5509 extra_attribs->str, response_data);
5511 g_string_free (extra_response, TRUE);
5512 g_string_free (extra_attribs, TRUE);
5530 return get_info (credentials, params, NULL, response_data);
5546 return get_nvts (credentials, params, NULL, NULL, response_data);
5556 params_toggle_overrides (
params_t *params,
const char *overrides)
5558 param_t *filt_id, *build_filter;
5559 const char *new_filt_id;
5561 build_filter =
params_get (params,
"build_filter");
5571 filt_id->
value = g_strdup (new_filt_id);
5579 if (build_filter == NULL)
5583 if (filter && filter->
value)
5586 old = filter->
value;
5587 filter->
value = g_strdup_printf (
"apply_overrides=%s %s",
5592 else if (strcmp (overrides,
"0"))
5594 "apply_overrides=1 rows=-2");
5597 "apply_overrides=0 rows=-2");
5615 const char *overrides, *schedules_only, *ignore_pagination;
5616 gchar *extra_attribs, *ret;
5619 schedules_only =
params_value (params,
"schedules_only");
5620 ignore_pagination =
params_value (params,
"ignore_pagination");
5624 params_toggle_overrides (params, overrides);
5626 extra_attribs = g_strdup_printf (
"%s%s%s"
5628 schedules_only ?
"schedules_only=\"" :
"",
5629 schedules_only ? schedules_only :
"",
5630 schedules_only ?
"\" " :
"",
5632 ?
"ignore_pagination=\""
5634 ignore_pagination ? ignore_pagination :
"",
5635 ignore_pagination ?
"\" " :
"");
5637 ret = get_many (
"task", credentials, params, extra_xml, extra_attribs,
5639 g_free (extra_attribs);
5656 return get_tasks (credentials, params, NULL, response_data);
5673 return xsl_transform_omp (credentials, g_strdup (
"<get_tasks_chart/>"),
5690 return get_tasks_chart (credentials, params, NULL, response_data);
5708 GString *xml = NULL;
5709 GString *commands_xml = NULL;
5710 entity_t commands_entity = NULL;
5711 entity_t task_entity = NULL;
5712 openvas_connection_t connection;
5713 int notes, get_overrides, apply_overrides;
5714 int get_target, get_alerts;
5715 const char *overrides, *task_id;
5719 if (task_id == NULL)
5720 return get_tasks (credentials, params, extra_xml, response_data);
5723 apply_overrides = overrides ? strcmp (overrides,
"0") : 1;
5737 "Internal error", __FUNCTION__, __LINE__,
5738 "An internal error occurred while getting the status. "
5739 "No update on status can be retrieved. "
5740 "Diagnostics: Failure to connect to manager daemon.",
5741 "/omp?cmd=get_tasks", response_data);
5746 if (openvas_connection_sendf
5751 " filter=\"apply_overrides=%i\""
5760 " sort_field=\"notes_nvt_name, notes.text\""
5763 notes ? task_id :
"",
5764 notes ?
"\"/>" :
"",
5767 " sort_field=\"overrides_nvt_name, overrides.text\""
5770 get_overrides ? task_id :
"",
5771 get_overrides ?
"\"/>" :
"")
5774 openvas_connection_close (&connection);
5777 "Internal error", __FUNCTION__, __LINE__,
5778 "An internal error occurred while getting the status. "
5779 "No update on the requested task can be retrieved. "
5780 "Diagnostics: Failure to send command to manager daemon.",
5781 "/omp?cmd=get_tasks", response_data);
5784 commands_xml = g_string_new (
"");
5785 xml = g_string_new (
"<get_task>");
5788 g_string_append (xml, extra_xml);
5790 g_string_append_printf (xml,
5791 "<apply_overrides>%i</apply_overrides>"
5792 "<delta>%s</delta>",
5797 if (read_string_c (&connection, &commands_xml))
5799 openvas_connection_close (&connection);
5800 g_string_free (commands_xml, TRUE);
5801 g_string_free (xml, TRUE);
5804 "Internal error", __FUNCTION__, __LINE__,
5805 "An internal error occurred while getting the status. "
5806 "No update of the status can be retrieved. "
5807 "Diagnostics: Failure to receive response from manager daemon.",
5808 "/omp?cmd=get_tasks", response_data);
5810 g_string_append (xml, commands_xml->str);
5812 if (parse_entity (commands_xml->str, &commands_entity))
5814 openvas_connection_close (&connection);
5815 g_string_free (commands_xml, TRUE);
5816 g_string_free (xml, TRUE);
5819 "Internal error", __FUNCTION__, __LINE__,
5820 "An internal error occurred while getting the status. "
5821 "No update of the status can be retrieved. "
5822 "Diagnostics: Failure to parse response from manager daemon.",
5823 "/omp?cmd=get_tasks", response_data);
5828 task_entity = entity_child (commands_entity,
"get_tasks_response");
5829 if (task_entity == NULL)
5831 g_warning (
"%s: No get_tasks_response found in manager response.",
5836 task_entity = entity_child (task_entity,
"task");
5837 if (task_entity == NULL)
5838 g_message (
"%s: No task found in manager response.", __FUNCTION__);
5839 else if (get_target || get_alerts)
5841 entities_t child_entities;
5842 entity_t child_entity;
5843 child_entities = task_entity->entities;
5845 while ((child_entity = first_entity (child_entities)))
5848 strcmp (entity_name (child_entity),
"alert") == 0)
5850 const char *resource_id
5851 = entity_attribute (child_entity,
"id");
5853 if (resource_id != NULL && strcmp (resource_id,
""))
5855 if (openvas_connection_sendf (&connection,
5857 " alert_id=\"%s\"/>",
5860 openvas_connection_close (&connection);
5861 g_string_free (xml, TRUE);
5862 g_string_free (commands_xml, TRUE);
5863 free_entity (commands_entity);
5865 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5868 __FUNCTION__, __LINE__,
5869 "An internal error occurred while getting an alert of a task. "
5870 "Diagnostics: Failure to send command to manager daemon.",
5871 "/omp?cmd=get_tasks",
5874 if (read_string_c (&connection, &xml))
5876 openvas_connection_close (&connection);
5877 g_string_free (commands_xml, TRUE);
5878 g_string_free (xml, TRUE);
5879 free_entity (commands_entity);
5881 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5884 __FUNCTION__, __LINE__,
5885 "An internal error occurred while getting an alert of a task. "
5886 "Diagnostics: Failure to receive response from manager daemon.",
5887 "/omp?cmd=get_tasks",
5894 strcmp (entity_name (child_entity),
"target") == 0)
5896 const char *resource_id
5897 = entity_attribute (child_entity,
"id");
5899 if (resource_id != NULL && strcmp (resource_id,
""))
5901 if (openvas_connection_sendf (&connection,
5903 " target_id=\"%s\"/>",
5906 openvas_connection_close (&connection);
5907 g_string_free (xml, TRUE);
5908 g_string_free (commands_xml, TRUE);
5909 free_entity (commands_entity);
5911 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5914 __FUNCTION__, __LINE__,
5915 "An internal error occurred while getting the target of a task. "
5916 "Diagnostics: Failure to send command to manager daemon.",
5917 "/omp?cmd=get_tasks",
5920 if (read_string_c (&connection, &xml))
5922 openvas_connection_close (&connection);
5923 g_string_free (commands_xml, TRUE);
5924 g_string_free (xml, TRUE);
5925 free_entity (commands_entity);
5927 = MHD_HTTP_INTERNAL_SERVER_ERROR;
5930 __FUNCTION__, __LINE__,
5931 "An internal error occurred while getting the target of a task. "
5932 "Diagnostics: Failure to receive response from manager daemon.",
5933 "/omp?cmd=get_tasks",
5939 child_entities = next_entities (child_entities);
5944 g_string_free (commands_xml, TRUE);
5945 free_entity (commands_entity);
5951 if (openvas_connection_sendf (&connection,
5953 " filter=\"first=1 rows=-1 type=4\"/>")
5956 g_string_free (xml, TRUE);
5957 openvas_connection_close (&connection);
5960 "Internal error", __FUNCTION__, __LINE__,
5961 "An internal error occurred while getting slaves list. "
5962 "The current list of resources is not available. "
5963 "Diagnostics: Failure to send command to manager daemon.",
5964 "/omp?cmd=get_tasks", response_data);
5967 if (read_string_c (&connection, &xml))
5969 g_string_free (xml, TRUE);
5970 openvas_connection_close (&connection);
5973 "Internal error", __FUNCTION__, __LINE__,
5974 "An internal error occurred while getting slaves list. "
5975 "The current list of resources is not available. "
5976 "Diagnostics: Failure to receive response from manager daemon.",
5977 "/omp?cmd=get_tasks", response_data);
5983 if (openvas_connection_sendf (&connection,
5985 " filter=\"resource_type=task"
5992 g_string_free (xml, TRUE);
5993 openvas_connection_close (&connection);
5996 "Internal error", __FUNCTION__, __LINE__,
5997 "An internal error occurred while getting tag names list. "
5998 "The current list of resources is not available. "
5999 "Diagnostics: Failure to send command to manager daemon.",
6000 "/omp?cmd=get_resources", response_data);
6003 if (read_string_c (&connection, &xml))
6005 g_string_free (xml, TRUE);
6006 openvas_connection_close (&connection);
6009 "Internal error", __FUNCTION__, __LINE__,
6010 "An internal error occurred while getting tag names list. "
6011 "The current list of resources is not available. "
6012 "Diagnostics: Failure to receive response from manager daemon.",
6013 "/omp?cmd=get_resources", response_data);
6018 g_string_append (xml,
"<permissions>");
6020 if (openvas_connection_sendf (&connection,
6022 " filter=\"name:^.*(task)s?$"
6023 " and resource_uuid=%s"
6024 " first=1 rows=-1\"/>",
6028 g_string_free (xml, TRUE);
6029 openvas_connection_close (&connection);
6032 "Internal error", __FUNCTION__, __LINE__,
6033 "An internal error occurred while getting permissions list. "
6034 "The current list of resources is not available. "
6035 "Diagnostics: Failure to send command to manager daemon.",
6036 "/omp?cmd=get_resources", response_data);
6039 if (read_string_c (&connection, &xml))
6041 g_string_free (xml, TRUE);
6042 openvas_connection_close (&connection);
6045 "Internal error", __FUNCTION__, __LINE__,
6046 "An internal error occurred while getting permissions list. "
6047 "The current list of resources is not available. "
6048 "Diagnostics: Failure to receive response from manager daemon.",
6049 "/omp?cmd=get_resources", response_data);
6052 g_string_append (xml,
"</permissions>");
6054 g_string_append (xml,
"</get_task>");
6056 openvas_connection_close (&connection);
6057 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
6074 return get_task (credentials, params, NULL, response_data);
6092 xml = g_string_new (
"<new_credential>");
6094 g_string_append (xml, extra_xml);
6095 g_string_append (xml,
"</new_credential>");
6096 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
6114 gchar *html, *response;
6115 const char *no_redirect;
6116 const char *name, *comment, *login, *type, *password, *passphrase;
6117 const char *private_key, *certificate, *community, *privacy_password;
6118 const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6132 privacy_password =
params_value (params,
"privacy_password");
6133 auth_algorithm =
params_value (params,
"auth_algorithm");
6134 privacy_algorithm =
params_value (params,
"privacy_algorithm");
6135 allow_insecure =
params_value (params,
"allow_insecure");
6138 autogenerate = strcmp (
params_value (params,
"autogenerate"),
"0");
6141 "Given autogenerate was invalid",
6142 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
6143 "Create Credential",
"new_credential");
6152 if (type && (strcmp (type,
"cc") == 0))
6155 ret = ompf (credentials,
6159 "<create_credential>"
6161 "<comment>%s</comment>"
6163 "<allow_insecure>%s</allow_insecure>"
6164 "</create_credential>",
6166 comment ? comment :
"",
6175 ret = ompf (credentials,
6179 "<create_credential>"
6181 "<comment>%s</comment>"
6184 "<allow_insecure>%s</allow_insecure>"
6185 "</create_credential>",
6187 comment ? comment :
"",
6195 if (type && (strcmp (type,
"up") == 0))
6198 "Create Credential",
"new_credential");
6200 "Create Credential",
"new_credential");
6202 ret = ompf (credentials,
6206 "<create_credential>"
6208 "<comment>%s</comment>"
6211 "<password>%s</password>"
6212 "<allow_insecure>%s</allow_insecure>"
6213 "</create_credential>",
6215 comment ? comment :
"",
6218 password ? password :
"",
6221 else if (type && (strcmp (type,
"usk") == 0))
6224 "Create Credential",
"new_credential");
6226 "Create Credential",
"new_credential");
6228 "Create Credential",
"new_credential");
6230 ret = ompf (credentials,
6234 "<create_credential>"
6236 "<comment>%s</comment>"
6240 "<private>%s</private>"
6241 "<phrase>%s</phrase>"
6243 "<allow_insecure>%s</allow_insecure>"
6244 "</create_credential>",
6246 comment ? comment :
"",
6249 private_key ? private_key :
"",
6250 passphrase ? passphrase :
"",
6253 else if (type && (strcmp (type,
"cc") == 0))
6256 "Create Credential",
"new_credential");
6258 "Create Credential",
"new_credential");
6260 ret = ompf (credentials,
6264 "<create_credential>"
6266 "<comment>%s</comment>"
6268 "<certificate>%s</certificate>"
6270 "<private>%s</private>"
6272 "<allow_insecure>%s</allow_insecure>"
6273 "</create_credential>",
6275 comment ? comment :
"",
6277 certificate ? certificate :
"",
6278 private_key ? private_key :
"",
6282 else if (type && (strcmp (type,
"snmp") == 0))
6285 "Create Credential",
"new_credential");
6287 "Create Credential",
"new_credential");
6289 "Create Credential",
"new_credential");
6291 "Create Credential",
"new_credential");
6293 "Create Credential",
"new_credential");
6295 "Create Credential",
"new_credential");
6297 if (privacy_password && strcmp (privacy_password,
""))
6298 ret = ompf (credentials,
6302 "<create_credential>"
6304 "<comment>%s</comment>"
6306 "<community>%s</community>"
6308 "<password>%s</password>"
6310 "<password>%s</password>"
6311 "<algorithm>%s</algorithm>"
6313 "<auth_algorithm>%s</auth_algorithm>"
6314 "<allow_insecure>%s</allow_insecure>"
6315 "</create_credential>",
6317 comment ? comment :
"",
6319 community ? community :
"",
6321 password ? password :
"",
6322 privacy_password ? privacy_password :
"",
6323 privacy_algorithm ? privacy_algorithm :
"",
6324 auth_algorithm ? auth_algorithm :
"",
6327 ret = ompf (credentials,
6331 "<create_credential>"
6333 "<comment>%s</comment>"
6335 "<community>%s</community>"
6337 "<password>%s</password>"
6338 "<auth_algorithm>%s</auth_algorithm>"
6339 "<allow_insecure>%s</allow_insecure>"
6340 "</create_credential>",
6342 comment ? comment :
"",
6344 community ? community :
"",
6346 password ? password :
"",
6347 auth_algorithm ? auth_algorithm :
"",
6354 "Internal error", __FUNCTION__, __LINE__,
6355 "An internal error occurred while creating a new credential. "
6356 "The credential could not be created. "
6357 "Diagnostics: Unrecognized credential type.",
6358 "/omp?cmd=get_credentials", response_data);
6371 "Internal error", __FUNCTION__, __LINE__,
6372 "An internal error occurred while creating a new credential. "
6373 "It is unclear whether the credential has been created or not. "
6374 "Diagnostics: Failure to send command to manager daemon.",
6375 "/omp?cmd=get_credentials", response_data);
6379 "Internal error", __FUNCTION__, __LINE__,
6380 "An internal error occurred while creating a new credential. "
6381 "It is unclear whether the credential has been created or not. "
6382 "Diagnostics: Failure to receive response from manager daemon.",
6383 "/omp?cmd=get_credentials", response_data);
6387 "Internal error", __FUNCTION__, __LINE__,
6388 "An internal error occurred while creating a new credential. "
6389 "It is unclear whether the credential has been created or not. "
6390 "Diagnostics: Internal Error.",
6391 "/omp?cmd=get_credentials", response_data);
6394 if (entity_attribute (entity,
"id"))
6395 params_add (params,
"credential_id", entity_attribute (entity,
"id"));
6396 html = response_from_entity (credentials, params, entity,
6397 (no_redirect && strcmp (no_redirect,
"0")),
6398 NULL,
"get_credentials",
6399 NULL,
"new_credential",
6400 "Create Credential",
6402 free_entity (entity);
6421 return get_one (
"credential", credentials, params, extra_xml,
6422 "targets=\"1\" scanners=\"1\"", response_data);
6438 return get_credential (credentials, params, NULL, response_data);
6463 openvas_connection_t connection;
6464 gchar *connect_html;
6465 const char *credential_id, *format;
6469 if (result_len) *result_len = 0;
6479 *html = connect_html;
6486 "Internal error", __FUNCTION__, __LINE__,
6487 "An internal error occurred while getting a credential. "
6488 "Diagnostics: Failure to connect to manager daemon.",
6489 "/omp?cmd=get_credentials", response_data);
6495 credential_id =
params_value (params,
"credential_id");
6498 if ((credential_id == NULL) || (format == NULL))
6500 openvas_connection_close (&connection);
6503 "Internal error", __FUNCTION__, __LINE__,
6504 "An internal error occurred while getting a credential. "
6505 "Diagnostics: Required parameter was NULL.",
6506 "/omp?cmd=get_credentials", response_data);
6510 if (openvas_connection_sendf (&connection,
6512 " credential_id=\"%s\""
6518 openvas_connection_close (&connection);
6521 "Internal error", __FUNCTION__, __LINE__,
6522 "An internal error occurred while getting a credential. "
6523 "Diagnostics: Failure to send command to manager daemon.",
6524 "/omp?cmd=get_credentials", response_data);
6530 if (strcmp (format,
"rpm") == 0
6531 || strcmp (format,
"deb") == 0
6532 || strcmp (format,
"exe") == 0)
6534 gchar *package_decoded = NULL;
6535 entity_t package_entity = NULL, credential_entity;
6540 if (read_entity_c (&connection, &entity))
6542 openvas_connection_close (&connection);
6545 "Internal error", __FUNCTION__, __LINE__,
6546 "An internal error occurred while getting a credential. "
6547 "The credential is not available. "
6548 "Diagnostics: Failure to receive response from manager daemon.",
6549 "/omp?cmd=get_credentials", response_data);
6553 credential_entity = entity_child (entity,
"credential");
6554 if (credential_entity)
6555 package_entity = entity_child (credential_entity,
"package");
6556 if (package_entity != NULL)
6559 char *package_encoded = entity_text (package_entity);
6560 if (strlen (package_encoded))
6562 package_decoded = (gchar *) g_base64_decode (package_encoded,
6564 if (package_decoded == NULL)
6566 package_decoded = (gchar *) g_strdup (
"");
6572 package_decoded = (gchar *) g_strdup (
"");
6575 if (result_len) *result_len = len;
6576 openvas_connection_close (&connection);
6577 *html = package_decoded;
6580 entity_t login_entity;
6581 login_entity = entity_child (credential_entity,
"login");
6583 *login = g_strdup (entity_text (login_entity));
6587 free_entity (entity);
6592 free_entity (entity);
6593 openvas_connection_close (&connection);
6596 "Internal error", __FUNCTION__, __LINE__,
6597 "An internal error occurred while getting a credential. "
6598 "The credential could not be delivered. "
6599 "Diagnostics: Failure to receive credential from manager daemon.",
6600 "/omp?cmd=get_credentials", response_data);
6606 entity_t credential_entity, key_entity = NULL;
6611 if (read_entity_c (&connection, &entity))
6613 openvas_connection_close (&connection);
6616 "Internal error", __FUNCTION__, __LINE__,
6617 "An internal error occurred while getting a credential. "
6618 "The credential could not be delivered. "
6619 "Diagnostics: Failure to receive credential from manager daemon.",
6620 "/omp?cmd=get_credentials", response_data);
6623 openvas_connection_close (&connection);
6625 credential_entity = entity_child (entity,
"credential");
6626 if (credential_entity)
6628 if (strcmp (format,
"pem") == 0)
6629 key_entity = entity_child (credential_entity,
"certificate");
6631 key_entity = entity_child (credential_entity,
"public_key");
6633 if (key_entity != NULL)
6635 *html = g_strdup (entity_text (key_entity));
6638 entity_t login_entity = entity_child (credential_entity,
"login");
6640 *login = g_strdup (entity_text (login_entity));
6644 free_entity (entity);
6649 "Internal error", __FUNCTION__, __LINE__,
6650 "An internal error occurred while getting a credential. "
6651 "The credential could not be delivered. "
6652 "Diagnostics: Failure to parse credential from manager daemon.",
6653 "/omp?cmd=get_credentials", response_data);
6654 free_entity (entity);
6674 enum content_type * content_type,
6675 char **content_disposition, gsize *content_length,
6678 return export_resource (
"credential", credentials, params, content_type,
6679 content_disposition, content_length, response_data);
6697 enum content_type * content_type,
6698 char **content_disposition, gsize *content_length,
6701 return export_many (
"credential", credentials, params, content_type,
6702 content_disposition, content_length, response_data);
6720 return get_many (
"credential", credentials, params, extra_xml, NULL,
6737 return get_credentials (credentials, params, NULL, response_data);
6754 "get_credentials", response_data);
6770 return new_credential (credentials, params, NULL, response_data);
6787 return edit_resource (
"credential", credentials, params, NULL, extra_xml,
6804 return edit_credential (credentials, params, NULL, response_data);
6820 int ret, change_password, change_passphrase;
6821 int change_community, change_privacy_password;
6822 gchar *html, *response;
6823 const char *no_redirect, *credential_id;
6824 const char *name, *comment, *login, *password, *passphrase;
6825 const char *private_key, *certificate, *community, *privacy_password;
6826 const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6831 credential_id =
params_value (params,
"credential_id");
6840 privacy_password =
params_value (params,
"privacy_password");
6841 auth_algorithm =
params_value (params,
"auth_algorithm");
6842 privacy_algorithm =
params_value (params,
"privacy_algorithm");
6843 allow_insecure =
params_value (params,
"allow_insecure");
6859 "Save Credential",
"edit_credential");
6861 change_community = (
params_value (params,
"change_community") ? 1 : 0);
6862 if (change_community)
6864 change_passphrase = (
params_value (params,
"change_passphrase") ? 1 : 0);
6865 if (change_passphrase)
6867 change_password = (
params_value (params,
"change_password") ? 1 : 0);
6868 if (change_password)
6870 change_privacy_password
6871 = (
params_value (params,
"change_privacy_password") ? 1 : 0);
6872 if (change_privacy_password)
6874 "Save Credential",
"edit_credential");
6877 command = g_string_new (
"");
6879 xml_string_append (command,
6880 "<modify_credential credential_id=\"%s\">"
6882 "<comment>%s</comment>"
6883 "<allow_insecure>%s</allow_insecure>",
6890 xml_string_append (command,
6891 "<auth_algorithm>%s</auth_algorithm>",
6894 if (certificate && strcmp (certificate,
""))
6895 xml_string_append (command,
6896 "<certificate>%s</certificate>",
6899 if (change_community)
6900 xml_string_append (command,
6901 "<community>%s</community>",
6904 if (login && strcmp (login,
""))
6905 xml_string_append (command,
6906 "<login>%s</login>",
6909 if (change_password)
6910 xml_string_append (command,
6911 "<password>%s</password>",
6914 if (privacy_algorithm || change_privacy_password)
6916 xml_string_append (command,
6918 if (privacy_algorithm && strcmp (privacy_algorithm,
""))
6920 xml_string_append (command,
6921 "<algorithm>%s</algorithm>",
6923 if (change_privacy_password)
6924 xml_string_append (command,
6925 "<password>%s</password>",
6928 else if (privacy_algorithm)
6930 xml_string_append (command,
6931 "<algorithm></algorithm>");
6932 xml_string_append (command,
6933 "<password></password>");
6936 xml_string_append (command,
6940 if ((private_key && strcmp (private_key,
"")) || change_passphrase)
6942 xml_string_append (command,
6944 if (change_passphrase)
6945 xml_string_append (command,
6946 "<phrase>%s</phrase>",
6949 xml_string_append (command,
6950 "<private>%s</private>",
6952 xml_string_append (command,
6956 xml_string_append (command,
6957 "</modify_credential>");
6962 ret = omp (credentials,
6967 g_string_free (command, TRUE);
6979 "Internal error", __FUNCTION__, __LINE__,
6980 "An internal error occurred while saving a Credential. "
6981 "The Credential was not saved. "
6982 "Diagnostics: Failure to send command to manager daemon.",
6983 "/omp?cmd=get_credentials", response_data);
6987 "Internal error", __FUNCTION__, __LINE__,
6988 "An internal error occurred while saving a Credential. "
6989 "It is unclear whether the Credential has been saved or not. "
6990 "Diagnostics: Failure to receive response from manager daemon.",
6991 "/omp?cmd=get_credentials", response_data);
6995 "Internal error", __FUNCTION__, __LINE__,
6996 "An internal error occurred while saving a Credential. "
6997 "It is unclear whether the Credential has been saved or not. "
6998 "Diagnostics: Internal Error.",
6999 "/omp?cmd=get_credentials", response_data);
7002 html = response_from_entity (credentials, params, entity,
7003 (no_redirect && strcmp (no_redirect,
"0")),
7004 NULL,
"get_credentials",
7005 NULL,
"edit_credential",
7006 "Save Credential", response_data);
7007 free_entity (entity);
7027 xml = g_string_new (
"<new_agent>");
7029 g_string_append (xml, extra_xml);
7030 g_string_append (xml,
"</new_agent>");
7031 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
7048 return new_agent (credentials, params, NULL, response_data);
7065 gchar *response, *html;
7066 const char *no_redirect;
7067 const char *name, *comment, *installer, *installer_filename, *installer_sig;
7068 const char *howto_install, *howto_use;
7069 int installer_size, installer_sig_size, howto_install_size, howto_use_size;
7071 gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
7080 installer_sig =
params_value (params,
"installer_sig");
7082 howto_install =
params_value (params,
"howto_install");
7092 installer_64 = (installer_size > 0)
7093 ? g_base64_encode ((guchar *) installer,
7097 installer_sig_64 = (installer_sig_size > 0)
7098 ? g_base64_encode ((guchar *) installer_sig,
7102 howto_install_64 = (howto_install_size > 0)
7103 ? g_base64_encode ((guchar *) howto_install,
7107 howto_use_64 = (howto_use_size > 0)
7108 ? g_base64_encode ((guchar *) howto_use,
7112 command = g_strdup_printf (
"<create_agent>"
7117 "<signature>%s</signature>"
7118 "<filename>%s</filename>"
7120 "<howto_install>%s</howto_install>"
7121 "<howto_use>%s</howto_use>"
7123 name, comment ?
"<comment>" :
"",
7124 comment ? comment :
"",
7125 comment ?
"</comment>" :
"",
7128 installer_filename ? installer_filename :
"",
7132 ret = omp (credentials,
7139 g_free (installer_64);
7140 g_free (howto_install_64);
7141 g_free (howto_use_64);
7153 "Internal error", __FUNCTION__, __LINE__,
7154 "An internal error occurred while creating a new agent. "
7155 "No new agent was created. "
7156 "Diagnostics: Failure to send command to manager daemon.",
7157 "/omp?cmd=get_agents", response_data);
7161 "Internal error", __FUNCTION__, __LINE__,
7162 "An internal error occurred while creating a new agent. "
7163 "It is unclear whether the agent has been created or not. "
7164 "Diagnostics: Failure to receive response from manager daemon.",
7165 "/omp?cmd=get_agents", response_data);
7169 "Internal error", __FUNCTION__, __LINE__,
7170 "An internal error occurred while creating a new agent. "
7171 "It is unclear whether the agent has been created or not. "
7172 "Diagnostics: Internal Error.",
7173 "/omp?cmd=get_agents", response_data);
7176 if (entity_attribute (entity,
"id"))
7177 params_add (params,
"agent_id", entity_attribute (entity,
"id"));
7178 html = response_from_entity (credentials, params, entity,
7179 (no_redirect && strcmp (no_redirect,
"0")),
7182 "Create Agent", response_data);
7183 free_entity (entity);
7201 return delete_resource (
"agent", credentials, params, 0,
"get_agents",
7227 openvas_connection_t connection;
7228 gchar *connect_html;
7229 const char *agent_id, *format;
7234 if ((agent_id == NULL) || (format == NULL))
7238 "Internal error", __FUNCTION__, __LINE__,
7239 "An internal error occurred while downloading "
7241 "Diagnostics: Required parameter was NULL.",
7242 "/omp?cmd=get_agents", response_data);
7256 *html = connect_html;
7264 "Internal error", __FUNCTION__, __LINE__,
7265 "An internal error occurred while getting the agent list. "
7266 "The current list of agents is not available. "
7267 "Diagnostics: Failure to connect to manager daemon.",
7268 "/omp?cmd=get_agents", response_data);
7275 if (openvas_connection_sendf (&connection,
7276 "<get_agents agent_id=\"%s\" format=\"%s\"/>",
7281 openvas_connection_close (&connection);
7284 "Internal error", __FUNCTION__, __LINE__,
7285 "An internal error occurred while getting agent list. "
7286 "The current list of agents is not available. "
7287 "Diagnostics: Failure to send command to manager daemon.",
7288 "/omp?cmd=get_agents", response_data);
7294 if (strcmp (format,
"installer") == 0
7295 || strcmp (format,
"howto_install") == 0
7296 || strcmp (format,
"howto_use") == 0)
7298 gchar *package_decoded = NULL;
7299 entity_t package_entity = NULL, agent_entity;
7304 if (read_entity_c (&connection, &entity))
7306 openvas_connection_close (&connection);
7309 "Internal error", __FUNCTION__, __LINE__,
7310 "An internal error occurred while getting a agent. "
7311 "The agent is not available. "
7312 "Diagnostics: Failure to receive response from manager daemon.",
7313 "/omp?cmd=get_agents", response_data);
7317 agent_entity = entity_child (entity,
"agent");
7319 package_entity = entity_child (agent_entity,
"package");
7320 if (package_entity != NULL)
7322 char *package_encoded = entity_text (package_entity);
7323 if (strlen (package_encoded))
7325 package_decoded = (gchar *) g_base64_decode (package_encoded,
7327 if (package_decoded == NULL)
7329 package_decoded = (gchar *) g_strdup (
"");
7335 package_decoded = (gchar *) g_strdup (
"");
7338 openvas_connection_close (&connection);
7339 *html = package_decoded;
7342 entity_t filename_entity;
7343 filename_entity = entity_child (package_entity,
7345 if (filename_entity)
7346 *filename = g_strdup (entity_text (filename_entity));
7349 if (!(*filename && strlen (*filename)))
7352 *filename = g_strdup_printf (
"agent-%s-%s", agent_id, format);
7355 free_entity (entity);
7360 free_entity (entity);
7361 openvas_connection_close (&connection);
7364 "Internal error", __FUNCTION__, __LINE__,
7365 "An internal error occurred while getting a agent. "
7366 "The agent could not be delivered. "
7367 "Diagnostics: Failure to receive agent from manager daemon.",
7368 "/omp?cmd=get_tasks", response_data);
7377 if (read_entity_c (&connection, &entity))
7379 openvas_connection_close (&connection);
7382 "Internal error", __FUNCTION__, __LINE__,
7383 "An internal error occurred while getting a agent. "
7384 "The agent could not be delivered. "
7385 "Diagnostics: Failure to receive agent from manager daemon.",
7386 "/omp?cmd=get_tasks", response_data);
7389 openvas_connection_close (&connection);
7391 free_entity (entity);
7394 "Internal error", __FUNCTION__, __LINE__,
7395 "An internal error occurred while getting a agent. "
7396 "The agent could not be delivered. "
7397 "Diagnostics: Failure to parse agent from manager daemon.",
7398 "/omp?cmd=get_tasks", response_data);
7417 return edit_resource (
"agent", credentials, params, NULL, extra_xml,
7434 return edit_agent (credentials, params, NULL, response_data);
7451 gchar *html, *response;
7452 const char *no_redirect, *agent_id, *name, *comment;
7468 ret = ompf (credentials,
7472 "<modify_agent agent_id=\"%s\">"
7474 "<comment>%s</comment>"
7488 "Internal error", __FUNCTION__, __LINE__,
7489 "An internal error occurred while saving a agent. "
7490 "The agent was not saved. "
7491 "Diagnostics: Failure to send command to manager daemon.",
7492 "/omp?cmd=get_agents", response_data);
7496 "Internal error", __FUNCTION__, __LINE__,
7497 "An internal error occurred while saving a agent. "
7498 "It is unclear whether the agent has been saved or not. "
7499 "Diagnostics: Failure to receive response from manager daemon.",
7500 "/omp?cmd=get_agents", response_data);
7504 "Internal error", __FUNCTION__, __LINE__,
7505 "An internal error occurred while saving a agent. "
7506 "It is unclear whether the agent has been saved or not. "
7507 "Diagnostics: Internal Error.",
7508 "/omp?cmd=get_agents", response_data);
7511 html = response_from_entity (credentials, params, entity,
7512 (no_redirect && strcmp (no_redirect,
"0")),
7515 "Save Agent", response_data);
7516 free_entity (entity);
7535 return get_one (
"agent", credentials, params, extra_xml, NULL, response_data);
7551 return get_agent (credentials, params, NULL, response_data);
7568 return get_many (
"agent", credentials, params, extra_xml, NULL,
7585 return get_agents (credentials, params, NULL, response_data);
7601 gchar *html, *response;
7602 const char *agent_id;
7607 if (agent_id == NULL)
7611 "Internal error", __FUNCTION__, __LINE__,
7612 "An internal error occurred while verifying an agent. "
7613 "Diagnostics: Required parameter was NULL.",
7614 "/omp?cmd=get_agents", response_data);
7618 ret = ompf (credentials,
7622 "<verify_agent agent_id=\"%s\" />",
7633 "Internal error", __FUNCTION__, __LINE__,
7634 "An internal error occurred while verifying a agent. "
7635 "The agent was not verified. "
7636 "Diagnostics: Failure to send command to manager daemon.",
7637 "/omp?cmd=get_agents", response_data);
7641 "Internal error", __FUNCTION__, __LINE__,
7642 "An internal error occurred while verifying a agent. "
7643 "It is unclear whether the agent was verified or not. "
7644 "Diagnostics: Failure to send command to manager daemon.",
7645 "/omp?cmd=get_agents", response_data);
7649 "Internal error", __FUNCTION__, __LINE__,
7650 "An internal error occurred while verifying a agent. "
7651 "It is unclear whether the agent was verified or not. "
7652 "Diagnostics: Failure to send command to manager daemon.",
7653 "/omp?cmd=get_agents", response_data);
7656 if (omp_success (entity))
7658 html = next_page (credentials, params, response, response_data);
7661 free_entity (entity);
7665 "Internal error", __FUNCTION__, __LINE__,
7666 "An internal error occurred while verifying a agent. "
7667 "It is unclear whether the agent was verified or not. "
7668 "Diagnostics: Failure to receive response from manager daemon.",
7669 "/omp?cmd=get_agents", response_data);
7675 html = get_agents (credentials, params, response, response_data);
7677 free_entity (entity);
7696 enum content_type * content_type,
char **content_disposition,
7700 content_disposition, content_length, response_data);
7718 enum content_type * content_type,
char **content_disposition,
7721 return export_many (
"agent", credentials, params, content_type,
7722 content_disposition, content_length, response_data);
7738 params_t *data_columns, *text_columns;
7739 params_t *sort_fields, *sort_stats, *sort_orders;
7746 const char *data_column, *group_column, *subgroup_column, *type;
7747 const char *filter, *filt_id, *xml_param;
7748 const char *first_group, *max_groups;
7750 gchar *filter_escaped, *command_escaped, *response;
7752 GString *xml, *command;
7759 subgroup_column =
params_value (params,
"subgroup_column");
7770 filter_escaped = g_markup_escape_text (filter, -1);
7774 || strcmp (filt_id,
"") == 0
7775 || strcmp (filt_id,
"0") == 0)
7776 filter_escaped = g_strdup (
"rows=-2");
7778 filter_escaped = NULL;
7782 if (xml_param == NULL || atoi (xml_param) == 0)
7784 return xsl_transform_omp (credentials, g_strdup (
"<get_aggregate/>"),
7787 xml = g_string_new (
"<get_aggregate>");
7789 command = g_string_new (
"<get_aggregates");
7790 g_string_append_printf (command,
" type=\"%s\"", type);
7792 g_string_append_printf (command,
" data_column=\"%s\"", data_column);
7794 g_string_append_printf (command,
" group_column=\"%s\"", group_column);
7795 if (subgroup_column)
7796 g_string_append_printf (command,
7797 " subgroup_column=\"%s\"", subgroup_column);
7798 if (filter_escaped && strcmp (filter_escaped,
""))
7799 g_string_append_printf (command,
" filter=\"%s\"", filter_escaped);
7800 if (filt_id && strcmp (filt_id,
""))
7801 g_string_append_printf (command,
" filt_id=\"%s\"", filt_id);
7802 if (first_group && strcmp (first_group,
""))
7803 g_string_append_printf (command,
" first_group=\"%s\"", first_group);
7804 if (max_groups && strcmp (max_groups,
""))
7805 g_string_append_printf (command,
" max_groups=\"%s\"", max_groups);
7806 if (mode && strcmp (mode,
""))
7807 g_string_append_printf (command,
" mode=\"%s\"", mode);
7808 g_string_append (command,
">");
7810 if (sort_fields && sort_stats && sort_orders)
7812 param_t *field_param, *stat_param, *order_param;
7813 gchar *field_i, *stat_i, *order_i;
7820 &field_i, &field_param)
7822 &stat_i, &stat_param)
7824 &order_i, &order_param))
7828 xml_string_append (command,
7829 "<sort field=\"%s\""
7832 field_param->
value ? field_param->
value :
"",
7834 order_param->
value ? order_param->
value :
"");
7846 xml_string_append (command,
7847 "<data_column>%s</data_column>",
7860 xml_string_append (command,
7861 "<text_column>%s</text_column>",
7867 g_string_append (command,
"</get_aggregates>");
7869 g_free (filter_escaped);
7871 command_escaped = g_markup_escape_text (command->str, -1);
7872 g_string_append (xml, command_escaped);
7873 g_free (command_escaped);
7875 ret = omp (credentials, &response, &entity, response_data, command->str);
7876 g_string_free (command, TRUE);
7887 "Internal error", __FUNCTION__, __LINE__,
7888 "An internal error occurred while getting aggregates. "
7889 "Diagnostics: Failure to send command to manager daemon.",
7890 "/omp?cmd=get_tasks", response_data);
7894 "Internal error", __FUNCTION__, __LINE__,
7895 "An internal error occurred while getting aggregates. "
7896 "Diagnostics: Failure to receive response from manager daemon.",
7897 "/omp?cmd=get_tasks", response_data);
7901 "Internal error", __FUNCTION__, __LINE__,
7902 "An internal error occurred while getting aggregates. "
7903 "Diagnostics: Internal Error.",
7904 "/omp?cmd=get_tasks", response_data);
7907 g_string_append (xml, response);
7909 g_string_append (xml,
"</get_aggregate>");
7911 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
7934 xml = g_string_new (
"<new_alert>");
7936 g_string_append (xml, extra_xml);
7942 ret = omp (credentials, &response, &entity, response_data,
7943 "<get_report_formats filter=\"rows=-1\"/>");
7952 "Internal error", __FUNCTION__, __LINE__,
7953 "An internal error occurred while getting Report "
7954 "Formats for new alert. "
7955 "Diagnostics: Failure to send command to manager daemon.",
7956 "/omp?cmd=get_alerts", response_data);
7960 "Internal error", __FUNCTION__, __LINE__,
7961 "An internal error occurred while getting Report "
7962 "Formats for new alert. "
7963 "Diagnostics: Failure to receive response from manager daemon.",
7964 "/omp?cmd=get_alerts", response_data);
7968 "Internal error", __FUNCTION__, __LINE__,
7969 "An internal error occurred while getting Report "
7970 "Formats for new alert. It is unclear whether"
7971 " the alert has been saved or not. "
7972 "Diagnostics: Internal Error.",
7973 "/omp?cmd=get_alerts", response_data);
7975 g_string_append (xml, response);
7977 free_entity (entity);
7981 ret = omp (credentials, &response, &entity, response_data,
7982 "<get_filters filter=\"rows=-1\"/>");
7992 "Internal error", __FUNCTION__, __LINE__,
7993 "An internal error occurred while getting Report "
7994 "Filters for new alert. "
7995 "The task was not saved. "
7996 "Diagnostics: Failure to send command to manager daemon.",
7997 "/omp?cmd=get_alerts", response_data);
8001 "Internal error", __FUNCTION__, __LINE__,
8002 "An internal error occurred while getting Report "
8003 "Filters for new alert. "
8004 "Diagnostics: Failure to receive response from manager daemon.",
8005 "/omp?cmd=get_alerts", response_data);
8009 "Internal error", __FUNCTION__, __LINE__,
8010 "An internal error occurred while getting Report "
8011 "Filters for new alert. "
8012 "Diagnostics: Internal Error.",
8013 "/omp?cmd=get_alerts", response_data);
8015 g_string_append (xml, response);
8017 free_entity (entity);
8021 ret = omp (credentials, &response, &entity, response_data,
8023 " schedules_only=\"1\""
8024 " filter=\"owner=any permission=start_task rows=-1\"/>");
8034 "Internal error", __FUNCTION__, __LINE__,
8035 "An internal error occurred while getting Tasks"
8037 "The task was not saved. "
8038 "Diagnostics: Failure to send command to manager daemon.",
8039 "/omp?cmd=get_alerts",
8044 "Internal error", __FUNCTION__, __LINE__,
8045 "An internal error occurred while getting Tasks"
8047 "Diagnostics: Failure to receive response from manager daemon.",
8048 "/omp?cmd=get_alerts",
8053 "Internal error", __FUNCTION__, __LINE__,
8054 "An internal error occurred while getting Tasks"
8056 "Diagnostics: Internal Error.",
8057 "/omp?cmd=get_alerts",
8060 g_string_append (xml, response);
8062 free_entity (entity);
8066 ret = omp (credentials, &response, &entity, response_data,
8068 " filter=\"type=up owner=any permission=any rows=-1\"/>");
8078 "Internal error", __FUNCTION__, __LINE__,
8079 "An internal error occurred while getting"
8080 " Credentials for new alert. "
8081 "The task was not saved. "
8082 "Diagnostics: Failure to send command to manager daemon.",
8083 "/omp?cmd=get_alerts",
8088 "Internal error", __FUNCTION__, __LINE__,
8089 "An internal error occurred while getting"
8090 " Credentials for new alert. "
8091 "Diagnostics: Failure to receive response from manager daemon.",
8092 "/omp?cmd=get_alerts",
8097 "Internal error", __FUNCTION__, __LINE__,
8098 "An internal error occurred while getting"
8099 " Credentials for new alert. "
8100 "Diagnostics: Internal Error.",
8101 "/omp?cmd=get_alerts",
8105 g_string_append (xml, response);
8107 free_entity (entity);
8109 g_string_append (xml,
"</new_alert>");
8110 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
8127 return new_alert (credentials, params, NULL, response_data);
8143 append_alert_event_data (GString *xml,
params_t *data,
const char *event)
8153 if ((strcmp (event,
"Task run status changed") == 0
8154 && strcmp (name,
"status") == 0)
8155 || ((strcmp (event,
"New SecInfo arrived") == 0
8156 || strcmp (event,
"Updated SecInfo arrived") == 0)
8157 && strcmp (name,
"secinfo_type") == 0))
8158 xml_string_append (xml,
8159 "<data><name>%s</name>%s</data>",
8173 append_alert_condition_data (GString *xml,
params_t *data,
8174 const char * condition)
8185 if (strcmp (condition,
"Filter count at least") == 0)
8187 if (strcmp (name,
"at_least_count") == 0)
8188 xml_string_append (xml,
8189 "<data><name>count</name>%s</data>",
8191 if (strcmp (name,
"at_least_filter_id") == 0)
8192 xml_string_append (xml,
8193 "<data><name>filter_id</name>%s</data>",
8196 else if (strcmp (condition,
"Filter count changed") == 0)
8198 if (strcmp (name,
"count") == 0
8199 || strcmp (name,
"filter_id") == 0)
8200 xml_string_append (xml,
8201 "<data><name>%s</name>%s</data>",
8204 else if (strcmp (name,
"filter_direction") == 0)
8205 xml_string_append (xml,
8206 "<data><name>direction</name>%s</data>",
8209 else if ((strcmp (condition,
"Severity at least") == 0
8210 && strcmp (name,
"severity") == 0)
8211 || (strcmp (condition,
"Severity changed") == 0
8212 && strcmp (name,
"direction") == 0))
8213 xml_string_append (xml,
8214 "<data><name>%s</name>%s</data>",
8229 append_alert_method_data (GString *xml,
params_t *data,
const char *method)
8243 if (strcmp (name,
"notice") == 0)
8245 notice = atoi (param->
value);
8249 if (strcmp (method,
"Sourcefire Connector"))
8254 if ((strcmp (method,
"HTTP Get") == 0
8255 && strcmp (name,
"URL") == 0)
8256 || (strcmp (method,
"Send") == 0
8257 && (strcmp (name,
"send_host") == 0
8258 || strcmp (name,
"send_port") == 0
8259 || strcmp (name,
"send_report_format") == 0))
8260 || (strcmp (method,
"SCP") == 0
8261 && (strcmp (name,
"scp_credential") == 0
8262 || strcmp (name,
"scp_host") == 0
8263 || strcmp (name,
"scp_known_hosts") == 0
8264 || strcmp (name,
"scp_path") == 0
8265 || strcmp (name,
"scp_report_format") == 0))
8266 || (strcmp (method,
"SNMP") == 0
8267 && (strcmp (name,
"snmp_community") == 0
8268 || strcmp (name,
"snmp_agent") == 0
8269 || strcmp (name,
"snmp_message") == 0))
8270 || (strcmp (method,
"verinice Connector") == 0
8271 && (strcmp (name,
"verinice_server_credential") == 0
8272 || strcmp (name,
"verinice_server_url") == 0
8273 || strcmp (name,
"verinice_server_report_format") == 0))
8274 || (strcmp (method,
"Email") == 0
8275 && (strcmp (name,
"to_address") == 0
8276 || strcmp (name,
"from_address") == 0
8277 || strcmp (name,
"subject") == 0
8278 || strcmp (name,
"notice") == 0
8279 || (strcmp (name,
"notice_report_format") == 0
8281 || (strcmp (name,
"notice_attach_format") == 0
8283 || (strcmp (method,
"Syslog") == 0
8284 && strcmp (name,
"submethod") == 0)
8285 || (strcmp (method,
"Start Task") == 0
8286 && strcmp (name,
"start_task_task") == 0)
8287 || strcmp (name,
"details_url") == 0)
8288 xml_string_append (xml,
8289 "<data><name>%s</name>%s</data>",
8292 else if (strcmp (method,
"Email") == 0
8294 && strcmp (name,
"message") == 0)
8295 xml_string_append (xml,
8296 "<data><name>message</name>%s</data>",
8298 else if (strcmp (method,
"Email") == 0
8300 && strcmp (name,
"message_attach") == 0)
8301 xml_string_append (xml,
8302 "<data><name>message</name>%s</data>",
8310 if (strcmp (name,
"pkcs12"))
8312 if (strcmp (name,
"defense_center_ip") == 0
8313 || strcmp (name,
"defense_center_port") == 0)
8314 xml_string_append (xml,
8315 "<data><name>%s</name>%s</data>",
8326 ? g_base64_encode ((guchar*) param->
value,
8329 xml_string_append (xml,
8330 "<data><name>%s</name>%s</data>",
8351 gchar *html, *response;
8352 const char *no_redirect;
8353 const char *name, *comment, *condition, *event, *method, *filter_id;
8354 params_t *method_data, *event_data, *condition_data;
8379 xml = g_string_new (
"");
8381 if ((strcmp (event,
"New SecInfo arrived") == 0) && event_data)
8389 if ((strcmp (name,
"feed_event") == 0)
8391 && (strcmp (param->
value,
"updated") == 0))
8393 event =
"Updated SecInfo arrived";
8398 xml_string_append (xml,
8401 "<filter id=\"%s\"/>"
8402 "<comment>%s</comment>"
8406 comment ? comment :
"",
8409 append_alert_event_data (xml, event_data, event);
8411 xml_string_append (xml,
8416 append_alert_method_data (xml, method_data, method);
8418 xml_string_append (xml,
8423 append_alert_condition_data (xml, condition_data, condition);
8425 xml_string_append (xml,
8429 ret = omp (credentials,
8434 g_string_free (xml, TRUE);
8443 "Internal error", __FUNCTION__, __LINE__,
8444 "An internal error occurred while creating a new alert. "
8445 "No new alert was created. "
8446 "Diagnostics: Failure to send command to manager daemon.",
8447 "/omp?cmd=get_alerts", response_data);
8451 "Internal error", __FUNCTION__, __LINE__,
8452 "An internal error occurred while creating a new alert. "
8453 "It is unclear whether the alert has been created or not. "
8454 "Diagnostics: Failure to receive response from manager daemon.",
8455 "/omp?cmd=get_alerts", response_data);
8459 "Internal error", __FUNCTION__, __LINE__,
8460 "An internal error occurred while creating a new alert. "
8461 "It is unclear whether the alert has been created or not. "
8462 "Diagnostics: Internal Error.",
8463 "/omp?cmd=get_alerts", response_data);
8466 if (entity_attribute (entity,
"id"))
8467 params_add (params,
"alert_id", entity_attribute (entity,
"id"));
8468 html = response_from_entity (credentials, params, entity,
8469 (no_redirect && strcmp (no_redirect,
"0")),
8472 "Create Alert", response_data);
8473 free_entity (entity);
8491 return delete_resource (
"alert", credentials, params, 0,
"get_alerts",
8512 extra = g_string_new (
"");
8514 g_string_append (extra, extra_xml);
8522 switch (omp (credentials, &response, &entity, response_data,
8523 "<get_report_formats"
8524 " filter=\"rows=-1\"/>"))
8532 "Internal error", __FUNCTION__, __LINE__,
8533 "An internal error occurred while getting Report "
8534 "Formats for the alert. "
8535 "Diagnostics: Failure to send command to manager daemon.",
8536 "/omp?cmd=get_alerts", response_data);
8540 "Internal error", __FUNCTION__, __LINE__,
8541 "An internal error occurred while getting Report "
8542 "Formats for the alert. "
8543 "Diagnostics: Failure to receive response from manager daemon.",
8544 "/omp?cmd=get_alerts", response_data);
8548 "Internal error", __FUNCTION__, __LINE__,
8549 "An internal error occurred while getting Report "
8550 "Formats for the alert. "
8551 "It is unclear whether the task has been saved or not. "
8552 "Diagnostics: Internal Error.",
8553 "/omp?cmd=get_alerts", response_data);
8556 g_string_append (extra, response);
8558 free_entity (entity);
8569 switch (omp (credentials, &response, &entity, response_data,
8571 " schedules_only=\"1\""
8572 " filter=\"owner=any permission=start_task rows=-1\"/>"))
8580 "Internal error", __FUNCTION__, __LINE__,
8581 "An internal error occurred while getting Tasks "
8583 "Diagnostics: Failure to send command to manager daemon.",
8584 "/omp?cmd=get_alerts", response_data);
8588 "Internal error", __FUNCTION__, __LINE__,
8589 "An internal error occurred while getting Tasks "
8591 "Diagnostics: Failure to receive response from manager daemon.",
8592 "/omp?cmd=get_alerts", response_data);
8596 "Internal error", __FUNCTION__, __LINE__,
8597 "An internal error occurred while getting Tasks "
8599 "Diagnostics: Internal Error.",
8600 "/omp?cmd=get_alerts", response_data);
8603 g_string_append (extra, response);
8605 free_entity (entity);
8618 switch (omp (credentials, &response, &entity, response_data,
8620 " filter=\"type=result rows=-1\"/>"))
8628 "Internal error", __FUNCTION__, __LINE__,
8629 "An internal error occurred while getting filters "
8631 "Diagnostics: Failure to send command to manager daemon.",
8632 "/omp?cmd=get_alerts", response_data);
8636 "Internal error", __FUNCTION__, __LINE__,
8637 "An internal error occurred while getting filters "
8639 "Diagnostics: Failure to receive response from manager daemon.",
8640 "/omp?cmd=get_alerts", response_data);
8644 "Internal error", __FUNCTION__, __LINE__,
8645 "An internal error occurred while getting filters "
8647 "Diagnostics: Internal Error.",
8648 "/omp?cmd=get_alerts", response_data);
8651 g_string_append (extra, response);
8653 free_entity (entity);
8657 html =
get_one (
"alert", credentials, params, extra->str,
"tasks=\"1\"",
8659 g_string_free (extra, TRUE);
8676 return get_alert (credentials, params, NULL, response_data);
8696 extra = g_string_new (
"");
8704 switch (omp (credentials, &response, &entity, response_data,
8706 " schedules_only=\"1\""
8707 " filter=\"owner=any permission=start_task rows=-1\"/>"))
8715 "Internal error", __FUNCTION__, __LINE__,
8716 "An internal error occurred getting the tasks. "
8717 "Diagnostics: Failure to send command to manager daemon.",
8718 "/omp?cmd=get_tasks",
8723 "Internal error", __FUNCTION__, __LINE__,
8724 "An internal error occurred getting the tasks. "
8725 "Diagnostics: Failure to receive response from manager daemon.",
8726 "/omp?cmd=get_tasks",
8731 "Internal error", __FUNCTION__, __LINE__,
8732 "An internal error occurred getting the reports. "
8733 "Diagnostics: Internal Error.",
8734 "/omp?cmd=get_tasks",
8738 g_string_append (extra, response);
8740 free_entity (entity);
8754 switch (omp (credentials, &response, &entity, response_data,
8756 " filter=\"type=result rows=-1\"/>"))
8764 "Internal error", __FUNCTION__, __LINE__,
8765 "An internal error occurred while getting filters "
8767 "Diagnostics: Failure to send command to manager daemon.",
8768 "/omp?cmd=get_tasks", response_data);
8772 "Internal error", __FUNCTION__, __LINE__,
8773 "An internal error occurred while getting filters "
8775 "Diagnostics: Failure to receive response from manager daemon.",
8776 "/omp?cmd=get_tasks", response_data);
8780 "Internal error", __FUNCTION__, __LINE__,
8781 "An internal error occurred while getting filters "
8783 "Diagnostics: Internal Error.",
8784 "/omp?cmd=get_tasks", response_data);
8787 g_string_append (extra, response);
8789 free_entity (entity);
8794 g_string_append (extra, extra_xml);
8795 html = get_many (
"alert", credentials, params, extra->str, NULL,
8797 g_string_free (extra, TRUE);
8814 return get_alerts (credentials, params, NULL, response_data);
8832 openvas_connection_t connection;
8834 const char *alert_id, *next, *filter;
8840 if (alert_id == NULL)
8844 "Internal error", __FUNCTION__, __LINE__,
8845 "An internal error occurred while editing an alert. "
8846 "The alert remains as it was. "
8847 "Diagnostics: Required parameter alert_id was NULL.",
8848 "/omp?cmd=get_alerts", response_data);
8852 next =
"get_alerts";
8866 "Internal error", __FUNCTION__, __LINE__,
8867 "An internal error occurred while editing an alert. "
8868 "The alert remains as it was. "
8869 "Diagnostics: Failure to connect to manager daemon.",
8870 "/omp?cmd=get_alerts", response_data);
8873 if (openvas_connection_sendf (&connection,
8880 openvas_connection_close (&connection);
8883 "Internal error", __FUNCTION__, __LINE__,
8884 "An internal error occurred while getting alert info. "
8885 "Diagnostics: Failure to send command to manager daemon.",
8886 "/omp?cmd=get_alerts", response_data);
8889 xml = g_string_new (
"<edit_alert>");
8892 g_string_append (xml, extra_xml);
8894 edit = g_markup_printf_escaped (
"<alert id=\"%s\"/>"
8898 "<filters><term>%s</term></filters>",
8902 g_string_append (xml, edit);
8905 if (read_string_c (&connection, &xml))
8907 g_string_free (xml, TRUE);
8908 openvas_connection_close (&connection);
8911 "Internal error", __FUNCTION__, __LINE__,
8912 "An internal error occurred while getting alert info. "
8913 "Diagnostics: Failure to receive response from manager daemon.",
8914 "/omp?cmd=get_alerts", response_data);
8921 if (openvas_connection_sendf (&connection,
8922 "<get_report_formats"
8923 " filter=\"rows=-1\"/>")
8926 g_string_free (xml, TRUE);
8927 openvas_connection_close (&connection);
8930 "Internal error", __FUNCTION__, __LINE__,
8931 "An internal error occurred while getting report formats. "
8932 "The current list of report formats is not available. "
8933 "Diagnostics: Failure to send command to manager daemon.",
8934 "/omp?cmd=get_alerts", response_data);
8937 if (read_string_c (&connection, &xml))
8939 g_string_free (xml, TRUE);
8940 openvas_connection_close (&connection);
8943 "Internal error", __FUNCTION__, __LINE__,
8944 "An internal error occurred while getting report formats. "
8945 "The current list of report formats is not available. "
8946 "Diagnostics: Failure to receive response from manager daemon.",
8947 "/omp?cmd=get_alerts", response_data);
8955 if (openvas_connection_sendf (&connection,
8956 "<get_filters filter=\"rows=-1\"/>")
8959 g_string_free (xml, TRUE);
8960 openvas_connection_close (&connection);
8963 "Internal error", __FUNCTION__, __LINE__,
8964 "An internal error occurred while getting the list "
8966 "The current list of filters is not available. "
8967 "Diagnostics: Failure to send command to manager daemon.",
8968 "/omp?cmd=get_alerts", response_data);
8971 if (read_string_c (&connection, &xml))
8973 g_string_free (xml, TRUE);
8974 openvas_connection_close (&connection);
8977 "Internal error", __FUNCTION__, __LINE__,
8978 "An internal error occurred while getting the list "
8980 "The current list of filters is not available. "
8981 "Diagnostics: Failure to receive response from manager daemon.",
8982 "/omp?cmd=get_filters", response_data);
8990 if (openvas_connection_sendf (&connection,
8992 " schedules_only=\"1\""
8993 " filter=\"owner=any permission=start_task"
8997 g_string_free (xml, TRUE);
8998 openvas_connection_close (&connection);
9001 "Internal error", __FUNCTION__, __LINE__,
9002 "An internal error occurred while getting the list "
9004 "The current list of tasks is not available. "
9005 "Diagnostics: Failure to send command to manager daemon.",
9006 "/omp?cmd=get_alerts", response_data);
9009 if (read_string_c (&connection, &xml))
9011 g_string_free (xml, TRUE);
9012 openvas_connection_close (&connection);
9015 "Internal error", __FUNCTION__, __LINE__,
9016 "An internal error occurred while getting the list "
9018 "The current list of tasks is not available. "
9019 "Diagnostics: Failure to receive response from manager daemon.",
9020 "/omp?cmd=get_tasks", response_data);
9028 if (openvas_connection_sendf (&connection,
9030 " filter=\"type=up owner=any permission=any"
9034 g_string_free (xml, TRUE);
9035 openvas_connection_close (&connection);
9038 "Internal error", __FUNCTION__, __LINE__,
9039 "An internal error occurred while getting the list "
9041 "The current list of tasks is not available. "
9042 "Diagnostics: Failure to send command to manager daemon.",
9043 "/omp?cmd=get_alerts", response_data);
9046 if (read_string_c (&connection, &xml))
9048 g_string_free (xml, TRUE);
9049 openvas_connection_close (&connection);
9052 "Internal error", __FUNCTION__, __LINE__,
9053 "An internal error occurred while getting the list "
9055 "The current list of tasks is not available. "
9056 "Diagnostics: Failure to receive response from manager daemon.",
9057 "/omp?cmd=get_tasks", response_data);
9063 g_string_append (xml,
"</edit_alert>");
9064 openvas_connection_close (&connection);
9065 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
9082 return edit_alert (credentials, params, NULL, response_data);
9100 gchar *html, *response;
9101 const char *no_redirect, *name, *comment, *alert_id;
9102 const char *event, *condition, *method;
9103 const char *filter_id;
9104 params_t *event_data, *condition_data, *method_data;
9124 xml = g_string_new (
"");
9132 if ((strcmp (event,
"New SecInfo arrived") == 0) && event_data)
9140 if ((strcmp (name,
"feed_event") == 0)
9142 && (strcmp (param->
value,
"updated") == 0))
9144 event =
"Updated SecInfo arrived";
9149 xml_string_append (xml,
9150 "<modify_alert alert_id=\"%s\">"
9152 "<filter id=\"%s\"/>"
9153 "<comment>%s</comment>"
9158 comment ? comment :
"",
9161 append_alert_event_data (xml, event_data, event);
9163 xml_string_append (xml,
9168 append_alert_method_data (xml, method_data, method);
9170 xml_string_append (xml,
9175 append_alert_condition_data (xml, condition_data, condition);
9177 xml_string_append (xml,
9181 ret = omp (credentials,
9186 g_string_free (xml, TRUE);
9195 "Internal error", __FUNCTION__, __LINE__,
9196 "An internal error occurred while saving a new alert. "
9197 "No new alert was created. "
9198 "Diagnostics: Failure to send command to manager daemon.",
9199 "/omp?cmd=get_alerts", response_data);
9203 "Internal error", __FUNCTION__, __LINE__,
9204 "An internal error occurred while saving a new alert. "
9205 "It is unclear whether the alert has been created or not. "
9206 "Diagnostics: Failure to receive response from manager daemon.",
9207 "/omp?cmd=get_alerts", response_data);
9211 "Internal error", __FUNCTION__, __LINE__,
9212 "An internal error occurred while saving a new alert. "
9213 "It is unclear whether the alert has been created or not. "
9214 "Diagnostics: Internal Error.",
9215 "/omp?cmd=get_alerts", response_data);
9218 html = response_from_entity (credentials, params, entity,
9219 (no_redirect && strcmp (no_redirect,
"0")),
9222 "Save Alert", response_data);
9223 free_entity (entity);
9241 openvas_connection_t connection;
9242 gchar *html, *response;
9243 const char *no_redirect, *alert_id;
9249 if (alert_id == NULL)
9253 "Internal error", __FUNCTION__, __LINE__,
9254 "An internal error occurred while testing an alert. "
9255 "Diagnostics: Required parameter was NULL.",
9256 "/omp?cmd=get_alerts", response_data);
9270 "Internal error", __FUNCTION__, __LINE__,
9271 "An internal error occurred while testing an alert. "
9272 "Diagnostics: Failure to connect to manager daemon.",
9273 "/omp?cmd=get_alerts", response_data);
9278 if (openvas_connection_sendf (&connection,
9279 "<test_alert alert_id=\"%s\"/>",
9283 openvas_connection_close (&connection);
9286 "Internal error", __FUNCTION__, __LINE__,
9287 "An internal error occurred while testing an alert. "
9288 "Diagnostics: Failure to send command to manager daemon.",
9289 "/omp?cmd=get_alerts", response_data);
9293 if (read_entity_and_text_c (&connection, &entity, &response))
9295 openvas_connection_close (&connection);
9298 "Internal error", __FUNCTION__, __LINE__,
9299 "An internal error occurred while testing an alert. "
9300 "Diagnostics: Failure to receive response from manager daemon.",
9301 "/omp?cmd=get_alerts", response_data);
9306 openvas_connection_close (&connection);
9307 html = response_from_entity (credentials, params, entity,
9308 (no_redirect && strcmp (no_redirect,
"0")),
9311 "Test Alert", response_data);
9313 free_entity (entity);
9332 enum content_type * content_type,
char **content_disposition,
9336 content_disposition, content_length, response_data);
9354 enum content_type * content_type,
char **content_disposition,
9357 return export_many (
"alert", credentials, params, content_type,
9358 content_disposition, content_length, response_data);
9376 openvas_connection_t connection;
9378 gchar *ssh_credential, *smb_credential, *esxi_credential, *snmp_credential;
9380 const char *filter, *first, *max;
9406 "Internal error", __FUNCTION__, __LINE__,
9407 "An internal error occurred while getting targets list. "
9408 "The current list of targets is not available. "
9409 "Diagnostics: Failure to connect to manager daemon.",
9410 "/omp?cmd=get_targets", response_data);
9414 "d74a9ee8-7d35-4879-9485-ab23f1bd45bc",
9415 openvas_connection_close (&connection));
9418 "6fc56b72-c1cf-451c-a4c4-3a9dc784c3bd",
9419 openvas_connection_close (&connection);
9420 g_free (port_list));
9423 "a25c0cfe-f977-417b-b1da-47da370c03e8",
9424 openvas_connection_close (&connection);
9426 g_free (ssh_credential));
9429 "83545bcf-0c49-4b4c-abbf-63baf82cc2a7",
9430 openvas_connection_close (&connection);
9432 g_free (ssh_credential);
9433 g_free (smb_credential));
9436 "024550b8-868e-4b3c-98bf-99bb732f6a0d",
9437 openvas_connection_close (&connection);
9439 g_free (ssh_credential);
9440 g_free (smb_credential);
9441 g_free (esxi_credential));
9443 xml = g_string_new (
"<new_target>");
9445 g_string_append_printf (xml,
9446 "<port_list_id>%s</port_list_id>"
9447 "<ssh_credential_id>%s</ssh_credential_id>"
9448 "<smb_credential_id>%s</smb_credential_id>"
9449 "<esxi_credential_id>%s</esxi_credential_id>"
9450 "<snmp_credential_id>%s</snmp_credential_id>",
9451 (port_list && strlen (port_list))
9453 :
"33d0cd82-57c6-11e1-8ed1-406186ea4fc5",
9454 ssh_credential ? ssh_credential :
"",
9455 smb_credential ? smb_credential :
"",
9456 esxi_credential ? esxi_credential :
"",
9457 snmp_credential ? snmp_credential :
"");
9460 g_free (ssh_credential);
9461 g_free (smb_credential);
9462 g_free (esxi_credential);
9465 g_string_append (xml, extra_xml);
9471 if (openvas_connection_sendf (&connection,
9473 " filter=\"rows=-1 sort=name\"/>")
9476 g_string_free (xml, TRUE);
9477 openvas_connection_close (&connection);
9480 "Internal error", __FUNCTION__, __LINE__,
9481 "An internal error occurred while getting targets list. "
9482 "The current list of targets is not available. "
9483 "Diagnostics: Failure to send command to manager daemon.",
9484 "/omp?cmd=get_targets", response_data);
9487 if (read_string_c (&connection, &xml))
9489 g_string_free (xml, TRUE);
9490 openvas_connection_close (&connection);
9493 "Internal error", __FUNCTION__, __LINE__,
9494 "An internal error occurred while getting targets list. "
9495 "The current list of targets is not available. "
9496 "Diagnostics: Failure to receive response from manager daemon.",
9497 "/omp?cmd=get_targets", response_data);
9505 if (openvas_connection_sendf (&connection,
9507 " filter=\"rows=-1 sort=name\"/>")
9510 g_string_free (xml, TRUE);
9511 openvas_connection_close (&connection);
9514 "Internal error", __FUNCTION__, __LINE__,
9515 "An internal error occurred while getting targets list. "
9516 "The current list of targets is not available. "
9517 "Diagnostics: Failure to send command to manager daemon.",
9518 "/omp?cmd=get_tasks", response_data);
9521 if (read_string_c (&connection, &xml))
9523 g_string_free (xml, TRUE);
9524 openvas_connection_close (&connection);
9527 "Internal error", __FUNCTION__, __LINE__,
9528 "An internal error occurred while getting targets list. "
9529 "The current list of targets is not available. "
9530 "Diagnostics: Failure to receive response from manager daemon.",
9531 "/omp?cmd=get_tasks", response_data);
9535 end = g_markup_printf_escaped (
"<filters><term>%s</term></filters>"
9536 "<targets start=\"%s\" max=\"%s\"/>"
9541 g_string_append (xml, end);
9544 openvas_connection_close (&connection);
9545 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
9562 return new_target (credentials, params, NULL, response_data);
9579 gchar *html, *response, *command;
9580 const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
9581 const char *target_ssh_credential, *port, *target_smb_credential;
9582 const char *target_esxi_credential, *target_snmp_credential, *target_source;
9583 const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
9584 const char *alive_tests, *hosts_filter, *file;
9585 gchar *ssh_credentials_element, *smb_credentials_element;
9586 gchar *esxi_credentials_element, *snmp_credentials_element;
9587 gchar *asset_hosts_element;
9588 gchar* comment_element = NULL;
9595 exclude_hosts =
params_value (params,
"exclude_hosts");
9596 reverse_lookup_only =
params_value (params,
"reverse_lookup_only");
9597 reverse_lookup_unify =
params_value (params,
"reverse_lookup_unify");
9598 target_source =
params_value (params,
"target_source");
9601 target_ssh_credential =
params_value (params,
"ssh_credential_id");
9603 target_smb_credential =
params_value (params,
"smb_credential_id");
9604 target_esxi_credential =
params_value (params,
"esxi_credential_id");
9605 target_snmp_credential =
params_value (params,
"snmp_credential_id");
9612 if (hosts == NULL && strcmp (target_source,
"manual") == 0)
9614 "Missing manual list of hosts",
9615 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9616 "Create Target",
"new_target");
9617 if (strcmp (target_source,
"file") == 0 && file == NULL)
9619 "Missing hosts file",
9620 G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9621 "Create Target",
"new_target");
9624 if (strcmp (target_source,
"asset_hosts") == 0)
9630 if (strcmp (target_ssh_credential,
"--"))
9637 if (comment != NULL)
9638 comment_element = g_strdup_printf (
"<comment>%s</comment>", comment);
9640 comment_element = g_strdup (
"");
9642 if (strcmp (target_ssh_credential,
"0") == 0)
9643 ssh_credentials_element = g_strdup (
"");
9645 ssh_credentials_element =
9646 g_strdup_printf (
"<ssh_credential id=\"%s\">"
9648 "</ssh_credential>",
9649 target_ssh_credential,
9652 if (strcmp (target_smb_credential,
"0") == 0)
9653 smb_credentials_element = g_strdup (
"");
9655 smb_credentials_element =
9656 g_strdup_printf (
"<smb_credential id=\"%s\"/>",
9657 target_smb_credential);
9659 if (strcmp (target_esxi_credential,
"0") == 0)
9660 esxi_credentials_element = g_strdup (
"");
9662 esxi_credentials_element =
9663 g_strdup_printf (
"<esxi_credential id=\"%s\"/>",
9664 target_esxi_credential);
9666 if (strcmp (target_snmp_credential,
"0") == 0)
9667 snmp_credentials_element = g_strdup (
"");
9669 snmp_credentials_element =
9670 g_strdup_printf (
"<snmp_credential id=\"%s\"/>",
9671 target_snmp_credential);
9673 if (strcmp (target_source,
"asset_hosts") == 0)
9674 asset_hosts_element = g_strdup_printf (
"<asset_hosts filter=\"%s\"/>",
9677 asset_hosts_element = g_strdup (
"");
9681 xml = g_string_new (
"");
9683 xml_string_append (xml,
9686 "<exclude_hosts>%s</exclude_hosts>"
9687 "<reverse_lookup_only>%s</reverse_lookup_only>"
9688 "<reverse_lookup_unify>%s</reverse_lookup_unify>"
9689 "<port_list id=\"%s\"/>"
9690 "<alive_tests>%s</alive_tests>",
9692 strcmp (target_source,
"file") == 0 ? file : hosts,
9693 exclude_hosts ? exclude_hosts :
"",
9694 reverse_lookup_only ? reverse_lookup_only :
"0",
9695 reverse_lookup_unify ? reverse_lookup_unify :
"0",
9699 command = g_strdup_printf (
"<create_target>"
9704 ssh_credentials_element,
9705 smb_credentials_element,
9706 esxi_credentials_element,
9707 snmp_credentials_element,
9708 asset_hosts_element);
9710 g_string_free (xml, TRUE);
9711 g_free (comment_element);
9712 g_free (ssh_credentials_element);
9713 g_free (smb_credentials_element);
9714 g_free (esxi_credentials_element);
9716 ret = omp (credentials,
9732 "Internal error", __FUNCTION__, __LINE__,
9733 "An internal error occurred while creating a new target. "
9734 "No new target was created. "
9735 "Diagnostics: Failure to send command to manager daemon.",
9736 "/omp?cmd=get_targets", response_data);
9740 "Internal error", __FUNCTION__, __LINE__,
9741 "An internal error occurred while creating a new target. "
9742 "It is unclear whether the target has been created or not. "
9743 "Diagnostics: Failure to receive response from manager daemon.",
9744 "/omp?cmd=get_targets", response_data);
9748 "Internal error", __FUNCTION__, __LINE__,
9749 "An internal error occurred while creating a new target. "
9750 "It is unclear whether the target has been created or not. "
9751 "Diagnostics: Internal Error.",
9752 "/omp?cmd=get_targets", response_data);
9755 if (entity_attribute (entity,
"id"))
9756 params_add (params,
"target_id", entity_attribute (entity,
"id"));
9757 html = response_from_entity (credentials, params, entity,
9758 (no_redirect && strcmp (no_redirect,
"0")),
9759 NULL,
"get_targets",
9761 "Create Target", response_data);
9762 free_entity (entity);
9772 #define CHECK(name) \
9775 response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \
9776 return gsad_message (credentials, \
9777 "Internal error", __FUNCTION__, __LINE__, \
9778 "An internal error occurred while cloning a resource. " \
9779 "The resource was not cloned. " \
9780 "Diagnostics: Required parameter '" G_STRINGIFY (name) \
9782 "/omp?cmd=get_tasks", response_data); \
9798 openvas_connection_t connection;
9799 gchar *html, *response;
9800 const char *id, *type, *alterable, *no_redirect, *next_id;
9801 gchar *next_id_name, *cap_type, *prev_action;
9824 "Internal error", __FUNCTION__, __LINE__,
9825 "An internal error occurred while cloning a resource. "
9826 "The resource was not cloned. "
9827 "Diagnostics: Failure to connect to manager daemon.",
9828 "/omp?cmd=get_tasks", response_data);
9833 if (alterable && strcmp (alterable,
"0"))
9835 if (openvas_connection_sendf (&connection,
9838 "<alterable>1</alterable>"
9845 openvas_connection_close (&connection);
9848 "Internal error", __FUNCTION__, __LINE__,
9849 "An internal error occurred while cloning a resource. "
9850 "The resource was not cloned. "
9851 "Diagnostics: Failure to send command to manager daemon.",
9852 "/omp?cmd=get_tasks", response_data);
9855 else if (openvas_connection_sendf (&connection,
9864 openvas_connection_close (&connection);
9867 "Internal error", __FUNCTION__, __LINE__,
9868 "An internal error occurred while cloning a resource. "
9869 "The resource was not cloned. "
9870 "Diagnostics: Failure to send command to manager daemon.",
9871 "/omp?cmd=get_tasks", response_data);
9875 if (read_entity_and_text_c (&connection, &entity, &response))
9877 openvas_connection_close (&connection);
9880 "Internal error", __FUNCTION__, __LINE__,
9881 "An internal error occurred while cloning a resource. "
9882 "It is unclear whether the resource has been cloned or not. "
9883 "Diagnostics: Failure to read response from manager daemon.",
9884 "/omp?cmd=get_tasks", response_data);
9887 openvas_connection_close (&connection);
9891 if (omp_success (entity) == 0 ||
params_given (params,
"next") == 0)
9894 next = g_strdup_printf (
"get_%ss", type);
9899 if (omp_success (entity))
9901 next_id = entity_attribute (entity,
"id");
9902 if (next_id == NULL)
9904 free_entity (entity);
9908 "Internal error", __FUNCTION__, __LINE__,
9909 "An internal error occurred while cloning a resource. "
9910 "The resource remains the same. "
9911 "Diagnostics: Error getting new resource.",
9912 "/omp?cmd=get_tasks", response_data);
9914 next_id_name = g_strdup_printf (
"%s_id", type);
9916 g_free (next_id_name);
9921 next_id_name = NULL;
9925 cap_type = capitalize (type);
9926 prev_action = g_strdup_printf (
"Clone %s", cap_type);
9927 html = response_from_entity (credentials, params, entity,
9928 (no_redirect && strcmp (no_redirect,
"0")),
9931 prev_action, response_data);
9933 free_entity (entity);
9935 g_free (prev_action);
9956 return delete_resource (
"target", credentials, params, 0,
"get_targets",
9990 return delete_resource (
"config", credentials, params, 1,
"get_trash",
10007 return delete_resource (
"alert", credentials, params, 1,
"get_trash",
10024 return delete_resource (
"credential", credentials, params, 1,
"get_trash",
10041 return delete_resource (
"report_format", credentials, params, 1,
"get_trash",
10058 return delete_resource (
"schedule", credentials, params, 1,
"get_trash",
10075 return delete_resource (
"target", credentials, params, 1,
"get_trash",
10111 openvas_connection_t connection;
10114 const char *target_id, *no_redirect;
10119 if (target_id == NULL)
10123 "Internal error", __FUNCTION__, __LINE__,
10124 "An internal error occurred while restoring a resource. "
10125 "The resource was not restored. "
10126 "Diagnostics: Required parameter was NULL.",
10127 "/omp?cmd=get_tasks", response_data);
10142 "Internal error", __FUNCTION__, __LINE__,
10143 "An internal error occurred while restoring a resource. "
10144 "The resource was not restored. "
10145 "Diagnostics: Failure to connect to manager daemon.",
10146 "/omp?cmd=get_trash", response_data);
10149 xml = g_string_new (
"");
10153 if (openvas_connection_sendf (&connection,
10159 g_string_free (xml, TRUE);
10160 openvas_connection_close (&connection);
10163 "Internal error", __FUNCTION__, __LINE__,
10164 "An internal error occurred while restoring a resource. "
10165 "The resource was not deleted. "
10166 "Diagnostics: Failure to send command to manager daemon.",
10167 "/omp?cmd=get_trash", response_data);
10170 if (read_entity_and_string_c (&connection, &entity, &xml))
10172 g_string_free (xml, TRUE);
10173 openvas_connection_close (&connection);
10176 "Internal error", __FUNCTION__, __LINE__,
10177 "An internal error occurred while restoring a resource. "
10178 "It is unclear whether the resource has been restored or not. "
10179 "Diagnostics: Failure to read response from manager daemon.",
10180 "/omp?cmd=get_trash", response_data);
10185 openvas_connection_close (&connection);
10186 ret = response_from_entity (credentials, params, entity,
10187 (no_redirect && strcmp (no_redirect,
"0")),
10190 "Restore", response_data);
10191 free_entity (entity);
10192 g_string_free (xml, FALSE);
10210 const char* no_redirect;
10212 openvas_connection_t connection;
10230 "Internal error", __FUNCTION__, __LINE__,
10231 "An internal error occurred while emptying the trashcan. "
10232 "Diagnostics: Failure to connect to manager daemon.",
10233 "/omp?cmd=get_trash", response_data);
10236 xml = g_string_new (
"");
10240 if (openvas_connection_sendf (&connection,
10241 "<empty_trashcan/>")
10244 g_string_free (xml, TRUE);
10245 openvas_connection_close (&connection);
10248 "Internal error", __FUNCTION__, __LINE__,
10249 "An internal error occurred while emptying the trashcan. "
10250 "Diagnostics: Failure to send command to manager daemon.",
10251 "/omp?cmd=get_trash", response_data);
10254 if (read_entity_and_string_c (&connection, &entity, &xml))
10256 g_string_free (xml, TRUE);
10257 openvas_connection_close (&connection);
10260 "Internal error", __FUNCTION__, __LINE__,
10261 "An internal error occurred while emptying the trashcan. "
10262 "Diagnostics: Failure to read response from manager daemon.",
10263 "/omp?cmd=get_trash", response_data);
10268 openvas_connection_close (&connection);
10270 ret = response_from_entity (credentials, params, entity,
10271 (no_redirect && strcmp (no_redirect,
"0")),
10274 "Empty Trashcan", response_data);
10275 free_entity (entity);
10276 g_string_free (xml, FALSE);
10296 const char *resource_type, *resource_id, *tag_id, *tag_name;
10298 resource_type =
params_value (params,
"resource_type");
10304 xml = g_string_new (
"<new_tag>");
10307 g_string_append (xml, extra_xml);
10309 end = g_markup_printf_escaped (
"<tag id=\"%s\"/>"
10310 "<resource_type>%s</resource_type>"
10311 "<resource_id>%s</resource_id>"
10312 "<tag_name>%s%s</tag_name>"
10313 "<tag_value></tag_value>"
10314 "<comment></comment>"
10315 "<active>1</active>"
10317 tag_id ? tag_id :
"0",
10318 resource_type ? resource_type :
"",
10319 resource_id ? resource_id :
"",
10320 tag_name ? tag_name : (resource_type
10323 tag_name ?
"" :
":unnamed");
10324 g_string_append (xml, end);
10327 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
10344 return new_tag (credentials, params, NULL, response_data);
10361 const char* no_redirect;
10363 const char *name, *comment, *value, *resource_type, *resource_id, *active;
10370 resource_type =
params_value (params,
"resource_type");
10383 switch (ompf (credentials,
10389 "<comment>%s</comment>"
10390 "<value>%s</value>"
10391 "<resource id=\"%s\">"
10394 "<active>%s</active>"
10409 "Internal error", __FUNCTION__, __LINE__,
10410 "An internal error occurred while creating a new tag. "
10411 "No new tag was created. "
10412 "Diagnostics: Failure to send command to manager daemon.",
10413 "/omp?cmd=get_targets", response_data);
10417 "Internal error", __FUNCTION__, __LINE__,
10418 "An internal error occurred while creating a new tag. "
10419 "It is unclear whether the tag has been created or not. "
10420 "Diagnostics: Failure to receive response from manager daemon.",
10421 "/omp?cmd=get_tags", response_data);
10425 "Internal error", __FUNCTION__, __LINE__,
10426 "An internal error occurred while creating a new tag. "
10427 "It is unclear whether the tag has been created or not. "
10428 "Diagnostics: Internal Error.",
10429 "/omp?cmd=get_tags", response_data);
10432 if (entity_attribute (entity,
"id"))
10433 params_add (params,
"tag_id", entity_attribute (entity,
"id"));
10434 ret = response_from_entity (credentials, params, entity,
10435 (no_redirect && strcmp (no_redirect,
"0")),
10438 "Create Tag", response_data);
10440 free_entity (entity);
10458 return delete_resource (
"tag", credentials, params, 0, NULL, response_data);
10493 openvas_connection_t connection;
10494 gchar *html, *edit;
10495 const char *tag_id;
10498 if (tag_id == NULL)
10502 "Internal error", __FUNCTION__, __LINE__,
10503 "An internal error occurred while editing a tag. "
10504 "The tag remains as it was. "
10505 "Diagnostics: Required parameter was NULL.",
10506 "/omp?cmd=get_tags", response_data);
10521 "Internal error", __FUNCTION__, __LINE__,
10522 "An internal error occurred while editing a tag. "
10523 "The tag remains as it was. "
10524 "Diagnostics: Failure to connect to manager daemon.",
10525 "/omp?cmd=get_tags", response_data);
10528 if (openvas_connection_sendf (&connection,
10535 openvas_connection_close (&connection);
10538 "Internal error", __FUNCTION__, __LINE__,
10539 "An internal error occurred while getting tag info. "
10540 "Diagnostics: Failure to send command to manager daemon.",
10541 "/omp?cmd=get_tags", response_data);
10544 xml = g_string_new (
"");
10546 edit = g_markup_printf_escaped (
"<edit_tag>"
10547 "<tag id=\"%s\"/>",
10550 g_string_append (xml, edit);
10554 g_string_append (xml, extra_xml);
10556 if (read_string_c (&connection, &xml))
10558 g_string_free (xml, TRUE);
10559 openvas_connection_close (&connection);
10562 "Internal error", __FUNCTION__, __LINE__,
10563 "An internal error occurred while getting target info. "
10564 "Diagnostics: Failure to receive response from manager daemon.",
10565 "/omp?cmd=get_tags", response_data);
10570 g_string_append (xml,
"</edit_tag>");
10571 openvas_connection_close (&connection);
10572 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
10589 return edit_tag (credentials, params, NULL, response_data);
10606 const char *name, *comment, *value, *resource_type, *resource_id, *active;
10607 const char *tag_id, *no_redirect;
10616 resource_type =
params_value (params,
"resource_type");
10630 switch (ompf (credentials,
10634 "<modify_tag tag_id=\"%s\">"
10636 "<comment>%s</comment>"
10637 "<value>%s</value>"
10638 "<resource id=\"%s\">"
10641 "<active>%s</active>"
10657 "Internal error", __FUNCTION__, __LINE__,
10658 "An internal error occurred while saving a tag. "
10659 "The tag remains the same. "
10660 "Diagnostics: Failure to send command to "
10662 "/omp?cmd=get_targets", response_data);
10666 "Internal error", __FUNCTION__, __LINE__,
10667 "An internal error occurred while saving a tag. "
10668 "It is unclear whether the tag has been saved "
10670 "Diagnostics: Failure to receive response from "
10672 "/omp?cmd=get_tags", response_data);
10676 "Internal error", __FUNCTION__, __LINE__,
10677 "An internal error occurred while saving a tag. "
10678 "It is unclear whether the tag has been saved "
10680 "Diagnostics: Internal Error.",
10681 "/omp?cmd=get_tags", response_data);
10684 ret = response_from_entity (credentials, params, entity,
10685 (no_redirect && strcmp (no_redirect,
"0")),
10688 "Save Tag", response_data);
10690 free_entity (entity);
10711 enum content_type * content_type,
char **content_disposition,
10715 content_disposition, content_length, response_data);
10733 enum content_type * content_type,
char **content_disposition,
10736 return export_many (
"tag", credentials, params, content_type,
10737 content_disposition, content_length, response_data);
10754 return get_one (
"tag", credentials, params, extra_xml, NULL, response_data);
10770 return get_tag (credentials, params, NULL, response_data);
10787 return get_many (
"tag", credentials, params, extra_xml, NULL, response_data);
10803 return get_tags (credentials, params, NULL, response_data);
10819 openvas_connection_t connection;
10820 gchar *html, *response;
10821 const char *no_redirect, *tag_id, *enable;
10828 if (tag_id == NULL)
10832 "Internal error", __FUNCTION__, __LINE__,
10833 "An internal error occurred while modifying a tag. "
10834 "The tag was not modified. "
10835 "Diagnostics: Required parameter tag_id was NULL.",
10836 "/omp?cmd=get_tasks", response_data);
10838 if (enable == NULL)
10842 "Internal error", __FUNCTION__, __LINE__,
10843 "An internal error occurred while modifying a tag. "
10844 "The tag was not modified. "
10845 "Diagnostics: Required parameter enable was NULL.",
10846 "/omp?cmd=get_tasks", response_data);
10861 "Internal error", __FUNCTION__, __LINE__,
10862 "An internal error occurred while modifying a tag."
10863 " The tag is not modified. "
10864 "Diagnostics: Failure to connect to"
10865 " manager daemon.",
10866 "/omp?cmd=get_tasks", response_data);
10871 if (openvas_connection_sendf (&connection,
10872 "<modify_tag tag_id=\"%s\">"
10873 "<active>%s</active>"
10879 openvas_connection_close (&connection);
10882 "Internal error", __FUNCTION__, __LINE__,
10883 "An internal error occurred while modifying a tag. "
10884 "The tag is not modified. "
10885 "Diagnostics: Failure to send command to"
10886 " manager daemon.",
10887 "/omp?cmd=get_tasks", response_data);
10891 if (read_entity_and_text_c (&connection, &entity, &response))
10893 openvas_connection_close (&connection);
10896 "Internal error", __FUNCTION__, __LINE__,
10897 "An internal error occurred while modifying a tag. "
10898 "It is unclear whether the tag has been modified"
10900 "Diagnostics: Failure to read response from"
10901 " manager daemon.",
10902 "/omp?cmd=get_tasks", response_data);
10905 if (! omp_success (entity))
10907 html = response_from_entity (credentials, params, entity,
10908 (no_redirect && strcmp (no_redirect,
"0")),
10911 "Toggle Tag", response_data);
10913 free_entity (entity);
10915 openvas_connection_close (&connection);
10935 openvas_connection_t connection;
10936 gchar *html, *edit;
10937 const char *target_id, *next, *filter, *first, *max;
10945 if (target_id == NULL)
10949 "Internal error", __FUNCTION__, __LINE__,
10950 "An internal error occurred while editing a target. "
10951 "The target remains as it was. "
10952 "Diagnostics: Required parameter was NULL.",
10953 "/omp?cmd=get_targets", response_data);
10957 next =
"get_target";
10971 "Internal error", __FUNCTION__, __LINE__,
10972 "An internal error occurred while editing a target. "
10973 "The target remains as it was. "
10974 "Diagnostics: Failure to connect to manager daemon.",
10975 "/omp?cmd=get_targets", response_data);
10978 if (openvas_connection_sendf (&connection,
10980 " target_id=\"%s\""
10981 " details=\"1\"/>",
10985 openvas_connection_close (&connection);
10988 "Internal error", __FUNCTION__, __LINE__,
10989 "An internal error occurred while getting target info. "
10990 "Diagnostics: Failure to send command to manager daemon.",
10991 "/omp?cmd=get_targets", response_data);
10994 xml = g_string_new (
"");
10997 g_string_append (xml, extra_xml);
11000 edit = g_markup_printf_escaped (
"<edit_target>"
11001 "<target id=\"%s\"/>"
11005 "<filters><term>%s</term></filters>"
11006 "<targets start=\"%s\" max=\"%s\"/>",
11012 g_string_append (xml, edit);
11015 if (read_string_c (&connection, &xml))
11017 g_string_free (xml, TRUE);
11018 openvas_connection_close (&connection);
11021 "Internal error", __FUNCTION__, __LINE__,
11022 "An internal error occurred while getting target info. "
11023 "Diagnostics: Failure to receive response from manager daemon.",
11024 "/omp?cmd=get_targets", response_data);
11031 if (openvas_connection_sendf (&connection,
11033 " filter=\"rows=-1 sort=name\"/>")
11036 g_string_free (xml, TRUE);
11037 openvas_connection_close (&connection);
11040 "Internal error", __FUNCTION__, __LINE__,
11041 "An internal error occurred while getting targets list. "
11042 "The current list of targets is not available. "
11043 "Diagnostics: Failure to send command to manager daemon.",
11044 "/omp?cmd=get_targets", response_data);
11047 if (read_string_c (&connection, &xml))
11049 g_string_free (xml, TRUE);
11050 openvas_connection_close (&connection);
11053 "Internal error", __FUNCTION__, __LINE__,
11054 "An internal error occurred while getting targets list. "
11055 "The current list of targets is not available. "
11056 "Diagnostics: Failure to receive response from manager daemon.",
11057 "/omp?cmd=get_targets", response_data);
11065 if (openvas_connection_sendf (&connection,
11067 " filter=\"rows=-1 sort=name\"/>")
11070 g_string_free (xml, TRUE);
11071 openvas_connection_close (&connection);
11074 "Internal error", __FUNCTION__, __LINE__,
11075 "An internal error occurred while getting targets list. "
11076 "The current list of targets is not available. "
11077 "Diagnostics: Failure to send command to manager daemon.",
11078 "/omp?cmd=get_tasks", response_data);
11081 if (read_string_c (&connection, &xml))
11083 g_string_free (xml, TRUE);
11084 openvas_connection_close (&connection);
11087 "Internal error", __FUNCTION__, __LINE__,
11088 "An internal error occurred while getting targets list. "
11089 "The current list of targets is not available. "
11090 "Diagnostics: Failure to receive response from manager daemon.",
11091 "/omp?cmd=get_tasks", response_data);
11097 g_string_append (xml,
"</edit_target>");
11098 openvas_connection_close (&connection);
11099 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
11116 return edit_target (credentials, params, NULL, response_data);
11133 return get_one (
"target", credentials, params, extra_xml,
"tasks=\"1\"",
11150 return get_target (credentials, params, NULL, response_data);
11167 return get_many (
"target", credentials, params, extra_xml, NULL,
11184 return get_targets (credentials, params, NULL, response_data);
11200 openvas_connection_t connection;
11201 gchar *html, *response;
11202 const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
11203 const char *target_ssh_credential, *port, *target_smb_credential;
11204 const char *target_esxi_credential, *target_snmp_credential, *target_source;
11205 const char *target_id, *port_list_id, *reverse_lookup_only;
11206 const char *reverse_lookup_unify, *alive_tests, *in_use;
11222 if (strcmp (in_use,
"0"))
11229 command = g_string_new (
"");
11230 xml_string_append (command,
11231 "<modify_target target_id=\"%s\">"
11233 "<comment>%s</comment>"
11234 "<alive_tests>%s</alive_tests>"
11235 "</modify_target>",
11238 comment ? comment :
"",
11243 ret = omp (credentials, &response, &entity, response_data, command->str);
11244 g_string_free (command, TRUE);
11253 "Internal error", __FUNCTION__, __LINE__,
11254 "An internal error occurred while saving a target. "
11255 "The target remains the same. "
11256 "Diagnostics: Failure to send command to manager daemon.",
11257 "/omp?cmd=get_targets", response_data);
11261 "Internal error", __FUNCTION__, __LINE__,
11262 "An internal error occurred while saving a target. "
11263 "It is unclear whether the target has been saved or not. "
11264 "Diagnostics: Failure to receive response from manager daemon.",
11265 "/omp?cmd=get_targets", response_data);
11269 "Internal error", __FUNCTION__, __LINE__,
11270 "An internal error occurred while saving a target. "
11271 "It is unclear whether the target has been saved or not. "
11272 "Diagnostics: Internal Error.",
11273 "/omp?cmd=get_targets", response_data);
11276 html = response_from_entity (credentials, params, entity,
11277 (no_redirect && strcmp (no_redirect,
"0")),
11278 NULL,
"get_targets",
11279 NULL,
"edit_target",
11280 "Save Target", response_data);
11282 free_entity (entity);
11288 exclude_hosts =
params_value (params,
"exclude_hosts");
11289 reverse_lookup_only =
params_value (params,
"reverse_lookup_only");
11290 reverse_lookup_unify =
params_value (params,
"reverse_lookup_unify");
11291 target_source =
params_value (params,
"target_source");
11293 target_ssh_credential =
params_value (params,
"ssh_credential_id");
11295 target_smb_credential =
params_value (params,
"smb_credential_id");
11296 target_esxi_credential =
params_value (params,
"esxi_credential_id");
11297 target_snmp_credential =
params_value (params,
"snmp_credential_id");
11306 if (strcmp (target_ssh_credential,
"--")
11307 && strcmp (target_ssh_credential,
"0"))
11322 "Internal error", __FUNCTION__, __LINE__,
11323 "An internal error occurred while modifying a target. "
11324 "The target was not modified. "
11325 "Diagnostics: Failure to connect to manager daemon.",
11326 "/omp?cmd=get_targets", response_data);
11329 if (hosts == NULL && strcmp (target_source,
"manual") == 0)
11331 openvas_connection_close (&connection);
11332 return new_target (credentials, params,
11336 if (strcmp (target_source,
"import") == 0 && name == NULL)
11339 openvas_connection_close (&connection);
11341 "Given target_source was invalid",
11343 html = new_target (credentials, params, msg, response_data);
11351 gchar *ssh_credentials_element, *smb_credentials_element;
11352 gchar *esxi_credentials_element, *snmp_credentials_element;
11353 gchar* comment_element;
11357 comment_element = g_strdup_printf (
"<comment>%s</comment>", comment);
11359 comment_element = g_strdup (
"");
11361 if (strcmp (target_ssh_credential,
"--") == 0)
11362 ssh_credentials_element = g_strdup (
"");
11364 ssh_credentials_element =
11365 g_strdup_printf (
"<ssh_credential id=\"%s\">"
11367 "</ssh_credential>",
11368 target_ssh_credential,
11371 if (strcmp (target_smb_credential,
"--") == 0)
11372 smb_credentials_element = g_strdup (
"");
11374 smb_credentials_element =
11375 g_strdup_printf (
"<smb_credential id=\"%s\"/>",
11376 target_smb_credential);
11378 if (strcmp (target_esxi_credential,
"--") == 0)
11379 esxi_credentials_element = g_strdup (
"");
11381 esxi_credentials_element =
11382 g_strdup_printf (
"<esxi_credential id=\"%s\"/>",
11383 target_esxi_credential);
11385 if (strcmp (target_snmp_credential,
"--") == 0)
11386 snmp_credentials_element = g_strdup (
"");
11388 snmp_credentials_element =
11389 g_strdup_printf (
"<snmp_credential id=\"%s\"/>",
11390 target_snmp_credential);
11392 command = g_string_new (
"");
11393 xml_string_append (command,
11394 "<modify_target target_id=\"%s\">"
11396 "<hosts>%s</hosts>"
11397 "<exclude_hosts>%s</exclude_hosts>"
11398 "<reverse_lookup_only>%s</reverse_lookup_only>"
11399 "<reverse_lookup_unify>%s</reverse_lookup_unify>"
11400 "<port_list id=\"%s\"/>"
11401 "<alive_tests>%s</alive_tests>",
11404 strcmp (target_source,
"file") == 0
11407 exclude_hosts ? exclude_hosts :
"",
11408 reverse_lookup_only ? reverse_lookup_only :
"0",
11409 reverse_lookup_unify ? reverse_lookup_unify :
"0",
11413 g_string_append_printf (command,
11415 "</modify_target>",
11417 ssh_credentials_element,
11418 smb_credentials_element,
11419 esxi_credentials_element,
11420 snmp_credentials_element);
11422 g_free (comment_element);
11423 g_free (ssh_credentials_element);
11424 g_free (smb_credentials_element);
11425 g_free (esxi_credentials_element);
11426 g_free (snmp_credentials_element);
11430 ret = openvas_connection_sendf (&connection,
"%s", command->str);
11431 g_string_free (command, TRUE);
11435 openvas_connection_close (&connection);
11438 "Internal error", __FUNCTION__, __LINE__,
11439 "An internal error occurred while modifying target. "
11440 "No target was modified. "
11441 "Diagnostics: Failure to send command to manager daemon.",
11442 "/omp?cmd=get_targets", response_data);
11446 if (read_entity_and_text_c (&connection, &entity, &response))
11448 openvas_connection_close (&connection);
11451 "Internal error", __FUNCTION__, __LINE__,
11452 "An internal error occurred while modifying a target. "
11453 "It is unclear whether the target has been modified or not. "
11454 "Diagnostics: Failure to receive response from manager daemon.",
11455 "/omp?cmd=get_targets", response_data);
11458 openvas_connection_close (&connection);
11460 html = response_from_entity (credentials, params, entity,
11461 (no_redirect && strcmp (no_redirect,
"0")),
11462 NULL,
"get_targets",
11463 NULL,
"edit_target",
11464 "Save Target", response_data);
11487 enum content_type * content_type,
char **content_disposition,
11491 content_disposition, content_length, response_data);
11509 enum content_type * content_type,
char **content_disposition,
11512 return export_many (
"target", credentials, params, content_type,
11513 content_disposition, content_length, response_data);
11532 entity_t entity = NULL;
11533 gchar *response = NULL;
11535 xml = g_string_new (
"<new_config>");
11537 g_string_append (xml, extra_xml);
11540 ret = omp (credentials, &response, &entity, response_data,
"<get_scanners/>");
11549 "Internal error", __FUNCTION__, __LINE__,
11550 "An internal error occurred while getting scanners"
11551 " for new config. Diagnostics: Failure to send"
11552 " command to manager daemon.",
11553 "/omp?cmd=get_configs", response_data);
11557 "Internal error", __FUNCTION__, __LINE__,
11558 "An internal error occurred while getting scanners"
11559 " for new config. " "Diagnostics: Failure to"
11560 " receive response from manager daemon.",
11561 "/omp?cmd=get_configs", response_data);
11565 "Internal error", __FUNCTION__, __LINE__,
11566 "An internal error occurred while getting scanners"
11567 "for new config. It is unclear whether the config"
11568 " has been saved or not. "
11569 "Diagnostics: Internal Error.",
11570 "/omp?cmd=get_configs", response_data);
11572 g_string_append (xml, response);
11574 free_entity (entity);
11576 g_string_append (xml,
"</new_config>");
11577 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
11594 return new_config (credentials, params, NULL, response_data);
11613 xml = g_string_new (
"<upload_config>");
11615 g_string_append (xml, extra_xml);
11616 g_string_append (xml,
"</upload_config>");
11618 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
11635 return upload_config (credentials, params, NULL, response_data);
11651 gchar *html, *response;
11652 const char *no_redirect, *name, *comment, *base, *scanner = NULL;
11663 if (!strcmp (base,
"0"))
11670 switch (ompf (credentials,
11677 "<comment>%s</comment>"
11678 "<scanner>%s</scanner>"
11679 "</create_config>",
11680 name, base, comment,
11689 "Internal error", __FUNCTION__, __LINE__,
11690 "An internal error occurred while creating a new config. "
11691 "No new config was created. "
11692 "Diagnostics: Failure to send command to manager daemon.",
11693 "/omp?cmd=get_configs", response_data);
11697 "Internal error", __FUNCTION__, __LINE__,
11698 "An internal error occurred while creating a new config. "
11699 "It is unclear whether the config has been created or not. "
11700 "Diagnostics: Failure to receive response from manager daemon.",
11701 "/omp?cmd=get_configs", response_data);
11705 "Internal error", __FUNCTION__, __LINE__,
11706 "An internal error occurred while creating a new config. "
11707 "It is unclear whether the config has been created or not. "
11708 "Diagnostics: Internal Error.",
11709 "/omp?cmd=get_configs", response_data);
11712 if (entity_attribute (entity,
"id"))
11713 params_add (params,
"config_id", entity_attribute (entity,
"id"));
11714 html = response_from_entity (credentials, params, entity,
11715 (no_redirect && strcmp (no_redirect,
"0")),
11716 NULL,
"get_configs",
11717 NULL,
"new_config",
11718 "Create Config", response_data);
11720 free_entity (entity);
11738 const char *no_redirect;
11739 gchar *command, *html, *response;
11749 command = g_strdup_printf (
"<create_config>"
11751 "</create_config>",
11753 ret = omp (credentials, &response, &entity, response_data, command);
11763 "Internal error", __FUNCTION__, __LINE__,
11764 "An internal error occurred while importing a config. "
11765 "The schedule remains the same. "
11766 "Diagnostics: Failure to send command to manager daemon.",
11767 "/omp?cmd=get_configs", response_data);
11771 "Internal error", __FUNCTION__, __LINE__,
11772 "An internal error occurred while importing a config. "
11773 "It is unclear whether the schedule has been saved or not. "
11774 "Diagnostics: Failure to receive response from manager daemon.",
11775 "/omp?cmd=get_configs", response_data);
11779 "Internal error", __FUNCTION__, __LINE__,
11780 "An internal error occurred while importing a config. "
11781 "It is unclear whether the schedule has been saved or not. "
11782 "Diagnostics: Internal Error.",
11783 "/omp?cmd=get_configs", response_data);
11788 html = response_from_entity (credentials, params, entity,
11789 (no_redirect && strcmp (no_redirect,
"0")),
11790 NULL,
"get_configs",
11791 NULL,
"new_config",
11792 "Import Config", response_data);
11793 free_entity (entity);
11812 return get_many (
"config", credentials, params, extra_xml, NULL,
11829 return get_configs (credentials, params, NULL, response_data);
11848 openvas_connection_t connection;
11850 const char *config_id;
11854 if (config_id == NULL)
11855 return get_configs (credentials, params, extra_xml, response_data);
11869 "Internal error", __FUNCTION__, __LINE__,
11870 "An internal error occurred while getting list of configs. "
11871 "The current list of configs is not available. "
11872 "Diagnostics: Failure to connect to manager daemon.",
11873 "/omp?cmd=get_configs", response_data);
11876 xml = g_string_new (
"<get_config_response>");
11877 if (edit) g_string_append (xml,
"<edit/>");
11880 g_string_append (xml, extra_xml);
11883 if (openvas_connection_sendf (&connection,
11885 " config_id=\"%s\""
11888 " preferences=\"1\"/>",
11892 g_string_free (xml, TRUE);
11893 openvas_connection_close (&connection);
11896 "Internal error", __FUNCTION__, __LINE__,
11897 "An internal error occurred while getting the config. "
11898 "The config is not available. "
11899 "Diagnostics: Failure to send command to manager daemon.",
11900 "/omp?cmd=get_configs", response_data);
11903 if (read_string_c (&connection, &xml))
11905 g_string_free (xml, TRUE);
11906 openvas_connection_close (&connection);
11909 "Internal error", __FUNCTION__, __LINE__,
11910 "An internal error occurred while getting the config. "
11911 "The config is not available. "
11912 "Diagnostics: Failure to receive response from manager daemon.",
11913 "/omp?cmd=get_configs", response_data);
11918 if (openvas_connection_sendf (&connection,
"<get_nvt_families/>") == -1)
11920 g_string_free (xml, TRUE);
11921 openvas_connection_close (&connection);
11924 "Internal error", __FUNCTION__, __LINE__,
11925 "An internal error occurred while getting the config. "
11926 "The config is not available. "
11927 "Diagnostics: Failure to send command to manager daemon.",
11928 "/omp?cmd=get_configs", response_data);
11931 if (read_string_c (&connection, &xml))
11933 g_string_free (xml, TRUE);
11934 openvas_connection_close (&connection);
11937 "Internal error", __FUNCTION__, __LINE__,
11938 "An internal error occurred while getting the config. "
11939 "The config is not available. "
11940 "Diagnostics: Failure to receive response from manager daemon.",
11941 "/omp?cmd=get_configs", response_data);
11947 if (openvas_connection_sendf (&connection,
"<get_scanners filter=\"type=1\"/>")
11950 g_string_free (xml, TRUE);
11951 openvas_connection_close (&connection);
11954 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11955 "An internal error occurred while getting the config. "
11956 "The config is not available. "
11957 "Diagnostics: Failure to send command to manager daemon.",
11958 "/omp?cmd=get_configs", response_data);
11961 if (read_string_c (&connection, &xml))
11963 g_string_free (xml, TRUE);
11964 openvas_connection_close (&connection);
11967 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11968 "An internal error occurred while getting the config. "
11969 "The config is not available. "
11970 "Diagnostics: Failure to receive response from manager daemon.",
11971 "/omp?cmd=get_configs", response_data);
11977 if (openvas_connection_sendf (&connection,
"<get_credentials/>") == -1)
11979 g_string_free (xml, TRUE);
11980 openvas_connection_close (&connection);
11983 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11984 "An internal error occurred while getting the config. "
11985 "The config is not available. "
11986 "Diagnostics: Failure to send command to manager daemon.",
11987 "/omp?cmd=get_configs", response_data);
11989 if (read_string_c (&connection, &xml))
11991 g_string_free (xml, TRUE);
11992 openvas_connection_close (&connection);
11995 (credentials,
"Internal error", __FUNCTION__, __LINE__,
11996 "An internal error occurred while getting the config. "
11997 "The config is not available. "
11998 "Diagnostics: Failure to receive response from manager daemon.",
11999 "/omp?cmd=get_configs", response_data);
12004 g_string_append (xml,
"<permissions>");
12006 if (openvas_connection_sendf (&connection,
12008 " filter=\"name:^.*(config)s?$"
12009 " and resource_uuid=%s"
12010 " first=1 rows=-1\"/>",
12014 g_string_free (xml, TRUE);
12015 openvas_connection_close (&connection);
12018 "Internal error", __FUNCTION__, __LINE__,
12019 "An internal error occurred while getting permissions list. "
12020 "The current list of resources is not available. "
12021 "Diagnostics: Failure to send command to manager daemon.",
12022 "/omp?cmd=get_resources", response_data);
12025 if (read_string_c (&connection, &xml))
12027 g_string_free (xml, TRUE);
12028 openvas_connection_close (&connection);
12031 "Internal error", __FUNCTION__, __LINE__,
12032 "An internal error occurred while getting permissions list. "
12033 "The current list of resources is not available. "
12034 "Diagnostics: Failure to receive response from manager daemon.",
12035 "/omp?cmd=get_resources", response_data);
12038 g_string_append (xml,
"</permissions>");
12042 g_string_append (xml,
"</get_config_response>");
12043 openvas_connection_close (&connection);
12044 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
12061 return get_config (credentials, params, NULL, 0, response_data);
12077 return get_config (credentials, params, extra_xml, 1, response_data);
12093 return edit_config (credentials, params, NULL, response_data);
12110 openvas_connection_t connection;
12112 const char *config_id, *next;
12116 CHECK_PARAM (config_id,
"Synchronize Config", get_configs);
12129 (credentials,
"Internal error", __FUNCTION__, __LINE__,
12130 "An internal error occurred while synchronizing a config. "
12131 "The config is not synchronized. "
12132 "Diagnostics: Failure to connect to manager daemon.",
12133 "/omp?cmd=get_configs", response_data);
12136 if (openvas_connection_sendf (&connection,
"<sync_config config_id=\"%s\"/>",
12140 openvas_connection_close (&connection);
12143 (credentials,
"Internal error", __FUNCTION__, __LINE__,
12144 "An internal error occurred while synchronizing a config. "
12145 "The config is not synchronized. "
12146 "Diagnostics: Failure to send command to manager daemon.",
12147 "/omp?cmd=get_configs", response_data);
12150 xml = g_string_new (
"");
12152 if (read_string_c (&connection, &xml))
12154 g_string_free (xml, TRUE);
12155 openvas_connection_close (&connection);
12158 (credentials,
"Internal error", __FUNCTION__, __LINE__,
12159 "An internal error occurred while synchronizing a config. "
12160 "It is unclear whether the config has been synchronized or not. "
12161 "Diagnostics: Failure to receive response from manager daemon.",
12162 "/omp?cmd=get_configs", response_data);
12166 if (next && !strcmp (next,
"get_config"))
12167 ret = get_config (credentials, params, xml->str, 0, response_data);
12169 ret = get_configs (credentials, params, xml->str, response_data);
12170 openvas_connection_close (&connection);
12171 g_string_free (xml, TRUE);
12190 save_osp_prefs (
credentials_t *credentials, openvas_connection_t *connection,
12191 params_t *params,
const char *next,
const char *fail_next,
12194 GHashTableIter iter;
12195 gpointer param_name, val;
12197 const char *config_id;
12200 g_hash_table_iter_init (&iter, params);
12202 while (g_hash_table_iter_next (&iter, ¶m_name, &val))
12210 if (!g_str_has_prefix (param_name,
"osp_pref_"))
12212 value = param->
value_size ? g_base64_encode ((guchar *) param->
value,
12217 param_name = ((
char *) param_name) + 9;
12218 if (openvas_connection_sendf (connection,
12219 "<modify_config config_id=\"%s\">"
12220 "<preference><name>%s</name>"
12221 "<value>%s</value></preference>"
12222 "</modify_config>",
12224 (
char *) param_name,
12231 (credentials,
"Internal error", __FUNCTION__, __LINE__,
12232 "An internal error occurred while saving a config. It is"
12233 " unclear whether the entire config has been saved. "
12234 "Diagnostics: Failure to send command to manager daemon.",
12235 "/omp?cmd=get_configs", response_data);
12239 ret = check_modify_config (credentials, connection, params, next,
12240 fail_next, success, response_data);
12260 openvas_connection_t connection;
12264 params_t *preferences, *selects, *trends;
12265 const char *config_id, *name, *comment, *scanner_id;
12289 "Internal error", __FUNCTION__, __LINE__,
12290 "An internal error occurred while saving a config. "
12291 "The current list of configs is not available. "
12292 "Diagnostics: Failure to connect to manager daemon.",
12293 "/omp?cmd=get_configs", response_data);
12299 omp_ret = openvas_connection_sendf_xml (&connection,
12300 "<modify_config config_id=\"%s\">"
12302 "<comment>%s</comment>"
12303 "<scanner>%s</scanner>"
12304 "</modify_config>",
12310 omp_ret = openvas_connection_sendf_xml (&connection,
12311 "<modify_config config_id=\"%s\">"
12313 "<comment>%s</comment>"
12314 "</modify_config>",
12321 openvas_connection_close (&connection);
12324 "Internal error", __FUNCTION__, __LINE__,
12325 "An internal error occurred while saving a config. "
12326 "It is unclear whether the entire config has been saved. "
12327 "Diagnostics: Failure to send command to manager daemon.",
12328 "/omp?cmd=get_configs", response_data);
12331 ret = check_modify_config (credentials, &connection, params,
12332 "get_config",
"edit_config",
12333 &success, response_data);
12336 openvas_connection_close (&connection);
12356 ? g_base64_encode ((guchar *) param->
value,
12360 if (openvas_connection_sendf (&connection,
12361 "<modify_config config_id=\"%s\">"
12364 "<value>%s</value>"
12366 "</modify_config>",
12373 openvas_connection_close (&connection);
12376 "Internal error", __FUNCTION__, __LINE__,
12377 "An internal error occurred while saving a config. "
12378 "It is unclear whether the entire config has been saved. "
12379 "Diagnostics: Failure to send command to manager daemon.",
12380 "/omp?cmd=get_configs", response_data);
12384 ret = check_modify_config (credentials, &connection, params,
12385 "get_config",
"edit_config",
12386 &success, response_data);
12389 openvas_connection_close (&connection);
12396 ret = save_osp_prefs (credentials, &connection, params,
12397 "get_config",
"edit_config",
12398 &success, response_data);
12401 openvas_connection_close (&connection);
12410 if (openvas_connection_sendf (&connection,
12411 "<modify_config config_id=\"%s\">"
12412 "<family_selection>"
12413 "<growing>%i</growing>",
12420 openvas_connection_close (&connection);
12423 "Internal error", __FUNCTION__, __LINE__,
12424 "An internal error occurred while saving a config. "
12425 "It is unclear whether the entire config has been saved. "
12426 "Diagnostics: Failure to send command to manager daemon.",
12427 "/omp?cmd=get_configs", response_data);
12440 if (openvas_connection_sendf (&connection,
12444 "<growing>%i</growing>"
12447 trends &&
member1 (trends, family))
12450 openvas_connection_close (&connection);
12453 "Internal error", __FUNCTION__, __LINE__,
12454 "An internal error occurred while saving a config. "
12455 "It is unclear whether the entire config has been saved. "
12456 "Diagnostics: Failure to send command to manager daemon.",
12457 "/omp?cmd=get_configs", response_data);
12471 if (param->
value[0] ==
'0')
continue;
12472 if (selects && member (selects, family))
continue;
12473 if (openvas_connection_sendf (&connection,
12477 "<growing>1</growing>"
12482 openvas_connection_close (&connection);
12485 "Internal error", __FUNCTION__, __LINE__,
12486 "An internal error occurred while saving a config. "
12487 "It is unclear whether the entire config has been saved. "
12488 "Diagnostics: Failure to send command to manager daemon.",
12489 "/omp?cmd=get_configs", response_data);
12494 if (openvas_connection_sendf (&connection,
12495 "</family_selection>"
12496 "</modify_config>")
12499 openvas_connection_close (&connection);
12502 "Internal error", __FUNCTION__, __LINE__,
12503 "An internal error occurred while saving a config. "
12504 "It is unclear whether the entire config has been saved. "
12505 "Diagnostics: Failure to send command to manager daemon.",
12506 "/omp?cmd=get_configs", response_data);
12509 ret = check_modify_config (credentials, &connection, params,
12510 "get_config",
"edit_config",
12511 NULL, response_data);
12513 openvas_connection_close (&connection);
12532 openvas_connection_t connection;
12534 const char *config_id, *name, *family, *sort_field, *sort_order;
12540 if ((config_id == NULL) || (name == NULL) || (family == NULL))
12544 "Internal error", __FUNCTION__, __LINE__,
12545 "An internal error occurred while getting config family. "
12546 "Diagnostics: Required parameter was NULL.",
12547 "/omp?cmd=get_configs", response_data);
12562 "Internal error", __FUNCTION__, __LINE__,
12563 "An internal error occurred while getting config family. "
12564 "The current list of configs is not available. "
12565 "Diagnostics: Failure to connect to manager daemon.",
12566 "/omp?cmd=get_configs", response_data);
12569 xml = g_string_new (
"<get_config_family_response>");
12570 if (edit) g_string_append (xml,
"<edit/>");
12572 g_string_append_printf (xml,
12573 "<config id=\"%s\">"
12574 "<name>%s</name><family>%s</family>"
12585 if (openvas_connection_sendf (&connection,
12587 " config_id=\"%s\" details=\"1\""
12588 " family=\"%s\" timeout=\"1\" preference_count=\"1\""
12589 " sort_field=\"%s\" sort_order=\"%s\"/>",
12592 sort_field ? sort_field :
"nvts.name",
12593 sort_order ? sort_order :
"ascending")
12596 g_string_free (xml, TRUE);
12597 openvas_connection_close (&connection);
12600 "Internal error", __FUNCTION__, __LINE__,
12601 "An internal error occurred while getting list of configs. "
12602 "The current list of configs is not available. "
12603 "Diagnostics: Failure to send command to manager daemon.",
12604 "/omp?cmd=get_configs", response_data);
12607 if (read_string_c (&connection, &xml))
12609 g_string_free (xml, TRUE);
12610 openvas_connection_close (&connection);
12613 "Internal error", __FUNCTION__, __LINE__,
12614 "An internal error occurred while getting list of configs. "
12615 "The current list of configs is not available. "
12616 "Diagnostics: Failure to receive response from manager daemon.",
12617 "/omp?cmd=get_configs", response_data);
12624 g_string_append (xml,
"<all>");
12626 if (openvas_connection_sendf (&connection,
12631 " preferences_config_id=\"%s\""
12632 " preference_count=\"1\""
12633 " sort_field=\"%s\""
12634 " sort_order=\"%s\"/>",
12637 sort_field ? sort_field :
"nvts.name",
12638 sort_order ? sort_order :
"ascending")
12641 g_string_free (xml, TRUE);
12642 openvas_connection_close (&connection);
12645 "Internal error", __FUNCTION__, __LINE__,
12646 "An internal error occurred while getting list of configs. "
12647 "The current list of configs is not available. "
12648 "Diagnostics: Failure to send command to manager daemon.",
12649 "/omp?cmd=get_configs", response_data);
12652 if (read_string_c (&connection, &xml))
12654 g_string_free (xml, TRUE);
12655 openvas_connection_close (&connection);
12658 "Internal error", __FUNCTION__, __LINE__,
12659 "An internal error occurred while getting list of configs. "
12660 "The current list of configs is not available. "
12661 "Diagnostics: Failure to receive response from manager daemon.",
12662 "/omp?cmd=get_configs", response_data);
12665 g_string_append (xml,
"</all>");
12668 g_string_append (xml,
"</get_config_family_response>");
12669 openvas_connection_close (&connection);
12670 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
12687 return get_config_family (credentials, params, 0, response_data);
12703 return get_config_family (credentials, params, 1, response_data);
12719 openvas_connection_t connection;
12722 const char *config_id, *family;
12728 if ((config_id == NULL) || (family == NULL))
12732 "Internal error", __FUNCTION__, __LINE__,
12733 "An internal error occurred while saving getting config family. "
12734 "The config has not been saved. "
12735 "Diagnostics: Required parameter was NULL.",
12736 "/omp?cmd=get_configs", response_data);
12751 "Internal error", __FUNCTION__, __LINE__,
12752 "An internal error occurred while saving a config. "
12753 "The current list of configs is not available. "
12754 "The config has not been saved. "
12755 "Diagnostics: Failure to connect to manager daemon.",
12756 "/omp?cmd=get_configs", response_data);
12761 if (openvas_connection_sendf (&connection,
12762 "<modify_config config_id=\"%s\">"
12764 "<family>%s</family>",
12769 openvas_connection_close (&connection);
12772 "Internal error", __FUNCTION__, __LINE__,
12773 "An internal error occurred while saving a config. "
12774 "It is unclear whether the entire config has been saved. "
12775 "Diagnostics: Failure to send command to manager daemon.",
12776 "/omp?cmd=get_configs", response_data);
12788 if (openvas_connection_sendf (&connection,
12789 "<nvt oid=\"%s\"/>",
12793 openvas_connection_close (&connection);
12796 "Internal error", __FUNCTION__, __LINE__,
12797 "An internal error occurred while saving a config. "
12798 "It is unclear whether the entire config has been saved. "
12799 "Diagnostics: Failure to send command to manager daemon.",
12800 "/omp?cmd=get_configs", response_data);
12804 if (openvas_connection_sendf (&connection,
12806 "</modify_config>")
12809 openvas_connection_close (&connection);
12812 "Internal error", __FUNCTION__, __LINE__,
12813 "An internal error occurred while saving a config. "
12814 "It is unclear whether the entire config has been saved. "
12815 "Diagnostics: Failure to send command to manager daemon.",
12816 "/omp?cmd=get_configs", response_data);
12819 ret = check_modify_config (credentials, &connection, params,
12820 "get_config_family",
"edit_config_family",
12821 NULL, response_data);
12823 openvas_connection_close (&connection);
12842 openvas_connection_t connection;
12844 const char *config_id, *name, *family, *sort_field, *sort_order, *nvt;
12851 if ((config_id == NULL) || (name == NULL))
12855 "Internal error", __FUNCTION__, __LINE__,
12856 "An internal error occurred while getting config family. "
12857 "Diagnostics: Required parameter was NULL.",
12858 "/omp?cmd=get_configs", response_data);
12873 "Internal error", __FUNCTION__, __LINE__,
12874 "An internal error occurred while getting list of configs. "
12875 "The current list of configs is not available. "
12876 "Diagnostics: Failure to connect to manager daemon.",
12877 "/omp?cmd=get_configs", response_data);
12880 xml = g_string_new (
"<get_config_nvt_response>");
12881 if (edit) g_string_append (xml,
"<edit/>");
12883 g_string_append_printf (xml,
12884 "<config id=\"%s\">"
12885 "<name>%s</name><family>%s</family>"
12889 family ? family :
"");
12894 if (openvas_connection_sendf (&connection,
12896 " config_id=\"%s\" nvt_oid=\"%s\""
12897 " details=\"1\" preferences=\"1\""
12898 " sort_field=\"%s\" sort_order=\"%s\"/>",
12901 sort_field ? sort_field :
"nvts.name",
12902 sort_order ? sort_order :
"ascending")
12905 g_string_free (xml, TRUE);
12906 openvas_connection_close (&connection);
12909 "Internal error", __FUNCTION__, __LINE__,
12910 "An internal error occurred while getting list of configs. "
12911 "The current list of configs is not available. "
12912 "Diagnostics: Failure to send command to manager daemon.",
12913 "/omp?cmd=get_configs", response_data);
12916 if (read_string_c (&connection, &xml))
12918 g_string_free (xml, TRUE);
12919 openvas_connection_close (&connection);
12922 "Internal error", __FUNCTION__, __LINE__,
12923 "An internal error occurred while getting list of configs. "
12924 "The current list of configs is not available. "
12925 "Diagnostics: Failure to receive response from manager daemon.",
12926 "/omp?cmd=get_configs", response_data);
12929 g_string_append (xml,
"</get_config_nvt_response>");
12931 if (openvas_connection_sendf (&connection,
12934 " sort_field=\"notes.text\"/>",
12938 g_string_free (xml, TRUE);
12939 openvas_connection_close (&connection);
12942 "Internal error", __FUNCTION__, __LINE__,
12943 "An internal error occurred while getting list of notes. "
12944 "The current list of notes is not available. "
12945 "Diagnostics: Failure to send command to manager daemon.",
12946 "/omp?cmd=get_configs", response_data);
12949 if (read_string_c (&connection, &xml))
12951 g_string_free (xml, TRUE);
12952 openvas_connection_close (&connection);
12955 "Internal error", __FUNCTION__, __LINE__,
12956 "An internal error occurred while getting list of notes. "
12957 "The current list of notes is not available. "
12958 "Diagnostics: Failure to receive response from manager daemon.",
12959 "/omp?cmd=get_configs", response_data);
12962 if (openvas_connection_sendf (&connection,
12965 " sort_field=\"overrides.text\"/>",
12969 g_string_free (xml, TRUE);
12970 openvas_connection_close (&connection);
12973 "Internal error", __FUNCTION__, __LINE__,
12974 "An internal error occurred while getting list of overrides. "
12975 "The current list of overrides is not available. "
12976 "Diagnostics: Failure to send command to manager daemon.",
12977 "/omp?cmd=get_configs", response_data);
12980 if (read_string_c (&connection, &xml))
12982 g_string_free (xml, TRUE);
12983 openvas_connection_close (&connection);
12986 "Internal error", __FUNCTION__, __LINE__,
12987 "An internal error occurred while getting list of overrides. "
12988 "The current list of overrides is not available. "
12989 "Diagnostics: Failure to receive response from manager daemon.",
12990 "/omp?cmd=get_configs", response_data);
12993 openvas_connection_close (&connection);
12994 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
13011 return get_config_nvt (credentials, params, 0, response_data);
13027 return get_config_nvt (credentials, params, 1, response_data);
13044 const char *config_id;
13046 char *modify_config_ret;
13048 modify_config_ret = NULL;
13054 openvas_connection_t connection;
13057 gchar *preference_name;
13074 "Internal error", __FUNCTION__, __LINE__,
13075 "An internal error occurred while getting list of configs. "
13076 "The current list of configs is not available. "
13077 "Diagnostics: Failure to connect to manager daemon.",
13078 "/omp?cmd=get_configs", response_data);
13084 int type_start, type_end, count, ret, is_timeout = 0;
13087 g_free (modify_config_ret);
13088 modify_config_ret = NULL;
13095 count = sscanf (preference_name,
13096 "%*[^[][%n%*[^]]%n]:",
13099 if (count == 0 && type_start > 0 && type_end > 0)
13101 if (strncmp (preference_name + type_start,
13103 type_end - type_start)
13113 gchar *password_name;
13120 if (strcmp (password_name, preference_name) == 0)
13130 else if (strncmp (preference_name + type_start,
13132 type_end - type_start)
13149 if (strcmp (file_name, preference_name) == 0)
13159 else if (strncmp (preference_name + type_start,
13161 type_end - type_start)
13170 ? g_base64_encode ((guchar *) preference->
value,
13176 const char *timeout;
13177 gchar *preference_name_escaped;
13181 if (timeout == NULL)
13184 openvas_connection_close (&connection);
13187 "Internal error", __FUNCTION__, __LINE__,
13188 "An internal error occurred while saving a config. "
13189 "It is unclear whether the entire config has been saved. "
13190 "Diagnostics: Required parameter was NULL.",
13191 "/omp?cmd=get_configs", response_data);
13194 preference_name_escaped = g_markup_escape_text (preference_name,
13197 if (strcmp (timeout,
"0") == 0)
13199 ret = openvas_connection_sendf (&connection,
13201 " config_id=\"%s\">"
13205 "</modify_config>",
13207 preference_name_escaped);
13209 ret = openvas_connection_sendf (&connection,
13211 " config_id=\"%s\">"
13214 "<value>%s</value>"
13216 "</modify_config>",
13218 preference_name_escaped,
13221 g_free (preference_name_escaped);
13225 gchar *preference_name_escaped;
13226 preference_name_escaped = g_markup_escape_text (preference_name,
13228 ret = openvas_connection_sendf (&connection,
13230 " config_id=\"%s\">"
13232 "<nvt oid=\"%s\"/>"
13234 "<value>%s</value>"
13236 "</modify_config>",
13239 preference_name_escaped,
13241 g_free (preference_name_escaped);
13247 openvas_connection_close (&connection);
13250 "Internal error", __FUNCTION__, __LINE__,
13251 "An internal error occurred while saving a config. "
13252 "It is unclear whether the entire config has been saved. "
13253 "Diagnostics: Failure to send command to manager daemon.",
13254 "/omp?cmd=get_configs", response_data);
13258 modify_config_ret = check_modify_config (credentials, &connection,
13262 &success, response_data);
13265 openvas_connection_close (&connection);
13266 return modify_config_ret;
13270 openvas_connection_close (&connection);
13273 return modify_config_ret;
13289 return delete_resource (
"config", credentials, params, 0,
"get_configs",
13307 enum content_type * content_type,
char **content_disposition,
13311 content_disposition, content_length, response_data);
13329 enum content_type * content_type,
char **content_disposition,
13332 return export_many (
"config", credentials, params, content_type,
13333 content_disposition, content_length, response_data);
13350 enum content_type * content_type,
char **content_disposition,
13354 content_disposition, content_length, response_data);
13372 enum content_type * content_type,
char **content_disposition,
13375 return export_many (
"note", credentials, params, content_type,
13376 content_disposition, content_length, response_data);
13393 enum content_type * content_type,
13394 char **content_disposition, gsize *content_length,
13397 return export_resource (
"override", credentials, params, content_type,
13398 content_disposition, content_length, response_data);
13416 enum content_type * content_type,
13417 char **content_disposition, gsize *content_length,
13420 return export_many (
"override", credentials, params, content_type,
13421 content_disposition, content_length, response_data);
13439 enum content_type * content_type,
13440 char **content_disposition, gsize *content_length,
13443 return export_resource (
"port_list", credentials, params, content_type,
13444 content_disposition, content_length,
13463 enum content_type * content_type,
13464 char **content_disposition, gsize *content_length,
13467 return export_many (
"port_list", credentials, params, content_type,
13468 content_disposition, content_length, response_data);
13485 enum content_type * content_type,
13486 char **content_disposition, gsize *content_length,
13490 entity_t entity, preference_entity, value_entity;
13491 openvas_connection_t connection;
13493 const char *config_id, *oid, *preference_name;
13495 *content_length = 0;
13509 "Internal error", __FUNCTION__, __LINE__,
13510 "An internal error occurred while getting a preference file. "
13511 "The file could not be delivered. "
13512 "Diagnostics: Failure to connect to manager daemon.",
13513 "/omp?cmd=get_tasks", response_data);
13518 preference_name =
params_value (params,
"preference_name");
13520 xml = g_string_new (
"<get_preferences_response>");
13522 if (config_id == NULL || oid == NULL || preference_name == NULL)
13526 if (openvas_connection_sendf (&connection,
13528 " config_id=\"%s\""
13530 " preference=\"%s\"/>",
13536 g_string_free (xml, TRUE);
13537 openvas_connection_close (&connection);
13540 "Internal error", __FUNCTION__, __LINE__,
13541 "An internal error occurred while getting a preference file. "
13542 "The file could not be delivered. "
13543 "Diagnostics: Failure to send command to manager daemon.",
13544 "/omp?cmd=get_tasks", response_data);
13548 if (read_entity_c (&connection, &entity))
13550 g_string_free (xml, TRUE);
13551 openvas_connection_close (&connection);
13554 "Internal error", __FUNCTION__, __LINE__,
13555 "An internal error occurred while getting a preference file. "
13556 "The file could not be delivered. "
13557 "Diagnostics: Failure to receive response from manager daemon.",
13558 "/omp?cmd=get_tasks", response_data);
13561 preference_entity = entity_child (entity,
"preference");
13562 if (preference_entity != NULL
13563 && (value_entity = entity_child (preference_entity,
"value")))
13565 char *content = strdup (entity_text (value_entity));
13567 *content_disposition = g_strdup_printf (
"attachment; filename=\"pref_file.bin\"");
13568 *content_length = strlen (content);
13569 free_entity (entity);
13570 g_string_free (xml, TRUE);
13571 openvas_connection_close (&connection);
13576 free_entity (entity);
13577 g_string_free (xml, TRUE);
13578 openvas_connection_close (&connection);
13581 "Internal error", __FUNCTION__, __LINE__,
13582 "An internal error occurred while getting a preference file. "
13583 "The file could not be delivered. "
13584 "Diagnostics: Failure to receive file from manager daemon.",
13585 "/omp?cmd=get_tasks", response_data);
13589 g_string_append (xml,
"</get_preferences_response>");
13590 openvas_connection_close (&connection);
13591 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
13610 enum content_type * content_type,
13611 char **content_disposition, gsize *content_length,
13614 return export_resource (
"report_format", credentials, params, content_type,
13615 content_disposition, content_length, response_data);
13633 enum content_type * content_type,
13634 char **content_disposition, gsize *content_length,
13637 return export_many (
"report_format", credentials, params, content_type,
13638 content_disposition, content_length, response_data);
13675 gsize *report_len, gchar **content_type,
char **content_disposition,
13676 const char *extra_xml,
int *error,
13679 GString *xml, *commands_xml;
13681 entity_t report_entity;
13682 openvas_connection_t connection;
13684 unsigned int first, max;
13685 GString *levels, *delta_states;
13686 const char *alert_id, *search_phrase, *min_qod, *type, *zone;
13687 const char *autofp, *autofp_value, *notes, *overrides, *result_hosts_only;
13688 const char *apply_overrides;
13689 const char *report_id, *sort_field, *sort_order, *result_id, *delta_report_id;
13690 const char *format_id, *first_result, *max_results, *host, *pos;
13691 const char *given_filt_id, *filt_id, *filter, *apply_filter, *report_section;
13692 const char *build_filter, *filter_extra;
13693 const char *host_search_phrase, *host_levels;
13694 const char *host_first_result, *host_max_results;
13696 int ignore_filter, ignore_pagination;
13697 gchar *built_filter;
13698 gchar *fname_format, *esc_response;
13706 apply_filter =
"no_pagination";
13710 report_section =
params_value (params,
"report_section");
13712 report_section =
"";
13714 ignore_filter = (strcmp (apply_filter,
"full")
13715 && strcmp (apply_filter,
"no_pagination")
13716 && strcmp (report_section,
"")
13717 && strcmp (report_section,
"results")
13718 && strcmp (report_section,
"summary"));
13722 const char *ignore_pagination_str =
params_value (params,
13723 "ignore_pagination");
13724 ignore_pagination = (ignore_pagination_str
13725 && strcmp (ignore_pagination_str,
"")
13726 && strcmp (ignore_pagination_str,
"0"));
13730 ignore_pagination = (strcmp (apply_filter,
"full")
13731 && strcmp (report_section,
"")
13732 && strcmp (report_section,
"results")
13733 && strcmp (report_section,
"summary"));
13737 if (alert_id == NULL)
13738 params_given (params,
"alert_id") || (alert_id =
"0");
13740 search_phrase =
params_value (params,
"search_phrase");
13741 if (search_phrase == NULL)
13742 params_given (params,
"search_phrase") || (search_phrase =
"");
13755 if (autofp == NULL)
13759 if (autofp_value == NULL)
13760 params_given (params,
"autofp_value") || (autofp_value =
"1");
13775 if (overrides == NULL)
13781 params_given (params,
"overrides") || (overrides =
"1");
13784 apply_overrides =
params_value (params,
"apply_overrides");
13785 if (apply_overrides == NULL)
13789 apply_overrides =
"0";
13791 params_given (params,
"apply_overrides") || (apply_overrides =
"1");
13794 result_hosts_only =
params_value (params,
"result_hosts_only");
13795 if (result_hosts_only == NULL)
13801 result_hosts_only =
"0";
13803 params_given (params,
"result_hosts_only") || (result_hosts_only =
"1");
13806 if (content_type) *content_type = NULL;
13807 if (report_len) *report_len = 0;
13809 if (autofp == NULL || strlen (autofp) == 0) autofp =
"0";
13811 if (autofp_value == NULL || strlen (autofp_value) == 0) autofp_value =
"1";
13813 if (strcmp (autofp,
"2") == 0)
13814 autofp_value =
"2";
13816 if (notes == NULL || strlen (notes) == 0) notes =
"1";
13818 if (overrides == NULL || strlen (overrides) == 0) overrides =
"1";
13820 if (result_hosts_only == NULL || strlen (result_hosts_only) == 0)
13821 result_hosts_only =
"1";
13831 if (error) *error = 1;
13838 if (error) *error = 1;
13841 "Internal error", __FUNCTION__, __LINE__,
13842 "An internal error occurred while getting a report. "
13843 "The report could not be delivered. "
13844 "Diagnostics: Failure to connect to manager daemon.",
13845 "/omp?cmd=get_tasks", response_data);
13851 commands_xml = g_string_new (
"");
13854 if (openvas_connection_sendf (&connection,
"%s", commands)
13857 g_string_free (commands_xml, TRUE);
13858 openvas_connection_close (&connection);
13859 if (error) *error = 1;
13862 "Internal error", __FUNCTION__, __LINE__,
13863 "An internal error occurred while getting a report. "
13864 "The report could not be delivered. "
13865 "Diagnostics: Failure to send extra commands to manager daemon.",
13866 "/omp?cmd=get_tasks", response_data);
13869 if (read_string_c (&connection, &commands_xml))
13871 g_string_free (commands_xml, TRUE);
13872 openvas_connection_close (&connection);
13873 if (error) *error = 1;
13876 "Internal error", __FUNCTION__, __LINE__,
13877 "An internal error occurred while getting a report. "
13878 "The report could not be delivered. "
13879 "Diagnostics: Failure to receive response from manager daemon.",
13880 "/omp?cmd=get_tasks", response_data);
13887 delta_states = g_string_new (
params_value (params,
"delta_states"));
13890 delta_states = g_string_new (
"");
13892 && atoi (
params_value (params,
"delta_state_changed")))
13893 g_string_append (delta_states,
"c");
13896 g_string_append (delta_states,
"g");
13899 g_string_append (delta_states,
"n");
13902 g_string_append (delta_states,
"s");
13905 if (strlen (delta_states->str) == 0) g_string_append (delta_states,
"gn");
13908 levels = g_string_new (
params_value (params,
"levels"));
13911 levels = g_string_new (
"");
13914 g_string_append (levels,
"h");
13917 g_string_append (levels,
"m");
13920 g_string_append (levels,
"l");
13923 g_string_append (levels,
"g");
13925 && atoi (
params_value (params,
"level_false_positive")))
13926 g_string_append (levels,
"f");
13929 if (type && (strcmp (type,
"assets") == 0))
13931 if (strlen (levels->str) == 0)
13932 g_string_append (levels,
"");
13934 else if (strlen (levels->str) == 0)
13935 g_string_append (levels,
"hml");
13941 if (report_id == NULL
13943 || (strcmp (type,
"prognostic")
13944 && strcmp (type,
"assets"))))
13945 return get_reports (credentials, params, extra_xml, response_data);
13947 if (strcmp (alert_id,
"0"))
13949 const char *status, *esc_filter;
13952 if (esc_filter == NULL)
13954 || (esc_filter =
"first=1 rows=-1"
13955 " result_hosts_only=0"
13956 " apply_overrides=1"
13957 " notes=1 overrides=1"
13958 " sort-reverse=severity");
13961 ret = openvas_connection_sendf_xml (&connection,
13963 " report_id=\"%s\""
13964 " filter=\"first=1 rows=-1"
13965 " result_hosts_only=0"
13966 " apply_overrides=1"
13967 " notes=1 overrides=1"
13968 " sort-reverse=severity\""
13969 " alert_id=\"%s\"/>",
13973 ret = openvas_connection_sendf_xml (&connection,
13975 " report_id=\"%s\""
13976 " ignore_pagination=\"%d\""
13978 " alert_id=\"%s\"/>",
13981 esc_filter ? esc_filter :
"",
13985 openvas_connection_close (&connection);
13986 g_string_free (commands_xml, TRUE);
13987 g_string_free (delta_states, TRUE);
13988 g_string_free (levels, TRUE);
13989 if (error) *error = 1;
13992 "Internal error", __FUNCTION__, __LINE__,
13993 "An internal error occurred while getting a report. "
13994 "The report could not be delivered. "
13995 "Diagnostics: Failure to send command to manager daemon.",
13996 "/omp?cmd=get_tasks", response_data);
13999 if (read_entity_and_text_c (&connection, &entity, &esc_response))
14001 openvas_connection_close (&connection);
14002 g_string_free (commands_xml, TRUE);
14003 g_string_free (delta_states, TRUE);
14004 g_string_free (levels, TRUE);
14005 if (error) *error = 1;
14008 "Internal error", __FUNCTION__, __LINE__,
14009 "An internal error occurred while getting a report. "
14010 "The report could not be delivered. "
14011 "Diagnostics: Failure to receive response from manager daemon.",
14012 "/omp?cmd=get_tasks", response_data);
14014 status = entity_attribute (entity,
"status");
14015 if ((status == NULL)
14016 || (strlen (status) == 0))
14018 free_entity (entity);
14019 openvas_connection_close (&connection);
14020 g_string_free (commands_xml, TRUE);
14021 g_string_free (delta_states, TRUE);
14022 if (error) *error = 1;
14025 "Internal error", __FUNCTION__, __LINE__,
14026 "An internal error occurred while getting a report. "
14027 "The report could not be delivered. "
14028 "Diagnostics: Failure to parse response from manager daemon.",
14029 "/omp?cmd=get_tasks", response_data);
14031 free_entity (entity);
14034 esc_response = NULL;
14037 delta_report_id =
params_value (params,
"delta_report_id");
14038 format_id =
params_value (params,
"report_format_id");
14041 if (first_result == NULL
14042 || sscanf (first_result,
"%u", &first) != 1)
14043 first_result =
"1";
14046 if (max_results == NULL
14047 || sscanf (max_results,
"%u", &max) != 1)
14050 if (openvas_connection_sendf (&connection,
14055 (type && (strcmp (type,
"prognostic") == 0))
14056 ?
" type=\"prognostic\""
14058 (type && (strcmp (type,
"assets") == 0))
14059 ?
" type=\"assets\""
14062 && (strcmp (type,
"assets") == 0)
14065 || strcmp (report_section,
"summary"),
14066 host ?
" host=\"" :
"",
14071 openvas_connection_close (&connection);
14072 g_string_free (delta_states, TRUE);
14073 g_string_free (commands_xml, TRUE);
14074 g_string_free (levels, TRUE);
14075 if (error) *error = 1;
14078 "Internal error", __FUNCTION__, __LINE__,
14079 "An internal error occurred while getting a report. "
14080 "The report could not be delivered. "
14081 "Diagnostics: Failure to send command to manager daemon.",
14082 "/omp?cmd=get_tasks", response_data);
14091 g_tree_replace (credentials->
last_filt_ids, g_strdup (
"report_result"),
14092 g_strdup (given_filt_id));
14093 filt_id = given_filt_id;
14095 else if (filter == NULL || strcmp (filter,
"") == 0)
14096 filt_id = g_tree_lookup (credentials->
last_filt_ids,
"report_result");
14100 if (filter == NULL)
14103 if ((build_filter && (strcmp (build_filter,
"1") == 0))
14104 || ((filter == NULL || strcmp (filter,
"") == 0)
14105 && (filter_extra == NULL || strcmp (filter_extra,
"") == 0)))
14107 GString *filter_buffer;
14108 filter_buffer = g_string_new (
"");
14110 g_string_append_printf (filter_buffer,
14112 " apply_overrides=%i"
14115 " result_hosts_only=%i"
14120 strcmp (autofp,
"0") ? autofp_value :
"0",
14122 ? (strcmp (apply_overrides,
"0") ? 1 : 0)
14124 strcmp (notes,
"0") ? 1 : 0,
14125 strcmp (overrides,
"0") ? 1 : 0,
14126 strcmp (result_hosts_only,
"0") ? 1 : 0,
14130 ? strcmp (sort_order,
"ascending")
14133 : ((sort_field == NULL
14134 || strcmp (sort_field,
"type") == 0
14135 || strcmp (sort_field,
"severity") == 0)
14138 sort_field ? sort_field :
"severity",
14141 if (search_phrase && strcmp (search_phrase,
""))
14143 gchar *search_phrase_escaped;
14144 search_phrase_escaped = g_markup_escape_text (search_phrase, -1);
14145 g_string_append_printf (filter_buffer,
14147 search_phrase_escaped);
14148 g_free (search_phrase_escaped);
14151 if (delta_states->str && strcmp (delta_states->str,
"")
14152 && delta_report_id && strcmp (delta_report_id,
""))
14153 g_string_append_printf (filter_buffer,
14154 " delta_states=%s",
14155 delta_states->str);
14157 if (min_qod && strcmp (min_qod,
""))
14158 g_string_append_printf (filter_buffer,
14162 if (zone && strcmp (zone,
""))
14163 g_string_append_printf (filter_buffer,
14167 if (filter && strcmp (filter,
""))
14168 g_string_append_printf (filter_buffer,
14172 built_filter = g_string_free (filter_buffer, FALSE);
14174 else if (filter || filter_extra)
14175 built_filter = g_strdup_printf (
"%s%s%s",
14176 filter ? filter :
"",
14177 filter && filter_extra ?
" " :
"",
14178 filter_extra ? filter_extra :
"");
14180 built_filter = NULL;
14182 if (type && (strcmp (type,
"prognostic") == 0))
14184 host_search_phrase =
params_value (params,
"host_search_phrase");
14185 if (host_search_phrase == NULL)
14187 || (host_search_phrase =
"");
14190 if (host_levels == NULL)
14192 || (host_levels =
"");
14194 host_first_result =
params_value (params,
"host_first_result");
14195 if (host_first_result == NULL
14196 || sscanf (host_first_result,
"%u", &first) != 1)
14197 host_first_result =
"1";
14199 host_max_results =
params_value (params,
"host_max_results");
14200 if (host_max_results == NULL
14201 || sscanf (host_max_results,
"%u", &max) != 1)
14204 if (host_search_phrase == NULL)
14206 openvas_connection_close (&connection);
14207 g_string_free (delta_states, TRUE);
14208 g_string_free (commands_xml, TRUE);
14209 g_string_free (levels, TRUE);
14210 xml = g_string_new (
"");
14212 "Given host search_phrase was invalid",
14214 if (error) *error = 1;
14216 return g_string_free (xml, FALSE);
14219 if (openvas_connection_sendf_xml (&connection,
14220 " host_search_phrase=\"%s\""
14221 " host_levels=\"%s\""
14222 " host_first_result=\"%s\""
14223 " host_max_results=\"%s\"",
14224 host_search_phrase,
14229 openvas_connection_close (&connection);
14230 g_string_free (delta_states, TRUE);
14231 g_string_free (commands_xml, TRUE);
14232 g_string_free (levels, TRUE);
14233 if (error) *error = 1;
14236 "Internal error", __FUNCTION__, __LINE__,
14237 "An internal error occurred while getting a report. "
14238 "The report could not be delivered. "
14239 "Diagnostics: Failure to send command to manager daemon.",
14240 "/omp?cmd=get_tasks", response_data);
14245 host_search_phrase = NULL;
14246 host_levels = NULL;
14247 host_first_result = NULL;
14248 host_max_results = NULL;
14253 if (sort_field == NULL && sort_order == NULL)
14254 if ((filt_id == NULL || strcmp (filt_id,
"") == 0)
14255 && (filter == NULL || strcmp (filter,
"") == 0))
14259 ret = openvas_connection_sendf_xml (&connection,
14261 " filter=\"first=1 rows=-1"
14262 " result_hosts_only=0 apply_overrides=1"
14263 " notes=1 overrides=1"
14264 " sort-reverse=severity\""
14265 " report_id=\"%s\""
14266 " delta_report_id=\"%s\""
14267 " format_id=\"%s\"/>",
14268 (type && ((strcmp (type,
"assets") == 0)
14269 || (strcmp (type,
"prognostic")
14273 delta_report_id ? delta_report_id :
"0",
14276 :
"a994b278-1f62-11e1-96ac-406186ea4fc5");
14278 ret = openvas_connection_sendf_xml (&connection,
14279 " ignore_pagination=\"%d\""
14283 " notes_details=\"1\""
14284 " overrides_details=\"1\""
14285 " report_id=\"%s\""
14286 " delta_report_id=\"%s\""
14287 " format_id=\"%s\"/>",
14289 filt_id ? filt_id :
"0",
14290 built_filter ? built_filter :
"",
14292 (type && ((strcmp (type,
"assets") == 0)
14293 || (strcmp (type,
"prognostic")
14297 delta_report_id ? delta_report_id :
"0",
14300 :
"a994b278-1f62-11e1-96ac-406186ea4fc5",
14303 sort_field ? sort_field :
"severity",
14306 : ((sort_field == NULL
14307 || strcmp (sort_field,
"type") == 0
14308 || strcmp (sort_field,
"severity") == 0)
14318 openvas_connection_close (&connection);
14319 g_string_free (delta_states, TRUE);
14320 g_string_free (commands_xml, TRUE);
14321 g_string_free (levels, TRUE);
14322 if (error) *error = 1;
14325 "Internal error", __FUNCTION__, __LINE__,
14326 "An internal error occurred while getting a report. "
14327 "The report could not be delivered. "
14328 "Diagnostics: Failure to send command to manager daemon.",
14329 "/omp?cmd=get_tasks", response_data);
14332 g_string_free (delta_states, TRUE);
14336 g_string_free (commands_xml, TRUE);
14337 g_string_free (levels, TRUE);
14338 if ((strcmp (format_id,
"a994b278-1f62-11e1-96ac-406186ea4fc5") == 0)
14339 || strcmp (format_id,
"5057e5cc-b825-11e4-9d0e-28d24461215b") == 0)
14341 const char *extension, *requested_content_type;
14344 if (read_entity_c (&connection, &entity))
14346 openvas_connection_close (&connection);
14347 if (error) *error = 1;
14350 "Internal error", __FUNCTION__, __LINE__,
14351 "An internal error occurred while getting a report. "
14352 "The report could not be delivered. "
14353 "Diagnostics: Failure to receive response from manager daemon.",
14354 "/omp?cmd=get_tasks", response_data);
14356 entity_t report = entity_child (entity,
"report");
14357 if (report == NULL)
14359 free_entity (entity);
14360 openvas_connection_close (&connection);
14361 if (error) *error = 1;
14364 "Internal error", __FUNCTION__, __LINE__,
14365 "An internal error occurred while getting a report. "
14366 "The report could not be delivered. "
14367 "Diagnostics: Response from manager daemon did not contain a report.",
14368 "/omp?cmd=get_tasks", response_data);
14370 extension = entity_attribute (report,
"extension");
14371 requested_content_type = entity_attribute (report,
"content_type");
14372 if (extension && requested_content_type && content_type
14373 && content_disposition)
14376 ret = setting_get_value (&connection,
14377 "e1a2ae0b-736e-4484-b029-330c9e15b900",
14382 openvas_connection_close (&connection);
14387 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14389 "Internal error", __FUNCTION__, __LINE__,
14390 "An internal error occurred while getting a setting. "
14391 "The setting could not be delivered. "
14392 "Diagnostics: Failure to send command to manager daemon.",
14393 "/omp?cmd=get_tasks",
14397 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14399 "Internal error", __FUNCTION__, __LINE__,
14400 "An internal error occurred while getting a setting. "
14401 "The setting could not be delivered. "
14402 "Diagnostics: Failure to receive response from manager daemon.",
14403 "/omp?cmd=get_tasks",
14407 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14409 "Internal error", __FUNCTION__, __LINE__,
14410 "An internal error occurred while getting a setting. "
14411 "The setting could not be delivered. "
14412 "Diagnostics: Internal error.",
14413 "/omp?cmd=get_tasks",
14418 if (fname_format == NULL)
14420 g_warning (
"%s : File name format setting not found.",
14422 fname_format =
"%T-%U";
14429 && ((strcmp (type,
"assets") == 0)
14430 || (strcmp (type,
"prognostic")
14435 if (file_name == NULL)
14436 file_name = g_strdup_printf (
"%s-%s",
14439 && ((strcmp (type,
"assets") == 0)
14440 || (strcmp (type,
"prognostic")
14445 *content_type = g_strdup (requested_content_type);
14446 *content_disposition
14447 = g_strdup_printf (
"attachment; filename=\"%s.%s\"",
14451 g_free (file_name);
14453 openvas_connection_close (&connection);
14454 xml = g_string_new (
"");
14455 print_entity_to_string (report, xml);
14456 free_entity (entity);
14457 if (error) *error = 1;
14458 return g_string_free (xml, FALSE);
14464 if (report_len == NULL)
14466 if (error) *error = 1;
14469 "Internal error", __FUNCTION__, __LINE__,
14470 "An internal error occurred while getting a report. "
14471 "The report could not be delivered. "
14472 "Diagnostics: Parameter error.",
14473 "/omp?cmd=get_tasks", response_data);
14477 if (read_entity_c (&connection, &entity))
14479 openvas_connection_close (&connection);
14480 if (error) *error = 1;
14483 "Internal error", __FUNCTION__, __LINE__,
14484 "An internal error occurred while getting a report. "
14485 "The report could not be delivered. "
14486 "Diagnostics: Failure to receive response from manager daemon.",
14487 "/omp?cmd=get_tasks", response_data);
14490 report_entity = entity_child (entity,
"report");
14491 if (report_entity != NULL)
14493 const char *extension, *requested_content_type;
14494 char *report_encoded;
14495 gchar *report_decoded;
14496 extension = entity_attribute (report_entity,
"extension");
14497 requested_content_type = entity_attribute (report_entity,
14499 report_encoded = entity_text (report_entity);
14501 (gchar *) g_base64_decode (report_encoded, report_len);
14504 if (report_decoded == NULL)
14506 report_decoded = g_strdup (
"");
14509 if (extension && requested_content_type && content_type
14510 && content_disposition)
14516 else if (type && (strcmp (type,
"prognostic") == 0))
14521 ret = setting_get_value
14523 "e1a2ae0b-736e-4484-b029-330c9e15b900",
14528 openvas_connection_close (&connection);
14533 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14535 "Internal error", __FUNCTION__, __LINE__,
14536 "An internal error occurred while getting a setting. "
14537 "The setting could not be delivered. "
14538 "Diagnostics: Failure to send command to manager daemon.",
14539 "/omp?cmd=get_tasks",
14543 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14545 "Internal error", __FUNCTION__, __LINE__,
14546 "An internal error occurred while getting a setting. "
14547 "The setting could not be delivered. "
14548 "Diagnostics: Failure to receive response from manager daemon.",
14549 "/omp?cmd=get_tasks",
14553 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14555 "Internal error", __FUNCTION__, __LINE__,
14556 "An internal error occurred while getting a setting. "
14557 "The setting could not be delivered. "
14558 "Diagnostics: Internal error.",
14559 "/omp?cmd=get_tasks",
14564 if (fname_format == NULL)
14566 g_warning (
"%s : File name format setting not found.",
14568 fname_format =
"%T-%U";
14572 "report",
id, report_entity);
14573 if (file_name == NULL)
14574 file_name = g_strdup_printf (
"%s-%s",
14577 *content_type = g_strdup (requested_content_type);
14578 *content_disposition
14579 = g_strdup_printf (
"attachment; filename=\"%s.%s\"",
14583 g_free (file_name);
14585 free_entity (entity);
14586 openvas_connection_close (&connection);
14587 if (error) *error = 1;
14588 return report_decoded;
14592 free_entity (entity);
14593 openvas_connection_close (&connection);
14594 if (error) *error = 1;
14597 "Internal error", __FUNCTION__, __LINE__,
14598 "An internal error occurred while getting a report. "
14599 "The report could not be delivered. "
14600 "Diagnostics: Failure to receive report from manager daemon.",
14601 "/omp?cmd=get_tasks", response_data);
14613 if (delta_report_id && result_id && strcmp (result_id,
"0"))
14614 xml = g_string_new (
"<get_delta_result>");
14615 else if (host || (type && (strcmp (type,
"prognostic") == 0)))
14617 if (type && (strcmp (type,
"prognostic") == 0))
14619 xml = g_string_new (
"<get_prognostic_report>");
14621 xml_string_append (xml,
14622 "<host_search_phrase>"
14624 "</host_search_phrase>"
14625 "<host_levels>%s</host_levels>"
14626 "<results start=\"%s\" max=\"%s\"/>",
14627 host_search_phrase,
14633 xml = g_string_new (
"<get_asset>");
14634 xml_string_append (xml,
14635 "<search_phrase>%s</search_phrase>"
14636 "<levels>%s</levels>"
14637 "<hosts start=\"%s\" max=\"%s\"/>",
14644 xml = g_string_new (
"<get_report>");
14647 g_string_append (xml, extra_xml);
14650 g_string_append (xml, commands_xml->str);
14651 g_string_free (commands_xml, TRUE);
14652 g_string_free (levels, TRUE);
14654 if (strcmp (alert_id,
"0"))
14656 g_string_append_printf (xml,
"<get_reports_alert_response>");
14659 g_string_append (xml, esc_response);
14660 g_free (esc_response);
14662 g_string_append_printf (xml,
"</get_reports_alert_response>");
14664 else if (delta_report_id)
14665 g_string_append_printf (xml,
14666 "<delta>%s</delta>"
14667 "<result id=\"%s\"/>",
14669 result_id ? result_id :
"0");
14672 if (read_entity_and_string_c (&connection, &entity, &xml))
14674 openvas_connection_close (&connection);
14675 if (error) *error = 1;
14678 "Internal error", __FUNCTION__, __LINE__,
14679 "An internal error occurred while getting a report. "
14680 "The report could not be delivered. "
14681 "Diagnostics: Failure to receive response from manager daemon.",
14682 "/omp?cmd=get_tasks", response_data);
14685 if ((filt_id == NULL) && (
params_value (params,
"filter") == NULL))
14692 term = entity_child (entity,
"report");
14694 && ((term = entity_child (term,
"report")))
14695 && ((term = entity_child (term,
"filters")))
14696 && ((term = entity_child (term,
"term"))))
14699 param =
params_add (params,
"filter", entity_text (term));
14705 if ((type && (strcmp (type,
"prognostic") == 0))
14708 if (openvas_connection_sendf
14710 "<get_report_formats"
14711 " filter=\"rows=-1 sort=name\"/>")
14714 g_string_free (xml, TRUE);
14715 openvas_connection_close (&connection);
14716 if (error) *error = 1;
14719 "Internal error", __FUNCTION__, __LINE__,
14720 "An internal error occurred while getting a report. "
14721 "The report could not be delivered. "
14722 "Diagnostics: Failure to send command to manager daemon.",
14723 "/omp?cmd=get_tasks", response_data);
14726 if (read_string_c (&connection, &xml))
14728 g_string_free (xml, TRUE);
14729 openvas_connection_close (&connection);
14730 if (error) *error = 1;
14733 "Internal error", __FUNCTION__, __LINE__,
14734 "An internal error occurred while getting a report. "
14735 "The report could not be delivered. "
14736 "Diagnostics: Failure to receive response from manager daemon.",
14737 "/omp?cmd=get_tasks", response_data);
14741 if (type && (strcmp (type,
"prognostic") == 0))
14747 g_string_append (xml,
"<filters>");
14749 if (openvas_connection_sendf_xml (&connection,
14751 " filter=\"type=result\"/>")
14754 g_string_free (xml, TRUE);
14755 openvas_connection_close (&connection);
14756 if (error) *error = 1;
14758 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14760 "Internal error", __FUNCTION__, __LINE__,
14761 "An internal error occurred while getting the filter list. "
14762 "The current list of filters is not available. "
14763 "Diagnostics: Failure to send command to manager daemon.",
14764 "/omp?cmd=get_tasks", response_data);
14767 if (read_string_c (&connection, &xml))
14769 g_string_free (xml, TRUE);
14770 openvas_connection_close (&connection);
14771 if (error) *error = 1;
14773 = MHD_HTTP_INTERNAL_SERVER_ERROR;
14775 "Internal error", __FUNCTION__, __LINE__,
14776 "An internal error occurred while getting the filter list. "
14777 "The current list of filters is not available. "
14778 "Diagnostics: Failure to receive response from manager daemon.",
14779 "/omp?cmd=get_tasks", response_data);
14782 g_string_append (xml,
"</filters>");
14785 g_string_append (xml,
"</get_prognostic_report>");
14786 openvas_connection_close (&connection);
14787 return g_string_free (xml, FALSE);
14790 if (type && (strcmp (type,
"assets") == 0))
14793 g_string_append (xml,
"</get_asset>");
14795 g_string_append (xml,
"</get_report>");
14796 openvas_connection_close (&connection);
14797 return g_string_free (xml, FALSE);
14800 report_entity = entity_child (entity,
"report");
14802 report_entity = entity_child (report_entity,
"report");
14806 entity_t task_entity, name;
14809 task_entity = entity_child (report_entity,
"task");
14812 id = entity_attribute (task_entity,
"id");
14813 name = entity_child (task_entity,
"name");
14818 task_id = g_strdup (
id);
14819 if (delta_report_id && result_id &&
id && name)
14820 g_string_append_printf (xml,
14821 "<task id=\"%s\"><name>%s</name></task>",
14823 entity_text (name));
14825 free_entity (entity);
14830 if (openvas_connection_sendf (&connection,
14831 "<get_tasks task_id=\"%s\" details=\"0\" />",
14836 g_string_free (xml, TRUE);
14837 openvas_connection_close (&connection);
14838 if (error) *error = 1;
14841 "Internal error", __FUNCTION__, __LINE__,
14842 "An internal error occurred while getting a report. "
14843 "The report could not be delivered. "
14844 "Diagnostics: Failure to send command to manager daemon.",
14845 "/omp?cmd=get_tasks", response_data);
14848 if (read_string_c (&connection, &xml))
14851 g_string_free (xml, TRUE);
14852 openvas_connection_close (&connection);
14853 if (error) *error = 1;
14856 "Internal error", __FUNCTION__, __LINE__,
14857 "An internal error occurred while getting a report. "
14858 "The report could not be delivered. "
14859 "Diagnostics: Failure to send command to manager daemon.",
14860 "/omp?cmd=get_tasks", response_data);
14866 if (delta_report_id && result_id && strcmp (result_id,
"0"))
14868 g_string_append (xml,
"</get_delta_result>");
14869 openvas_connection_close (&connection);
14870 return g_string_free (xml, FALSE);
14875 gchar *default_report_format, *err;
14879 err = setting_get_value_error (credentials,
14881 "353304fc-645e-11e6-ba7a-28d24461215b",
14882 &default_report_format,
14886 g_string_free (xml, TRUE);
14887 openvas_connection_close (&connection);
14888 if (error) *error = 1;
14892 g_string_append_printf (xml,
14893 "<report_format_id>%s</report_format_id>",
14894 default_report_format);
14898 if (openvas_connection_sendf
14900 "<get_report_formats"
14901 " filter=\"rows=-1 sort=name\"/>")
14904 g_string_free (xml, TRUE);
14905 openvas_connection_close (&connection);
14906 if (error) *error = 1;
14909 "Internal error", __FUNCTION__, __LINE__,
14910 "An internal error occurred while getting a report. "
14911 "The report could not be delivered. "
14912 "Diagnostics: Failure to send command to manager daemon.",
14913 "/omp?cmd=get_tasks", response_data);
14916 if (read_string_c (&connection, &xml))
14918 g_string_free (xml, TRUE);
14919 openvas_connection_close (&connection);
14920 if (error) *error = 1;
14923 "Internal error", __FUNCTION__, __LINE__,
14924 "An internal error occurred while getting a report. "
14925 "The report could not be delivered. "
14926 "Diagnostics: Failure to receive response from manager daemon.",
14927 "/omp?cmd=get_tasks", response_data);
14933 if (openvas_connection_sendf
14936 " filter=\"rows=-1 sort=name\"/>")
14939 g_string_free (xml, TRUE);
14940 openvas_connection_close (&connection);
14941 if (error) *error = 1;
14944 "Internal error", __FUNCTION__, __LINE__,
14945 "An internal error occurred while getting a report. "
14946 "The report could not be delivered. "
14947 "Diagnostics: Failure to send command to manager daemon.",
14948 "/omp?cmd=get_tasks", response_data);
14951 if (read_string_c (&connection, &xml))
14953 g_string_free (xml, TRUE);
14954 openvas_connection_close (&connection);
14955 if (error) *error = 1;
14958 "Internal error", __FUNCTION__, __LINE__,
14959 "An internal error occurred while getting a report. "
14960 "The report could not be delivered. "
14961 "Diagnostics: Failure to receive response from manager daemon.",
14962 "/omp?cmd=get_tasks", response_data);
14970 g_string_append (xml,
"<filters>");
14972 if (openvas_connection_sendf_xml (&connection,
14974 " filter=\"type=result\"/>")
14977 g_string_free (xml, TRUE);
14978 openvas_connection_close (&connection);
14979 if (error) *error = 1;
14982 "Internal error", __FUNCTION__, __LINE__,
14983 "An internal error occurred while getting the filter list. "
14984 "The current list of filters is not available. "
14985 "Diagnostics: Failure to send command to manager daemon.",
14986 "/omp?cmd=get_tasks", response_data);
14989 if (read_string_c (&connection, &xml))
14991 g_string_free (xml, TRUE);
14992 openvas_connection_close (&connection);
14993 if (error) *error = 1;
14996 "Internal error", __FUNCTION__, __LINE__,
14997 "An internal error occurred while getting the filter list. "
14998 "The current list of filters is not available. "
14999 "Diagnostics: Failure to receive response from manager daemon.",
15000 "/omp?cmd=get_tasks", response_data);
15003 g_string_append (xml,
"</filters>");
15008 if (openvas_connection_sendf (&connection,
15010 " filter=\"resource_type=report"
15013 " names_only=\"1\""
15017 g_string_free (xml, TRUE);
15018 openvas_connection_close (&connection);
15021 "Internal error", __FUNCTION__, __LINE__,
15022 "An internal error occurred while getting tag names list. "
15023 "The current list of resources is not available. "
15024 "Diagnostics: Failure to send command to manager daemon.",
15025 "/omp?cmd=get_resources", response_data);
15028 if (read_string_c (&connection, &xml))
15030 g_string_free (xml, TRUE);
15031 openvas_connection_close (&connection);
15034 "Internal error", __FUNCTION__, __LINE__,
15035 "An internal error occurred while getting tag names list. "
15036 "The current list of resources is not available. "
15037 "Diagnostics: Failure to receive response from manager daemon.",
15038 "/omp?cmd=get_resources", response_data);
15041 g_string_append (xml,
"</get_report>");
15042 openvas_connection_close (&connection);
15043 return g_string_free (xml, FALSE);
15061 gsize *report_len, gchar ** content_type,
15067 result = get_report (credentials, params, NULL, report_len, content_type,
15068 content_disposition, NULL, &error, response_data);
15070 return error ? result : xsl_transform_omp (credentials, result,
15088 const char *overrides;
15093 params_toggle_overrides (params, overrides);
15095 return get_many (
"report", credentials, params, extra_xml, NULL,
15112 return get_reports (credentials, params, NULL, response_data);
15129 const char *report_id, *report_section, *type;
15133 report_section =
params_value (params,
"report_section");
15137 if (report_section == NULL)
15138 report_section =
"results";
15140 if (report_id == NULL && (type == NULL || strcmp (type,
"prognostic")))
15144 "Internal error", __FUNCTION__, __LINE__,
15145 "An internal error occurred."
15146 " Diagnostics: report_id was NULL.",
15147 "/omp?cmd=get_tasks", response_data);
15150 if (!strcmp (report_section,
"results"))
15154 result = get_report (credentials, params, NULL, NULL, NULL, NULL,
15155 extra_xml, &error, response_data);
15157 return error ? result : xsl_transform_omp (credentials, result,
15161 result = get_report (credentials, params, NULL, NULL, NULL,
15162 NULL, NULL, &error, response_data);
15166 xml = g_string_new (
"");
15167 g_string_append_printf (xml,
"<get_report_%s_response>", report_section);
15169 g_string_append (xml, extra_xml);
15170 g_string_append (xml, result);
15171 if (strcmp (
params_value (params,
"report_section"),
"topology") == 0)
15176 ret = omp (credentials,
15180 "<get_report_formats"
15181 " filter=\"rows=-1\"/>");
15189 g_string_free (xml, TRUE);
15192 "Internal error", __FUNCTION__, __LINE__,
15193 "An internal error occurred while getting the "
15194 "result formats list. "
15195 "Diagnostics: Failure to send command to manager daemon.",
15196 "/omp?cmd=get_tasks", response_data);
15198 g_string_free (xml, TRUE);
15201 "Internal error", __FUNCTION__, __LINE__,
15202 "An internal error occurred while getting the "
15203 "result formats list. "
15204 "Diagnostics: Failure to receive response from manager daemon.",
15205 "/omp?cmd=get_tasks", response_data);
15207 g_string_free (xml, TRUE);
15210 "Internal error", __FUNCTION__, __LINE__,
15211 "An internal error occurred while getting the "
15212 "result formats list. "
15213 "Diagnostics: Internal Error.",
15214 "/omp?cmd=get_tasks", response_data);
15217 g_string_append (xml, response);
15221 g_string_append_printf (xml,
"</get_report_%s_response>", report_section);
15223 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
15240 return get_report_section (credentials, params, NULL, response_data);
15257 const char *ssl_cert;
15262 if (ssl_cert == NULL)
15266 "Internal error", __FUNCTION__, __LINE__,
15267 "An internal error occurred."
15268 " Diagnostics: ssl_cert was NULL.",
15269 "/omp?cmd=get_reports", response_data);
15272 unescaped = g_uri_unescape_string (ssl_cert, NULL);
15274 cert = g_strdup_printf (
"-----BEGIN CERTIFICATE-----\n"
15275 "%s\n-----END CERTIFICATE-----\n",
15278 *response_size = strlen (cert);
15280 g_free (unescaped);
15298 const char *ca_pub;
15302 if (ca_pub == NULL)
15306 "Internal error", __FUNCTION__, __LINE__,
15307 "An internal error occurred."
15308 " Diagnostics: ca_pub was NULL.",
15309 "/omp?cmd=get_reports", response_data);
15312 unescaped = g_uri_unescape_string (ca_pub, NULL);
15313 *response_size = strlen (unescaped);
15331 const char *key_pub;
15335 if (key_pub == NULL)
15339 "Internal error", __FUNCTION__, __LINE__,
15340 "An internal error occurred."
15341 " Diagnostics: key_pub was NULL.",
15342 "/omp?cmd=get_reports", response_data);
15346 unescaped = g_uri_unescape_string (key_pub, NULL);
15347 *response_size = strlen (unescaped);
15366 enum content_type * content_type,
char **content_disposition,
15370 content_disposition, content_length, response_data);
15388 enum content_type * content_type,
15389 char **content_disposition, gsize *content_length,
15392 return export_many (
"result", credentials, params, content_type,
15393 content_disposition, content_length, response_data);
15410 const char *overrides;
15415 params_toggle_overrides (params, overrides);
15417 return get_many (
"result", credentials, params, extra_xml, NULL,
15434 return get_results (credentials,
15456 get_result (
credentials_t *credentials,
const char *result_id,
15457 const char *task_id,
const char *task_name,
15458 const char *apply_overrides,
const char *commands,
15459 const char *report_id,
const char *autofp,
15463 openvas_connection_t connection;
15466 if (apply_overrides == NULL)
15467 apply_overrides =
"1";
15469 if (autofp == NULL)
15484 "Internal error", __FUNCTION__, __LINE__,
15485 "An internal error occurred while getting a result. "
15486 "Diagnostics: Failure to connect to manager daemon.",
15487 "/omp?cmd=get_tasks", response_data);
15490 xml = g_string_new (
"<get_result>");
15493 g_string_append (xml, extra_xml);
15495 xml_string_append (xml,
15496 "<task id=\"%s\"><name>%s</name></task>"
15497 "<report id=\"%s\"/>",
15504 if (openvas_connection_sendf (&connection,
15508 " result_id=\"%s\""
15510 " filter=\"autofp=%s"
15511 " apply_overrides=%s"
15514 " overrides_details=\"1\""
15515 " notes_details=\"1\""
15518 commands ? commands :
"",
15520 task_id ?
" task_id=\"" :
"",
15521 task_id ? task_id :
"",
15522 task_id ?
"\"" :
"",
15528 g_string_free (xml, TRUE);
15529 openvas_connection_close (&connection);
15532 "Internal error", __FUNCTION__, __LINE__,
15533 "An internal error occurred while getting a result. "
15534 "Diagnostics: Failure to send command to manager daemon.",
15535 "/omp?cmd=get_tasks", response_data);
15538 if (read_string_c (&connection, &xml))
15540 g_string_free (xml, TRUE);
15541 openvas_connection_close (&connection);
15544 "Internal error", __FUNCTION__, __LINE__,
15545 "An internal error occurred while getting a result. "
15546 "Diagnostics: Failure to receive response from manager daemon.",
15547 "/omp?cmd=get_tasks", response_data);
15552 if (openvas_connection_sendf (&connection,
15554 " filter=\"resource_type=result"
15557 " names_only=\"1\""
15561 g_string_free (xml, TRUE);
15562 openvas_connection_close (&connection);
15565 "Internal error", __FUNCTION__, __LINE__,
15566 "An internal error occurred while getting tag names list. "
15567 "The current list of resources is not available. "
15568 "Diagnostics: Failure to send command to manager daemon.",
15569 "/omp?cmd=get_resources", response_data);
15572 if (read_string_c (&connection, &xml))
15574 g_string_free (xml, TRUE);
15575 openvas_connection_close (&connection);
15578 "Internal error", __FUNCTION__, __LINE__,
15579 "An internal error occurred while getting tag names list. "
15580 "The current list of resources is not available. "
15581 "Diagnostics: Failure to receive response from manager daemon.",
15582 "/omp?cmd=get_resources", response_data);
15587 g_string_append (xml,
"</get_result>");
15588 openvas_connection_close (&connection);
15589 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
15606 return get_result (credentials,
15632 return get_result (credentials,
15659 return get_many (
"note", credentials, params, extra_xml, NULL, response_data);
15675 return get_notes (credentials, params, NULL, response_data);
15692 return get_one (
"note", credentials, params, extra_xml, NULL, response_data);
15708 return get_note (credentials, params, NULL, response_data);
15726 openvas_connection_t connection;
15728 const char *oid, *hosts, *port, *severity, *task_id, *task_name, *result_id;
15731 const char *report_id, *first_result, *max_results, *sort_field;
15732 const char *sort_order, *levels, *autofp, *notes;
15733 const char *overrides, *result_hosts_only, *search_phrase;
15745 search_phrase =
params_value (params,
"search_phrase");
15750 result_hosts_only =
params_value (params,
"result_hosts_only");
15769 "Internal error", __FUNCTION__, __LINE__,
15770 "An internal error occurred while creating a new note. "
15771 "No new note was created. "
15772 "Diagnostics: Failure to connect to manager daemon.",
15773 "/omp?cmd=get_notes", response_data);
15776 if (result_id == NULL || task_id == NULL)
15778 xml = g_string_new (
"");
15780 xml_string_append (xml,
15788 g_string_append (xml, extra_xml);
15790 if (openvas_connection_sendf (&connection,
15792 " schedules_only=\"1\""
15793 " details=\"0\"/>")
15796 openvas_connection_close (&connection);
15799 "Internal error", __FUNCTION__, __LINE__,
15800 "An internal error occurred while creating a new note. "
15801 "No new note was created. "
15802 "Diagnostics: Failure to send command to manager daemon.",
15803 "/omp?cmd=get_notes", response_data);
15806 if (read_string_c (&connection, &xml))
15808 g_string_free (xml, TRUE);
15809 openvas_connection_close (&connection);
15812 "Internal error", __FUNCTION__, __LINE__,
15813 "An internal error occurred while creating a new note. "
15814 "No new note was created. "
15815 "Diagnostics: Failure to receive response from manager daemon.",
15816 "/omp?cmd=get_notes", response_data);
15819 g_string_append (xml,
"</new_note>");
15820 openvas_connection_close (&connection);
15821 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
15825 if (openvas_connection_sendf (&connection,
15827 " result_id=\"%s\""
15829 " notes_details=\"1\""
15831 " result_hosts_only=\"1\"/>",
15836 openvas_connection_close (&connection);
15839 "Internal error", __FUNCTION__, __LINE__,
15840 "An internal error occurred while creating a new note. "
15841 "No new note was created. "
15842 "Diagnostics: Failure to send command to manager daemon.",
15843 "/omp?cmd=get_notes", response_data);
15846 xml = g_string_new (
"");
15848 xml_string_append (xml,
15851 "<hosts>%s</hosts>"
15853 "<severity>%s</severity>"
15857 "<result id=\"%s\"/>"
15860 "<report id=\"%s\"/>"
15861 "<first_result>%s</first_result>"
15862 "<max_results>%s</max_results>"
15863 "<sort_field>%s</sort_field>"
15864 "<sort_order>%s</sort_order>"
15865 "<levels>%s</levels>"
15866 "<autofp>%s</autofp>"
15867 "<notes>%s</notes>"
15868 "<overrides>%s</overrides>"
15869 "<result_hosts_only>%s</result_hosts_only>"
15870 "<search_phrase>%s</search_phrase>",
15893 g_string_append (xml, extra_xml);
15895 if (read_string_c (&connection, &xml))
15897 g_string_free (xml, TRUE);
15898 openvas_connection_close (&connection);
15901 "Internal error", __FUNCTION__, __LINE__,
15902 "An internal error occurred while creating a new note. "
15903 "It is unclear whether the note has been created or not. "
15904 "Diagnostics: Failure to receive response from manager daemon.",
15905 "/omp?cmd=get_notes", response_data);
15910 g_string_append (xml,
"</new_note>");
15911 openvas_connection_close (&connection);
15912 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
15929 return new_note (credentials, params, NULL, response_data);
15947 const char *no_redirect, *oid, *severity, *port, *hosts;
15948 const char *text, *task_id, *note_result_id;
15950 const char *active, *days;
15969 if (strcmp (port,
"--") == 0)
15976 if (num < 0 || num > 65535)
15984 if (strcmp (hosts,
"--") == 0)
16005 if (task_id && (strcmp (task_id,
"0") == 0))
16020 note_result_id =
params_value (params,
"note_result_id");
16021 if (note_result_id && (strcmp (note_result_id,
"0") == 0))
16022 note_result_id =
params_value (params,
"note_result_uuid");
16026 switch (ompf (credentials,
16031 "<active>%s</active>"
16032 "<nvt oid=\"%s\"/>"
16033 "<hosts>%s</hosts>"
16035 "<severity>%s</severity>"
16037 "<task id=\"%s\"/>"
16038 "<result id=\"%s\"/>"
16040 strcmp (active,
"1")
16042 : (days ? days :
"-1"),
16057 "Internal error", __FUNCTION__, __LINE__,
16058 "An internal error occurred while creating a new note. "
16059 "No new note was created. "
16060 "Diagnostics: Failure to send command to manager daemon.",
16061 "/omp?cmd=get_notes", response_data);
16065 "Internal error", __FUNCTION__, __LINE__,
16066 "An internal error occurred while creating a new note. "
16067 "It is unclear whether the note has been created or not. "
16068 "Diagnostics: Failure to receive response from manager daemon.",
16069 "/omp?cmd=get_notes", response_data);
16073 "Internal error", __FUNCTION__, __LINE__,
16074 "An internal error occurred while creating a new note. "
16075 "It is unclear whether the note has been created or not. "
16076 "Diagnostics: Internal Error.",
16077 "/omp?cmd=get_notes", response_data);
16080 if (entity_attribute (entity,
"id"))
16081 params_add (params,
"note_id", entity_attribute (entity,
"id"));
16082 ret = response_from_entity (credentials, params, entity,
16083 (no_redirect && strcmp (no_redirect,
"0")),
16086 "Create Note", response_data);
16087 free_entity (entity);
16105 return delete_resource (
"note", credentials, params, 0, NULL, response_data);
16140 openvas_connection_t connection;
16142 const char *note_id;
16158 "Internal error", __FUNCTION__, __LINE__,
16159 "An internal error occurred while editing a note. "
16160 "The note remains as it was. "
16161 "Diagnostics: Failure to connect to manager daemon.",
16162 "/omp?cmd=get_notes", response_data);
16165 if (openvas_connection_sendf (&connection,
16173 openvas_connection_close (&connection);
16176 "Internal error", __FUNCTION__, __LINE__,
16177 "An internal error occurred while editing a note. "
16178 "The note remains as it was. "
16179 "Diagnostics: Failure to send command to manager daemon.",
16180 "/omp?cmd=get_notes", response_data);
16183 xml = g_string_new (
"");
16185 xml_string_append (xml,
"<edit_note>");
16188 g_string_append (xml, extra_xml);
16190 if (read_string_c (&connection, &xml))
16192 g_string_free (xml, TRUE);
16193 openvas_connection_close (&connection);
16196 "Internal error", __FUNCTION__, __LINE__,
16197 "An internal error occurred while editing a note. "
16198 "The note remains as it was. "
16199 "Diagnostics: Failure to receive response from manager daemon.",
16200 "/omp?cmd=get_notes", response_data);
16205 g_string_append (xml,
"</edit_note>");
16206 openvas_connection_close (&connection);
16207 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
16224 return edit_note (credentials, params, NULL, response_data);
16242 const char *no_redirect;
16243 const char *note_id, *text, *hosts, *port, *severity, *note_task_id;
16244 const char *note_result_id, *active, *days;
16276 note_result_id =
params_value (params,
"note_result_id");
16293 switch (ompf (credentials,
16297 "<modify_note note_id=\"%s\">"
16298 "<active>%s</active>"
16299 "<hosts>%s</hosts>"
16301 "<severity>%s</severity>"
16303 "<task id=\"%s\"/>"
16304 "<result id=\"%s\"/>"
16307 strcmp (active,
"1")
16309 : (days ? days :
"-1"),
16310 hosts ? hosts :
"",
16312 severity ? severity :
"",
16323 "Internal error", __FUNCTION__, __LINE__,
16324 "An internal error occurred while saving a note. "
16325 "The note remains the same. "
16326 "Diagnostics: Failure to send command to manager daemon.",
16327 "/omp?cmd=get_notes", response_data);
16331 "Internal error", __FUNCTION__, __LINE__,
16332 "An internal error occurred while saving a note. "
16333 "It is unclear whether the note has been saved or not. "
16334 "Diagnostics: Failure to receive response from manager daemon.",
16335 "/omp?cmd=get_notes", response_data);
16339 "Internal error", __FUNCTION__, __LINE__,
16340 "An internal error occurred while saving a note. "
16341 "It is unclear whether the note has been saved or not. "
16342 "Diagnostics: Internal Error.",
16343 "/omp?cmd=get_notes", response_data);
16346 ret = response_from_entity (credentials, params, entity,
16347 (no_redirect && strcmp (no_redirect,
"0")),
16350 "Save Note", response_data);
16352 free_entity (entity);
16371 return get_many (
"override", credentials, params, extra_xml, NULL,
16388 return get_overrides (credentials, params, NULL, response_data);
16405 return get_one (
"override", credentials, params, extra_xml, NULL,
16422 return get_override (credentials, params, NULL, response_data);
16440 openvas_connection_t connection;
16442 const char *oid, *hosts, *port, *severity, *task_id, *task_name, *result_id;
16445 const char *report_id, *first_result, *max_results, *sort_field;
16446 const char *sort_order, *levels, *autofp, *notes;
16447 const char *overrides, *result_hosts_only, *search_phrase;
16459 search_phrase =
params_value (params,
"search_phrase");
16464 result_hosts_only =
params_value (params,
"result_hosts_only");
16483 "Internal error", __FUNCTION__, __LINE__,
16484 "An internal error occurred while creating a new override. "
16485 "No new override was created. "
16486 "Diagnostics: Failure to connect to manager daemon.",
16487 "/omp?cmd=get_overrides", response_data);
16490 if (result_id == NULL || task_id == NULL)
16492 xml = g_string_new (
"");
16494 xml_string_append (xml,
16502 g_string_append (xml, extra_xml);
16504 if (openvas_connection_sendf (&connection,
16506 " schedules_only=\"1\""
16507 " details=\"0\"/>")
16510 openvas_connection_close (&connection);
16513 "Internal error", __FUNCTION__, __LINE__,
16514 "An internal error occurred while creating a new override. "
16515 "No new override was created. "
16516 "Diagnostics: Failure to send command to manager daemon.",
16517 "/omp?cmd=get_overrides", response_data);
16520 if (read_string_c (&connection, &xml))
16522 g_string_free (xml, TRUE);
16523 openvas_connection_close (&connection);
16526 "Internal error", __FUNCTION__, __LINE__,
16527 "An internal error occurred while creating a new override. "
16528 "No new override was created. "
16529 "Diagnostics: Failure to receive response from manager daemon.",
16530 "/omp?cmd=get_overrides", response_data);
16533 g_string_append (xml,
"</new_override>");
16534 openvas_connection_close (&connection);
16535 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
16539 if (openvas_connection_sendf (&connection,
16541 " result_id=\"%s\""
16543 " notes_details=\"1\""
16545 " overrides_details=\"1\""
16547 " result_hosts_only=\"1\"/>",
16552 openvas_connection_close (&connection);
16555 "Internal error", __FUNCTION__, __LINE__,
16556 "An internal error occurred while creating a new override. "
16557 "No new override was created. "
16558 "Diagnostics: Failure to send command to manager daemon.",
16559 "/omp?cmd=get_overrides", response_data);
16562 xml = g_string_new (
"");
16564 xml_string_append (xml,
16567 "<hosts>%s</hosts>"
16569 "<severity>%s</severity>"
16573 "<result id=\"%s\"/>"
16576 "<report id=\"%s\"/>"
16577 "<first_result>%s</first_result>"
16578 "<max_results>%s</max_results>"
16579 "<sort_field>%s</sort_field>"
16580 "<sort_order>%s</sort_order>"
16581 "<levels>%s</levels>"
16582 "<autofp>%s</autofp>"
16583 "<notes>%s</notes>"
16584 "<overrides>%s</overrides>"
16585 "<result_hosts_only>%s</result_hosts_only>"
16586 "<search_phrase>%s</search_phrase>",
16609 g_string_append (xml, extra_xml);
16611 if (read_string_c (&connection, &xml))
16613 g_string_free (xml, TRUE);
16614 openvas_connection_close (&connection);
16617 "Internal error", __FUNCTION__, __LINE__,
16618 "An internal error occurred while creating a new override. "
16619 "It is unclear whether the override has been created or not. "
16620 "Diagnostics: Failure to receive response from manager daemon.",
16621 "/omp?cmd=get_overrides", response_data);
16626 g_string_append (xml,
"</new_override>");
16627 openvas_connection_close (&connection);
16628 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
16645 return new_override (credentials, params, NULL, response_data);
16663 const char *no_redirect;
16664 const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
16665 const char *text, *task_id, *override_result_id;
16667 const char *active, *days;
16683 custom_severity =
params_value (params,
"custom_severity");
16686 if (custom_severity != NULL && strcmp (custom_severity,
"0"))
16692 new_severity = NULL;
16700 new_severity =
params_value (params,
"new_severity_from_list");
16703 "new_severity_from_list"),
16705 new_severity = NULL;
16714 if (strcmp (port,
"--") == 0)
16721 if (num < 0 || num > 65535)
16729 if (strcmp (hosts,
"--") == 0)
16750 if (task_id && (strcmp (task_id,
"0") == 0))
16751 task_id =
params_value (params,
"override_task_uuid");
16762 override_result_id =
params_value (params,
"override_result_id");
16763 if (override_result_id && (strcmp (override_result_id,
"0") == 0))
16764 override_result_id =
params_value (params,
"override_result_uuid");
16768 switch (ompf (credentials,
16772 "<create_override>"
16773 "<active>%s</active>"
16774 "<nvt oid=\"%s\"/>"
16775 "<hosts>%s</hosts>"
16777 "<severity>%s</severity>"
16778 "<new_severity>%s</new_severity>"
16780 "<task id=\"%s\"/>"
16781 "<result id=\"%s\"/>"
16782 "</create_override>",
16783 strcmp (active,
"1")
16785 : (days ? days :
"-1"),
16793 override_result_id))
16801 "Internal error", __FUNCTION__, __LINE__,
16802 "An internal error occurred while creating a new override. "
16803 "No new override was created. "
16804 "Diagnostics: Failure to send command to manager daemon.",
16805 "/omp?cmd=get_overrides", response_data);
16809 "Internal error", __FUNCTION__, __LINE__,
16810 "An internal error occurred while creating a new override. "
16811 "It is unclear whether the override has been created or not. "
16812 "Diagnostics: Failure to receive response from manager daemon.",
16813 "/omp?cmd=get_overrides", response_data);
16817 "Internal error", __FUNCTION__, __LINE__,
16818 "An internal error occurred while creating a new override. "
16819 "It is unclear whether the override has been created or not. "
16820 "Diagnostics: Internal Error.",
16821 "/omp?cmd=get_overrides", response_data);
16824 if (entity_attribute (entity,
"id"))
16825 params_add (params,
"override_id", entity_attribute (entity,
"id"));
16826 ret = response_from_entity (credentials, params, entity,
16827 (no_redirect && strcmp (no_redirect,
"0")),
16828 NULL,
"get_overrides",
16829 NULL,
"new_override",
16830 "Create Override", response_data);
16831 free_entity (entity);
16866 return delete_resource (
"override", credentials, params, 1,
"get_trash",
16885 openvas_connection_t connection;
16887 const char *override_id;
16903 "Internal error", __FUNCTION__, __LINE__,
16904 "An internal error occurred while editing an override. "
16905 "The override remains as it was. "
16906 "Diagnostics: Failure to connect to manager daemon.",
16907 "/omp?cmd=get_overrides", response_data);
16910 if (openvas_connection_sendf (&connection,
16912 " override_id=\"%s\""
16918 openvas_connection_close (&connection);
16921 "Internal error", __FUNCTION__, __LINE__,
16922 "An internal error occurred while editing an override. "
16923 "The override remains as it was. "
16924 "Diagnostics: Failure to send command to manager daemon.",
16925 "/omp?cmd=get_overrides", response_data);
16928 xml = g_string_new (
"");
16930 xml_string_append (xml,
"<edit_override>");
16933 g_string_append (xml, extra_xml);
16935 if (read_string_c (&connection, &xml))
16937 g_string_free (xml, TRUE);
16938 openvas_connection_close (&connection);
16941 "Internal error", __FUNCTION__, __LINE__,
16942 "An internal error occurred while editing an override. "
16943 "The override remains as it was. "
16944 "Diagnostics: Failure to receive response from manager daemon.",
16945 "/omp?cmd=get_overrides", response_data);
16950 g_string_append (xml,
"</edit_override>");
16951 openvas_connection_close (&connection);
16952 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
16969 return edit_override (credentials, params, NULL, response_data);
16987 const char *no_redirect, *override_id, *text, *hosts, *port;
16988 const char *severity, *custom_severity, *new_severity;
16989 const char *override_task_id, *override_result_id, *active, *days;
17020 custom_severity =
params_value (params,
"custom_severity");
17021 if (custom_severity && strcmp (custom_severity,
"0") != 0)
17024 new_severity =
params_value (params,
"new_severity_from_list");
17026 override_task_id =
params_value (params,
"override_task_id");
17027 override_result_id =
params_value (params,
"override_result_id");
17045 switch (ompf (credentials,
17049 "<modify_override override_id=\"%s\">"
17050 "<active>%s</active>"
17051 "<hosts>%s</hosts>"
17053 "<severity>%s</severity>"
17054 "<new_severity>%s</new_severity>"
17056 "<task id=\"%s\"/>"
17057 "<result id=\"%s\"/>"
17058 "</modify_override>",
17060 strcmp (active,
"1")
17062 : (days ? days :
"-1"),
17063 hosts ? hosts :
"",
17065 severity ? severity :
"",
17069 override_result_id))
17077 "Internal error", __FUNCTION__, __LINE__,
17078 "An internal error occurred while saving a override. "
17079 "The override remains the same. "
17080 "Diagnostics: Failure to send command to manager daemon.",
17081 "/omp?cmd=get_overrides", response_data);
17085 "Internal error", __FUNCTION__, __LINE__,
17086 "An internal error occurred while saving a override. "
17087 "It is unclear whether the override has been saved or not. "
17088 "Diagnostics: Failure to receive response from manager daemon.",
17089 "/omp?cmd=get_overrides", response_data);
17093 "Internal error", __FUNCTION__, __LINE__,
17094 "An internal error occurred while saving a override. "
17095 "It is unclear whether the override has been saved or not. "
17096 "Diagnostics: Internal Error.",
17097 "/omp?cmd=get_overrides", response_data);
17100 ret = response_from_entity (credentials, params, entity,
17101 (no_redirect && strcmp (no_redirect,
"0")),
17102 NULL,
"get_overrides",
17103 NULL,
"edit_override",
17104 "Save Override", response_data);
17106 free_entity (entity);
17128 return get_many (
"scanner", credentials, params, extra_xml, NULL,
17145 return get_scanners (credentials, params, NULL, response_data);
17162 return get_one (
"scanner", credentials, params, extra_xml, NULL,
17179 return get_scanner (credentials, params, NULL, response_data);
17196 enum content_type * content_type,
17197 char **content_disposition, gsize *content_length,
17200 return export_resource (
"scanner", credentials, params, content_type,
17201 content_disposition, content_length, response_data);
17218 enum content_type * content_type,
17219 char **content_disposition, gsize *content_length,
17222 return export_many (
"scanner", credentials, params, content_type,
17223 content_disposition, content_length, response_data);
17240 openvas_connection_t connection;
17256 "Internal error", __FUNCTION__, __LINE__,
17257 "An internal error occurred while getting the credentials list. "
17258 "Diagnostics: Failure to connect to manager daemon.",
17259 "/omp?cmd=get_tasks", response_data);
17262 if (openvas_connection_sendf (&connection,
17264 " filter=\"first=1 rows=-1\" />")
17267 openvas_connection_close (&connection);
17270 "Internal error", __FUNCTION__, __LINE__,
17271 "An internal error occurred while getting the credentials list. "
17272 "Diagnostics: Failure to send command to manager daemon.",
17273 "/omp?cmd=get_tasks", response_data);
17276 xml = g_string_new (
"<new_scanner>");
17278 g_string_append (xml, extra_xml);
17280 if (read_string_c (&connection, &xml))
17282 g_string_free (xml, TRUE);
17283 openvas_connection_close (&connection);
17286 "Internal error", __FUNCTION__, __LINE__,
17287 "An internal error occurred while getting the credentials list. "
17288 "Diagnostics: Failure to receive response from manager daemon.",
17289 "/omp?cmd=get_tasks", response_data);
17292 g_string_append (xml,
"</new_scanner>");
17293 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
17310 return new_scanner (credentials, params, NULL, response_data);
17326 gchar *html, *response;
17327 const char *scanner_id, *next;
17332 CHECK_PARAM (scanner_id,
"Verify Scanner", get_scanners);
17335 ret = ompf (credentials,
17339 "<verify_scanner scanner_id=\"%s\"/>",
17350 "Internal error", __FUNCTION__, __LINE__,
17351 "An internal error occurred while verifying a scanner. "
17352 "The scanner was not verified. "
17353 "Diagnostics: Failure to send command to manager daemon.",
17354 "/omp?cmd=get_scanners", response_data);
17358 "Internal error", __FUNCTION__, __LINE__,
17359 "An internal error occurred while verifying a scanner. "
17360 "It is unclear whether the scanner was verified or not. "
17361 "Diagnostics: Failure to send command to manager daemon.",
17362 "/omp?cmd=get_scanners", response_data);
17366 "Internal error", __FUNCTION__, __LINE__,
17367 "An internal error occurred while verifying a scanner. "
17368 "It is unclear whether the scanner was verified or not. "
17369 "Diagnostics: Failure to send command to manager daemon.",
17370 "/omp?cmd=get_scanners", response_data);
17373 if (omp_success (entity))
17375 html = next_page (credentials, params, response, response_data);
17378 free_entity (entity);
17382 "Internal error", __FUNCTION__, __LINE__,
17383 "An internal error occurred while verifying a scanner. "
17384 "It is unclear whether the scanner was verified or not. "
17385 "Diagnostics: Failure to receive response from manager daemon.",
17386 "/omp?cmd=get_scanners", response_data);
17393 if (next && !strcmp (next,
"get_scanner"))
17394 html = get_scanner (credentials, params, response, response_data);
17396 html = get_scanners (credentials, params, response, response_data);
17399 free_entity (entity);
17419 gchar *response = NULL;
17420 const char *no_redirect;
17421 const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
17422 entity_t entity = NULL;
17431 credential_id =
params_value (params,
"credential_id");
17442 ret = ompf (credentials, &response, &entity, response_data,
17444 "<name>%s</name><comment>%s</comment>"
17445 "<host>%s</host><port>%s</port><type>%s</type>"
17446 "<ca_pub>%s</ca_pub>"
17447 "<credential id=\"%s\"/>"
17448 "</create_scanner>",
17449 name, comment, host, port, type, ca_pub, credential_id);
17451 ret = ompf (credentials, &response, &entity, response_data,
17453 "<name>%s</name><comment>%s</comment>"
17454 "<host>%s</host><port>%s</port><type>%s</type>"
17455 "<credential id=\"%s\"/>"
17456 "</create_scanner>",
17457 name, comment, host, port, type, credential_id);
17466 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17467 "An internal error occurred while creating a new scanner. "
17468 "No new scanner was created. "
17469 "Diagnostics: Failure to send command to manager daemon.",
17470 "/omp?cmd=get_scanners", response_data);
17474 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17475 "An internal error occurred while creating a new scanner. "
17476 "It is unclear whether the scanner has been created or not. "
17477 "Diagnostics: Failure to receive response from manager daemon.",
17478 "/omp?cmd=get_scanners", response_data);
17482 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17483 "An internal error occurred while creating a new scanner. "
17484 "It is unclear whether the scanner has been created or not. "
17485 "Diagnostics: Internal Error.",
17486 "/omp?cmd=get_scanners", response_data);
17489 if (entity_attribute (entity,
"id"))
17490 params_add (params,
"scanner_id", entity_attribute (entity,
"id"));
17491 html = response_from_entity (credentials, params, entity,
17492 (no_redirect && strcmp (no_redirect,
"0")),
17493 NULL,
"get_scanners",
17494 NULL,
"new_scanner",
17495 "Create Scanner", response_data);
17496 free_entity (entity);
17514 return delete_resource (
"scanner", credentials, params, 0,
"get_scanners",
17531 return delete_resource (
"scanner", credentials, params, 1,
"get_trash",
17550 openvas_connection_t connection;
17552 const char *scanner_id, *next;
17557 if (scanner_id == NULL)
17561 "Internal error", __FUNCTION__, __LINE__,
17562 "An internal error occurred while editing a scanner. "
17563 "The scanner remains as it was. "
17564 "Diagnostics: Required parameter was NULL.",
17565 "/omp?cmd=get_tasks", response_data);
17569 next =
"get_scanner";
17583 "Internal error", __FUNCTION__, __LINE__,
17584 "An internal error occurred while editing a scanner. "
17585 "The scanner remains as it was. "
17586 "Diagnostics: Failure to connect to manager daemon.",
17587 "/omp?cmd=get_tasks", response_data);
17590 if (openvas_connection_sendf (&connection,
17592 "<get_scanners scanner_id=\"%s\" details=\"1\" />"
17593 "<get_credentials filter=\"first=1 rows=-1\" />"
17598 openvas_connection_close (&connection);
17601 "Internal error", __FUNCTION__, __LINE__,
17602 "An internal error occurred while getting scanner info. "
17603 "Diagnostics: Failure to send command to manager daemon.",
17604 "/omp?cmd=get_tasks", response_data);
17607 xml = g_string_new (
"");
17610 g_string_append (xml, extra_xml);
17612 g_string_append_printf (xml,
17614 "<scanner id=\"%s\"/>"
17620 if (read_string_c (&connection, &xml))
17622 g_string_free (xml, TRUE);
17623 openvas_connection_close (&connection);
17626 "Internal error", __FUNCTION__, __LINE__,
17627 "An internal error occurred while getting scanner info. "
17628 "Diagnostics: Failure to receive response from manager daemon.",
17629 "/omp?cmd=get_tasks", response_data);
17634 g_string_append (xml,
"</edit_scanner>");
17635 openvas_connection_close (&connection);
17636 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
17653 return edit_scanner (credentials, params, NULL, response_data);
17669 gchar *response = NULL;
17670 entity_t entity = NULL;
17671 const char *no_redirect;
17672 const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
17673 const char *credential_id, *which_cert;
17686 credential_id =
params_value (params,
"credential_id");
17702 if (strcmp (which_cert,
"new") == 0 || strcmp (which_cert,
"default") == 0)
17704 if (ca_pub == NULL)
17707 ret = ompf (credentials, &response, &entity, response_data,
17708 "<modify_scanner scanner_id=\"%s\">"
17710 "<comment>%s</comment>"
17711 "<ca_pub>%s</ca_pub>"
17712 "<credential id=\"%s\"/>"
17713 "</modify_scanner>",
17714 scanner_id, name, comment ?:
"",
17715 strcmp (which_cert,
"new") == 0 ? ca_pub :
"",
17718 ret = ompf (credentials, &response, &entity, response_data,
17719 "<modify_scanner scanner_id=\"%s\">"
17721 "<comment>%s</comment>"
17725 "<ca_pub>%s</ca_pub>"
17726 "<credential id=\"%s\"/>"
17727 "</modify_scanner>",
17728 scanner_id, name, comment ?:
"", host, port, type,
17729 strcmp (which_cert,
"new") == 0 ? ca_pub :
"",
17736 ret = ompf (credentials, &response, &entity, response_data,
17737 "<modify_scanner scanner_id=\"%s\">"
17739 "<comment>%s</comment>"
17740 "<credential id=\"%s\"/>"
17741 "</modify_scanner>",
17742 scanner_id, name, comment ?:
"", credential_id);
17744 ret = ompf (credentials, &response, &entity, response_data,
17745 "<modify_scanner scanner_id=\"%s\">"
17747 "<comment>%s</comment>"
17751 "<credential id=\"%s\"/>"
17752 "</modify_scanner>",
17753 scanner_id, name, comment ?:
"", host, port, type,
17765 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17766 "An internal error occurred while saving a scanner. "
17767 "The scanner remains the same. "
17768 "Diagnostics: Failure to send command to manager daemon.",
17769 "/omp?cmd=get_scanners", response_data);
17773 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17774 "An internal error occurred while saving a scanner. "
17775 "It is unclear whether the scanner has been saved or not. "
17776 "Diagnostics: Failure to receive response from manager daemon.",
17777 "/omp?cmd=get_scanners", response_data);
17781 (credentials,
"Internal error", __FUNCTION__, __LINE__,
17782 "An internal error occurred while saving a scanner. "
17783 "It is unclear whether the scanner has been saved or not. "
17784 "Diagnostics: Internal Error.",
17785 "/omp?cmd=get_scanners", response_data);
17788 html = response_from_entity (credentials, params, entity,
17789 (no_redirect && strcmp (no_redirect,
"0")),
17790 NULL,
"get_scanners",
17791 NULL,
"edit_scanner",
17792 "Save Scanner", response_data);
17794 free_entity (entity);
17816 return get_one (
"schedule", credentials, params, extra_xml,
"tasks=\"1\"",
17833 return get_schedule (credentials, params, NULL, response_data);
17850 return get_many (
"schedule", credentials, params, extra_xml, NULL,
17867 return get_schedules (credentials, params, NULL, response_data);
17886 struct tm *now_broken;
17887 xml = g_string_new (
"<new_schedule>");
17889 now_broken = localtime (&now);
17890 g_string_append_printf (xml,
17892 "<minute>%s%i</minute>"
17893 "<hour>%s%i</hour>"
17894 "<day_of_month>%s%i</day_of_month>"
17895 "<month>%s%i</month>"
17898 (now_broken->tm_min > 9 ?
"" :
"0"),
17899 now_broken->tm_min,
17900 (now_broken->tm_hour > 9 ?
"" :
"0"),
17901 now_broken->tm_hour,
17902 (now_broken->tm_mday > 9 ?
"" :
"0"),
17903 now_broken->tm_mday,
17904 ((now_broken->tm_mon + 1) > 9 ?
"" :
"0"),
17905 (now_broken->tm_mon + 1),
17906 (now_broken->tm_year + 1900));
17909 g_string_append (xml, extra_xml);
17910 g_string_append (xml,
"</new_schedule>");
17911 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
17928 return new_schedule (credentials, params, NULL, response_data);
17946 const char *no_redirect;
17947 const char *name, *comment, *hour, *minute, *day_of_month, *month, *year;
17948 const char *period, *period_unit, *duration, *duration_unit, *timezone;
17958 duration_unit =
params_value (params,
"duration_unit");
17980 switch (ompf (credentials,
17984 "<create_schedule>"
17986 "<comment>%s</comment>"
17989 "<minute>%s</minute>"
17990 "<day_of_month>%s</day_of_month>"
17991 "<month>%s</month>"
18002 "<timezone>%s</timezone>"
18003 "</create_schedule>",
18011 (strcmp (period_unit,
"")
18015 (strcmp (duration_unit,
"")
18027 "Internal error", __FUNCTION__, __LINE__,
18028 "An internal error occurred while creating a new schedule. "
18029 "No new schedule was created. "
18030 "Diagnostics: Failure to send command to manager daemon.",
18031 "/omp?cmd=get_schedules", response_data);
18035 "Internal error", __FUNCTION__, __LINE__,
18036 "An internal error occurred while creating a new schedule. "
18037 "It is unclear whether the schedule has been created or not. "
18038 "Diagnostics: Failure to receive response from manager daemon.",
18039 "/omp?cmd=get_schedules", response_data);
18043 "Internal error", __FUNCTION__, __LINE__,
18044 "An internal error occurred while creating a new schedule. "
18045 "It is unclear whether the schedule has been created or not. "
18046 "Diagnostics: Internal Error.",
18047 "/omp?cmd=get_schedules", response_data);
18050 if (entity_attribute (entity,
"id"))
18051 params_add (params,
"schedule_id", entity_attribute (entity,
"id"));
18052 ret = response_from_entity (credentials, params, entity,
18053 (no_redirect && strcmp (no_redirect,
"0")),
18054 NULL,
"get_schedules",
18055 NULL,
"new_schedule",
18056 "Create Schedule", response_data);
18057 free_entity (entity);
18075 return delete_resource (
"schedule", credentials, params, 0,
"get_schedules",
18093 openvas_connection_t connection;
18096 struct tm *now_broken;
18097 struct tm start_time, end_time;
18099 const char *slave_id;
18100 const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
18101 const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
18106 now_broken = localtime (&now);
18120 start_time.tm_year = start_year ? atoi (start_year) - 1900
18121 : now_broken->tm_year;
18122 start_time.tm_mon = start_month ? atoi (start_month) - 1
18123 : now_broken->tm_mon;
18124 start_time.tm_mday = start_day ? atoi (start_day) : now_broken->tm_mday;
18125 start_time.tm_hour = start_hour ? atoi (start_hour) : now_broken->tm_hour;
18126 start_time.tm_min = start_minute ? atoi (start_minute) : now_broken->tm_min;
18128 end_time.tm_year = end_year ? atoi (end_year) - 1900
18129 : now_broken->tm_year;
18130 end_time.tm_mon = end_month ? atoi (end_month) - 1
18131 : now_broken->tm_mon;
18132 end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
18133 end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
18134 end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
18148 "Internal error", __FUNCTION__, __LINE__,
18149 "An internal error occurred while getting the system reports. "
18150 "The current list of system reports is not available. "
18151 "Diagnostics: Failure to connect to manager daemon.",
18152 "/omp?cmd=get_tasks", response_data);
18155 xml = g_string_new (
"<get_system_reports>");
18157 g_string_append_printf (xml,
18158 "<slave id=\"%s\"/>",
18159 slave_id ? slave_id :
"0");
18162 g_string_append_printf (xml,
18164 "<minute>%i</minute>"
18166 "<day_of_month>%i</day_of_month>"
18167 "<month>%i</month>"
18171 start_time.tm_hour,
18172 start_time.tm_mday,
18173 start_time.tm_mon + 1,
18174 start_time.tm_year + 1900);
18176 g_string_append_printf (xml,
18178 "<minute>%i</minute>"
18180 "<day_of_month>%i</day_of_month>"
18181 "<month>%i</month>"
18187 end_time.tm_mon + 1,
18188 end_time.tm_year + 1900);
18192 if (openvas_connection_sendf (&connection,
18193 "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
18194 slave_id ? slave_id :
"0")
18197 g_string_free (xml, TRUE);
18198 openvas_connection_close (&connection);
18201 "Internal error", __FUNCTION__, __LINE__,
18202 "An internal error occurred while getting the system reports. "
18203 "The current list of system reports is not available. "
18204 "Diagnostics: Failure to send command to manager daemon.",
18205 "/omp?cmd=get_tasks", response_data);
18208 if (read_string_c (&connection, &xml))
18210 g_string_free (xml, TRUE);
18211 openvas_connection_close (&connection);
18214 "Internal error", __FUNCTION__, __LINE__,
18215 "An internal error occurred while getting the system reports. "
18216 "The current list of system reports is not available. "
18217 "Diagnostics: Failure to receive response from manager daemon.",
18218 "/omp?cmd=get_tasks", response_data);
18225 if (openvas_connection_sendf (&connection,
18227 " filter=\"sort=name rows=-1 type=4\"/>")
18230 g_string_free (xml, TRUE);
18231 openvas_connection_close (&connection);
18234 "Internal error", __FUNCTION__, __LINE__,
18235 "An internal error occurred while getting the system reports. "
18236 "The current list of system reports is not available. "
18237 "Diagnostics: Failure to send command to manager daemon.",
18238 "/omp?cmd=get_tasks", response_data);
18241 if (read_string_c (&connection, &xml))
18243 g_string_free (xml, TRUE);
18244 openvas_connection_close (&connection);
18247 "Internal error", __FUNCTION__, __LINE__,
18248 "An internal error occurred while getting the system reports. "
18249 "The current list of system reports is not available. "
18250 "Diagnostics: Failure to receive response from manager daemon.",
18251 "/omp?cmd=get_tasks", response_data);
18257 g_string_append (xml,
"</get_system_reports>");
18258 openvas_connection_close (&connection);
18259 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
18278 enum content_type *content_type,
18279 gsize *content_length,
18283 entity_t report_entity;
18284 openvas_connection_t connection;
18287 struct tm *now_broken;
18288 const char *slave_id;
18289 const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
18290 const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
18291 struct tm start_time, end_time;
18293 *content_length = 0;
18301 now_broken = localtime (&now);
18315 start_time.tm_year = start_year ? atoi (start_year) - 1900
18316 : now_broken->tm_year;
18317 start_time.tm_mon = start_month ? atoi (start_month) - 1
18318 : now_broken->tm_mon;
18319 start_time.tm_mday = start_day ? atoi (start_day) : now_broken->tm_mday;
18320 start_time.tm_hour = start_hour ? atoi (start_hour) : now_broken->tm_hour;
18321 start_time.tm_min = start_minute ? atoi (start_minute) : now_broken->tm_min;
18322 start_time.tm_zone = now_broken->tm_zone;
18324 end_time.tm_year = end_year ? atoi (end_year) - 1900
18325 : now_broken->tm_year;
18326 end_time.tm_mon = end_month ? atoi (end_month) - 1
18327 : now_broken->tm_mon;
18328 end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
18329 end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
18330 end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
18331 end_time.tm_zone = now_broken->tm_zone;
18334 if (sscanf (url,
"%500[^ /]./report.png", name) == 1)
18336 gchar *omp_command;
18342 gchar *start_time_str, *end_time_str;
18346 = g_strdup_printf (
"%04d-%02d-%02dT%02d:%02d:00",
18347 start_time.tm_year + 1900,
18348 start_time.tm_mon + 1,
18349 start_time.tm_mday,
18350 start_time.tm_hour,
18351 start_time.tm_min);
18354 = g_strdup_printf (
"%04d-%02d-%02dT%02d:%02d:00",
18355 end_time.tm_year + 1900,
18356 end_time.tm_mon + 1,
18362 = g_markup_printf_escaped (
"<get_system_reports"
18364 " start_time=\"%s\""
18366 " slave_id=\"%s\"/>",
18370 slave_id ? slave_id :
"0");
18371 g_free (start_time_str);
18372 g_free (end_time_str);
18374 if (openvas_connection_sendf (&connection,
18379 g_free (omp_command);
18380 openvas_connection_close (&connection);
18383 g_free (omp_command);
18386 if (read_entity_c (&connection, &entity))
18388 openvas_connection_close (&connection);
18392 report_entity = entity_child (entity,
"system_report");
18393 if (report_entity == NULL)
18395 free_entity (entity);
18396 openvas_connection_close (&connection);
18400 report_entity = entity_child (report_entity,
"report");
18401 if (report_entity == NULL)
18403 free_entity (entity);
18404 openvas_connection_close (&connection);
18409 char *content_64 = entity_text (report_entity);
18410 char *content = NULL;
18412 if (content_64 && strlen (content_64))
18414 content = (
char *) g_base64_decode (content_64,
18422 content = g_strdup (
"helo");
18426 free_entity (entity);
18427 openvas_connection_close (&connection);
18449 return get_one (
"report_format", credentials, params, extra_xml,
18450 "alerts =\"1\" params=\"1\"", response_data);
18466 return get_report_format (credentials, params, NULL, response_data);
18483 return get_many (
"report_format", credentials, params, extra_xml, NULL,
18500 return get_report_formats (credentials, params, NULL, response_data);
18518 xml = g_string_new (
"<new_report_format>");
18520 g_string_append (xml, extra_xml);
18521 g_string_append (xml,
"</new_report_format>");
18522 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
18539 return new_report_format (credentials, params, NULL, response_data);
18556 "get_report_formats", response_data);
18573 gchar *all_rfs_response, *response, *ext_extra_xml;
18575 if (simple_ompf (
"getting Report Formats",
18576 credentials, &all_rfs_response, response_data,
18577 "<get_report_formats"
18578 " filter=\"rows=-1\"/>"))
18580 return all_rfs_response;
18583 ext_extra_xml = g_strdup_printf (
"%s"
18584 "<all_formats>%s</all_formats>",
18585 extra_xml ? extra_xml :
"",
18587 g_free (all_rfs_response);
18589 response =
edit_resource (
"report_format", credentials, params, NULL,
18590 ext_extra_xml, response_data);
18591 g_free (ext_extra_xml);
18608 return edit_report_format (credentials, params, NULL, response_data);
18624 const char* no_redirect;
18625 gchar *command, *html, *response;
18635 command = g_strdup_printf (
"<create_report_format>"
18637 "</create_report_format>",
18639 ret = omp (credentials, &response, &entity, response_data, command);
18649 "Internal error", __FUNCTION__, __LINE__,
18650 "An internal error occurred while importing a report format. "
18651 "The schedule remains the same. "
18652 "Diagnostics: Failure to send command to manager daemon.",
18653 "/omp?cmd=get_report_formats", response_data);
18657 "Internal error", __FUNCTION__, __LINE__,
18658 "An internal error occurred while importing a report format. "
18659 "It is unclear whether the schedule has been saved or not. "
18660 "Diagnostics: Failure to receive response from manager daemon.",
18661 "/omp?cmd=get_report_formats", response_data);
18665 "Internal error", __FUNCTION__, __LINE__,
18666 "An internal error occurred while importing a report format. "
18667 "It is unclear whether the schedule has been saved or not. "
18668 "Diagnostics: Internal Error.",
18669 "/omp?cmd=get_report_formats", response_data);
18674 if (entity_attribute (entity,
"id"))
18675 params_add (params,
"report_format_id", entity_attribute (entity,
"id"));
18676 html = response_from_entity (credentials, params, entity,
18677 (no_redirect && strcmp (no_redirect,
"0")),
18678 NULL,
"get_report_formats",
18679 NULL,
"new_report_format",
18680 "Create Report Format", response_data);
18682 free_entity (entity);
18701 gchar *html, *response;
18702 params_t *preferences, *id_list_params, *include_id_lists;
18703 const char *no_redirect, *report_format_id, *name, *summary, *enable;
18707 report_format_id =
params_value (params,
"report_format_id");
18713 "edit_report_format");
18719 include_id_lists =
params_values (params,
"include_id_list:");
18720 if (include_id_lists)
18722 GHashTable *id_lists;
18724 gchar *param_name, *pref_name, *value, *old_values, *new_values;
18726 GHashTableIter hash_table_iter;
18728 id_lists = g_hash_table_new_full (g_str_hash, g_str_equal,
18734 if (param->
value == NULL)
18737 g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (
""));
18743 if (param->
value == NULL)
18746 gchar *colon_pos = strchr (param->
value,
':');
18748 pref_name = g_strndup (param->
value, colon_pos - param->
value);
18749 value = g_strdup (colon_pos + 1);
18751 old_values = g_hash_table_lookup (id_lists, pref_name);
18753 if (old_values && strcmp (old_values,
""))
18755 new_values = g_strdup_printf (
"%s,%s", old_values, value);
18756 g_hash_table_insert (id_lists, pref_name, new_values);
18759 else if (old_values)
18761 g_hash_table_insert (id_lists, pref_name, value);
18765 g_hash_table_iter_init (&hash_table_iter, id_lists);
18766 while (g_hash_table_iter_next (&hash_table_iter,
18767 (
void**)&pref_name, (
void**)&value))
18771 value_64 = strlen (value)
18772 ? g_base64_encode ((guchar *) value, strlen (value))
18777 ret = ompf (credentials,
18781 "<modify_report_format"
18782 " report_format_id=\"%s\">"
18785 "<value>%s</value>"
18787 "</modify_report_format>",
18798 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18800 "Internal error", __FUNCTION__, __LINE__,
18801 "An internal error occurred while saving a Report Format. "
18802 "The Report Format was not saved. "
18803 "Diagnostics: Failure to send command to manager daemon.",
18804 "/omp?cmd=get_report_formats",
18808 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18810 "Internal error", __FUNCTION__, __LINE__,
18811 "An internal error occurred while saving a Report Format. "
18812 "It is unclear whether the Report Format has been saved or not. "
18813 "Diagnostics: Failure to receive response from manager daemon.",
18814 "/omp?cmd=get_report_formats",
18819 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18821 "Internal error", __FUNCTION__, __LINE__,
18822 "An internal error occurred while saving a Report Format. "
18823 "It is unclear whether the Report Format has been saved or not. "
18824 "Diagnostics: Internal Error.",
18825 "/omp?cmd=get_report_formats",
18849 int type_start, type_end, count;
18851 count = sscanf (param_name,
18852 "%*[^[][%n%*[^]]%n]:",
18855 if (count == 0 && type_start > 0 && type_end > 0)
18860 ? g_base64_encode ((guchar *) param->
value,
18866 ret = ompf (credentials,
18870 "<modify_report_format"
18871 " report_format_id=\"%s\">"
18874 "<value>%s</value>"
18876 "</modify_report_format>",
18878 param_name + type_end + 2,
18887 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18889 "Internal error", __FUNCTION__, __LINE__,
18890 "An internal error occurred while saving a Report Format. "
18891 "The Report Format was not saved. "
18892 "Diagnostics: Failure to send command to manager daemon.",
18893 "/omp?cmd=get_report_formats",
18897 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18899 "Internal error", __FUNCTION__, __LINE__,
18900 "An internal error occurred while saving a Report Format. "
18901 "It is unclear whether the Report Format has been saved or not. "
18902 "Diagnostics: Failure to receive response from manager daemon.",
18903 "/omp?cmd=get_report_formats",
18908 = MHD_HTTP_INTERNAL_SERVER_ERROR;
18910 "Internal error", __FUNCTION__, __LINE__,
18911 "An internal error occurred while saving a Report Format. "
18912 "It is unclear whether the Report Format has been saved or not. "
18913 "Diagnostics: Internal Error.",
18914 "/omp?cmd=get_report_formats",
18925 ret = ompf (credentials,
18929 "<modify_report_format"
18930 " report_format_id=\"%s\">"
18932 "<summary>%s</summary>"
18933 "<active>%s</active>"
18934 "</modify_report_format>",
18949 "Internal error", __FUNCTION__, __LINE__,
18950 "An internal error occurred while saving a Report Format. "
18951 "The Report Format was not saved. "
18952 "Diagnostics: Failure to send command to manager daemon.",
18953 "/omp?cmd=get_report_formats", response_data);
18957 "Internal error", __FUNCTION__, __LINE__,
18958 "An internal error occurred while saving a Report Format. "
18959 "It is unclear whether the Report Format has been saved or not. "
18960 "Diagnostics: Failure to receive response from manager daemon.",
18961 "/omp?cmd=get_report_formats", response_data);
18965 "Internal error", __FUNCTION__, __LINE__,
18966 "An internal error occurred while saving a Report Format. "
18967 "It is unclear whether the Report Format has been saved or not. "
18968 "Diagnostics: Internal Error.",
18969 "/omp?cmd=get_report_formats", response_data);
18972 html = response_from_entity (credentials, params, entity,
18973 (no_redirect && strcmp (no_redirect,
"0")),
18974 NULL,
"get_report_formats",
18975 NULL,
"edit_report_format",
18976 "Save Report Format", response_data);
18977 free_entity (entity);
18996 gchar *html, *response;
18997 const char *report_format_id;
19000 report_format_id =
params_value (params,
"report_format_id");
19001 if (report_format_id == NULL)
19005 "Internal error", __FUNCTION__, __LINE__,
19006 "An internal error occurred while verifying a report format. "
19007 "Diagnostics: Required parameter was NULL.",
19008 "/omp?cmd=get_report_formats", response_data);
19015 ret = ompf (credentials,
19019 "<verify_report_format report_format_id=\"%s\"/>",
19030 "Internal error", __FUNCTION__, __LINE__,
19031 "An internal error occurred while verifying a report format. "
19032 "The report format was not verified. "
19033 "Diagnostics: Failure to send command to manager daemon.",
19034 "/omp?cmd=get_report_formats", response_data);
19038 "Internal error", __FUNCTION__, __LINE__,
19039 "An internal error occurred while verifying a report format. "
19040 "It is unclear whether the report format was verified or not. "
19041 "Diagnostics: Failure to send command to manager daemon.",
19042 "/omp?cmd=get_report_formats", response_data);
19046 "Internal error", __FUNCTION__, __LINE__,
19047 "An internal error occurred while verifying a report format. "
19048 "It is unclear whether the report format was verified or not. "
19049 "Diagnostics: Failure to send command to manager daemon.",
19050 "/omp?cmd=get_report_formats", response_data);
19053 if (omp_success (entity))
19055 html = next_page (credentials, params, response, response_data);
19058 free_entity (entity);
19062 "Internal error", __FUNCTION__, __LINE__,
19063 "An internal error occurred while verifying a report format. "
19064 "It is unclear whether the report format was verified or not. "
19065 "Diagnostics: Failure to receive response from manager daemon.",
19066 "/omp?cmd=get_report_formats", response_data);
19072 html = get_report_formats (credentials, params, response, response_data);
19074 free_entity (entity);
19092 const char *no_redirect, *name;
19096 gchar *param_name, *html, *response;
19111 "Internal error", __FUNCTION__, __LINE__,
19112 "An internal error occurred while trying to start a wizard. "
19113 "Diagnostics: Required parameter 'name' was NULL.",
19114 "/omp?cmd=get_tasks", response_data);
19116 run = g_string_new (
"<run_wizard>");
19118 g_string_append_printf (run,
19128 xml_string_append (run,
19131 "<value>%s</value>"
19137 g_string_append (run,
"</params></run_wizard>");
19141 ret = omp (credentials, &response, &entity, response_data, run->str);
19142 g_string_free (run, TRUE);
19151 "Internal error", __FUNCTION__, __LINE__,
19152 "An internal error occurred while running a wizard. "
19153 "The wizard did not start. "
19154 "Diagnostics: Failure to send command to manager daemon.",
19155 "/omp?cmd=get_tasks", response_data);
19159 "Internal error", __FUNCTION__, __LINE__,
19160 "An internal error occurred while running a wizard. "
19161 "It is unclear whether the wizard started or not. "
19162 "Diagnostics: Failure to receive response from manager daemon.",
19163 "/omp?cmd=get_tasks", response_data);
19167 "Internal error", __FUNCTION__, __LINE__,
19168 "An internal error occurred while running a wizard. "
19169 "It is unclear whether the wizard started or not. "
19170 "Diagnostics: Internal Error.",
19171 "/omp?cmd=get_tasks", response_data);
19174 html = response_from_entity (credentials, params, entity,
19175 (no_redirect && strcmp (no_redirect,
"0")),
19178 "Run Wizard", response_data);
19179 free_entity (entity);
19184 #define GET_TRASH_RESOURCE(capability, command, name) \
19185 if (command_enabled (credentials, capability)) \
19187 if (openvas_connection_sendf \
19190 " filter=\"rows=-1 sort=name\"" \
19191 " trash=\"1\"/>") \
19194 g_string_free (xml, TRUE); \
19195 openvas_connection_close (&connection); \
19196 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \
19197 return gsad_message \
19199 "Internal error", __FUNCTION__, __LINE__, \
19200 "An internal error occurred while getting " \
19201 name " list for trash." \
19202 "Diagnostics: Failure to send command to" \
19203 " manager daemon.", \
19204 "/omp?cmd=get_trash", response_data); \
19207 if (read_string_c (&connection, &xml)) \
19209 g_string_free (xml, TRUE); \
19210 openvas_connection_close (&connection); \
19211 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \
19212 return gsad_message \
19214 "Internal error", __FUNCTION__, __LINE__, \
19215 "An internal error occurred while getting " name " list."\
19216 "Diagnostics: Failure to receive response from" \
19217 " manager daemon.", \
19218 "/omp?cmd=get_tasks", response_data); \
19237 openvas_connection_t connection;
19252 "Internal error", __FUNCTION__, __LINE__,
19253 "An internal error occurred while getting the trash. "
19254 "Diagnostics: Failure to connect to manager daemon.",
19255 "/omp?cmd=get_tasks", response_data);
19258 xml = g_string_new (
"<get_trash>");
19261 g_string_append (xml, extra_xml);
19300 g_string_append (xml,
"</get_trash>");
19301 openvas_connection_close (&connection);
19302 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
19305 #undef GET_TRASH_RESOURCE
19320 return get_trash (credentials, params, NULL, response_data);
19338 openvas_connection_t connection;
19353 "Internal error", __FUNCTION__, __LINE__,
19354 "An internal error occurred while getting the settings. "
19355 "Diagnostics: Failure to connect to manager daemon.",
19356 "/omp?cmd=get_tasks", response_data);
19359 xml = g_string_new (
"<get_my_settings>");
19362 g_string_append (xml, extra_xml);
19366 if (openvas_connection_sendf (&connection,
19368 " sort_field=\"name\""
19369 " sort_order=\"ascending\"/>")
19372 g_string_free (xml, TRUE);
19373 openvas_connection_close (&connection);
19376 "Internal error", __FUNCTION__, __LINE__,
19377 "An internal error occurred while getting the settings. "
19378 "The current list of settings is not available. "
19379 "Diagnostics: Failure to send command to manager daemon.",
19380 "/omp?cmd=get_tasks", response_data);
19383 if (read_string_c (&connection, &xml))
19385 g_string_free (xml, TRUE);
19386 openvas_connection_close (&connection);
19389 "Internal error", __FUNCTION__, __LINE__,
19390 "An internal error occurred while getting the settings. "
19391 "The current list of settings is not available. "
19392 "Diagnostics: Failure to receive response from manager daemon.",
19393 "/omp?cmd=get_tasks", response_data);
19398 g_string_append (xml,
"</get_my_settings>");
19399 openvas_connection_close (&connection);
19400 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
19422 commands = g_string_new (
"<commands>");
19424 g_string_append (commands,
"<get_alerts/>");
19426 g_string_append (commands,
"<get_configs/>");
19428 g_string_append (commands,
"<get_filters/>");
19430 g_string_append (commands,
"<get_credentials/>");
19432 g_string_append (commands,
"<get_port_lists/>");
19434 g_string_append (commands,
"<get_report_formats/>");
19436 g_string_append (commands,
"<get_scanners/>");
19438 g_string_append (commands,
"<get_schedules/>");
19440 g_string_append (commands,
"<get_targets/>");
19441 g_string_append (commands,
"</commands>");
19446 ret = omp (credentials, &response, &entity, response_data, commands->str);
19447 g_string_free (commands, TRUE);
19456 "Internal error", __FUNCTION__, __LINE__,
19457 "An internal error occurred while getting resources "
19458 "for the settings. "
19459 "Diagnostics: Failure to send command to manager daemon.",
19460 "/omp?cmd=get_my_settings", response_data);
19464 "Internal error", __FUNCTION__, __LINE__,
19465 "An internal error occurred while getting resources "
19466 "for the settings. "
19467 "Diagnostics: Failure to receive response from manager daemon.",
19468 "/omp?cmd=get_alerts", response_data);
19472 "Internal error", __FUNCTION__, __LINE__,
19473 "An internal error occurred while getting resources "
19474 "for the settings. "
19475 "It is unclear whether the task has been saved or not. "
19476 "Diagnostics: Internal Error.",
19477 "/omp?cmd=get_alerts", response_data);
19479 free_entity (entity);
19481 return get_my_settings (credentials, params, response, response_data);
19498 GString *commands, *xml;
19499 openvas_connection_t connection;
19501 gchar *html, *filters_xml;
19505 commands = g_string_new (
"<commands>");
19507 g_string_append (commands,
"<get_alerts/>");
19509 g_string_append (commands,
"<get_configs/>");
19511 g_string_append (commands,
"<get_credentials/>");
19513 g_string_append (commands,
"<get_filters/>");
19515 g_string_append (commands,
"<get_port_lists/>");
19517 g_string_append (commands,
"<get_report_formats/>");
19519 g_string_append (commands,
"<get_scanners/>");
19521 g_string_append (commands,
"<get_schedules/>");
19523 g_string_append (commands,
"<get_targets/>");
19524 g_string_append (commands,
"</commands>");
19526 filters_xml = NULL;
19528 ret = omp (credentials, &filters_xml, &entity, response_data, commands->str);
19529 g_string_free (commands, TRUE);
19538 "Internal error", __FUNCTION__, __LINE__,
19539 "An internal error occurred while getting resources "
19540 "for the settings. "
19541 "Diagnostics: Failure to send command to manager daemon.",
19542 "/omp?cmd=get_my_settings", response_data);
19546 "Internal error", __FUNCTION__, __LINE__,
19547 "An internal error occurred while getting resources "
19549 "Diagnostics: Failure to receive response from manager daemon.",
19550 "/omp?cmd=get_my_settings", response_data);
19554 "Internal error", __FUNCTION__, __LINE__,
19555 "An internal error occurred while getting resources "
19556 "for the settings. "
19557 "Diagnostics: Internal Error.",
19558 "/omp?cmd=get_my_settings", response_data);
19560 free_entity (entity);
19574 "Internal error", __FUNCTION__, __LINE__,
19575 "An internal error occurred while getting the settings. "
19576 "Diagnostics: Failure to connect to manager daemon.",
19577 "/omp?cmd=get_my_settings", response_data);
19580 xml = g_string_new (
"<edit_my_settings>");
19583 g_string_append (xml, extra_xml);
19585 g_string_append (xml, filters_xml);
19586 g_free (filters_xml);
19590 if (openvas_connection_sendf (&connection,
19592 " sort_field=\"name\""
19593 " sort_order=\"ascending\"/>")
19596 g_string_free (xml, TRUE);
19597 openvas_connection_close (&connection);
19600 "Internal error", __FUNCTION__, __LINE__,
19601 "An internal error occurred while getting the settings. "
19602 "The current list of settings is not available. "
19603 "Diagnostics: Failure to send command to manager daemon.",
19604 "/omp?cmd=get_my_settings", response_data);
19607 if (read_string_c (&connection, &xml))
19609 g_string_free (xml, TRUE);
19610 openvas_connection_close (&connection);
19613 "Internal error", __FUNCTION__, __LINE__,
19614 "An internal error occurred while getting the settings. "
19615 "The current list of settings is not available. "
19616 "Diagnostics: Failure to receive response from manager daemon.",
19617 "/omp?cmd=get_my_settings", response_data);
19622 g_string_append (xml,
"</edit_my_settings>");
19623 openvas_connection_close (&connection);
19624 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
19641 return edit_my_settings (credentials, params, NULL, response_data);
19656 send_settings_filters (openvas_connection_t *connection,
params_t *data,
19657 params_t *changed, GString *xml,
int *modify_failed_flag,
19670 const char* changed_value =
params_value (changed, uuid);
19671 if (changed_value == NULL
19672 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19676 base64 = g_base64_encode ((guchar*) param->
value,
19677 strlen (param->
value));
19679 base64 = g_strdup(
"");
19680 if (openvas_connection_sendf_xml (connection,
19681 "<modify_setting setting_id=\"%s\">"
19682 "<value>%s</value>"
19683 "</modify_setting>",
19694 xml_string_append (xml,
19695 "<save_setting id=\"%s\">",
19697 if (read_entity_and_string_c (connection, &entity, &xml))
19699 free_entity (entity);
19702 xml_string_append (xml,
"</save_setting>");
19703 if (! omp_success (entity))
19706 if (modify_failed_flag)
19707 *modify_failed_flag = 1;
19709 free_entity(entity);
19732 const char *accept_language,
char **timezone,
19733 char **password,
char **severity,
char **language,
19736 openvas_connection_t connection;
19738 const char *lang, *text, *old_passwd, *passwd, *status, *max;
19739 const char *details_fname, *list_fname, *report_fname;
19740 gchar *lang_64, *text_64, *max_64, *fname_64;
19743 params_t *changed, *defaults, *filters;
19744 int modify_failed = 0;
19745 const char *changed_value;
19758 details_fname =
params_value (params,
"details_fname");
19762 || (passwd == NULL)
19763 || (old_passwd == NULL)
19766 || (details_fname == NULL)
19767 || (list_fname == NULL)
19768 || (report_fname == NULL))
19769 return edit_my_settings (credentials, params,
19771 (
"Save My Settings"),
19786 "Internal error", __FUNCTION__, __LINE__,
19787 "An internal error occurred while saving settings. "
19788 "The settings remains the same. "
19789 "Diagnostics: Failure to connect to manager daemon.",
19790 "/omp?cmd=get_my_settings", response_data);
19793 xml = g_string_new (
"");
19796 if ((strlen (passwd) || strlen (old_passwd))
19797 && (changed_value == NULL
19798 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0"))))
19801 omp_authenticate_info_opts_t auth_opts;
19805 auth_opts = omp_authenticate_info_opts_defaults;
19806 auth_opts.username = credentials->
username;
19807 auth_opts.password = old_passwd;
19808 switch (omp_authenticate_info_ext_c (&connection, auth_opts))
19815 "Internal error", __FUNCTION__, __LINE__,
19816 "An internal error occurred while saving settings. "
19817 "The settings remains the same. "
19818 "Diagnostics: Manager closed connection during authenticate.",
19819 "/omp?cmd=get_my_settings", response_data);
19822 g_string_append (xml,
19824 " status_text=\"Password error\""
19825 " operation=\"Save My Settings\">"
19826 "You tried to change your password, but the old"
19827 " password was not provided or was incorrect. "
19828 " Please enter the correct old password or remove"
19829 " old and new passwords to apply any other changes"
19830 " of your settings."
19832 return edit_my_settings (credentials, params,
19833 g_string_free (xml, FALSE),
19838 "Internal error", __FUNCTION__, __LINE__,
19839 "An internal error occurred while saving settings. "
19840 "The settings remains the same. "
19841 "Diagnostics: Internal Error.",
19842 "/omp?cmd=get_my_settings", response_data);
19845 passwd_64 = g_base64_encode ((guchar*) passwd, strlen (passwd));
19847 if (openvas_connection_sendf (&connection,
19849 "<name>Password</name>"
19850 "<value>%s</value>"
19851 "</modify_setting>",
19852 passwd_64 ? passwd_64 :
"")
19855 g_free (passwd_64);
19856 openvas_connection_close (&connection);
19859 "Internal error", __FUNCTION__, __LINE__,
19860 "An internal error occurred while saving settings. "
19861 "It is unclear whether all the settings were saved. "
19862 "Diagnostics: Failure to send command to manager daemon.",
19863 "/omp?cmd=get_my_settings", response_data);
19865 g_free (passwd_64);
19868 xml_string_append (xml,
"<save_setting name=\"Password\">");
19869 if (read_entity_and_string_c (&connection, &entity, &xml))
19871 g_string_free (xml, TRUE);
19872 openvas_connection_close (&connection);
19875 "Internal error", __FUNCTION__, __LINE__,
19876 "An internal error occurred while saving settings. "
19877 "Diagnostics: Failure to receive response from manager daemon.",
19878 "/omp?cmd=get_my_settings", response_data);
19880 xml_string_append (xml,
"</save_setting>");
19882 status = entity_attribute (entity,
"status");
19883 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
19886 credentials->
password = g_strdup (passwd);
19887 *password = g_strdup (passwd);
19898 if (changed_value == NULL
19899 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19901 text_64 = g_base64_encode ((guchar*) text, strlen (text));
19903 if (openvas_connection_sendf (&connection,
19905 "<name>Timezone</name>"
19906 "<value>%s</value>"
19907 "</modify_setting>",
19908 text_64 ? text_64 :
"")
19912 openvas_connection_close (&connection);
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,
"<save_setting name=\"Timezone\">");
19925 if (read_entity_and_string_c (&connection, &entity, &xml))
19927 g_string_free (xml, TRUE);
19928 openvas_connection_close (&connection);
19931 "Internal error", __FUNCTION__, __LINE__,
19932 "An internal error occurred while saving settings. "
19933 "Diagnostics: Failure to receive response from manager daemon.",
19934 "/omp?cmd=get_my_settings", response_data);
19936 xml_string_append (xml,
"</save_setting>");
19938 status = entity_attribute (entity,
"status");
19939 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
19942 credentials->
timezone = g_strdup (strlen (text) ? text :
"UTC");
19943 *timezone = g_strdup (strlen (text) ? text :
"UTC");
19948 if (setenv (
"TZ", credentials->
timezone, 1) == -1)
19950 openvas_connection_close (&connection);
19951 g_critical (
"%s: failed to set TZ\n", __FUNCTION__);
19952 exit (EXIT_FAILURE);
19965 if (changed_value == NULL
19966 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
19968 max_64 = g_base64_encode ((guchar*) max, strlen (max));
19970 if (openvas_connection_sendf (&connection,
19973 "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">"
19974 "<value>%s</value>"
19975 "</modify_setting>",
19976 max_64 ? max_64 :
"")
19980 openvas_connection_close (&connection);
19983 "Internal error", __FUNCTION__, __LINE__,
19984 "An internal error occurred while saving settings. "
19985 "It is unclear whether all the settings were saved. "
19986 "Diagnostics: Failure to send command to manager daemon.",
19987 "/omp?cmd=get_my_settings", response_data);
19992 xml_string_append (xml,
19993 "<save_setting id=\"%s\">",
19994 "5f5a8712-8017-11e1-8556-406186ea4fc5");
19995 if (read_entity_and_string_c (&connection, &entity, &xml))
19997 g_string_free (xml, TRUE);
19998 openvas_connection_close (&connection);
20001 "Internal error", __FUNCTION__, __LINE__,
20002 "An internal error occurred while saving settings. "
20003 "It is unclear whether all the settings were saved. "
20004 "Diagnostics: Failure to receive response from manager daemon.",
20005 "/omp?cmd=get_my_settings", response_data);
20007 xml_string_append (xml,
"</save_setting>");
20008 if (! omp_success (entity))
20016 changed_value =
params_value (changed,
"details_fname");
20017 if (changed_value == NULL
20018 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20020 fname_64 = g_base64_encode ((guchar*) details_fname, strlen (details_fname));
20022 if (openvas_connection_sendf (&connection,
20025 "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">"
20026 "<value>%s</value>"
20027 "</modify_setting>",
20028 fname_64 ? fname_64 :
"")
20032 openvas_connection_close (&connection);
20035 "Internal error", __FUNCTION__, __LINE__,
20036 "An internal error occurred while saving settings. "
20037 "It is unclear whether all the settings were saved. "
20038 "Diagnostics: Failure to send command to manager daemon.",
20039 "/omp?cmd=get_my_settings", response_data);
20044 xml_string_append (xml,
20045 "<save_setting id=\"%s\">",
20046 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
20047 if (read_entity_and_string_c (&connection, &entity, &xml))
20049 g_string_free (xml, TRUE);
20050 openvas_connection_close (&connection);
20053 "Internal error", __FUNCTION__, __LINE__,
20054 "An internal error occurred while saving settings. "
20055 "It is unclear whether all the settings were saved. "
20056 "Diagnostics: Failure to receive response from manager daemon.",
20057 "/omp?cmd=get_my_settings", response_data);
20059 xml_string_append (xml,
"</save_setting>");
20060 if (omp_success (entity) != 1)
20069 if (changed_value == NULL
20070 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20072 fname_64 = g_base64_encode ((guchar*) list_fname, strlen (list_fname));
20074 if (openvas_connection_sendf (&connection,
20077 "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">"
20078 "<value>%s</value>"
20079 "</modify_setting>",
20080 fname_64 ? fname_64 :
"")
20084 openvas_connection_close (&connection);
20087 "Internal error", __FUNCTION__, __LINE__,
20088 "An internal error occurred while saving settings. "
20089 "It is unclear whether all the settings were saved. "
20090 "Diagnostics: Failure to send command to manager daemon.",
20091 "/omp?cmd=get_my_settings", response_data);
20096 xml_string_append (xml,
20097 "<save_setting id=\"%s\">",
20098 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
20099 if (read_entity_and_string_c (&connection, &entity, &xml))
20101 g_string_free (xml, TRUE);
20102 openvas_connection_close (&connection);
20105 "Internal error", __FUNCTION__, __LINE__,
20106 "An internal error occurred while saving settings. "
20107 "It is unclear whether all the settings were saved. "
20108 "Diagnostics: Failure to receive response from manager daemon.",
20109 "/omp?cmd=get_my_settings", response_data);
20111 xml_string_append (xml,
"</save_setting>");
20112 if (omp_success (entity) != 1)
20120 changed_value =
params_value (changed,
"report_fname");
20121 if (changed_value == NULL
20122 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20124 fname_64 = g_base64_encode ((guchar*) report_fname, strlen (report_fname));
20126 if (openvas_connection_sendf (&connection,
20129 "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">"
20130 "<value>%s</value>"
20131 "</modify_setting>",
20132 fname_64 ? fname_64 :
"")
20136 openvas_connection_close (&connection);
20139 "Internal error", __FUNCTION__, __LINE__,
20140 "An internal error occurred while saving settings. "
20141 "It is unclear whether all the settings were saved. "
20142 "Diagnostics: Failure to send command to manager daemon.",
20143 "/omp?cmd=get_my_settings", response_data);
20148 xml_string_append (xml,
20149 "<save_setting id=\"%s\">",
20150 "e1a2ae0b-736e-4484-b029-330c9e15b900");
20151 if (read_entity_and_string_c (&connection, &entity, &xml))
20153 g_string_free (xml, TRUE);
20154 openvas_connection_close (&connection);
20157 "Internal error", __FUNCTION__, __LINE__,
20158 "An internal error occurred while saving settings. "
20159 "It is unclear whether all the settings were saved. "
20160 "Diagnostics: Failure to receive response from manager daemon.",
20161 "/omp?cmd=get_my_settings", response_data);
20163 xml_string_append (xml,
"</save_setting>");
20164 if (omp_success (entity) != 1)
20173 if (changed_value == NULL
20174 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20176 lang_64 = g_base64_encode ((guchar*) lang, strlen (lang));
20178 if (openvas_connection_sendf (&connection,
20181 "=\"6765549a-934e-11e3-b358-406186ea4fc5\">"
20182 "<value>%s</value>"
20183 "</modify_setting>",
20184 lang_64 ? lang_64 :
"")
20188 openvas_connection_close (&connection);
20191 "Internal error", __FUNCTION__, __LINE__,
20192 "An internal error occurred while saving settings. "
20193 "It is unclear whether all the settings were saved. "
20194 "Diagnostics: Failure to send command to manager daemon.",
20195 "/omp?cmd=get_my_settings", response_data);
20200 xml_string_append (xml,
20201 "<save_setting id=\"%s\">",
20202 "6765549a-934e-11e3-b358-406186ea4fc5");
20203 if (read_entity_and_string_c (&connection, &entity, &xml))
20205 g_string_free (xml, TRUE);
20206 openvas_connection_close (&connection);
20209 "Internal error", __FUNCTION__, __LINE__,
20210 "An internal error occurred while saving settings. "
20211 "It is unclear whether all the settings were saved. "
20212 "Diagnostics: Failure to receive response from manager daemon.",
20213 "/omp?cmd=get_my_settings", response_data);
20215 xml_string_append (xml,
"</save_setting>");
20216 if (omp_success (entity))
20218 gchar *language_code;
20223 credentials->
language = language_code;
20224 *language = g_strdup (lang);
20243 if (send_settings_filters (&connection, defaults, changed, xml,
20244 &modify_failed, response_data))
20246 openvas_connection_close (&connection);
20249 "Internal error", __FUNCTION__, __LINE__,
20250 "An internal error occurred while saving settings. "
20251 "It is unclear whether all the settings were saved. "
20252 "Diagnostics: Failure to send command to manager daemon.",
20253 "/omp?cmd=get_my_settings", response_data);
20259 if (send_settings_filters (&connection, filters, changed, xml, &modify_failed,
20262 openvas_connection_close (&connection);
20265 "Internal error", __FUNCTION__, __LINE__,
20266 "An internal error occurred while saving settings. "
20267 "It is unclear whether all the settings were saved. "
20268 "Diagnostics: Failure to send command to manager daemon.",
20269 "/omp?cmd=get_my_settings", response_data);
20274 changed_value =
params_value (changed,
"severity_class");
20275 if (changed_value == NULL
20276 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20280 ? g_base64_encode ((guchar*) text, strlen (text))
20283 if (openvas_connection_sendf (&connection,
20286 "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">"
20287 "<value>%s</value>"
20288 "</modify_setting>",
20289 text_64 ? text_64 :
"")
20293 openvas_connection_close (&connection);
20296 "Internal error", __FUNCTION__, __LINE__,
20297 "An internal error occurred while saving settings. "
20298 "It is unclear whether all the settings were saved. "
20299 "Diagnostics: Failure to send command to manager daemon.",
20300 "/omp?cmd=get_my_settings", response_data);
20305 xml_string_append (xml,
20306 "<save_setting id=\"%s\">",
20307 "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
20308 if (read_entity_and_string_c (&connection, &entity, &xml))
20310 g_string_free (xml, TRUE);
20311 openvas_connection_close (&connection);
20314 "Internal error", __FUNCTION__, __LINE__,
20315 "An internal error occurred while saving settings. "
20316 "It is unclear whether all the settings were saved. "
20317 "Diagnostics: Failure to receive response from manager daemon.",
20318 "/omp?cmd=get_my_settings", response_data);
20320 xml_string_append (xml,
"</save_setting>");
20322 status = entity_attribute (entity,
"status");
20323 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
20326 if ((text != NULL) && (strlen (text) > 0))
20328 credentials->
severity = g_strdup (text);
20329 *severity = g_strdup (text);
20341 changed_value =
params_value (changed,
"dynamic_severity");
20342 if (changed_value == NULL
20343 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20347 ? g_base64_encode ((guchar*) text, strlen (text))
20350 if (openvas_connection_sendf (&connection,
20353 "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">"
20354 "<value>%s</value>"
20355 "</modify_setting>",
20356 text_64 ? text_64 :
"")
20360 openvas_connection_close (&connection);
20363 "Internal error", __FUNCTION__, __LINE__,
20364 "An internal error occurred while saving settings. "
20365 "It is unclear whether all the settings were saved. "
20366 "Diagnostics: Failure to send command to manager daemon.",
20367 "/omp?cmd=get_my_settings", response_data);
20372 xml_string_append (xml,
20373 "<save_setting id=\"%s\">",
20374 "77ec2444-e7f2-4a80-a59b-f4237782d93f");
20375 if (read_entity_and_string_c (&connection, &entity, &xml))
20377 g_string_free (xml, TRUE);
20378 openvas_connection_close (&connection);
20381 "Internal error", __FUNCTION__, __LINE__,
20382 "An internal error occurred while saving settings. "
20383 "It is unclear whether all the settings were saved. "
20384 "Diagnostics: Failure to receive response from manager daemon.",
20385 "/omp?cmd=get_my_settings", response_data);
20387 xml_string_append (xml,
"</save_setting>");
20388 if (! omp_success (entity))
20396 changed_value =
params_value (changed,
"default_severity");
20397 if (changed_value == NULL
20398 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
20402 ? g_base64_encode ((guchar*) text, strlen (text))
20405 if (openvas_connection_sendf (&connection,
20408 "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">"
20409 "<value>%s</value>"
20410 "</modify_setting>",
20411 text_64 ? text_64 :
"")
20415 openvas_connection_close (&connection);
20418 "Internal error", __FUNCTION__, __LINE__,
20419 "An internal error occurred while saving settings. "
20420 "It is unclear whether all the settings were saved. "
20421 "Diagnostics: Failure to send command to manager daemon.",
20422 "/omp?cmd=get_my_settings", response_data);
20427 xml_string_append (xml,
20428 "<save_setting id=\"%s\">",
20429 "7eda49c5-096c-4bef-b1ab-d080d87300df");
20430 if (read_entity_and_string_c (&connection, &entity, &xml))
20432 g_string_free (xml, TRUE);
20433 openvas_connection_close (&connection);
20436 "Internal error", __FUNCTION__, __LINE__,
20437 "An internal error occurred while saving settings. "
20438 "It is unclear whether all the settings were saved. "
20439 "Diagnostics: Failure to receive response from manager daemon.",
20440 "/omp?cmd=get_my_settings", response_data);
20442 xml_string_append (xml,
"</save_setting>");
20443 if (! omp_success (entity))
20450 openvas_connection_close (&connection);
20452 return edit_my_settings (credentials, params, g_string_free (xml, FALSE),
20455 return get_my_settings (credentials, params, g_string_free (xml, FALSE),
20473 openvas_connection_t connection;
20475 entity_t help_response;
20489 "Internal error", __FUNCTION__, __LINE__,
20490 "An internal error occurred while getting the OMP doc. "
20491 "The resource is currently not available. "
20492 "Diagnostics: Failure to connect to manager daemon.",
20493 "/omp?cmd=get_tasks", response_data);
20496 xml = g_string_new (
"");
20497 g_string_append_printf (xml,
"<get_protocol_doc>");
20501 if (openvas_connection_sendf (&connection,
"<help format=\"XML\"/>")
20504 g_string_free (xml, TRUE);
20505 openvas_connection_close (&connection);
20508 "Internal error", __FUNCTION__, __LINE__,
20509 "An internal error occurred while getting the OMP doc. "
20510 "Diagnostics: Failure to send command to manager daemon.",
20511 "/omp?cmd=get_tasks", response_data);
20514 help_response = NULL;
20515 if (read_entity_and_string_c (&connection, &help_response, &xml))
20517 g_string_free (xml, TRUE);
20518 openvas_connection_close (&connection);
20521 "Internal error", __FUNCTION__, __LINE__,
20522 "An internal error occurred while getting the OMP doc. "
20523 "Diagnostics: Failure to receive response from manager daemon.",
20524 "/omp?cmd=get_tasks", response_data);
20526 free_entity (help_response);
20528 openvas_connection_close (&connection);
20532 g_string_append_printf (xml,
"</get_protocol_doc>");
20533 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
20551 enum content_type * content_type,
20552 char **content_disposition, gsize *content_length,
20555 entity_t entity, response;
20556 openvas_connection_t connection;
20557 char *content = NULL;
20559 const char *format;
20563 *content_length = 0;
20577 "Internal error", __FUNCTION__, __LINE__,
20578 "An internal error occurred while getting the OMP doc. "
20579 "Diagnostics: Failure to connect to manager daemon.",
20580 "/omp?cmd=get_protocol_doc", response_data);
20587 if (openvas_connection_sendf (&connection,
20588 "<help format=\"%s\"/>",
20592 openvas_connection_close (&connection);
20595 "Internal error", __FUNCTION__, __LINE__,
20596 "An internal error occurred while getting a list. "
20597 "The list could not be delivered. "
20598 "Diagnostics: Failure to send command to manager daemon.",
20599 "/omp?cmd=get_protocol_doc", response_data);
20603 if (read_entity_and_text_c (&connection, &response, &content))
20605 openvas_connection_close (&connection);
20608 "Internal error", __FUNCTION__, __LINE__,
20609 "An internal error occurred while getting OMP doc. "
20610 "Diagnostics: Failure to receive response from manager daemon.",
20611 "/omp?cmd=get_protocol_doc", response_data);
20613 openvas_connection_close (&connection);
20615 if (strcmp (format,
"xml") == 0)
20616 *content_length = strlen (content);
20620 entity = entity_child (response,
"schema");
20621 if (entity == NULL)
20623 free_entity (response);
20626 "Internal error", __FUNCTION__, __LINE__,
20627 "An internal error occurred while getting OMP doc. "
20628 "Diagnostics: Schema element missing.",
20629 "/omp?cmd=get_protocol_doc", response_data);
20632 content_64 = entity_text (entity);
20633 if (strlen (content_64) == 0)
20635 free_entity (response);
20638 "Internal error", __FUNCTION__, __LINE__,
20639 "An internal error occurred while getting OMP doc. "
20640 "Diagnostics: Schema empty.",
20641 "/omp?cmd=get_protocol_doc", response_data);
20644 content = (
char *) g_base64_decode (content_64, content_length);
20648 tm = localtime (&now);
20650 *content_disposition = g_strdup_printf (
"attachment;"
20651 " filename=\"omp-%d-%d-%d.%s\"",
20656 free_entity (response);
20657 openvas_connection_close (&connection);
20678 return get_one (
"group", credentials, params, extra_xml, NULL, response_data);
20694 return get_group (credentials, params, NULL, response_data);
20711 return get_many (
"group", credentials, params, extra_xml, NULL,
20728 return get_groups (credentials, params, NULL, response_data);
20746 xml = g_string_new (
"<new_group>");
20748 g_string_append (xml, extra_xml);
20749 g_string_append (xml,
"</new_group>");
20750 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
20767 return new_group (credentials, params, NULL, response_data);
20783 return delete_resource (
"group", credentials, params, 1,
"get_trash",
20801 "get_groups", response_data);
20817 gchar *html, *response, *command, *specials_element;
20818 const char *no_redirect, *name, *comment, *
users, *grant_full;
20835 xml = g_string_new (
"");
20837 xml_string_append (xml,
20839 "<comment>%s</comment>"
20840 "<users>%s</users>",
20846 specials_element = g_strdup_printf (
"<full/>");
20848 specials_element = NULL;
20850 command = g_strdup_printf (
"<create_group>"
20859 g_string_free (xml, TRUE);
20860 g_free (specials_element);
20862 ret = omp (credentials, &response, &entity, response_data, command);
20872 "Internal error", __FUNCTION__, __LINE__,
20873 "An internal error occurred while creating a new group. "
20874 "No new group was created. "
20875 "Diagnostics: Failure to send command to manager daemon.",
20876 "/omp?cmd=get_groups", response_data);
20880 "Internal error", __FUNCTION__, __LINE__,
20881 "An internal error occurred while creating a new group. "
20882 "It is unclear whether the group has been created or not. "
20883 "Diagnostics: Failure to receive response from manager daemon.",
20884 "/omp?cmd=get_groups", response_data);
20888 "Internal error", __FUNCTION__, __LINE__,
20889 "An internal error occurred while creating a new group. "
20890 "It is unclear whether the group has been created or not. "
20891 "Diagnostics: Internal Error.",
20892 "/omp?cmd=get_groups", response_data);
20895 if (entity_attribute (entity,
"id"))
20896 params_add (params,
"group_id", entity_attribute (entity,
"id"));
20897 html = response_from_entity (credentials, params, entity,
20898 (no_redirect && strcmp (no_redirect,
"0")),
20899 NULL,
"get_groups",
20901 "Create Group", response_data);
20902 free_entity (entity);
20921 return edit_resource (
"group", credentials, params, NULL, extra_xml,
20938 return edit_group (credentials, params, NULL, response_data);
20955 enum content_type * content_type,
char **content_disposition,
20959 content_disposition, content_length, response_data);
20977 enum content_type * content_type,
char **content_disposition,
20980 return export_many (
"group", credentials, params, content_type,
20981 content_disposition, content_length, response_data);
20998 gchar *html, *response;
20999 const char *no_redirect, *group_id, *name, *comment, *
users;
21017 ret = ompf (credentials,
21021 "<modify_group group_id=\"%s\">"
21023 "<comment>%s</comment>"
21024 "<users>%s</users>"
21039 "Internal error", __FUNCTION__, __LINE__,
21040 "An internal error occurred while saving a group. "
21041 "The group was not saved. "
21042 "Diagnostics: Failure to send command to manager daemon.",
21043 "/omp?cmd=get_groups", response_data);
21047 "Internal error", __FUNCTION__, __LINE__,
21048 "An internal error occurred while saving a group. "
21049 "It is unclear whether the group has been saved or not. "
21050 "Diagnostics: Failure to receive response from manager daemon.",
21051 "/omp?cmd=get_groups", response_data);
21055 "Internal error", __FUNCTION__, __LINE__,
21056 "An internal error occurred while saving a group. "
21057 "It is unclear whether the group has been saved or not. "
21058 "Diagnostics: Internal Error.",
21059 "/omp?cmd=get_groups", response_data);
21062 html = response_from_entity (credentials, params, entity,
21063 (no_redirect && strcmp (no_redirect,
"0")),
21064 NULL,
"get_groups",
21065 NULL,
"edit_group",
21066 "Save Group", response_data);
21067 free_entity (entity);
21089 return get_one (
"permission", credentials, params, extra_xml,
"alerts=\"1\"",
21106 return get_permission (credentials, params, NULL, response_data);
21123 return get_many (
"permission", credentials, params, extra_xml, NULL,
21140 return get_permissions (credentials, params, NULL, response_data);
21156 return delete_resource (
"permission", credentials, params, 1,
"get_trash",
21193 xml = g_string_new (
"<new_permission>");
21202 switch (omp (credentials, &response, &entity, response_data,
21203 "<get_users filter=\"rows=-1 permission=get_users\"/>"))
21211 "Internal error", __FUNCTION__, __LINE__,
21212 "An internal error occurred getting the user list. "
21213 "No new user was created. "
21214 "Diagnostics: Failure to send command to manager daemon.",
21215 "/omp?cmd=get_users", response_data);
21219 "Internal error", __FUNCTION__, __LINE__,
21220 "An internal error occurred getting the user list. "
21221 "No new user was created. "
21222 "Diagnostics: Failure to receive response from manager daemon.",
21223 "/omp?cmd=get_users", response_data);
21227 "Internal error", __FUNCTION__, __LINE__,
21228 "An internal error occurred getting the user list. "
21229 "No new user was created. "
21230 "Diagnostics: Internal Error.",
21231 "/omp?cmd=get_users", response_data);
21234 g_string_append (xml, response);
21236 free_entity (entity);
21247 switch (omp (credentials, &response, &entity, response_data,
21248 "<get_groups filter=\"rows=-1 permission=get_groups\"/>"))
21256 "Internal error", __FUNCTION__, __LINE__,
21257 "An internal error occurred getting the group list. "
21258 "No new user was created. "
21259 "Diagnostics: Failure to send command to manager daemon.",
21260 "/omp?cmd=get_users", response_data);
21264 "Internal error", __FUNCTION__, __LINE__,
21265 "An internal error occurred getting the group list. "
21266 "No new user was created. "
21267 "Diagnostics: Failure to receive response from manager daemon.",
21268 "/omp?cmd=get_users", response_data);
21272 "Internal error", __FUNCTION__, __LINE__,
21273 "An internal error occurred getting the group list. "
21274 "No new user was created. "
21275 "Diagnostics: Internal Error.",
21276 "/omp?cmd=get_users", response_data);
21279 g_string_append (xml, response);
21281 free_entity (entity);
21292 switch (omp (credentials, &response, &entity, response_data,
21293 "<get_roles filter=\"rows=-1 permission=get_roles\"/>"))
21301 "Internal error", __FUNCTION__, __LINE__,
21302 "An internal error occurred getting the role list. "
21303 "No new user was created. "
21304 "Diagnostics: Failure to send command to manager daemon.",
21305 "/omp?cmd=get_users", response_data);
21309 "Internal error", __FUNCTION__, __LINE__,
21310 "An internal error occurred getting the role list. "
21311 "No new user was created. "
21312 "Diagnostics: Failure to receive response from manager daemon.",
21313 "/omp?cmd=get_users", response_data);
21317 "Internal error", __FUNCTION__, __LINE__,
21318 "An internal error occurred getting the role list. "
21319 "No new user was created. "
21320 "Diagnostics: Internal Error.",
21321 "/omp?cmd=get_users", response_data);
21324 g_string_append (xml, response);
21326 free_entity (entity);
21331 g_string_append (xml, extra_xml);
21333 g_string_append (xml,
"</new_permission>");
21335 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
21352 return new_permission (credentials, params, NULL, response_data);
21369 gchar *html, *response;
21370 const char *no_redirect, *name, *comment, *resource_id, *resource_type;
21371 const char *subject_id, *subject_type, *subject_name;
21374 gchar *subject_response;
21375 entity_t get_subject_entity = NULL;
21376 entity_t subject_entity;
21382 resource_type =
params_value (params,
"optional_resource_type");
21397 "Create Permission",
"new_permission");
21399 ret = ompf (credentials,
21401 &get_subject_entity,
21403 "<get_%ss filter=\"rows=1 name=%s\">"
21417 "Internal error", __FUNCTION__, __LINE__,
21418 "An internal error occurred while getting"
21419 " the subject for a permission. "
21420 "The permission was not created. "
21421 "Diagnostics: Failure to send command"
21422 " to manager daemon.",
21423 "/omp?cmd=get_permissions", response_data);
21427 "Internal error", __FUNCTION__, __LINE__,
21428 "An internal error occurred while getting"
21429 " the subject for a permission. "
21430 "The permission was not created. "
21431 "Diagnostics: Failure to receive response"
21432 " from manager daemon.",
21433 "/omp?cmd=get_permissions", response_data);
21437 "Internal error", __FUNCTION__, __LINE__,
21438 "An internal error occurred while getting"
21439 " the subject for a permission. "
21440 "The permission was not created. "
21441 "Diagnostics: Internal Error.",
21442 "/omp?cmd=get_permissions", response_data);
21445 subject_entity = entity_child (get_subject_entity, subject_type);
21447 if (subject_entity)
21448 subject_id = entity_attribute (subject_entity,
"id");
21450 if (subject_id == NULL)
21453 msg = g_strdup_printf (
"<gsad_msg status_text=\"Subject not found\""
21454 " operation=\"create_permission\">"
21455 "Could not find a %s with name '%s'."
21458 subject_name ? subject_name :
"");
21459 return next_page (credentials, params, msg, response_data);
21462 else if (strcmp (subject_type,
"user") == 0)
21463 subject_id =
params_value (params,
"permission_user_id");
21464 else if (strcmp (subject_type,
"group") == 0)
21465 subject_id =
params_value (params,
"permission_group_id");
21466 else if (strcmp (subject_type,
"role") == 0)
21467 subject_id =
params_value (params,
"permission_role_id");
21474 if (strcmp (name,
"task_proxy") == 0)
21478 ret = ompf (credentials,
21483 "<create_permission>"
21484 "<name>get_tasks</name>"
21485 "<comment>%s</comment>"
21486 "<resource id=\"%s\"/>"
21487 "<subject id=\"%s\"><type>%s</type></subject>"
21488 "</create_permission>"
21489 "<create_permission>"
21490 "<name>modify_task</name>"
21491 "<comment>%s</comment>"
21492 "<resource id=\"%s\"/>"
21493 "<subject id=\"%s\"><type>%s</type></subject>"
21494 "</create_permission>"
21495 "<create_permission>"
21496 "<name>start_task</name>"
21497 "<comment>%s</comment>"
21498 "<resource id=\"%s\"/>"
21499 "<subject id=\"%s\"><type>%s</type></subject>"
21500 "</create_permission>"
21501 "<create_permission>"
21502 "<name>stop_task</name>"
21503 "<comment>%s</comment>"
21504 "<resource id=\"%s\"/>"
21505 "<subject id=\"%s\"><type>%s</type></subject>"
21506 "</create_permission>"
21507 "<create_permission>"
21508 "<name>resume_task</name>"
21509 "<comment>%s</comment>"
21510 "<resource id=\"%s\"/>"
21511 "<subject id=\"%s\"><type>%s</type></subject>"
21512 "</create_permission>"
21514 comment ? comment :
"",
21515 resource_id ? resource_id :
"",
21518 comment ? comment :
"",
21519 resource_id ? resource_id :
"",
21522 comment ? comment :
"",
21523 resource_id ? resource_id :
"",
21526 comment ? comment :
"",
21527 resource_id ? resource_id :
"",
21530 comment ? comment :
"",
21531 resource_id ? resource_id :
"",
21535 if (get_subject_entity)
21536 free_entity (get_subject_entity);
21546 "Internal error", __FUNCTION__, __LINE__,
21547 "An internal error occurred while creating a permission. "
21548 "The permission was not created. "
21549 "Diagnostics: Failure to send command to manager daemon.",
21550 "/omp?cmd=get_permissions", response_data);
21554 "Internal error", __FUNCTION__, __LINE__,
21555 "An internal error occurred while creating a permission. "
21556 "It is unclear whether the permission has been created or not. "
21557 "Diagnostics: Failure to receive response from manager daemon.",
21558 "/omp?cmd=get_permissions", response_data);
21562 "Internal error", __FUNCTION__, __LINE__,
21563 "An internal error occurred while creating a permission. "
21564 "It is unclear whether the permission has been created or not. "
21565 "Diagnostics: Internal Error.",
21566 "/omp?cmd=get_permissions", response_data);
21569 if (entity_attribute (entity,
"id"))
21570 params_add (params,
"permission_id", entity_attribute (entity,
"id"));
21571 html = response_from_entity (credentials, params, entity,
21572 (no_redirect && strcmp (no_redirect,
"0")),
21573 NULL,
"get_permissions",
21574 NULL,
"new_permission",
21575 "Create Permission", response_data);
21581 ret = ompf (credentials,
21585 "<create_permission>"
21587 "<comment>%s</comment>"
21588 "<resource id=\"%s\">"
21591 "<subject id=\"%s\"><type>%s</type></subject>"
21592 "</create_permission>",
21594 comment ? comment :
"",
21595 resource_id ? resource_id :
"",
21596 resource_type ? resource_type :
"",
21600 if (get_subject_entity)
21601 free_entity (get_subject_entity);
21611 "Internal error", __FUNCTION__, __LINE__,
21612 "An internal error occurred while creating a permission. "
21613 "The permission was not created. "
21614 "Diagnostics: Failure to send command to manager daemon.",
21615 "/omp?cmd=get_permissions", response_data);
21619 "Internal error", __FUNCTION__, __LINE__,
21620 "An internal error occurred while creating a permission. "
21621 "It is unclear whether the permission has been created or not. "
21622 "Diagnostics: Failure to receive response from manager daemon.",
21623 "/omp?cmd=get_permissions", response_data);
21627 "Internal error", __FUNCTION__, __LINE__,
21628 "An internal error occurred while creating a permission. "
21629 "It is unclear whether the permission has been created or not. "
21630 "Diagnostics: Internal Error.",
21631 "/omp?cmd=get_permissions", response_data);
21634 if (entity_attribute (entity,
"id"))
21635 params_add (params,
"permission_id", entity_attribute (entity,
"id"));
21636 html = response_from_entity (credentials, params, entity,
21637 (no_redirect && strcmp (no_redirect,
"0")),
21638 NULL,
"get_permissions",
21639 NULL,
"new_permission",
21640 "Create Permission", response_data);
21642 free_entity (entity);
21647 #define CHECK_OMPF_RET \
21654 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \
21655 return gsad_message (credentials, \
21656 "Internal error", __FUNCTION__, __LINE__, \
21657 "An internal error occurred while creating a permission. " \
21658 "The permission was not created. " \
21659 "Diagnostics: Failure to send command to manager daemon.", \
21660 "/omp?cmd=get_permissions", response_data); \
21662 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \
21663 return gsad_message (credentials, \
21664 "Internal error", __FUNCTION__, __LINE__, \
21665 "An internal error occurred while creating a permission. " \
21666 "It is unclear whether the permission has been created or not. " \
21667 "Diagnostics: Failure to receive response from manager daemon.", \
21668 "/omp?cmd=get_permissions", response_data); \
21670 response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR; \
21671 return gsad_message (credentials, \
21672 "Internal error", __FUNCTION__, __LINE__, \
21673 "An internal error occurred while creating a permission. " \
21674 "It is unclear whether the permission has been created or not. " \
21675 "Diagnostics: Internal Error.", \
21676 "/omp?cmd=get_permissions", response_data); \
21678 if (omp_success (entity)) \
21681 free_entity (entity); \
21682 g_free (response); \
21687 = response_from_entity (credentials, params, entity, \
21688 (no_redirect && strcmp (no_redirect, "0")), \
21689 NULL, "get_permissions", \
21690 NULL, "new_permissions", \
21691 "Create Permissions", response_data); \
21692 free_entity (entity); \
21693 g_free (response); \
21712 const char *resource_id, *restrict_type;
21718 xml = g_string_new (
"<new_permissions>");
21727 switch (omp (credentials, &response, &entity, response_data,
21728 "<get_users filter=\"rows=-1 permission=get_users\"/>"))
21736 "Internal error", __FUNCTION__, __LINE__,
21737 "An internal error occurred getting the user list. "
21738 "No new user was created. "
21739 "Diagnostics: Failure to send command to manager daemon.",
21740 "/omp?cmd=get_users", response_data);
21744 "Internal error", __FUNCTION__, __LINE__,
21745 "An internal error occurred getting the user list. "
21746 "No new user was created. "
21747 "Diagnostics: Failure to receive response from manager daemon.",
21748 "/omp?cmd=get_users", response_data);
21752 "Internal error", __FUNCTION__, __LINE__,
21753 "An internal error occurred getting the user list. "
21754 "No new user was created. "
21755 "Diagnostics: Internal Error.",
21756 "/omp?cmd=get_users", response_data);
21759 g_string_append (xml, response);
21761 free_entity (entity);
21772 switch (omp (credentials, &response, &entity, response_data,
21773 "<get_groups filter=\"rows=-1 permission=get_groups\"/>"))
21781 "Internal error", __FUNCTION__, __LINE__,
21782 "An internal error occurred getting the group list. "
21783 "No new user was created. "
21784 "Diagnostics: Failure to send command to manager daemon.",
21785 "/omp?cmd=get_users", response_data);
21789 "Internal error", __FUNCTION__, __LINE__,
21790 "An internal error occurred getting the group list. "
21791 "No new user was created. "
21792 "Diagnostics: Failure to receive response from manager daemon.",
21793 "/omp?cmd=get_users", response_data);
21797 "Internal error", __FUNCTION__, __LINE__,
21798 "An internal error occurred getting the group list. "
21799 "No new user was created. "
21800 "Diagnostics: Internal Error.",
21801 "/omp?cmd=get_users", response_data);
21804 g_string_append (xml, response);
21806 free_entity (entity);
21817 switch (omp (credentials, &response, &entity, response_data,
21818 "<get_roles filter=\"rows=-1 permission=get_roles\"/>"))
21826 "Internal error", __FUNCTION__, __LINE__,
21827 "An internal error occurred getting the role list. "
21828 "No new user was created. "
21829 "Diagnostics: Failure to send command to manager daemon.",
21830 "/omp?cmd=get_users", response_data);
21834 "Internal error", __FUNCTION__, __LINE__,
21835 "An internal error occurred getting the role list. "
21836 "No new user was created. "
21837 "Diagnostics: Failure to receive response from manager daemon.",
21838 "/omp?cmd=get_users", response_data);
21842 "Internal error", __FUNCTION__, __LINE__,
21843 "An internal error occurred getting the role list. "
21844 "No new user was created. "
21845 "Diagnostics: Internal Error.",
21846 "/omp?cmd=get_users", response_data);
21849 g_string_append (xml, response);
21851 free_entity (entity);
21856 restrict_type =
params_value (params,
"restrict_type");
21857 if (resource_id && restrict_type)
21859 gchar *get_command;
21863 get_command = g_strdup_printf (
"get_%ss", restrict_type);
21866 switch (ompf (credentials, &response, &entity, response_data,
21867 "<%s %s_id=\"%s\" details=\"0\"/>",
21868 get_command, restrict_type, resource_id))
21874 g_free (get_command);
21876 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21878 "Internal error", __FUNCTION__, __LINE__,
21879 "An internal error occurred getting a resource. "
21880 "No new permission was created. "
21881 "Diagnostics: Failure to send command to manager daemon.",
21882 "/omp?cmd=get_users", response_data);
21884 g_free (get_command);
21886 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21888 "Internal error", __FUNCTION__, __LINE__,
21889 "An internal error occurred getting a resource. "
21890 "No new permission was created. "
21891 "Diagnostics: Failure to receive response from manager daemon.",
21892 "/omp?cmd=get_users", response_data);
21894 g_free (get_command);
21896 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21898 "Internal error", __FUNCTION__, __LINE__,
21899 "An internal error occurred getting a resource. "
21900 "No new permission was created. "
21901 "Diagnostics: Internal Error.",
21902 "/omp?cmd=get_users", response_data);
21904 g_string_append (xml, response);
21906 free_entity (entity);
21914 const char* related_type;
21915 gchar *get_command;
21919 related_type = related_param->
value;
21921 get_command = g_strdup_printf (
"get_%ss", related_type);
21924 switch (ompf (credentials, &response, &entity, response_data,
21925 "<%s %s_id=\"%s\" details=\"0\"/>",
21926 get_command, related_type, related_id))
21932 g_free (get_command);
21934 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21936 "Internal error", __FUNCTION__, __LINE__,
21937 "An internal error occurred getting a resource. "
21938 "No new permission was created. "
21939 "Diagnostics: Failure to send command to manager daemon.",
21940 "/omp?cmd=get_users", response_data);
21942 g_free (get_command);
21944 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21946 "Internal error", __FUNCTION__, __LINE__,
21947 "An internal error occurred getting a resource. "
21948 "No new permission was created. "
21949 "Diagnostics: Failure to receive response from manager daemon.",
21950 "/omp?cmd=get_users", response_data);
21952 g_free (get_command);
21954 = MHD_HTTP_INTERNAL_SERVER_ERROR;
21956 "Internal error", __FUNCTION__, __LINE__,
21957 "An internal error occurred getting a resource. "
21958 "No new permission was created. "
21959 "Diagnostics: Internal Error.",
21960 "/omp?cmd=get_users", response_data);
21962 g_string_append (xml, response);
21964 free_entity (entity);
21969 g_string_append (xml, extra_xml);
21971 g_string_append (xml,
"</new_permissions>");
21973 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
22007 gchar *html, *response, *summary_response, *next_url;
22009 const char *no_redirect, *permission, *comment, *resource_id, *resource_type;
22010 const char *subject_id, *subject_type, *subject_name;
22011 int include_related;
22015 gchar *subject_response;
22016 entity_t get_subject_entity = NULL;
22017 entity_t subject_entity;
22023 resource_type =
params_value (params,
"resource_type");
22027 include_related = atoi (
params_value (params,
"include_related"));
22041 ret = ompf (credentials,
22043 &get_subject_entity,
22045 "<get_%ss filter=\"rows=1 name=%s\">"
22059 "Internal error", __FUNCTION__, __LINE__,
22060 "An internal error occurred while getting"
22061 " the subject for a permission. "
22062 "The permission was not created. "
22063 "Diagnostics: Failure to send command"
22064 " to manager daemon.",
22065 "/omp?cmd=get_permissions", response_data);
22069 "Internal error", __FUNCTION__, __LINE__,
22070 "An internal error occurred while getting"
22071 " the subject for a permission. "
22072 "The permission was not created. "
22073 "Diagnostics: Failure to receive response"
22074 " from manager daemon.",
22075 "/omp?cmd=get_permissions", response_data);
22079 "Internal error", __FUNCTION__, __LINE__,
22080 "An internal error occurred while getting"
22081 " the subject for a permission. "
22082 "The permission was not created. "
22083 "Diagnostics: Internal Error.",
22084 "/omp?cmd=get_permissions", response_data);
22087 subject_entity = entity_child (get_subject_entity, subject_type);
22089 if (subject_entity)
22090 subject_id = entity_attribute (subject_entity,
"id");
22092 if (subject_id == NULL)
22095 msg = g_strdup_printf (
"<gsad_msg status_text=\"Subject not found\""
22096 " operation=\"create_permission\">"
22097 "Could not find a %s with name '%s'."
22100 subject_name ? subject_name :
"");
22101 return next_page (credentials, params, msg, response_data);
22104 else if (strcmp (subject_type,
"user") == 0)
22105 subject_id =
params_value (params,
"permission_user_id");
22106 else if (strcmp (subject_type,
"group") == 0)
22107 subject_id =
params_value (params,
"permission_group_id");
22108 else if (strcmp (subject_type,
"role") == 0)
22109 subject_id =
params_value (params,
"permission_role_id");
22119 if (include_related != 2)
22121 if (strcmp (permission,
"read") == 0
22122 || strcmp (permission,
"proxy") == 0)
22126 ret = ompf (credentials,
22130 "<create_permission>"
22131 "<name>get_%ss</name>"
22132 "<comment>%s</comment>"
22133 "<resource id=\"%s\">"
22135 "<subject id=\"%s\"><type>%s</type></subject>"
22136 "</create_permission>",
22138 comment ? comment :
"",
22146 if ((strcmp (permission,
"proxy") == 0)
22147 && strcmp (resource_type,
"result")
22148 && strcmp (resource_type,
"report"))
22152 ret = ompf (credentials,
22156 "<create_permission>"
22157 "<name>modify_%s</name>"
22158 "<comment>%s</comment>"
22159 "<resource id=\"%s\">"
22161 "<subject id=\"%s\"><type>%s</type></subject>"
22162 "</create_permission>",
22164 comment ? comment :
"",
22171 if (strcmp (resource_type,
"task") == 0)
22175 ret = ompf (credentials,
22179 "<create_permission>"
22180 "<name>start_%s</name>"
22181 "<comment>%s</comment>"
22182 "<resource id=\"%s\">"
22184 "<subject id=\"%s\"><type>%s</type></subject>"
22185 "</create_permission>",
22187 comment ? comment :
"",
22196 ret = ompf (credentials,
22200 "<create_permission>"
22201 "<name>stop_%s</name>"
22202 "<comment>%s</comment>"
22203 "<resource id=\"%s\">"
22205 "<subject id=\"%s\"><type>%s</type></subject>"
22206 "</create_permission>",
22208 comment ? comment :
"",
22217 ret = ompf (credentials,
22221 "<create_permission>"
22222 "<name>resume_%s</name>"
22223 "<comment>%s</comment>"
22224 "<resource id=\"%s\">"
22226 "<subject id=\"%s\"><type>%s</type></subject>"
22227 "</create_permission>",
22229 comment ? comment :
"",
22237 if (strcmp (resource_type,
"alert") == 0)
22241 ret = ompf (credentials,
22245 "<create_permission>"
22246 "<name>test_%s</name>"
22247 "<comment>%s</comment>"
22248 "<resource id=\"%s\">"
22250 "<subject id=\"%s\"><type>%s</type></subject>"
22251 "</create_permission>",
22253 comment ? comment :
"",
22261 if (strcmp (resource_type,
"agent") == 0
22262 || strcmp (resource_type,
"report_format") == 0
22263 || strcmp (resource_type,
"scanner") == 0)
22267 ret = ompf (credentials,
22271 "<create_permission>"
22272 "<name>verify_%s</name>"
22273 "<comment>%s</comment>"
22274 "<resource id=\"%s\">"
22276 "<subject id=\"%s\"><type>%s</type></subject>"
22277 "</create_permission>",
22279 comment ? comment :
"",
22290 if (include_related)
22303 char *related_id = name;
22304 char *related_type = param->
value;
22306 if (strcmp (permission,
"read") == 0
22307 || strcmp (permission,
"proxy") == 0)
22311 ret = ompf (credentials,
22315 "<create_permission>"
22316 "<name>get_%ss</name>"
22317 "<comment>%s</comment>"
22318 "<resource id=\"%s\">"
22320 "<subject id=\"%s\"><type>%s</type></subject>"
22321 "</create_permission>",
22323 comment ? comment :
"",
22331 if ((strcmp (permission,
"proxy") == 0)
22332 && strcmp (related_type,
"result")
22333 && strcmp (related_type,
"report"))
22337 ret = ompf (credentials,
22341 "<create_permission>"
22342 "<name>modify_%s</name>"
22343 "<comment>%s</comment>"
22344 "<resource id=\"%s\">"
22346 "<subject id=\"%s\"><type>%s</type></subject>"
22347 "</create_permission>",
22349 comment ? comment :
"",
22356 if (strcmp (related_type,
"task") == 0)
22360 ret = ompf (credentials,
22364 "<create_permission>"
22365 "<name>start_%s</name>"
22366 "<comment>%s</comment>"
22367 "<resource id=\"%s\">"
22369 "<subject id=\"%s\"><type>%s</type></subject>"
22370 "</create_permission>",
22372 comment ? comment :
"",
22381 ret = ompf (credentials,
22385 "<create_permission>"
22386 "<name>stop_%s</name>"
22387 "<comment>%s</comment>"
22388 "<resource id=\"%s\">"
22390 "<subject id=\"%s\"><type>%s</type></subject>"
22391 "</create_permission>",
22393 comment ? comment :
"",
22402 ret = ompf (credentials,
22406 "<create_permission>"
22407 "<name>resume_%s</name>"
22408 "<comment>%s</comment>"
22409 "<resource id=\"%s\">"
22411 "<subject id=\"%s\"><type>%s</type></subject>"
22412 "</create_permission>",
22414 comment ? comment :
"",
22422 if (strcmp (related_type,
"alert") == 0)
22426 ret = ompf (credentials,
22430 "<create_permission>"
22431 "<name>test_%s</name>"
22432 "<comment>%s</comment>"
22433 "<resource id=\"%s\">"
22435 "<subject id=\"%s\"><type>%s</type></subject>"
22436 "</create_permission>",
22438 comment ? comment :
"",
22446 if (strcmp (related_type,
"agent") == 0
22447 || strcmp (related_type,
"report_format") == 0
22448 || strcmp (related_type,
"scanner") == 0)
22452 ret = ompf (credentials,
22456 "<create_permission>"
22457 "<name>verify_%s</name>"
22458 "<comment>%s</comment>"
22459 "<resource id=\"%s\">"
22461 "<subject id=\"%s\"><type>%s</type></subject>"
22462 "</create_permission>",
22464 comment ? comment :
"",
22476 if (get_subject_entity)
22477 free_entity (get_subject_entity);
22479 summary_response = g_strdup_printf(
"Successfully created %i permissions",
22482 next_url = next_page_url (credentials, params,
22483 NULL,
"new_permissions",
22484 "Create Permissions",
22485 G_STRINGIFY (MHD_HTTP_CREATED),
22490 html = action_result_page (credentials, response_data,
22491 "Create Permissions",
22492 G_STRINGIFY (MHD_HTTP_CREATED),
22500 response_data->
redirect = next_url;
22505 #undef CHECK_OMPF_RET
22524 extra = g_string_new (
"");
22533 switch (omp (credentials, &response, &entity, response_data,
22534 "<get_users filter=\"rows=-1\"/>"))
22542 "Internal error", __FUNCTION__, __LINE__,
22543 "An internal error occurred getting the user list. "
22544 "No new user was created. "
22545 "Diagnostics: Failure to send command to manager daemon.",
22546 "/omp?cmd=get_users", response_data);
22550 "Internal error", __FUNCTION__, __LINE__,
22551 "An internal error occurred getting the user list. "
22552 "No new user was created. "
22553 "Diagnostics: Failure to receive response from manager daemon.",
22554 "/omp?cmd=get_users", response_data);
22558 "Internal error", __FUNCTION__, __LINE__,
22559 "An internal error occurred getting the user list. "
22560 "No new user was created. "
22561 "Diagnostics: Internal Error.",
22562 "/omp?cmd=get_users", response_data);
22565 g_string_append (extra, response);
22567 free_entity (entity);
22578 switch (omp (credentials, &response, &entity, response_data,
22579 "<get_groups filter=\"rows=-1\"/>"))
22587 "Internal error", __FUNCTION__, __LINE__,
22588 "An internal error occurred getting the group list. "
22589 "No new user was created. "
22590 "Diagnostics: Failure to send command to manager daemon.",
22591 "/omp?cmd=get_users", response_data);
22595 "Internal error", __FUNCTION__, __LINE__,
22596 "An internal error occurred getting the group list. "
22597 "No new user was created. "
22598 "Diagnostics: Failure to receive response from manager daemon.",
22599 "/omp?cmd=get_users", response_data);
22603 "Internal error", __FUNCTION__, __LINE__,
22604 "An internal error occurred getting the group list. "
22605 "No new user was created. "
22606 "Diagnostics: Internal Error.",
22607 "/omp?cmd=get_users", response_data);
22610 g_string_append (extra, response);
22612 free_entity (entity);
22623 switch (omp (credentials, &response, &entity, response_data,
22624 "<get_roles filter=\"rows=-1\"/>"))
22632 "Internal error", __FUNCTION__, __LINE__,
22633 "An internal error occurred getting the role list. "
22634 "No new user was created. "
22635 "Diagnostics: Failure to send command to manager daemon.",
22636 "/omp?cmd=get_users", response_data);
22640 "Internal error", __FUNCTION__, __LINE__,
22641 "An internal error occurred getting the role list. "
22642 "No new user was created. "
22643 "Diagnostics: Failure to receive response from manager daemon.",
22644 "/omp?cmd=get_users", response_data);
22648 "Internal error", __FUNCTION__, __LINE__,
22649 "An internal error occurred getting the role list. "
22650 "No new user was created. "
22651 "Diagnostics: Internal Error.",
22652 "/omp?cmd=get_users", response_data);
22655 g_string_append (extra, response);
22657 free_entity (entity);
22662 g_string_append (extra, extra_xml);
22663 html =
edit_resource (
"permission", credentials, params, NULL, extra->str,
22665 g_string_free (extra, TRUE);
22699 enum content_type * content_type,
22700 char **content_disposition, gsize *content_length,
22703 return export_resource (
"permission", credentials, params, content_type,
22704 content_disposition, content_length, response_data);
22722 enum content_type * content_type,
22723 char **content_disposition, gsize *content_length,
22726 return export_many (
"permission", credentials, params, content_type,
22727 content_disposition, content_length, response_data);
22743 gchar *html, *response;
22744 const char *no_redirect;
22745 const char *permission_id, *name, *comment, *resource_id, *resource_type;
22746 const char *subject_id, *subject_type;
22751 permission_id =
params_value (params,
"permission_id");
22756 resource_type =
params_value (params,
"optional_resource_type");
22766 if (strcmp (subject_type,
"user") == 0)
22768 else if (strcmp (subject_type,
"group") == 0)
22770 else if (strcmp (subject_type,
"role") == 0)
22780 ret = ompf (credentials,
22784 "<modify_permission permission_id=\"%s\">"
22786 "<comment>%s</comment>"
22787 "<subject id=\"%s\">"
22790 "<resource id=\"%s\">"
22793 "</modify_permission>",
22799 (resource_id && strlen (resource_id)) ? resource_id :
"0",
22800 resource_type ? resource_type :
"");
22809 "Internal error", __FUNCTION__, __LINE__,
22810 "An internal error occurred while modifying a permission. "
22811 "The permission was not modified. "
22812 "Diagnostics: Failure to send command to manager daemon.",
22813 "/omp?cmd=get_permissions", response_data);
22817 "Internal error", __FUNCTION__, __LINE__,
22818 "An internal error occurred while modifying a permission. "
22819 "It is unclear whether the permission has been modified or not. "
22820 "Diagnostics: Failure to receive response from manager daemon.",
22821 "/omp?cmd=get_permissions", response_data);
22825 "Internal error", __FUNCTION__, __LINE__,
22826 "An internal error occurred while modifying a permission. "
22827 "It is unclear whether the permission has been modified or not. "
22828 "Diagnostics: Internal Error.",
22829 "/omp?cmd=get_permissions", response_data);
22832 html = response_from_entity (credentials, params, entity,
22833 (no_redirect && strcmp (no_redirect,
"0")),
22834 NULL,
"get_permissions",
22835 NULL,
"edit_permission",
22836 "Save Permission", response_data);
22837 free_entity (entity);
22860 xml = g_string_new (
"<new_port_list>");
22862 g_string_append (xml, extra_xml);
22863 g_string_append (xml,
"</new_port_list>");
22864 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
22884 xml = g_string_new (
"<upload_port_list>");
22886 g_string_append (xml, extra_xml);
22887 g_string_append (xml,
"</upload_port_list>");
22889 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
22906 return upload_port_list (credentials, params, NULL, response_data);
22922 gchar *html, *response;
22923 const char *no_redirect, *name, *comment, *port_range, *from_file;
22939 switch (ompf (credentials,
22943 "<create_port_list>"
22945 "<port_range>%s</port_range>"
22946 "<comment>%s</comment>"
22947 "</create_port_list>",
22949 strcmp (from_file,
"0")
22952 comment ? comment :
""))
22960 "Internal error", __FUNCTION__, __LINE__,
22961 "An internal error occurred while creating a new port list. "
22962 "No new port list was created. "
22963 "Diagnostics: Failure to send command to manager daemon.",
22964 "/omp?cmd=get_port_lists", response_data);
22968 "Internal error", __FUNCTION__, __LINE__,
22969 "An internal error occurred while creating a new port list. "
22970 "It is unclear whether the port list has been created or not. "
22971 "Diagnostics: Failure to receive response from manager daemon.",
22972 "/omp?cmd=get_port_lists", response_data);
22976 "Internal error", __FUNCTION__, __LINE__,
22977 "An internal error occurred while creating a new port list. "
22978 "It is unclear whether the port list has been created or not. "
22979 "Diagnostics: Internal Error.",
22980 "/omp?cmd=get_port_lists", response_data);
22983 if (entity_attribute (entity,
"id"))
22984 params_add (params,
"port_list_id", entity_attribute (entity,
"id"));
22985 html = response_from_entity (credentials, params, entity,
22986 (no_redirect && strcmp (no_redirect,
"0")),
22987 NULL,
"get_port_lists",
22988 NULL,
"new_port_list",
22989 "Create Port List", response_data);
22990 free_entity (entity);
23010 xml = g_string_new (
"<new_port_range>");
23012 g_string_append (xml, extra_xml);
23013 g_string_append (xml,
"</new_port_range>");
23014 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
23031 return new_port_range (credentials, params, NULL, response_data);
23048 gchar *html, *response;
23049 const char *no_redirect, *port_list_id, *start, *end, *type;
23067 ret = ompf (credentials,
23071 "<create_port_range>"
23072 "<port_list id=\"%s\"/>"
23073 "<start>%s</start>"
23076 "</create_port_range>",
23090 "Internal error", __FUNCTION__, __LINE__,
23091 "An internal error occurred while creating a Port Range. "
23092 "The Port Range was not created. "
23093 "Diagnostics: Failure to send command to manager daemon.",
23094 "/omp?cmd=get_port_lists", response_data);
23098 "Internal error", __FUNCTION__, __LINE__,
23099 "An internal error occurred while creating a Port Range. "
23100 "It is unclear whether the Port Range has been created or not. "
23101 "Diagnostics: Failure to receive response from manager daemon.",
23102 "/omp?cmd=get_port_lists", response_data);
23106 "Internal error", __FUNCTION__, __LINE__,
23107 "An internal error occurred while creating a Port Range. "
23108 "It is unclear whether the Port Range has been created or not. "
23109 "Diagnostics: Internal Error.",
23110 "/omp?cmd=get_port_lists", response_data);
23113 html = response_from_entity (credentials, params, entity,
23114 (no_redirect && strcmp (no_redirect,
"0")),
23115 NULL,
"edit_port_list",
23116 NULL,
"edit_port_list",
23117 "Create Port Range", response_data);
23118 free_entity (entity);
23137 return get_one (
"port_list", credentials, params, extra_xml,
23138 "targets=\"1\" details=\"1\"", response_data);
23154 return get_port_list (credentials, params, NULL, response_data);
23171 return get_many (
"port_list", credentials, params, extra_xml, NULL,
23188 return get_port_lists (credentials, params, NULL, response_data);
23204 return new_port_list (credentials, params, NULL, response_data);
23221 return edit_resource (
"port_list", credentials, params, NULL, extra_xml,
23238 return edit_port_list (credentials, params, NULL, response_data);
23255 gchar *html, *response;
23256 const char *no_redirect, *port_list_id, *name, *comment;
23272 ret = ompf (credentials,
23276 "<modify_port_list port_list_id=\"%s\">"
23278 "<comment>%s</comment>"
23279 "</modify_port_list>",
23292 "Internal error", __FUNCTION__, __LINE__,
23293 "An internal error occurred while saving a Port List. "
23294 "The Port List was not saved. "
23295 "Diagnostics: Failure to send command to manager daemon.",
23296 "/omp?cmd=get_port_lists", response_data);
23300 "Internal error", __FUNCTION__, __LINE__,
23301 "An internal error occurred while saving a Port List. "
23302 "It is unclear whether the Port List has been saved or not. "
23303 "Diagnostics: Failure to receive response from manager daemon.",
23304 "/omp?cmd=get_port_lists", response_data);
23308 "Internal error", __FUNCTION__, __LINE__,
23309 "An internal error occurred while saving a Port List. "
23310 "It is unclear whether the Port List has been saved or not. "
23311 "Diagnostics: Internal Error.",
23312 "/omp?cmd=get_port_lists", response_data);
23315 html = response_from_entity (credentials, params, entity,
23316 (no_redirect && strcmp (no_redirect,
"0")),
23317 NULL,
"get_port_lists",
23318 NULL,
"edit_port_list",
23319 "Save Port List", response_data);
23320 free_entity (entity);
23338 return delete_resource (
"port_list", credentials, params, 0,
"get_port_lists",
23355 return delete_resource (
"port_list", credentials, params, 1,
"get_trash",
23373 "edit_port_list", response_data);
23389 const char *no_redirect;
23390 gchar *command, *html, *response;
23400 command = g_strdup_printf (
"<create_port_list>"
23402 "</create_port_list>",
23404 ret = omp (credentials, &response, &entity, response_data, command);
23414 "Internal error", __FUNCTION__, __LINE__,
23415 "An internal error occurred while importing a port_list. "
23416 "The schedule remains the same. "
23417 "Diagnostics: Failure to send command to manager daemon.",
23418 "/omp?cmd=get_port_lists",
23423 "Internal error", __FUNCTION__, __LINE__,
23424 "An internal error occurred while importing a port_list. "
23425 "It is unclear whether the schedule has been saved or not. "
23426 "Diagnostics: Failure to receive response from manager daemon.",
23427 "/omp?cmd=get_port_lists",
23432 "Internal error", __FUNCTION__, __LINE__,
23433 "An internal error occurred while importing a port_list. "
23434 "It is unclear whether the schedule has been saved or not. "
23435 "Diagnostics: Internal Error.",
23436 "/omp?cmd=get_port_lists",
23442 html = response_from_entity (credentials, params, entity,
23443 (no_redirect && strcmp (no_redirect,
"0")),
23444 NULL,
"get_port_lists",
23445 NULL,
"new_port_list",
23446 "Import Port List", response_data);
23447 free_entity (entity);
23470 xml = g_string_new (
"<new_role>");
23472 g_string_append (xml, extra_xml);
23473 g_string_append (xml,
"</new_role>");
23474 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
23491 return new_role (credentials, params, NULL, response_data);
23543 const char *no_redirect, *name, *comment, *
users;
23557 switch (ompf (credentials,
23563 "<comment>%s</comment>"
23564 "<users>%s</users>"
23576 "Internal error", __FUNCTION__, __LINE__,
23577 "An internal error occurred while creating a new role. "
23578 "No new role was created. "
23579 "Diagnostics: Failure to send command to manager daemon.",
23580 "/omp?cmd=get_targets", response_data);
23584 "Internal error", __FUNCTION__, __LINE__,
23585 "An internal error occurred while creating a new role. "
23586 "It is unclear whether the role has been created or not. "
23587 "Diagnostics: Failure to receive response from manager daemon.",
23588 "/omp?cmd=get_roles", response_data);
23592 "Internal error", __FUNCTION__, __LINE__,
23593 "An internal error occurred while creating a new role. "
23594 "It is unclear whether the role has been created or not. "
23595 "Diagnostics: Internal Error.",
23596 "/omp?cmd=get_roles", response_data);
23599 if (entity_attribute (entity,
"id"))
23600 params_add (params,
"role_id", entity_attribute (entity,
"id"));
23601 ret = response_from_entity (credentials, params, entity,
23602 (no_redirect && strcmp (no_redirect,
"0")),
23605 "Create Role", response_data);
23606 free_entity (entity);
23628 extra = g_string_new (
"");
23637 switch (ompf (credentials, &response, &entity, response_data,
23639 " filter=\"rows=-1 subject_type=role and subject_uuid=%s\"/>",
23648 "Internal error", __FUNCTION__, __LINE__,
23649 "An internal error occurred getting the permission list. "
23650 "Diagnostics: Failure to send command to manager daemon.",
23651 "/omp?cmd=get_roles", response_data);
23655 "Internal error", __FUNCTION__, __LINE__,
23656 "An internal error occurred getting the permission list. "
23657 "Diagnostics: Failure to receive response from manager daemon.",
23658 "/omp?cmd=get_roles", response_data);
23662 "Internal error", __FUNCTION__, __LINE__,
23663 "An internal error occurred getting the permission list. "
23664 "Diagnostics: Internal Error.",
23665 "/omp?cmd=get_roles", response_data);
23668 g_string_append (extra, response);
23670 free_entity (entity);
23681 switch (ompf (credentials, &response, &entity, response_data,
23683 " filter=\"rows=-1 owner=%s\"/>",
23692 "Internal error", __FUNCTION__, __LINE__,
23693 "An internal error occurred getting the group list. "
23694 "Diagnostics: Failure to send command to manager daemon.",
23695 "/omp?cmd=get_roles", response_data);
23699 "Internal error", __FUNCTION__, __LINE__,
23700 "An internal error occurred getting the group list. "
23701 "Diagnostics: Failure to receive response from manager daemon.",
23702 "/omp?cmd=get_roles", response_data);
23706 "Internal error", __FUNCTION__, __LINE__,
23707 "An internal error occurred getting the group list. "
23708 "Diagnostics: Internal Error.",
23709 "/omp?cmd=get_roles", response_data);
23712 g_string_append (extra, response);
23714 free_entity (entity);
23719 g_string_append (extra, extra_xml);
23720 html =
edit_resource (
"role", credentials, params, NULL, extra->str,
23722 g_string_free (extra, TRUE);
23739 return edit_role (credentials, params, NULL, response_data);
23756 return get_one (
"role", credentials, params, extra_xml, NULL, response_data);
23772 return get_role (credentials, params, NULL, response_data);
23789 return get_many (
"role", credentials, params, extra_xml, NULL, response_data);
23805 return get_roles (credentials, params, NULL, response_data);
23822 enum content_type * content_type,
char **content_disposition,
23826 content_disposition, content_length, response_data);
23844 enum content_type * content_type,
char **content_disposition,
23847 return export_many (
"role", credentials, params, content_type,
23848 content_disposition, content_length, response_data);
23865 gchar *html, *response;
23866 const char *no_redirect, *role_id, *name, *comment, *
users;
23884 ret = ompf (credentials,
23888 "<modify_role role_id=\"%s\">"
23890 "<comment>%s</comment>"
23891 "<users>%s</users>"
23906 "Internal error", __FUNCTION__, __LINE__,
23907 "An internal error occurred while saving a role. "
23908 "The role was not saved. "
23909 "Diagnostics: Failure to send command to manager daemon.",
23910 "/omp?cmd=get_roles", response_data);
23914 "Internal error", __FUNCTION__, __LINE__,
23915 "An internal error occurred while saving a role. "
23916 "It is unclear whether the role has been saved or not. "
23917 "Diagnostics: Failure to receive response from manager daemon.",
23918 "/omp?cmd=get_roles", response_data);
23922 "Internal error", __FUNCTION__, __LINE__,
23923 "An internal error occurred while saving a role. "
23924 "It is unclear whether the role has been saved or not. "
23925 "Diagnostics: Internal Error.",
23926 "/omp?cmd=get_roles", response_data);
23929 html = response_from_entity (credentials, params, entity,
23930 (no_redirect && strcmp (no_redirect,
"0")),
23933 "Save Role", response_data);
23934 free_entity (entity);
23957 openvas_connection_t connection;
23958 gchar *html, *response;
23961 gchar current_timestamp[30];
23971 "Internal error", __FUNCTION__, __LINE__,
23972 "An internal error occurred while getting the feed list. "
23973 "The current list of feeds is not available. "
23974 "Diagnostics: Failure to connect to manager daemon.",
23975 "/omp?cmd=get_tasks", response_data);
23978 return xsl_transform_omp (credentials,
23980 (
"<gsad_msg status_text=\"Access refused.\""
23981 " operation=\"List Feeds\">"
23982 "Only users given the Administrator role"
23983 " may access Feed Administration."
23988 if (openvas_connection_sendf (&connection,
23994 openvas_connection_close (&connection);
23997 "Internal error", __FUNCTION__, __LINE__,
23998 "An internal error occurred while getting the feed list. "
23999 "The current list of feeds is not available. "
24000 "Diagnostics: Failure to send command to manager daemon.",
24001 "/omp?cmd=get_tasks", response_data);
24004 if (read_entity_and_text_c (&connection, &entity, &text))
24006 openvas_connection_close (&connection);
24009 "Internal error", __FUNCTION__, __LINE__,
24010 "An internal error occurred while getting the feed. "
24011 "The current list of feeds is not available. "
24012 "Diagnostics: Failure to receive response from manager daemon.",
24013 "/omp?cmd=get_tasks", response_data);
24017 tm = gmtime (&now);
24019 || (strftime (current_timestamp,
24021 "%Y-%m-%dT%H:%M:%S",
24025 current_timestamp[0] =
'\0';
24028 response = g_strdup_printf (
"<get_feeds>"
24030 "<current_time_utc>%s</current_time_utc>"
24033 current_timestamp);
24037 openvas_connection_close (&connection);
24038 return xsl_transform_omp (credentials, response, response_data);
24055 const char *sync_cmd,
const char *action,
24056 const char *feed_name,
24059 const char *no_redirect;
24062 openvas_connection_t connection;
24074 msg = g_strdup_printf
24075 (
"An internal error occurred while synchronizing with %s. "
24076 "Feed synchronization is currently not available. "
24077 "Diagnostics: Failure to connect to manager daemon.",
24080 "Internal error", __FUNCTION__, __LINE__,
24081 msg,
"/omp?cmd=get_tasks", response_data);
24086 return xsl_transform_omp (credentials,
24088 (
"<gsad_msg status_text=\"Access refused.\""
24089 " operation=\"%s\">"
24090 "Only users given the Administrator role"
24091 " may access Feed Administration."
24097 if (openvas_connection_sendf (&connection,
24102 openvas_connection_close (&connection);
24105 msg = g_strdup_printf
24106 (
"An internal error occurred while synchronizing with %s. "
24107 "Feed synchronization is currently not available. "
24108 "Diagnostics: Failure to send command to manager daemon.",
24111 "Internal error", __FUNCTION__, __LINE__,
24112 msg,
"/omp?cmd=get_tasks", response_data);
24117 if (read_entity_and_text_c (&connection, &entity, &text))
24119 openvas_connection_close (&connection);
24122 msg = g_strdup_printf
24123 (
"An internal error occurred while synchronizing with %s. "
24124 "Feed synchronization is currently not available. "
24125 "Diagnostics: Failure to receive response from manager daemon.",
24128 "Internal error", __FUNCTION__, __LINE__,
24129 msg,
"/omp?cmd=get_tasks", response_data);
24134 openvas_connection_close (&connection);
24135 html = response_from_entity (credentials, params, entity,
24136 (no_redirect && strcmp (no_redirect,
"0")),
24139 action, response_data);
24157 return sync_feed (credentials, params,
24158 "sync_feed",
"Synchronize Feed",
"the NVT feed",
24175 return sync_feed (credentials, params,
24176 "sync_scap",
"Synchronize Feed",
"the SCAP feed",
24193 return sync_feed (credentials, params,
24194 "sync_cert",
"Synchronize CERT Feed",
"the CERT feed",
24215 return get_one (
"filter", credentials, params, extra_xml,
"alerts=\"1\"",
24232 return get_filter (credentials, params, NULL, response_data);
24249 return get_many (
"filter", credentials, params, extra_xml, NULL,
24266 return get_filters (credentials, params, NULL, response_data);
24284 xml = g_string_new (
"<new_filter>");
24286 g_string_append (xml, extra_xml);
24287 g_string_append (xml,
"</new_filter>");
24288 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
24305 gchar *html, *response;
24306 const char *no_redirect, *name, *comment, *term, *type;
24313 type =
params_value (params,
"optional_resource_type");
24320 switch (ompf (credentials,
24326 "<comment>%s</comment>"
24329 "</create_filter>",
24341 "Internal error", __FUNCTION__, __LINE__,
24342 "An internal error occurred while creating a new alert. "
24343 "No new alert was created. "
24344 "Diagnostics: Failure to send command to manager daemon.",
24345 "/omp?cmd=get_alerts", response_data);
24349 "Internal error", __FUNCTION__, __LINE__,
24350 "An internal error occurred while creating a new alert. "
24351 "It is unclear whether the alert has been created or not. "
24352 "Diagnostics: Failure to receive response from manager daemon.",
24353 "/omp?cmd=get_alerts", response_data);
24357 "Internal error", __FUNCTION__, __LINE__,
24358 "An internal error occurred while creating a new alert. "
24359 "It is unclear whether the alert has been created or not. "
24360 "Diagnostics: Internal Error.",
24361 "/omp?cmd=get_alerts", response_data);
24364 if (omp_success (entity))
24366 const char *filter_id;
24368 filter_id = entity_attribute (entity,
"id");
24369 if (filter_id && strlen (filter_id))
24372 param =
params_add (params,
"filt_id", filter_id);
24378 if (entity_attribute (entity,
"id"))
24379 params_add (params,
"filter_id", entity_attribute (entity,
"id"));
24380 html = response_from_entity (credentials, params, entity,
24381 (no_redirect && strcmp (no_redirect,
"0")),
24382 NULL,
"get_filters",
24383 NULL,
"new_filter",
24384 "Create Filter", response_data);
24385 free_entity (entity);
24403 return delete_resource (
"filter", credentials, params, 1,
"get_trash",
24425 if (
id && id->
value && filt_id && filt_id->
value
24426 && (strcmp (id->
value, filt_id->
value) == 0))
24428 filt_id->
value = NULL;
24431 if (
id && id->
value)
24437 g_tree_foreach (credentials->
last_filt_ids, (GTraverseFunc)find_by_value,
24439 if (find.
keys != NULL)
24441 list = g_list_first (find.
keys);
24443 while (list != NULL)
24445 g_debug (
"%s removing filter from last filter ids for %s\n",
24446 __FUNCTION__, (
char *)list->data);
24448 list = g_list_next (find.
keys);
24455 return delete_resource (
"filter", credentials, params, 0,
"get_filters",
24473 return edit_resource (
"filter", credentials, params, NULL, extra_xml,
24490 return edit_filter (credentials, params, NULL, response_data);
24507 enum content_type * content_type,
char **content_disposition,
24511 content_disposition, content_length, response_data);
24529 enum content_type * content_type,
char **content_disposition,
24532 return export_many (
"filter", credentials, params, content_type,
24533 content_disposition, content_length, response_data);
24549 return new_filter (credentials, params, NULL, response_data);
24565 openvas_connection_t connection;
24567 gchar *html, *response;
24568 const char *no_redirect, *filter_id, *name, *comment, *term, *type;
24575 type =
params_value (params,
"optional_resource_type");
24595 "Internal error", __FUNCTION__, __LINE__,
24596 "An internal error occurred while saving a filter. "
24597 "The filter was not saved. "
24598 "Diagnostics: Failure to connect to manager daemon.",
24599 "/omp?cmd=get_filters", response_data);
24607 ret = openvas_connection_sendf_xml (&connection,
24608 "<modify_filter filter_id=\"%s\">"
24610 "<comment>%s</comment>"
24613 "</modify_filter>",
24622 openvas_connection_close (&connection);
24625 "Internal error", __FUNCTION__, __LINE__,
24626 "An internal error occurred while modifying a filter. "
24627 "The filter was not modified. "
24628 "Diagnostics: Failure to send command to manager daemon.",
24629 "/omp?cmd=get_filters", response_data);
24633 if (read_entity_and_text_c (&connection, &entity, &response))
24635 openvas_connection_close (&connection);
24638 "Internal error", __FUNCTION__, __LINE__,
24639 "An internal error occurred while modifying a filter. "
24640 "It is unclear whether the filter has been modified or not. "
24641 "Diagnostics: Failure to receive response from manager daemon.",
24642 "/omp?cmd=get_filters", response_data);
24647 openvas_connection_close (&connection);
24651 html = response_from_entity (credentials, params, entity,
24652 (no_redirect && strcmp (no_redirect,
"0")),
24653 NULL,
"get_filters",
24654 NULL,
"edit_filter",
24655 "Save Filter", response_data);
24657 free_entity (entity);
24680 "tasks=\"1\"", extra_xml, response_data);
24696 return edit_schedule (credentials, params, NULL, response_data);
24713 enum content_type * content_type,
24714 char **content_disposition, gsize *content_length,
24717 return export_resource (
"schedule", credentials, params, content_type,
24718 content_disposition, content_length, response_data);
24735 enum content_type * content_type,
24736 char **content_disposition, gsize *content_length,
24739 return export_many (
"schedule", credentials, params, content_type,
24740 content_disposition, content_length, response_data);
24758 const char *no_redirect, *schedule_id, *name, *comment;
24759 const char *hour, *minute, *day_of_month, *month, *year, *timezone;
24760 const char *period, *period_unit, *duration, *duration_unit;
24771 duration_unit =
params_value (params,
"duration_unit");
24794 switch (ompf (credentials,
24798 "<modify_schedule schedule_id=\"%s\">"
24800 "<comment>%s</comment>"
24803 "<minute>%s</minute>"
24804 "<day_of_month>%s</day_of_month>"
24805 "<month>%s</month>"
24808 "<timezone>%s</timezone>"
24817 "</modify_schedule>",
24820 comment ? comment :
"",
24827 (strcmp (period_unit,
"")
24831 (strcmp (duration_unit,
"")
24842 "Internal error", __FUNCTION__, __LINE__,
24843 "An internal error occurred while saving a schedule. "
24844 "The schedule remains the same. "
24845 "Diagnostics: Failure to send command to manager daemon.",
24846 "/omp?cmd=get_schedules", response_data);
24850 "Internal error", __FUNCTION__, __LINE__,
24851 "An internal error occurred while saving a schedule. "
24852 "It is unclear whether the schedule has been saved or not. "
24853 "Diagnostics: Failure to receive response from manager daemon.",
24854 "/omp?cmd=get_schedules", response_data);
24858 "Internal error", __FUNCTION__, __LINE__,
24859 "An internal error occurred while saving a schedule. "
24860 "It is unclear whether the schedule has been saved or not. "
24861 "Diagnostics: Internal Error.",
24862 "/omp?cmd=get_schedules", response_data);
24865 ret = response_from_entity (credentials, params, entity,
24866 (no_redirect && strcmp (no_redirect,
"0")),
24867 NULL,
"get_schedules",
24868 NULL,
"edit_schedule",
24869 "Save Schedule", response_data);
24870 free_entity (entity);
24894 xml = g_string_new (
"<new_user>");
24896 g_string_append (xml, extra_xml);
24905 switch (omp (credentials, &response, &entity, response_data,
24906 "<describe_auth/>"))
24914 "Internal error", __FUNCTION__, __LINE__,
24915 "An internal error occurred getting the auth list. "
24916 "No new user was created. "
24917 "Diagnostics: Failure to send command to manager daemon.",
24918 "/omp?cmd=get_users", response_data);
24922 "Internal error", __FUNCTION__, __LINE__,
24923 "An internal error occurred getting the auth list. "
24924 "No new user was created. "
24925 "Diagnostics: Failure to receive response from manager daemon.",
24926 "/omp?cmd=get_users", response_data);
24930 "Internal error", __FUNCTION__, __LINE__,
24931 "An internal error occurred getting the auth list. "
24932 "No new user was created. "
24933 "Diagnostics: Internal Error.",
24934 "/omp?cmd=get_users", response_data);
24937 g_string_append (xml, response);
24939 free_entity (entity);
24950 switch (omp (credentials, &response, &entity, response_data,
24959 "Internal error", __FUNCTION__, __LINE__,
24960 "An internal error occurred getting the group list. "
24961 "No new user was created. "
24962 "Diagnostics: Failure to send command to manager daemon.",
24963 "/omp?cmd=get_users", response_data);
24967 "Internal error", __FUNCTION__, __LINE__,
24968 "An internal error occurred getting the group list. "
24969 "No new user was created. "
24970 "Diagnostics: Failure to receive response from manager daemon.",
24971 "/omp?cmd=get_users", response_data);
24975 "Internal error", __FUNCTION__, __LINE__,
24976 "An internal error occurred getting the group list. "
24977 "No new user was created. "
24978 "Diagnostics: Internal Error.",
24979 "/omp?cmd=get_users", response_data);
24982 g_string_append (xml, response);
24984 free_entity (entity);
24995 switch (omp (credentials, &response, &entity, response_data,
25004 "Internal error", __FUNCTION__, __LINE__,
25005 "An internal error occurred getting the role list. "
25006 "No new user was created. "
25007 "Diagnostics: Failure to send command to manager daemon.",
25008 "/omp?cmd=get_users", response_data);
25012 "Internal error", __FUNCTION__, __LINE__,
25013 "An internal error occurred getting the role list. "
25014 "No new user was created. "
25015 "Diagnostics: Failure to receive response from manager daemon.",
25016 "/omp?cmd=get_users", response_data);
25020 "Internal error", __FUNCTION__, __LINE__,
25021 "An internal error occurred getting the role list. "
25022 "No new user was created. "
25023 "Diagnostics: Internal Error.",
25024 "/omp?cmd=get_users", response_data);
25027 g_string_append (xml, response);
25029 free_entity (entity);
25033 g_string_append (xml,
"</new_user>");
25034 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
25051 return new_user (credentials, params, NULL, response_data);
25086 gchar *response = NULL;
25087 entity_t entity = NULL;
25091 switch (omp (credentials, &response, &entity, response_data,
25092 "<get_users filter=\"first=1 rows=-1\"/>"))
25100 "Internal error", __FUNCTION__, __LINE__,
25101 "An internal error occurred getting the user list. "
25102 "Diagnostics: Failure to send command to manager daemon.",
25103 "/omp?cmd=get_users", response_data);
25107 "Internal error", __FUNCTION__, __LINE__,
25108 "An internal error occurred getting the user list. "
25109 "Diagnostics: Failure to receive response from manager daemon.",
25110 "/omp?cmd=get_users", response_data);
25114 "Internal error", __FUNCTION__, __LINE__,
25115 "An internal error occurred getting the user list. "
25116 "Diagnostics: Internal Error.",
25117 "/omp?cmd=get_users", response_data);
25121 xml = g_string_new (
"<delete_user>");
25123 g_string_append (xml, extra_xml);
25126 g_string_append (xml, response);
25127 free_entity (entity);
25131 g_string_append (xml, extra_xml);
25133 g_string_append (xml,
"</delete_user>");
25134 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
25151 return delete_user_confirm (credentials, params, NULL, response_data);
25171 extra = g_string_new (
"");
25173 g_string_append (extra, extra_xml);
25181 switch (omp (credentials, &response, &entity, response_data,
25182 "<describe_auth/>"))
25190 "Internal error", __FUNCTION__, __LINE__,
25191 "An internal error occurred getting the auth list. "
25192 "Diagnostics: Failure to send command to manager daemon.",
25193 "/omp?cmd=get_users", response_data);
25197 "Internal error", __FUNCTION__, __LINE__,
25198 "An internal error occurred getting the auth list. "
25199 "Diagnostics: Failure to receive response from manager daemon.",
25200 "/omp?cmd=get_users", response_data);
25204 "Internal error", __FUNCTION__, __LINE__,
25205 "An internal error occurred getting the auth list. "
25206 "Diagnostics: Internal Error.",
25207 "/omp?cmd=get_users", response_data);
25210 g_string_append (extra, response);
25212 free_entity (entity);
25215 html =
get_one (
"user", credentials, params, extra->str, NULL, response_data);
25216 g_string_free (extra, TRUE);
25233 return get_user (credentials, params, NULL, response_data);
25253 extra = g_string_new (
"");
25261 switch (omp (credentials, &response, &entity, response_data,
25262 "<describe_auth/>"))
25270 "Internal error", __FUNCTION__, __LINE__,
25271 "An internal error occurred getting the auth list. "
25272 "Diagnostics: Failure to send command to manager daemon.",
25273 "/omp?cmd=get_users", response_data);
25277 "Internal error", __FUNCTION__, __LINE__,
25278 "An internal error occurred getting the auth list. "
25279 "Diagnostics: Failure to receive response from manager daemon.",
25280 "/omp?cmd=get_users", response_data);
25284 "Internal error", __FUNCTION__, __LINE__,
25285 "An internal error occurred getting the auth list. "
25286 "Diagnostics: Internal Error.",
25287 "/omp?cmd=get_users", response_data);
25290 g_string_append (extra, response);
25292 free_entity (entity);
25296 g_string_append (extra, extra_xml);
25297 html = get_many (
"user", credentials, params, extra->str, NULL,
25299 g_string_free (extra, TRUE);
25316 return get_users (credentials, params, NULL, response_data);
25332 const char *no_redirect;
25333 const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
25334 const char *auth_method;
25337 GString *group_elements, *role_elements, *string;
25338 gchar *buf, *response, *html;
25359 string = g_string_new (
"<create_user>");
25360 buf = g_markup_printf_escaped (
"<name>%s</name>"
25361 "<password>%s</password>",
25365 g_string_append (
string, buf);
25368 group_elements = g_string_new (
"<groups>");
25383 if (param->
value && strcmp (param->
value,
"--"))
25384 g_string_append_printf (group_elements,
25385 "<group id=\"%s\"/>",
25389 g_string_append (
string, group_elements->str);
25390 g_string_free (group_elements, TRUE);
25391 g_string_append (
string,
"</groups>");
25393 role_elements = g_string_new (
"");
25408 if (param->
value && strcmp (param->
value,
"--"))
25409 g_string_append_printf (role_elements,
25410 "<role id=\"%s\"/>",
25414 g_string_append (
string, role_elements->str);
25415 g_string_free (role_elements, TRUE);
25417 buf = g_markup_printf_escaped (
"<hosts allow=\"%s\">%s</hosts>"
25418 "<ifaces allow=\"%s\">%s</ifaces>",
25419 hosts_allow, hosts, ifaces_allow, ifaces);
25420 g_string_append (
string, buf);
25422 if (auth_method && !strcmp (auth_method,
"1"))
25424 (
string,
"<sources><source>ldap_connect</source></sources>");
25425 else if (auth_method && !strcmp (auth_method,
"2"))
25427 (
string,
"<sources><source>radius_connect</source></sources>");
25428 g_string_append (
string,
"</create_user>");
25430 buf = g_string_free (
string, FALSE);
25434 ret = omp (credentials, &response, &entity, response_data, buf);
25444 "Internal error", __FUNCTION__, __LINE__,
25445 "An internal error occurred while creating a new user. "
25446 "No new user was created. "
25447 "Diagnostics: Failure to send command to manager daemon.",
25448 "/omp?cmd=get_users", response_data);
25452 "Internal error", __FUNCTION__, __LINE__,
25453 "An internal error occurred while creating a new user. "
25454 "It is unclear whether the user has been created or not. "
25455 "Diagnostics: Failure to receive response from manager daemon.",
25456 "/omp?cmd=get_users", response_data);
25460 "Internal error", __FUNCTION__, __LINE__,
25461 "An internal error occurred while creating a new user. "
25462 "It is unclear whether the user has been created or not. "
25463 "Diagnostics: Internal Error.",
25464 "/omp?cmd=get_users", response_data);
25467 if (entity_attribute (entity,
"id"))
25468 params_add (params,
"user_id", entity_attribute (entity,
"id"));
25469 html = response_from_entity (credentials, params, entity,
25470 (no_redirect && strcmp (no_redirect,
"0")),
25473 "Create User", response_data);
25474 free_entity (entity);
25496 extra = g_string_new (
"");
25504 switch (omp (credentials, &response, &entity, response_data,
25505 "<describe_auth/>"))
25513 "Internal error", __FUNCTION__, __LINE__,
25514 "An internal error occurred getting the auth list. "
25515 "Diagnostics: Failure to send command to manager daemon.",
25516 "/omp?cmd=get_users", response_data);
25520 "Internal error", __FUNCTION__, __LINE__,
25521 "An internal error occurred getting the auth list. "
25522 "Diagnostics: Failure to receive response from manager daemon.",
25523 "/omp?cmd=get_users", response_data);
25527 "Internal error", __FUNCTION__, __LINE__,
25528 "An internal error occurred getting the auth list. "
25529 "Diagnostics: Internal Error.",
25530 "/omp?cmd=get_users", response_data);
25533 g_string_append (extra, response);
25535 free_entity (entity);
25546 switch (omp (credentials, &response, &entity, response_data,
25555 "Internal error", __FUNCTION__, __LINE__,
25556 "An internal error occurred getting the group list. "
25557 "Diagnostics: Failure to send command to manager daemon.",
25558 "/omp?cmd=get_users", response_data);
25562 "Internal error", __FUNCTION__, __LINE__,
25563 "An internal error occurred getting the group list. "
25564 "Diagnostics: Failure to receive response from manager daemon.",
25565 "/omp?cmd=get_users", response_data);
25569 "Internal error", __FUNCTION__, __LINE__,
25570 "An internal error occurred getting the group list. "
25571 "Diagnostics: Internal Error.",
25572 "/omp?cmd=get_users", response_data);
25575 g_string_append (extra, response);
25577 free_entity (entity);
25588 switch (omp (credentials, &response, &entity, response_data,
25597 "Internal error", __FUNCTION__, __LINE__,
25598 "An internal error occurred getting the role list. "
25599 "No new user was created. "
25600 "Diagnostics: Failure to send command to manager daemon.",
25601 "/omp?cmd=get_users", response_data);
25605 "Internal error", __FUNCTION__, __LINE__,
25606 "An internal error occurred getting the role list. "
25607 "No new user was created. "
25608 "Diagnostics: Failure to receive response from manager daemon.",
25609 "/omp?cmd=get_users", response_data);
25613 "Internal error", __FUNCTION__, __LINE__,
25614 "An internal error occurred getting the role list. "
25615 "No new user was created. "
25616 "Diagnostics: Internal Error.",
25617 "/omp?cmd=get_users", response_data);
25620 g_string_append (extra, response);
25622 free_entity (entity);
25627 g_string_append (extra, extra_xml);
25628 html =
edit_resource (
"user", credentials, params, NULL, extra->str,
25630 g_string_free (extra, TRUE);
25647 return edit_user (credentials, params, NULL, response_data);
25662 xml = g_string_new (
"");
25663 buf = g_markup_printf_escaped (
"<auth_settings name=\"%s\">", name);
25664 g_string_append (xml, buf);
25669 gchar * response = NULL;
25670 entity_t entity = NULL;
25672 switch (omp (credentials, &response, &entity, response_data,
25673 "<describe_auth/>"))
25681 "Internal error", __FUNCTION__, __LINE__,
25682 "An internal error occurred getting the auth list. "
25683 "Diagnostics: Failure to send command to manager daemon.",
25684 "/omp?cmd=get_users", response_data);
25688 "Internal error", __FUNCTION__, __LINE__,
25689 "An internal error occurred getting the auth list. "
25690 "Diagnostics: Failure to receive response from manager daemon.",
25691 "/omp?cmd=get_users", response_data);
25695 "Internal error", __FUNCTION__, __LINE__,
25696 "An internal error occurred getting the auth list. "
25697 "Diagnostics: Internal Error.",
25698 "/omp?cmd=get_users", response_data);
25702 g_string_append (xml, response);
25703 free_entity (entity);
25707 g_string_append (xml,
"</auth_settings>");
25709 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
25729 char ctime_now[200];
25731 const char* xml_flag;
25734 if (credentials->
token == NULL)
25744 xml =
login_xml (message, NULL, ctime_now, NULL, NULL, NULL);
25746 if (xml_flag && strcmp (xml_flag,
"0"))
25768 char **password_return,
char **modified_user,
25772 gchar *html, *response, *buf;
25773 const char *no_redirect;
25774 const char *user_id, *login, *old_login, *modify_password, *password;
25775 const char *hosts, *hosts_allow, *ifaces, *ifaces_allow;
25777 GString *command, *group_elements, *role_elements;
25779 const char *status;
25781 *password_return = NULL;
25782 *modified_user = NULL;
25795 modify_password =
params_value (params,
"modify_password");
25816 command = g_string_new (
"");
25817 buf = g_markup_printf_escaped (
"<modify_user user_id=\"%s\">"
25818 "<password modify=\"%s\">"
25823 g_string_append (command, buf);
25828 buf = g_markup_printf_escaped (
"<new_name>%s</new_name>",
25830 g_string_append (command, buf);
25834 buf = g_markup_printf_escaped (
"<hosts allow=\"%s\">%s</hosts>"
25835 "<ifaces allow=\"%s\">%s</ifaces>",
25836 hosts_allow, hosts, ifaces_allow, ifaces);
25837 g_string_append (command, buf);
25840 if (modify_password && !strcmp (modify_password,
"2"))
25841 g_string_append (command,
"<sources><source>ldap_connect</source></sources>");
25842 else if (modify_password && !strcmp (modify_password,
"3"))
25843 g_string_append (command,
"<sources><source>radius_connect</source></sources>");
25845 g_string_append (command,
"<sources><source>file</source></sources>");
25847 group_elements = g_string_new (
"<groups>");
25862 if (param->
value && strcmp (param->
value,
"--"))
25863 g_string_append_printf (group_elements,
25864 "<group id=\"%s\"/>",
25868 g_string_append (command, group_elements->str);
25869 g_string_free (group_elements, TRUE);
25870 g_string_append (command,
"</groups>");
25872 role_elements = g_string_new (
"");
25887 if (param->
value && strcmp (param->
value,
"--"))
25888 g_string_append_printf (role_elements,
25889 "<role id=\"%s\"/>",
25894 g_string_append_printf (role_elements,
"<role id=\"0\"/>");
25896 g_string_append (command, role_elements->str);
25897 g_string_free (role_elements, TRUE);
25899 g_string_append (command,
"</modify_user>");
25903 ret = omp (credentials,
25908 g_string_free (command, TRUE);
25912 status = entity_attribute (entity,
"status");
25913 if (status && (strlen (status) > 0) && (status[0] ==
'2'))
25916 = g_strdup (old_login ? old_login : credentials->
username);
25918 if (strcmp (modify_password,
"0")
25919 || (login && strcmp (old_login, login)))
25922 if (strcmp (modify_password,
"0")
25923 && strcmp (modify_password,
"2")
25924 && strcmp (modify_password,
"3")
25928 credentials->
password = g_strdup (password);
25929 *password_return = g_strdup (password);
25938 "Internal error", __FUNCTION__, __LINE__,
25939 "An internal error occurred while saving a user. "
25940 "The user was not saved. "
25941 "Diagnostics: Failure to send command to manager daemon.",
25942 "/omp?cmd=get_users", response_data);
25946 "Internal error", __FUNCTION__, __LINE__,
25947 "An internal error occurred while saving a user. "
25948 "It is unclear whether the user has been saved or not. "
25949 "Diagnostics: Failure to receive response from manager daemon.",
25950 "/omp?cmd=get_users", response_data);
25954 "Internal error", __FUNCTION__, __LINE__,
25955 "An internal error occurred while saving a user. "
25956 "It is unclear whether the user has been saved or not. "
25957 "Diagnostics: Internal Error.",
25958 "/omp?cmd=get_users", response_data);
25961 if (omp_success (entity)
25962 && (!strcmp (modify_password,
"2")
25963 || !strcmp (modify_password,
"3"))
25966 free_entity (entity);
25968 html = logout (credentials,
25969 "Authentication method changed."
25970 " Please login with LDAP password.",
25974 html = response_from_entity (credentials, params, entity,
25975 (no_redirect && strcmp (no_redirect,
"0")),
25978 "Save User", response_data);
25979 free_entity (entity);
25998 enum content_type * content_type,
char **content_disposition,
26002 content_disposition, content_length, response_data);
26020 enum content_type * content_type,
char **content_disposition,
26023 return export_many (
"user", credentials, params, content_type,
26024 content_disposition, content_length, response_data);
26032 const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
26033 const char *cvss_vector, *name;
26044 xml = g_string_new (
"<cvss_calculator>");
26047 if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
26049 char *vector = g_strdup_printf
26050 (
"AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c",
26051 *cvss_av, *cvss_ac, *cvss_au, *cvss_c, *cvss_i, *cvss_a);
26053 g_string_append_printf (xml,
26054 "<cvss_vector>%s</cvss_vector>"
26055 "<cvss_score>%.1f</cvss_score>",
26057 get_cvss_score_from_base_metrics (vector));
26059 g_string_append_printf
26061 "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>"
26062 "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>"
26063 "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
26064 *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a);
26068 else if (cvss_vector)
26070 double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
26072 g_string_append_printf (xml,
26073 "<cvss_vector>%s</cvss_vector>"
26074 "<cvss_score>%.1f</cvss_score>",
26078 if (cvss_score != -1.0)
26080 cvss_av = strstr (cvss_vector,
"AV:");
26081 cvss_ac = strstr (cvss_vector,
"/AC:");
26082 cvss_au = strstr (cvss_vector,
"/Au:");
26083 if (cvss_au == NULL)
26084 cvss_au = strstr (cvss_vector,
"/AU:");
26085 cvss_c = strstr (cvss_vector,
"/C:");
26086 cvss_i = strstr (cvss_vector,
"/I:");
26087 cvss_a = strstr (cvss_vector,
"/A:");
26089 if (cvss_av && cvss_ac && cvss_au && cvss_c
26090 && cvss_i && cvss_a)
26091 g_string_append_printf
26093 "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>"
26094 "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>"
26095 "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
26096 *(cvss_av + 3), *(cvss_ac + 4), *(cvss_au + 4),
26097 *(cvss_c + 3), *(cvss_i + 3), *(cvss_a + 3));
26100 else if (name && !strcmp (
"vector", name))
26102 g_string_append_printf (xml,
26103 "<cvss_score>%.1f</cvss_score>",
26107 g_string_append (xml,
"</cvss_calculator>");
26108 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
26134 if (credentials->
guest)
26140 xml = g_string_new (
"<dashboard>");
26141 g_string_append_printf (xml,
"<name>%s</name>", name);
26147 if (strcasecmp (name,
"") == 0
26148 || strcasecmp (name,
"Main") == 0
26149 || strcasecmp (name,
"SecInfo") == 0)
26151 ret = ompf (credentials,
26155 "<get_info type=\"cve\" info_id=\"--\"/>");
26163 g_string_free (xml, TRUE);
26166 "Internal error", __FUNCTION__, __LINE__,
26167 "An internal error occurred while "
26168 "testing SecInfo database availability. "
26169 "Diagnostics: Failure to send command to "
26171 "/omp?cmd=dashboard", response_data);
26173 g_string_free (xml, TRUE);
26176 "Internal error", __FUNCTION__, __LINE__,
26177 "An internal error occurred while "
26178 "testing SecInfo database availability. "
26179 "Diagnostics: Failure to receive response from "
26181 "/omp?cmd=dashboard", response_data);
26183 g_string_free (xml, TRUE);
26186 "Internal error", __FUNCTION__, __LINE__,
26187 "An internal error occurred while "
26188 "testing SecInfo database availability. "
26189 "Diagnostics: Internal Error.",
26190 "/omp?cmd=dashboard", response_data);
26192 g_string_append_printf (xml,
26193 "<secinfo_test>%s</secinfo_test>",
26196 free_entity (entity);
26199 if (strcasecmp (name,
"SecInfo") == 0)
26200 ret = ompf (credentials,
26204 "<get_filters filter=\"type=info or type= first=1 rows=-1\"/>");
26206 ret = ompf (credentials,
26210 "<get_filters filter=\"first=1 rows=-1\"/>");
26218 g_string_free (xml, TRUE);
26221 "Internal error", __FUNCTION__, __LINE__,
26222 "An internal error occurred while getting the "
26224 "Diagnostics: Failure to send command to "
26226 "/omp?cmd=dashboard", response_data);
26228 g_string_free (xml, TRUE);
26231 "Internal error", __FUNCTION__, __LINE__,
26232 "An internal error occurred while getting the "
26234 "Diagnostics: Failure to receive response from "
26236 "/omp?cmd=dashboard", response_data);
26238 g_string_free (xml, TRUE);
26241 "Internal error", __FUNCTION__, __LINE__,
26242 "An internal error occurred while getting the "
26244 "Diagnostics: Internal Error.",
26245 "/omp?cmd=dashboard", response_data);
26248 g_string_append (xml, response);
26250 free_entity (entity);
26252 g_string_append (xml,
"</dashboard>");
26253 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
26260 #define AUTH_CONF_SETTING(key, value) \
26261 "<auth_conf_setting>" \
26262 "<key>" key "</key>" \
26263 "<value>" value "</value>" \
26264 "</auth_conf_setting>"
26280 entity_t entity = NULL;
26281 char *html, *response = NULL, *truefalse;
26282 const char *no_redirect, *method;
26285 && (strcmp (
params_value (params,
"enable"),
"1") == 0))
26286 truefalse =
"true";
26288 truefalse =
"false";
26293 if (!strcmp (method,
"method:ldap_connect"))
26295 const char *ldaphost, *authdn, *certificate;
26302 if (
params_given (params,
"certificate") && strcmp (certificate,
""))
26306 ret = ompf (credentials, &response, &entity, response_data,
26308 "<group name=\"%s\">"
26314 "</modify_auth>", method, truefalse, ldaphost, authdn,
26319 ret = ompf (credentials, &response, &entity, response_data,
26321 "<group name=\"%s\">"
26326 "</modify_auth>", method, truefalse, ldaphost, authdn);
26328 else if (!strcmp (method,
"method:radius_connect"))
26330 const char *radiushost, *radiuskey;
26337 ret = ompf (credentials, &response, &entity, response_data,
26339 "<group name=\"%s\">"
26344 "</modify_auth>", method, truefalse, radiushost, radiuskey);
26347 return get_users (credentials, params,
26349 (
"Save Authentication Configuration"),
26360 "Internal error", __FUNCTION__, __LINE__,
26361 "An internal error occurred while saving the auth settings. "
26362 "The settings were not saved. "
26363 "Diagnostics: Failure to send command to manager daemon.",
26364 "/omp?cmd=get_users", response_data);
26368 "Internal error", __FUNCTION__, __LINE__,
26369 "An internal error occurred while saving the auth settings. "
26370 "It is unclear whether the settings have been saved or not. "
26371 "Diagnostics: Failure to receive response from manager daemon.",
26372 "/omp?cmd=get_users", response_data);
26376 "Internal error", __FUNCTION__, __LINE__,
26377 "An internal error occurred while saving the auth settings. "
26378 "It is unclear whether the settings have been saved or not. "
26379 "Diagnostics: Internal Error.",
26380 "/omp?cmd=get_users", response_data);
26383 html = response_from_entity (credentials, params, entity,
26384 (no_redirect && strcmp (no_redirect,
"0")),
26386 NULL,
"modify_auth",
26387 "Save Authentication Configuration",
26389 free_entity (entity);
26407 gchar **pref_id, gchar **pref_value,
26410 *pref_id = g_strdup (
params_value (params,
"chart_preference_id"));
26411 *pref_value = g_strdup (
params_value (params,
"chart_preference_value"));
26413 gchar* value_64 = g_base64_encode ((guchar*)*pref_value,
26414 strlen (*pref_value));
26419 if (*pref_id == NULL)
26422 return (
"<save_chart_preference_response"
26423 " status=\"400\" status_text=\"Invalid or missing name\"/>");
26425 if (*pref_value == NULL)
26428 return (
"<save_chart_preference_response"
26429 " status=\"400\" status_text=\"Invalid or missing value\"/>");
26434 ret = ompf (credentials, &response, &entity, response_data,
26435 "<modify_setting setting_id=\"%s\">"
26436 "<value>%s</value>"
26437 "</modify_setting>",
26438 *pref_id, value_64);
26448 "Internal error", __FUNCTION__, __LINE__,
26449 "An internal error occurred while saving settings. "
26450 "It is unclear whether all the settings were saved. "
26451 "Diagnostics: Failure to send command to manager daemon.",
26452 "/omp?cmd=get_my_settings", response_data);
26456 "Internal error", __FUNCTION__, __LINE__,
26457 "An internal error occurred while saving settings. "
26458 "It is unclear whether all the settings were saved. "
26459 "Diagnostics: Failure to receive response from manager daemon.",
26460 "/omp?cmd=get_my_settings", response_data);
26464 "Internal error", __FUNCTION__, __LINE__,
26465 "An internal error occurred while saving settings. "
26466 "It is unclear whether all the settings were saved. "
26467 "Diagnostics: Internal Error.",
26468 "/omp?cmd=get_my_settings", response_data);
26471 if (omp_success (entity))
26473 free_entity (entity);
26475 return (
"<save_chart_preference_response"
26476 " status=\"200\" status_text=\"OK\"/>");
26481 gchar* ret_response
26482 = g_strdup_printf(
"<save_chart_preference_response"
26483 " status=\"%s\" status_text=\"%s\"/>",
26484 entity_attribute (entity,
"status"),
26485 entity_attribute (entity,
"status_text"));
26486 free_entity (entity);
26488 return ret_response;
26510 openvas_connection_t connection;
26526 "Internal error", __FUNCTION__, __LINE__,
26527 "An internal error occurred while getting the wizard. "
26528 "Diagnostics: Failure to connect to manager daemon.",
26529 "/omp?cmd=get_tasks", response_data);
26536 "Internal error", __FUNCTION__, __LINE__,
26537 "An internal error occurred while getting the wizard. "
26538 "Given name was invalid",
26539 "/omp?cmd=get_tasks", response_data);
26542 xml = g_string_new (
"");
26543 g_string_append_printf (xml,
26545 extra_xml ? extra_xml :
"",
26549 if (openvas_connection_sendf_xml (&connection,
26550 "<run_wizard read_only=\"1\">"
26552 "<mode>init</mode>"
26557 g_string_free (xml, TRUE);
26558 openvas_connection_close (&connection);
26561 "Internal error", __FUNCTION__, __LINE__,
26562 "An internal error occurred while getting the wizard. "
26563 "Diagnostics: Failure to send command to manager daemon.",
26564 "/omp?cmd=get_tasks", response_data);
26567 if (read_string_c (&connection, &xml))
26569 g_string_free (xml, TRUE);
26570 openvas_connection_close (&connection);
26573 "Internal error", __FUNCTION__, __LINE__,
26574 "An internal error occurred while getting the"
26576 "Diagnostics: Failure to receive response from"
26577 " manager daemon.",
26578 "/omp?cmd=get_tasks", response_data);
26583 if (openvas_connection_sendf_xml (&connection,
26585 " setting_id=\"20f3034c-e709-11e1-87e7-406186ea4fc5\"/>")
26588 g_string_free (xml, TRUE);
26589 openvas_connection_close (&connection);
26592 "Internal error", __FUNCTION__, __LINE__,
26593 "An internal error occurred while getting the wizard. "
26594 "Diagnostics: Failure to send command to manager daemon.",
26595 "/omp?cmd=get_tasks", response_data);
26598 if (read_string_c (&connection, &xml))
26600 g_string_free (xml, TRUE);
26601 openvas_connection_close (&connection);
26604 "Internal error", __FUNCTION__, __LINE__,
26605 "An internal error occurred while the wizard. "
26606 "Diagnostics: Failure to receive response from manager daemon.",
26607 "/omp?cmd=get_tasks", response_data);
26612 g_string_append_printf (xml,
"</wizard>");
26613 openvas_connection_close (&connection);
26614 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
26631 return wizard (credentials, params, NULL, response_data);
26652 gchar *param_name, *response;
26667 "Internal error", __FUNCTION__, __LINE__,
26668 "An internal error occurred while trying to start a wizard. "
26669 "Diagnostics: Required parameter 'get_name' was NULL.",
26670 "/omp?cmd=get_tasks", response_data);
26673 run = g_string_new (
"<run_wizard read_only=\"1\">");
26675 g_string_append_printf (run,
26685 xml_string_append (run,
26688 "<value>%s</value>"
26694 g_string_append (run,
"</params></run_wizard>");
26698 ret = omp (credentials, &response, &entity, response_data, run->str);
26699 g_string_free (run, TRUE);
26708 "Internal error", __FUNCTION__, __LINE__,
26709 "An internal error occurred while running a wizard. "
26710 "The wizard did not start. "
26711 "Diagnostics: Failure to send command to manager daemon.",
26712 "/omp?cmd=get_tasks", response_data);
26716 "Internal error", __FUNCTION__, __LINE__,
26717 "An internal error occurred while running a wizard. "
26718 "It is unclear whether the wizard started or not. "
26719 "Diagnostics: Failure to receive response from manager daemon.",
26720 "/omp?cmd=get_tasks", response_data);
26724 "Internal error", __FUNCTION__, __LINE__,
26725 "An internal error occurred while running a wizard. "
26726 "It is unclear whether the wizard started or not. "
26727 "Diagnostics: Internal Error.",
26728 "/omp?cmd=get_tasks", response_data);
26731 wizard_xml = g_strdup_printf (
"<wizard><%s/>%s%s</wizard>",
26733 extra_xml ? extra_xml :
"",
26736 return xsl_transform_omp (credentials, wizard_xml, response_data);
26752 return wizard_get (credentials, params, NULL, response_data);
26769 enum content_type *content_type,
26770 char **content_disposition, gsize *content_length,
26773 GString *bulk_string;
26774 const char *type, *subtype, *action;
26785 "Internal error", __FUNCTION__, __LINE__,
26786 "An internal error occurred while performing a bulk action. "
26787 "Diagnostics: Required parameter 'resource_type' was NULL.",
26788 "/omp?cmd=get_tasks", response_data);
26790 if (strcmp (type,
"info") == 0)
26793 if (subtype == NULL)
26797 "Internal error", __FUNCTION__, __LINE__,
26798 "An internal error occurred while performing a bulk action. "
26799 "Diagnostics: Required parameter 'info_type' was NULL.",
26800 "/omp?cmd=get_tasks", response_data);
26818 "Internal error", __FUNCTION__, __LINE__,
26819 "An internal error occurred while performing a bulk action. "
26820 "Diagnostics: Could not determine the action.",
26821 "/omp?cmd=get_tasks", response_data);
26824 if (strcmp (action,
"create") == 0)
26827 && strcmp (
params_value (params,
"bulk_select"),
"1") == 0)
26829 bulk_string = g_string_new (
"first=1 rows=-1");
26836 xml_string_append (bulk_string,
26842 && strcmp (
params_value (params,
"bulk_select"),
"2") == 0)
26844 bulk_string = g_string_new (
"first=1 rows=-1 ");
26845 g_string_append (bulk_string,
params_value (params,
"filter") ? :
"");
26849 bulk_string = g_string_new (
params_value (params,
"filter") ? :
"");
26851 param =
params_add (params,
"hosts_filter", bulk_string->str);
26854 g_string_free (bulk_string, TRUE);
26856 return new_target (credentials, params, NULL, response_data);
26859 if (strcmp (action,
"export") == 0)
26862 && strcmp (
params_value (params,
"bulk_select"),
"1") == 0)
26865 = g_string_new (
"first=1 rows=-1 uuid=");
26872 xml_string_append (bulk_string,
26878 && strcmp (
params_value (params,
"bulk_select"),
"2") == 0)
26881 = g_string_new (
"first=1 rows=-1 ");
26882 g_string_append (bulk_string,
params_value (params,
"filter") ? :
"");
26887 = g_string_new (
params_value (params,
"filter") ? :
"");
26889 params_add (params,
"filter", g_string_free (bulk_string, FALSE));
26891 return export_many (type, credentials, params, content_type,
26892 content_disposition, content_length, response_data);
26895 bulk_string = g_string_new (
"<process_bulk>");
26897 g_string_append_printf (bulk_string,
26899 "<action>%s</action>",
26903 g_string_append (bulk_string,
"<selections>");
26906 && strcmp (
params_value (params,
"bulk_select"),
"2") == 0)
26912 ret = ompf (credentials, &response, &entity, response_data,
26913 "<get_%ss filter=\"first=1 rows=-1 %s\"/>",
26919 free_entity (entity);
26921 g_string_free (bulk_string, TRUE);
26931 "Internal error", __FUNCTION__, __LINE__,
26932 "An internal error occurred while getting a"
26933 " resources list. "
26934 "Diagnostics: Failure to send command to"
26935 " manager daemon.",
26936 "/omp?cmd=get_my_settings", response_data);
26940 "Internal error", __FUNCTION__, __LINE__,
26941 "An internal error occurred while getting a"
26942 " resources list. "
26943 "Diagnostics: Failure to receive response from"
26944 " manager daemon.",
26945 "/omp?cmd=get_my_settings", response_data);
26949 "Internal error", __FUNCTION__, __LINE__,
26950 "An internal error occurred while getting a"
26951 " resources list. "
26952 "Diagnostics: Internal Error.",
26953 "/omp?cmd=get_my_settings", response_data);
26956 entities_t entities = entity->entities;
26957 entity_t child_entity;
26959 while ((child_entity = first_entity (entities)))
26961 if (strcmp (entity_name (child_entity), type) == 0)
26963 const char *resource_id
26964 = entity_attribute (child_entity,
"id");
26967 xml_string_append (bulk_string,
26968 "<selection id=\"%s\" />",
26971 entities = next_entities (entities);
26981 xml_string_append (bulk_string,
26982 "<selection id=\"%s\" />",
26986 g_string_append (bulk_string,
"</selections>");
26988 if (strcmp (action,
"delete") == 0 && strcmp (type,
"user") == 0)
26994 ret = ompf (credentials, &response, &entity, response_data,
26995 "<get_users filter=\"first=1 rows=-1\"/>",
27001 free_entity (entity);
27003 g_string_free (bulk_string, TRUE);
27013 "Internal error", __FUNCTION__, __LINE__,
27014 "An internal error occurred while getting a"
27015 " resources list. "
27016 "Diagnostics: Failure to send command to"
27017 " manager daemon.",
27018 "/omp?cmd=get_my_settings", response_data);
27022 "Internal error", __FUNCTION__, __LINE__,
27023 "An internal error occurred while getting a"
27024 " resources list. "
27025 "Diagnostics: Failure to receive response from"
27026 " manager daemon.",
27027 "/omp?cmd=get_my_settings", response_data);
27031 "Internal error", __FUNCTION__, __LINE__,
27032 "An internal error occurred while getting a"
27033 " resources list. "
27034 "Diagnostics: Internal Error.",
27035 "/omp?cmd=get_my_settings", response_data);
27038 g_string_append (bulk_string, response);
27039 free_entity (entity);
27043 g_string_append (bulk_string,
"</process_bulk>");
27045 return xsl_transform_omp (credentials, g_string_free (bulk_string, FALSE),
27062 openvas_connection_t connection;
27063 const char *no_redirect, *type;
27064 GString *commands_xml;
27069 gchar *html, *response;
27071 gchar *extra_attribs;
27079 "Internal error", __FUNCTION__, __LINE__,
27080 "An internal error occurred while deleting resources. "
27081 "The resources were not deleted. "
27082 "Diagnostics: Required parameter 'resource_type' was NULL.",
27083 "/omp?cmd=get_tasks", response_data);
27087 extra_attribs = NULL;
27090 if (strcmp (type,
"user") == 0)
27092 const char* inheritor_id;
27095 extra_attribs = g_strdup_printf (
"inheritor_id=\"%s\"", inheritor_id);
27098 commands_xml = g_string_new (
"<commands>");
27106 xml_string_append (commands_xml,
27107 "<delete_%s %s_id=\"%s\" ultimate=\"0\"",
27112 g_string_append_printf (commands_xml,
" %s/>", extra_attribs);
27114 g_string_append (commands_xml,
"/>");
27118 g_string_append (commands_xml,
"</commands>");
27132 "Internal error", __FUNCTION__, __LINE__,
27133 "An internal error occurred while deleting resources. "
27134 "The resources were not deleted. "
27135 "Diagnostics: Failure to connect to manager daemon.",
27136 "/omp?cmd=get_tasks", response_data);
27141 if (openvas_connection_sendf_xml (&connection,
27145 g_string_free (commands_xml, TRUE);
27146 openvas_connection_close (&connection);
27149 "Internal error", __FUNCTION__, __LINE__,
27150 "An internal error occurred while deleting resources. "
27151 "The resources were not deleted. "
27152 "Diagnostics: Failure to send command to manager daemon.",
27153 "/omp?cmd=get_tasks", response_data);
27155 g_string_free (commands_xml, TRUE);
27158 if (read_entity_and_text_c (&connection, &entity, &response))
27160 openvas_connection_close (&connection);
27163 "Internal error", __FUNCTION__, __LINE__,
27164 "An internal error occurred while deleting resources. "
27165 "It is unclear whether the resources have been deleted or not. "
27166 "Diagnostics: Failure to read response from manager daemon.",
27167 "/omp?cmd=get_tasks", response_data);
27170 openvas_connection_close (&connection);
27177 next = g_strdup_printf (
"get_%ss", type);
27181 html = response_from_entity (credentials, params, entity,
27182 (no_redirect && strcmp (no_redirect,
"0")),
27185 "Bulk Delete", response_data);
27187 free_entity (entity);
27210 xml = g_string_new (
"<new_host>");
27212 g_string_append (xml, extra_xml);
27213 g_string_append (xml,
"</new_host>");
27214 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
27231 return new_host (credentials, params, NULL, response_data);
27248 gchar *html, *response;
27249 const char *no_redirect, *name, *comment;
27263 xml = g_string_new (
"");
27265 xml_string_append (xml,
27268 "<type>host</type>"
27270 "<comment>%s</comment>"
27276 ret = omp (credentials,
27281 g_string_free (xml, TRUE);
27290 "Internal error", __FUNCTION__, __LINE__,
27291 "An internal error occurred while creating a new host. "
27292 "No new host was created. "
27293 "Diagnostics: Failure to send command to manager daemon.",
27294 "/omp?cmd=get_assets", response_data);
27298 "Internal error", __FUNCTION__, __LINE__,
27299 "An internal error occurred while creating a new host. "
27300 "It is unclear whether the host has been created or not. "
27301 "Diagnostics: Failure to receive response from manager daemon.",
27302 "/omp?cmd=get_assets", response_data);
27306 "Internal error", __FUNCTION__, __LINE__,
27307 "An internal error occurred while creating a new host. "
27308 "It is unclear whether the host has been created or not. "
27309 "Diagnostics: Internal Error.",
27310 "/omp?cmd=get_assets", response_data);
27313 if (entity_attribute (entity,
"id"))
27314 params_add (params,
"asset_id", entity_attribute (entity,
"id"));
27315 html = response_from_entity (credentials, params, entity,
27316 (no_redirect && strcmp (no_redirect,
"0")),
27317 NULL,
"get_assets",
27319 "Create Host", response_data);
27320 free_entity (entity);
27340 GString *extra_attribs, *extra_response;
27341 const char *asset_type;
27344 if (asset_type == NULL)
27347 param =
params_add (params,
"asset_type",
"host");
27353 if (strcmp (asset_type,
"host")
27354 && strcmp (asset_type,
"os"))
27358 "Internal error", __FUNCTION__, __LINE__,
27359 "An internal error occurred while getting an asset. "
27360 "Diagnostics: Invalid asset_type parameter value",
27361 "/omp?cmd=get_asset", response_data);
27369 "Internal error", __FUNCTION__, __LINE__,
27370 "An internal error occurred while getting an asset. "
27371 "Diagnostics: Both ID and Name set.",
27372 "/omp?cmd=get_asset", response_data);
27375 extra_response = g_string_new (extra_xml ? extra_xml :
"");
27377 extra_attribs = g_string_new (
"");
27378 g_string_append_printf (extra_attribs,
"type=\"%s\"",
27381 g_string_append_printf (extra_attribs,
27385 g_string_append_printf (extra_attribs,
27386 " asset_id=\"%s\"",
27389 g_string_append_printf (extra_attribs,
27393 ret =
get_one (
"asset", credentials, params, extra_response->str,
27394 extra_attribs->str, response_data);
27396 g_string_free (extra_response, TRUE);
27397 g_string_free (extra_attribs, TRUE);
27415 return get_asset (credentials, params, NULL, response_data);
27433 GString *extra_attribs, *extra_response;
27434 const char *asset_type;
27437 if (asset_type == NULL)
27440 param =
params_add (params,
"asset_type",
"host");
27446 if (strcmp (asset_type,
"host")
27447 && strcmp (asset_type,
"os"))
27451 "Internal error", __FUNCTION__, __LINE__,
27452 "An internal error occurred while getting Assets. "
27453 "Diagnostics: Invalid asset_type parameter value",
27454 "/omp?cmd=get_assets", response_data);
27457 extra_response = g_string_new (extra_xml ? extra_xml :
"");
27459 extra_attribs = g_string_new(
"");
27460 g_string_append_printf (extra_attribs,
"type=\"%s\" ignore_pagination=\"%s\"",
27466 g_string_append_printf (extra_attribs,
27469 ret = get_many (
"asset", credentials, params, extra_response->str,
27470 extra_attribs->str, response_data);
27472 g_string_free (extra_response, TRUE);
27473 g_string_free (extra_attribs, TRUE);
27491 return get_assets (credentials, params, NULL, response_data);
27509 const char *no_redirect, *report_id, *filter;
27521 switch (ompf (credentials,
27526 "<report id=\"%s\">"
27527 "<filter><term>%s</term></filter>"
27539 "Internal error", __FUNCTION__, __LINE__,
27540 "An internal error occurred while creating an asset. "
27541 "No new asset was created. "
27542 "Diagnostics: Failure to send command to manager daemon.",
27543 "/omp?cmd=get_tasks", response_data);
27547 "Internal error", __FUNCTION__, __LINE__,
27548 "An internal error occurred while creating an asset. "
27549 "It is unclear whether the asset has been created or not. "
27550 "Diagnostics: Failure to receive response from manager daemon.",
27551 "/omp?cmd=get_tasks", response_data);
27555 "Internal error", __FUNCTION__, __LINE__,
27556 "An internal error occurred while creating an asset. "
27557 "It is unclear whether the asset has been created or not. "
27558 "Diagnostics: Internal Error.",
27559 "/omp?cmd=get_tasks", response_data);
27562 ret = response_from_entity (credentials, params, entity,
27563 (no_redirect && strcmp (no_redirect,
"0")),
27564 NULL,
"get_report_section",
27565 NULL,
"get_report_section",
27566 "Create Asset", response_data);
27567 free_entity (entity);
27585 openvas_connection_t connection;
27586 gchar *html, *response, *resource_id;
27587 const char *next_id, *no_redirect;
27592 resource_id = g_strdup (
params_value (params,
"asset_id"));
27594 resource_id = g_strdup (
params_value (params,
"report_id"));
27599 "Internal error", __FUNCTION__, __LINE__,
27600 "An internal error occurred while deleting an asset. "
27601 "The asset was not deleted. "
27602 "Diagnostics: Required parameter was NULL.",
27603 "/omp?cmd=get_tasks", response_data);
27614 g_free (param->
value);
27615 param->
value = g_strdup (next_id);
27627 g_free (resource_id);
27632 g_free (resource_id);
27635 "Internal error", __FUNCTION__, __LINE__,
27636 "An internal error occurred while deleting an asset. "
27637 "The asset is not deleted. "
27638 "Diagnostics: Failure to connect to manager daemon.",
27639 "/omp?cmd=get_tasks", response_data);
27644 if (openvas_connection_sendf (&connection,
27645 "<delete_asset %s_id=\"%s\"/>",
27647 ?
"asset" :
"report",
27651 openvas_connection_close (&connection);
27652 g_free (resource_id);
27655 "Internal error", __FUNCTION__, __LINE__,
27656 "An internal error occurred while deleting an asset. "
27657 "The asset is not deleted. "
27658 "Diagnostics: Failure to send command to manager daemon.",
27659 "/omp?cmd=get_tasks", response_data);
27662 g_free (resource_id);
27665 if (read_entity_and_text_c (&connection, &entity, &response))
27667 openvas_connection_close (&connection);
27670 "Internal error", __FUNCTION__, __LINE__,
27671 "An internal error occurred while deleting an asset. "
27672 "It is unclear whether the asset has been deleted or not. "
27673 "Diagnostics: Failure to read response from manager daemon.",
27674 "/omp?cmd=get_tasks", response_data);
27677 openvas_connection_close (&connection);
27685 if (no_redirect && strcmp (no_redirect,
"0"))
27687 html = next_page (credentials, params, response, response_data);
27692 "Internal error", __FUNCTION__, __LINE__,
27693 "An internal error occurred while deleting an "
27694 "asset. Diagnostics: Error in parameter next.",
27695 "/omp?cmd=get_tasks", response_data);
27700 next_url = next_page_url (credentials, params,
27701 NULL,
"get_asset",
"delete_asset",
27702 entity_attribute (entity,
"status"),
27703 entity_attribute (entity,
"status_text"));
27704 response_data->
redirect = next_url;
27710 free_entity (entity);
27728 enum content_type * content_type,
char **content_disposition,
27732 content_disposition, content_length, response_data);
27750 enum content_type * content_type,
char **content_disposition,
27753 return export_many (
"asset", credentials, params, content_type,
27754 content_disposition, content_length, response_data);
27772 const char *asset_id;
27777 if (asset_id == NULL)
27781 "Internal error", __FUNCTION__, __LINE__,
27782 "An internal error occurred while editing a asset. "
27783 "The asset remains as it was. "
27784 "Diagnostics: Required ID parameter was NULL.",
27785 "/omp?cmd=get_tasks", response_data);
27788 xml = g_string_new (
"");
27790 g_string_append_printf (xml,
"<edit_asset>");
27793 g_string_append (xml, extra_xml);
27797 switch (ompf (credentials,
27804 " details=\"1\"/>",
27812 g_string_free (xml, TRUE);
27814 "Internal error", __FUNCTION__, __LINE__,
27815 "An internal error occurred while getting the asset. "
27816 "Diagnostics: Failure to send command to manager daemon.",
27817 "/omp?cmd=get_assets", response_data);
27820 g_string_free (xml, TRUE);
27822 "Internal error", __FUNCTION__, __LINE__,
27823 "An internal error occurred while getting the asset. "
27824 "Diagnostics: Failure to receive response from manager daemon.",
27825 "/omp?cmd=get_assets", response_data);
27828 g_string_free (xml, TRUE);
27830 "Internal error", __FUNCTION__, __LINE__,
27831 "An internal error occurred while getting the asset. "
27832 "Diagnostics: Internal Error.",
27833 "/omp?cmd=get_assets", response_data);
27836 g_string_append (xml, response);
27837 g_string_append_printf (xml,
"</edit_asset>");
27838 free_entity (entity);
27840 return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
27857 return edit_asset (credentials, params, NULL, response_data);
27874 gchar *html, *response;
27875 const char *no_redirect, *asset_id, *comment;
27889 ret = ompf (credentials,
27893 "<modify_asset asset_id=\"%s\">"
27894 "<comment>%s</comment>"
27907 "Internal error", __FUNCTION__, __LINE__,
27908 "An internal error occurred while saving an asset. "
27909 "The asset was not saved. "
27910 "Diagnostics: Failure to send command to manager daemon.",
27911 "/omp?cmd=get_assets", response_data);
27915 "Internal error", __FUNCTION__, __LINE__,
27916 "An internal error occurred while saving an asset. "
27917 "It is unclear whether the asset has been saved or not. "
27918 "Diagnostics: Failure to receive response from manager daemon.",
27919 "/omp?cmd=get_assets", response_data);
27923 "Internal error", __FUNCTION__, __LINE__,
27924 "An internal error occurred while saving an asset. "
27925 "It is unclear whether the asset has been saved or not. "
27926 "Diagnostics: Internal Error.",
27927 "/omp?cmd=get_assets", response_data);
27930 html = response_from_entity (credentials, params, entity,
27931 (no_redirect && strcmp (no_redirect,
"0")),
27932 NULL,
"get_assets",
27933 NULL,
"edit_asset",
27934 "Save Asset", response_data);
27935 free_entity (entity);
27954 return xsl_transform_omp (credentials, g_strdup (
"<get_assets_chart/>"),
27971 return get_assets_chart (credentials, params, NULL, response_data);
27987 struct sockaddr_un address;
27992 sock = socket (AF_UNIX, SOCK_STREAM, 0);
27995 g_warning (
"Failed to create server socket");
28001 address.sun_family = AF_UNIX;
28002 strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
28003 if (connect (sock, (
struct sockaddr *) &address,
sizeof (address)) == -1)
28005 g_warning (
"Failed to connect to server: %s", strerror (errno));
28027 if (address == NULL)
28034 connection->socket = openvas_server_open (&connection->session,
28037 connection->credentials = NULL;
28042 if (connection->socket == -1)
28066 gchar **role, gchar **timezone, gchar **severity,
28067 gchar **capabilities, gchar **language, gchar **pw_warning,
28068 GTree **chart_prefs, gchar **autorefresh)
28070 openvas_connection_t connection;
28072 omp_authenticate_info_opts_t auth_opts;
28078 g_debug (
"%s failed to acquire socket!\n", __FUNCTION__);
28090 g_debug (
"Sleeping!");
28094 auth_opts = omp_authenticate_info_opts_defaults;
28095 auth_opts.username = username;
28096 auth_opts.password = password;
28097 auth_opts.role = role;
28098 auth_opts.severity = severity;
28099 auth_opts.timezone = timezone;
28100 auth_opts.pw_warning = pw_warning;
28102 auth = omp_authenticate_info_ext_c (&connection, auth_opts);
28106 const char* status;
28113 ret = setting_get_value (&connection,
28114 "6765549a-934e-11e3-b358-406186ea4fc5",
28124 openvas_connection_close (&connection);
28127 openvas_connection_close (&connection);
28133 ret = openvas_connection_sendf (&connection,
28134 "<help format=\"XML\" type=\"brief\"/>");
28137 openvas_connection_close (&connection);
28144 if (read_entity_and_text_c (&connection, &entity, &response))
28146 openvas_connection_close (&connection);
28152 status = entity_attribute (entity,
"status");
28154 || strlen (status) == 0)
28157 free_entity (entity);
28161 free_entity (entity);
28164 *capabilities = response;
28168 openvas_connection_close (&connection);
28175 ret = openvas_connection_sendf (&connection,
28177 " filter='name~\"Dashboard\"'/>");
28180 openvas_connection_close (&connection);
28186 if (read_entity_and_text_c (&connection, &entity, &response))
28188 openvas_connection_close (&connection);
28193 status = entity_attribute (entity,
"status");
28195 || strlen (status) == 0)
28198 free_entity (entity);
28204 entities_t entities = entity->entities;
28205 entity_t child_entity;
28206 *chart_prefs = g_tree_new_full ((GCompareDataFunc) g_strcmp0,
28207 NULL, g_free, g_free);
28209 while ((child_entity = first_entity (entities)))
28211 if (strcmp (entity_name (child_entity),
"setting") == 0)
28213 const char *setting_id
28214 = entity_attribute (child_entity,
"id");
28215 const char *setting_value
28216 = entity_text (entity_child (child_entity,
"value"));
28218 if (setting_id && setting_value)
28219 g_tree_insert (*chart_prefs,
28220 g_strdup (setting_id),
28221 g_strdup (setting_value));
28223 entities = next_entities (entities);
28225 free_entity (entity);
28230 free_entity (entity);
28232 openvas_connection_close (&connection);
28238 ret = setting_get_value (&connection,
28239 "578a1c14-e2dc-45ef-a591-89d31391d007",
28249 openvas_connection_close (&connection);
28252 openvas_connection_close (&connection);
28256 openvas_connection_close (&connection);
28261 openvas_connection_close (&connection);
28282 omp_authenticate_info_opts_t auth_opts;
28293 *html = logout (credentials,
"Logged out. OMP service is down.",
28299 g_debug (
"in manager_connect: Trying to authenticate with %s/%s\n",
28305 auth_opts = omp_authenticate_info_opts_defaults;
28306 auth_opts.username = credentials->
username;
28307 auth_opts.password = credentials->
password;
28308 if (omp_authenticate_info_ext_c (connection, auth_opts))
28310 g_debug (
"authenticate failed!\n");
28311 openvas_connection_close (connection);
28322 g_debug (
"Sleeping!");
char * export_notes_omp(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 * get_report_omp(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 * get_agents_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all agents, XSL transform the result.
char * edit_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_schedule XML, XSL transform the result.
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 * get_protocol_doc_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get OMP doc.
char * run_wizard_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Run a wizard and XSL transform the result.
char * save_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a filter, get all filters, XSL transform the result.
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
char * get_reports_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all reports, XSL transform the result.
char * export_scanners_omp(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 * edit_config_nvt_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit details of an NVT for a config, XSL transform the result.
params_t * params_values(params_t *params, const char *name)
Get values of param.
char * export_permission_omp(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_asset_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get asset, XSL transform the result.
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 * get_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one credential, XSL transform the result.
char * get_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an override, XSL transform the result.
char * export_role_omp(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.
char * save_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a tag, get all tags, XSL transform the result.
char * save_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save task, get next page, XSL transform the result.
char * export_result_omp(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.
char * new_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new filter.
char * process_bulk_omp(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_one(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_report_formats_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all Report Formats, XSL transform the result.
char * get_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one filter, XSL transform the result.
char * edit_schedule(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_info_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get info, XSL transform the result.
char * export_users_omp(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.
void cmd_response_data_init(cmd_response_data_t *data)
Initializes a cmd_response_data_t struct.
char * create_port_range_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Add a range to a port list, XSL transform the result.
char * save_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save override, get next page, XSL transform the result.
char * delete_group_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a group, get all groups, XSL transform the result.
char * edit_note(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 * create_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an agent, get all agents, XSL transform result.
char * capabilities
Capabilites of manager.
param_t * params_get(params_t *params, const char *name)
Get param.
char * timezone
User's timezone.
char * get_permissions_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all permissions, XSL transform the result.
char * create_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create config, get all configs, XSL transform the result.
content_type
Content types.
char * get_credentials_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one or all credentials, XSL transform the result.
char * edit_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_scanner XML, XSL transform the result.
char * edit_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit note, get next page, XSL transform the result.
char * edit_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_target XML, XSL transform the result.
char * save_group_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a group, return the next page.
char * get_roles_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all roles, XSL transform the result.
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_group_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_group XML, XSL transform the result.
char * edit_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_filter XML, XSL transform the result.
char * dashboard(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Show a dashboard.
char * export_preference_file_omp(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.
char * get_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one schedule, XSL transform the result.
char * clone_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Clone a resource, XSL transform the result.
char * get_aggregate_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an aggregate of resources.
char * edit_override(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.
char * delete_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete report format, get report formats, XSL transform the result.
char * save_config_omp(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 * edit_asset_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_asset XML, XSL transform the result.
char * export_alert_omp(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.
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 * new_user_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new user.
char * download_ssl_cert(credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
Get an SSL Certificate.
char * edit_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a config, XSL transform the result.
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
char * create_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a task, get all tasks, XSL transform the result.
struct sockaddr_storage address
The IP address of this program, "the GSAD".
char * delete_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a filter, get all filters, XSL transform the result.
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
char * resume_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Resume a task, get all tasks, XSL transform the result.
char * get_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a note, XSL transform the result.
char * edit_resource(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 * save_role_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a role, return the next page.
char * edit_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_credential XML, XSL transform the result.
char * new_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new target.
char * save_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save note, get next page, XSL transform the result.
char * toggle_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Set tag enabled status.
gchar * manager_address
The address the manager is on.
char * caller
Caller URL, for POST relogin.
char * stop_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Stop a task, get all tasks, XSL transform the result.
char * get_tags_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tags, XSL transform the result.
char * delete_trash_group_omp(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 * export_port_lists_omp(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 * export_tag_omp(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.
char * edit_target(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 * sync_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Sync config, get configs, XSL transform the result.
Response information for commands.
char * edit_permission(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 * export_tags_omp(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 * edit_user(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_user XML, 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 * new_container_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new task.
char * export_credentials_omp(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_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one alert, XSL transform the result.
const char * params_filename(params_t *params, const char *name)
Get filename of param.
char * delete_trash_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash schedule, get all trash, XSL transform the result.
char * delete_trash_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash task, get all trash, XSL transform the result.
int download_credential_omp(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 * export_agent_omp(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.
void set_language_code(gchar **lang, const gchar *language)
Set language code of user.
char * save_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save scanner, get next page, XSL transform the result.
char * export_override_omp(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.
char * delete_trash_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash agent, get all agents, 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_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a note, get all notes, XSL transform the result.
char * upload_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the upload scan config page.
char * edit_my_settings_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page with user's settings, for editing.
char * create_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a note, get report, XSL transform the result.
#define RESULTS_PER_PAGE
Initial filtered results per page on the report summary.
char * delete_user_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a user, get all users, XSL transform the result.
char * export_schedule_omp(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_config_omp(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 * resource_action(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.
void cmd_response_data_reset(cmd_response_data_t *data)
Clears a cmd_response_data_t struct.
char * edit_port_list_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_port_list XML, XSL transform the result.
char * save_config_family_omp(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 * delete_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a task, get all tasks, XSL transform the result.
char * get_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a task, XSL transform the result.
char * get_report_section_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a report section, XSL transform the result.
char * new_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new scan config page.
char * create_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an alert, get all alerts, XSL transform the result.
Structure of credential related information.
char * create_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a filter, get all filters, XSL transform the result.
char * delete_trash_filter_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a filter, get all filters, XSL transform the result.
char * export_groups_omp(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.
int manager_use_tls
Whether to use TLS for Manager connections.
char * new_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new agent page.
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
char * get_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one agent, XSL transform the result.
char * delete_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a schedule, get all schedules, XSL transform the result.
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
char * get_group_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one group, 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 * username
Name of user.
char * export_assets_omp(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 * export_filters_omp(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.
char * get_assets_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get assets, XSL transform the result.
char * import_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import config, get all configs, XSL transform the result.
char * new_role_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new role.
char * delete_port_list_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a port list, get all port lists, XSL transform the result.
char * create_user_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a user, get all users, XSL transform the result.
char * new_override(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new overrides page.
int user_set_autorefresh(const gchar *token, const gchar *autorefresh)
Set default autorefresh interval of user.
char * bulk_delete_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete multiple resources, get next page, XSL transform the result.
char * new_host_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new host page.
char * autorefresh
Auto-refresh interval.
char * create_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a permission, get all permissions, XSL transform the result.
GTree * last_filt_ids
Last filter ids.
char * client_address
Client's address.
char * get_config_family_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of a family for a config, XSL transform the result.
char * export_user_omp(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 * get_filters_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all filters, 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 * new_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new schedule page.
char * save_config_nvt_omp(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 * edit_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_agent XML, XSL transform the result.
void init_find_by_value(find_by_value_t *find, gchar *value)
char * edit_agent(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 * delete_trash_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a note, get all notes, XSL transform the result.
char * get_system_reports_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all system reports, XSL transform the result.
Headers/structs used generally in GSA.
char * wizard_get_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns a wizard_get page.
#define CHECK(name)
Check a param.
char * delete_trash_scanner_omp(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_report_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete report, get task status, XSL transform the result.
char * edit_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit override, get next page, XSL transform the result.
Structure to search a key by value.
char * edit_role_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_role XML, XSL transform the result.
char * delete_role_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a role, get all roles, XSL transform the result.
char * edit_config_family_omp(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 * edit_tag(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
char * edit_scanner(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_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete override, get next page, XSL transform the result.
char * export_roles_omp(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 * cvss_calculator(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
char * new_permission(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 * delete_user_confirm_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Show confirmation deleting a user, XSL transform the result.
char * export_results_omp(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 * export_tasks_omp(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 * save_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save credential, get next page, XSL transform the result.
char * wizard_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns a wizard page.
struct timeval cmd_start
Seconds since command page handler started.
char * save_user_omp(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.
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 * export_overrides_omp(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 * create_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an override, get report, XSL transform the result.
char * new_permissions_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
char * new_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new alert.
char * save_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a permission, get all permissions, XSL transform the result.
char * new_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new report format page.
char * start_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Start a task, get all tasks, XSL transform the result.
char * export_schedules_omp(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.
char * get_config_nvt_omp(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 * get_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a config, XSL transform the result.
char * get_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one scanner, XSL transform the result.
char * export_configs_omp(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.
char * save_asset_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify an asset, get all assets, XSL transform the result.
char * new_port_range_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new Port Range page.
char * get_feeds_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get descriptions of the feeds connected to the manager.
char * get_configs_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all scan configs, XSL transform the result.
char * get_user_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one user, XSL transform the result.
char * create_permissions_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create multiple permission, get next page, XSL transform the result.
char * delete_port_range_omp(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 * delete_trash_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash target, get all trash, XSL transform the result.
char * export_alerts_omp(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 * get_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one target, XSL transform the result.
char * edit_alert(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 * create_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a target, get all targets, XSL transform the result.
char * export_report_formats_omp(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 * delete_trash_role_omp(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 * edit_filter(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 * edit_asset(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit XML, XSL transform the result.
char * new_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new overrides page.
char * delete_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete credential, get all credentials, XSL transform result.
char * new_note(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new notes page.
char * get_assets_chart_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an assets chart, XSL transform the result.
char * create_role_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a role, get all roles, XSL transform the result.
#define GET_TRASH_RESOURCE(capability, command, name)
char * upload_report_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the upload report page.
char * export_scanner_omp(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 * get_my_settings_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page with user's settings.
char * new_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new task.
GPtrArray * users
User session data.
char * sync_cert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with a CERT feed and XSL transform the result.
char * auth_settings_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
char * download_ca_pub(credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
Get a Scanner's CA Certificate.
char * edit_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
char * create_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a schedule, get all schedules, XSL transform the result.
char * export_agents_omp(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.
char * create_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a tag, get report, XSL transform the result.
char * get_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one permission, XSL transform the result.
int guest
Whether the user is a guest user.
char * create_group_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a group, get all groups, XSL transform the result.
char * get_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one report format, XSL transform the result.
char * new_permissions(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 * create_asset_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an asset, get report, XSL transform the result.
int manager_port
The port the manager is on.
char * create_container_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a container task, serve next page.
char * export_credential_omp(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.
char * export_omp_doc_omp(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 * delete_trash_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash config, get all trash, XSL transform the result.
char * delete_trash_port_list_omp(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 * token
Session token.
char * get_scanners_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all scanners, XSL transform the result.
const char * params_value(params_t *params, const char *name)
Get value of param.
char * new_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new target.
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
char * new_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
char * import_report_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import report, get all reports, XSL transform the result.
char * export_report_format_omp(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.
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
#define GSAD_MESSAGE_INVALID
Answer for invalid input.
char * verify_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify scanner, get scanners, XSL transform the result.
char * delete_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a permission, get all permissions, XSL transform the result.
char * delete_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete note, get next page, XSL transform the result.
char * get_groups_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all groups, XSL transform the result.
char * get_trash_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all trash, XSL transform the result.
char * get_users_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all users, XSL transform the result.
char * get_system_report_omp(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 * download_key_pub(credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
Get a Scanner's Certificate.
char * get_tasks_chart_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a tasks chart, XSL transform the result.
const gchar * vendor_version_get()
Get the vendor version.
int charts
Whether to show charts for this user.
char * export_task_omp(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.
char * pw_warning
Password policy warning message.
char * sync_feed_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with an NVT feed and XSL transform the result.
char * get_info(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Requests SecInfo.
gchar * redirect
HTTP status code.
char * get_results_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all results, XSL transform the result.
char * edit_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_task XML, XSL transform the result.
char * delete_trash_report_format_omp(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 * get_tasks_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tasks, XSL transform the result.
char * edit_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_report_format XML, XSL transform the result.
char * get_schedules_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all schedules, XSL transform the result.
char * empty_trashcan_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Empty the trashcan, get all trash, XSL transform the result.
char * xsl_transform(const char *xml_text, cmd_response_data_t *response_data)
XSL Transformation.
char * delete_trash_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash alert, get all trash, XSL transform the result.
char * get_nvts_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Requests NVT details, accepting extra commands.
char * delete_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a target, get all targets, XSL transform the result.
GTree * chart_prefs
Chart preferences.
char * new_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new scanner page.
char * import_port_list_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import port list, get all port_lists, XSL transform the result.
char * export_group_omp(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 * severity
Severity class.
char * get_targets_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all targets, XSL transform the result.
char * create_port_list_omp(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_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a scanner, get all scanners, XSL transform the result.
char * restore_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Restore a resource, get all trash, XSL transform the result.
char * get_role_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one role, XSL transform the result.
char * get_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one tag, XSL transform the result.
char * save_container_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save container task, get next page, XSL transform the result.
void free_find_by_value(find_by_value_t *find)
int download_agent_omp(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 * delete_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete agent, get all agents, XSL transform result.
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
gchar * message_invalid(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 * create_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a credential, get all credentials, XSL transform result.
char * create_host_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a host, serve next page.
char * save_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify an alert, get all alerts, XSL transform the result.
char * get_port_list_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one port_list, XSL transform the result.
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
char * save_schedule_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save schedule, get next page, XSL transform the result.
char * delete_tag_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete note, get next page, XSL transform the result.
#define params_iterator_init
char * current_page
Current page URL, for refresh.
char * test_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Test an alert, get all alerts XSL transform the result.
char * move_task_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Reassign a task to a new OMP slave.
char * new_port_list_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new Port List page.
char * get_port_lists_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all port_lists, XSL transform the result.
char * upload_port_list_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the upload port list page.
char * export_port_list_omp(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 * language
Accept-Language browser header.
char * edit_user_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
char * edit_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_alert XML, XSL transform the result.
char * sync_scap_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with a SCAP feed and XSL transform the result.
char * export_targets_omp(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 * save_my_settings_omp(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.
char * verify_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify agent, get agents, XSL transform the result.
char * save_target_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a target, get all targets, XSL transform the result.
char * export_note_omp(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.
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_omp.
char * export_target_omp(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 * new_group_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new group.
int openvas_connection_open(openvas_connection_t *connection, const gchar *address, int port)
Connect to an address.
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 * edit_group(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 * get_alerts_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all alerts, XSL transform the result.
char * new_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new Credential.
char * get_result_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one result, XSL transform the result.
#define params_iterator_t
char * get_notes_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all notes, XSL transform the result.
Headers for GSA's OMP communication module.
char * save_port_list_omp(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 * export_asset_omp(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 * delete_config_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete config, get all configs, XSL transform the result.
void buffer_languages_xml(GString *buffer)
Write the list of installed languages to a buffer as XML.
char * delete_resource(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 * delete_trash_credential_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a trash credential, get all trash, XSL transform the result.
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
char * save_chart_preference_omp(credentials_t *credentials, params_t *params, gchar **pref_id, gchar **pref_value, cmd_response_data_t *response_data)
Save chart preferences.
char * save_agent_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a agent, get all agents, XSL transform the result.
char * get_overrides_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all overrides, XSL transform the result.
char * new_note_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Return the new notes page.
char * delete_trash_override_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a override, get all overrides, XSL transform the result.
char * password
User's password.
char * export_filter_omp(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 * verify_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify report format, get report formats, XSL transform the result.
char * export_permissions_omp(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.
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
char * delete_trash_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a permission, get all permissions, XSL transform the result.
char * import_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import report format, get all report formats, XSL transform result.
char * save_report_format_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save report_format, get next page, XSL transform the result.
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
char * save_auth_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save authentication settings.
char * delete_asset_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete an asset, go to the next page.
char * delete_alert_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete an alert, get all alerts, XSL transform the result.
char * create_report_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a report, get all tasks, XSL transform the result.
char * edit_permission_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_permission XML, XSL transform the result.
char * create_scanner_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a scanner, get all scanners, XSL transform the result.
int connect_unix(const gchar *path)
Connect to OpenVAS Manager daemon.
char * export_resource(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.