39 #include <arpa/inet.h> 44 #include <gvm/base/cvss.h> 45 #include <gvm/gmp/gmp.h> 46 #include <gvm/util/fileutils.h> 47 #include <gvm/util/serverutils.h> 48 #include <gvm/util/xmlutils.h> 49 #include <microhttpd.h> 51 #include <netinet/in.h> 55 #include <sys/socket.h> 65 #define G_LOG_DOMAIN "gsad gmp" 70 #define OPENVASMD_ADDRESS "127.0.0.1" 73 #define GSAD_MESSAGE_INVALID \ 74 "<gsad_msg status_text=\"%s\" operation=\"%s\">" \ 75 "At least one entered value contains invalid characters or exceeds" \ 76 " a size limit. You may use the Back button of your browser to adjust" \ 77 " the entered values. If in doubt, the online help of the respective " \ 79 " will lead you to the appropriate help page." \ 83 #define GSAD_MESSAGE_INVALID_PARAM(op) \ 84 "<gsad_msg status_text=\"Invalid parameter\" operation=\"" op "\">" \ 85 "At least one entered value contains invalid characters or exceeds" \ 86 " a size limit. You may use the Back button of your browser to adjust" \ 87 " the entered values. If in doubt, the online help of the respective " \ 89 " will lead you to the appropriate help page." \ 96 #define GSAD_STATUS_INVALID_REQUEST MHD_HTTP_UNPROCESSABLE_ENTITY 101 #define RESULTS_PER_PAGE 100 106 #define FILT_ID_NONE "0" 111 #define FILT_ID_USER_SETTING "-2" 119 #define CHECK_VARIABLE_INVALID(name, op_name) \ 122 return message_invalid (connection, credentials, params, response_data, \ 123 "Given " G_STRINGIFY (name) " was invalid", \ 342 const char *details,
const char *
id);
368 gmp_init (
const gchar *manager_address_unix,
const gchar *manager_address_tls,
371 if (manager_address_unix)
376 else if (manager_address_tls)
417 if (gvm_connection_sendf (connection,
"<get_filters filter_id='%s'/>",
423 if (read_entity_c (connection, &entity))
461 string = g_string_new (
"");
463 gettimeofday (&tv, NULL);
464 res = g_markup_printf_escaped (
466 "<version>%s</version>" 467 "<vendor_version>%s</vendor_version>" 470 "<timezone>%s</timezone>" 472 "<session>%ld</session>" 474 "<severity>%s</severity>" 477 "<client_address>%s</client_address>" 478 "<backend_operation>%.2f</backend_operation>",
486 g_string_append (
string, res);
492 warning_elem = g_markup_printf_escaped (
"<password_warning>" 494 "</password_warning>",
496 g_string_append (
string, warning_elem);
497 g_free (warning_elem);
500 g_string_append_printf (
string,
501 "<capabilities>%s</capabilities>" 508 return g_string_free (
string, FALSE);
528 if (strcmp (name,
string) == 0)
551 && strcmp (name,
string) == 0)
571 params_t *params,
const char *next,
const char *fail_next,
576 const char *status_text;
585 if (read_entity_c (connection, &entity))
588 MHD_HTTP_INTERNAL_SERVER_ERROR);
590 credentials,
"Internal error", __FUNCTION__, __LINE__,
591 "An internal error occurred while saving a config. " 592 "It is unclear whether the entire config has been saved. " 593 "Diagnostics: Failure to read command to manager daemon.",
599 status_text = entity_attribute (entity,
"status_text");
600 if (status_text == NULL)
602 free_entity (entity);
604 MHD_HTTP_INTERNAL_SERVER_ERROR);
606 credentials,
"Internal error", __FUNCTION__, __LINE__,
607 "An internal error occurred while saving a config. " 608 "It is unclear whether the entire config has been saved. " 609 "Diagnostics: Failure to parse status_text from response.",
613 if (
str_equal (status_text,
"Config is in use"))
615 const char *message =
"The config is now in use by a task," 616 " so only name and comment can be modified.";
620 "Save Config", message, NULL, NULL);
622 free_entity (entity);
625 else if (
str_equal (status_text,
"MODIFY_CONFIG name must be unique"))
627 const char *message =
"A config with the given name exists already.";
631 "Save Config", message, NULL, NULL);
633 free_entity (entity);
642 "Save Config", response_data);
643 free_entity (entity);
663 status = entity_attribute (entity,
"status");
664 if ((status == NULL) || (strlen (status) == 0))
667 return status[0] ==
'2';
682 MHD_HTTP_INTERNAL_SERVER_ERROR);
683 else if (
str_equal (entity_attribute (entity,
"status_text"),
684 "Permission denied"))
686 else if (
str_equal (entity_attribute (entity,
"status"),
"404"))
714 *entity_return = NULL;
716 ret = gvm_connection_sendf (connection,
"%s", command);
723 if (read_entity_and_text_c (connection, &entity, response))
728 *entity_return = entity;
730 free_entity (entity);
749 simple_gmpf (gvm_connection_t *connection,
const gchar *message_operation,
758 va_start (args, format);
759 command = g_markup_vprintf_escaped (format, args);
763 gmp (connection,
credentials, response, &entity, response_data, command);
775 MHD_HTTP_INTERNAL_SERVER_ERROR);
779 message = g_strdup_printf (
780 "An internal error occurred while %s. " 781 " The operation was not started." 782 " Diagnostics: Failure to send command to manager" 784 message_operation ? message_operation :
"performing an operation");
786 __LINE__, message, response_data);
793 MHD_HTTP_INTERNAL_SERVER_ERROR);
797 message = g_strdup_printf (
798 "An internal error occurred while %s." 799 " It is unclear whether the operation succeeded." 800 " Diagnostics: Failure to receive response from manager" 802 message_operation ? message_operation :
"performing an operation");
804 __LINE__, message, response_data);
811 MHD_HTTP_INTERNAL_SERVER_ERROR);
815 message = g_strdup_printf (
816 "An internal error occurred while %s." 817 " It is unclear whether the operation succeeded." 818 " Diagnostics: Internal Error.",
819 message_operation ? message_operation :
"performing an operation");
821 __LINE__, message, response_data);
840 free_entity (entity);
860 gchar **response, entity_t *entity_return,
867 va_start (args, format);
868 command = g_markup_vprintf_escaped (format, args);
871 ret =
gmp (connection,
credentials, response, entity_return, response_data,
898 ret = gvm_connection_sendf (connection,
"<get_settings setting_id=\"%s\"/>",
904 if (read_entity_and_text_c (connection, &entity, &response))
907 status = entity_attribute (entity,
"status");
908 if (status == NULL || strlen (status) == 0)
911 free_entity (entity);
915 if (status[0] ==
'2')
918 setting = entity_child (entity,
"setting");
921 free_entity (entity);
925 setting = entity_child (setting,
"value");
928 free_entity (entity);
932 *value = g_strdup (entity_text (setting));
934 free_entity (entity);
940 free_entity (entity);
967 const char *action,
const char *message,
const char *details,
972 xml = g_string_new (
"");
973 xml_string_append (xml,
975 "<action>%s</action>" 976 "<message>%s</message>",
977 action ? action :
"", message ? message :
"");
980 xml_string_append (xml,
"<details>%s</details>", details);
983 xml_string_append (xml,
"<id>%s</id>",
id);
985 g_string_append (xml,
"</action_result>");
988 g_string_free (xml, FALSE), response_data);
1006 const char *message,
const char *op_name)
1009 op_name, message, NULL, NULL);
1024 params_t *params, entity_t entity,
const char *action,
1028 entity_t status_details_entity;
1037 status_details_entity = entity_child (entity,
"status_details");
1040 entity_attribute (entity,
"status_text"),
1041 entity_text (status_details_entity),
1042 entity_attribute (entity,
"id"));
1060 get_one (gvm_connection_t *connection,
const char *type,
1069 id_name = g_strdup_printf (
"%s_id", type);
1075 xml = g_string_new (
"");
1076 g_string_append_printf (xml,
"<get_%s>", type);
1079 g_string_append (xml, extra_xml);
1083 if (gvm_connection_sendf (connection,
1088 type, type,
id, extra_attribs ? extra_attribs :
"")
1091 g_string_free (xml, TRUE);
1093 MHD_HTTP_INTERNAL_SERVER_ERROR);
1095 credentials,
"Internal error", __FUNCTION__, __LINE__,
1096 "An internal error occurred while getting resources list. " 1097 "The current list of resources is not available. " 1098 "Diagnostics: Failure to send command to manager daemon.",
1102 if (read_entity_and_string_c (connection, &entity, &xml))
1104 g_string_free (xml, TRUE);
1106 MHD_HTTP_INTERNAL_SERVER_ERROR);
1108 credentials,
"Internal error", __FUNCTION__, __LINE__,
1109 "An internal error occurred while getting resources list. " 1110 "The current list of resources is not available. " 1111 "Diagnostics: Failure to receive response from manager daemon.",
1123 entity_attribute (entity,
"status_text"), response_data);
1125 g_string_free (xml, TRUE);
1126 free_entity (entity);
1131 free_entity (entity);
1133 g_string_append_printf (xml,
"</get_%s>", type);
1135 g_string_free (xml, FALSE), response_data);
1152 get_many (gvm_connection_t *connection,
const char *type,
1158 gchar *request, *built_filter;
1159 const char *build_filter, *filt_id, *filter, *filter_extra;
1160 const char *first, *max, *sort_field, *sort_order, *owner, *permission;
1161 const char *replace_task_id;
1162 const char *overrides, *autofp, *autofp_value, *min_qod;
1163 const char *level_high, *level_medium, *level_low, *level_log;
1164 const char *level_false_positive;
1165 const char *details;
1173 replace_task_id =
params_value (params,
"replace_task_id");
1186 level_false_positive =
params_value (params,
"level_false_positive");
1189 if (details == NULL || strcmp (details,
"") == 0)
1198 g_debug (
"%s filter doesn't exist anymore %s!\n", __FUNCTION__, filt_id);
1202 g_debug (
"%s filter response didn't contain a status!\n", __FUNCTION__);
1206 g_debug (
"%s could not send filter request!\n", __FUNCTION__);
1210 g_debug (
"%s could not read entity from filter response!\n",
1218 xml = g_string_new (
"");
1219 type_many = g_string_new (type);
1222 if (strcmp (type,
"info") != 0)
1223 g_string_append (type_many,
"s");
1225 g_string_append_printf (xml,
"<get_%s>", type_many->str);
1228 g_string_append (xml, extra_xml);
1230 built_filter = NULL;
1233 if ((build_filter &&
str_equal (build_filter,
"1"))
1234 || ((filter == NULL ||
str_equal (filter,
""))
1235 && (filter_extra == NULL ||
str_equal (filter_extra,
""))))
1237 if (build_filter && (strcmp (build_filter,
"1") == 0))
1240 const char *search_phrase, *task_id;
1245 g_strdup_printf (
"apply_overrides=%i min_qod=%s ",
1246 overrides && !
str_equal (overrides,
"0"),
1247 min_qod ? min_qod :
"");
1249 else if (strcmp (type,
"result") == 0)
1251 gchar *levels = g_strdup_printf (
1252 "%s%s%s%s%s", level_high ?
"h" :
"",
1253 level_medium ?
"m" :
"", level_low ?
"l" :
"",
1254 level_log ?
"g" :
"", level_false_positive ?
"f" :
"");
1255 task = g_strdup_printf (
1256 "apply_overrides=%i min_qod=%s" 1257 " autofp=%s levels=%s ",
1258 (overrides && !
str_equal (overrides,
"0")),
1259 min_qod ? min_qod :
"",
1260 (autofp && autofp_value) ? autofp_value :
"0", levels);
1266 search_phrase =
params_value (params,
"search_phrase");
1268 built_filter = g_strdup_printf (
1269 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1270 task ? task :
"", task_id ?
"task_id=" :
"",
1271 task_id ? task_id :
"", task_id ?
" " :
"",
1272 first ?
"first=" :
"", first ? first :
"", first ?
" " :
"",
1273 max ?
"rows=" :
"", max ? max :
"", max ?
" " :
"",
1274 sort_field ? ((sort_order && strcmp (sort_order,
"ascending"))
1278 sort_field ? sort_field :
"", sort_field ?
" " :
"",
1279 permission ?
"permission=" :
"", permission ? permission :
"",
1280 permission ?
" " :
"", owner ?
"owner=" :
"",
1281 owner ? owner :
"", owner ?
" " :
"",
1282 (filter && search_phrase) ?
" " :
"", filter ? filter :
"",
1283 search_phrase ?
" " :
"", search_phrase ? search_phrase :
"");
1287 else if (strcmp (type,
"info") == 0
1291 filter =
"sort-reverse=published rows=-2";
1293 filter =
"sort-reverse=modified rows=-2";
1295 filter =
"sort-reverse=created rows=-2";
1298 filter =
"sort=roles rows=-2";
1301 const char *task_id;
1304 built_filter = g_strdup_printf (
"task_id=%s apply_overrides=1" 1305 " rows=-2 sort-reverse=date",
1308 filter =
"apply_overrides=1 rows=-2 sort-reverse=date";
1312 built_filter = g_strdup_printf (
1313 "apply_overrides=%d autofp=%s rows=-2" 1314 " sort-reverse=created",
1315 (overrides == NULL ||
str_equal (overrides,
"1")),
1316 (autofp &&
str_equal (autofp,
"1")) ? autofp_value :
"0");
1320 filter =
"rows=-2 sort=nvt";
1325 filter =
"apply_overrides=1 rows=-2";
1326 if (filt_id && !
str_equal (filt_id,
""))
1335 else if (
str_equal (filter,
"apply_overrides=1")
1339 else if (replace_task_id)
1341 const char *task_id;
1345 g_strdup_printf (
"task_id=%s %s", task_id, filter ? filter :
"");
1350 request = g_markup_printf_escaped (
1352 " %sfilter=\"%s%s%s%s\"" 1353 " filter_replace=\"%s\"" 1356 " sort_field=\"%s\"" 1357 " sort_order=\"%s\"",
1358 strcmp (type,
"report") ?
"" :
"report_", filt_id ? filt_id :
"0",
1359 strcmp (type,
"report") ?
"" :
"report_",
1360 built_filter ? built_filter : (filter ? filter :
""),
1361 filter_extra ?
" " :
"", filter_extra ? filter_extra :
"",
1362 filter_extra ?
" " :
"", replace_task_id ?
"task_id" :
"",
1363 first ? first :
"1", max ? max :
"-2", sort_field ? sort_field :
"name",
1364 sort_order ? sort_order :
"ascending");
1366 g_free (built_filter);
1367 if (gvm_connection_sendf (connection,
"<get_%s details=\"%s\" %s %s/>",
1369 strcmp (type,
"report") ? details :
"0", request,
1370 extra_attribs ? extra_attribs :
"")
1374 g_string_free (xml, TRUE);
1375 g_string_free (type_many, TRUE);
1377 MHD_HTTP_INTERNAL_SERVER_ERROR);
1379 credentials,
"Internal error", __FUNCTION__, __LINE__,
1380 "An internal error occurred while getting a resource list. " 1381 "The current list of resources is not available. " 1382 "Diagnostics: Failure to send command to manager daemon.",
1386 if (read_string_c (connection, &xml))
1388 g_string_free (xml, TRUE);
1389 g_string_free (type_many, TRUE);
1391 MHD_HTTP_INTERNAL_SERVER_ERROR);
1393 credentials,
"Internal error", __FUNCTION__, __LINE__,
1394 "An internal error occurred while getting resources list. " 1395 "The current list of resources is not available. " 1396 "Diagnostics: Failure to receive response from manager daemon.",
1401 g_string_append_printf (xml,
"</get_%s>", type_many->str);
1402 g_string_free (type_many, TRUE);
1404 g_string_free (xml, FALSE), response_data);
1423 const char *extra_get_attribs,
const char *extra_xml,
1428 const char *resource_id;
1430 id_name = g_strdup_printf (
"%s_id", type);
1434 if (resource_id == NULL)
1438 credentials,
"Internal error", __FUNCTION__, __LINE__,
1439 "An internal error occurred while editing a resource. " 1440 "The resource remains as it was. " 1441 "Diagnostics: Required ID parameter was NULL.",
1445 if (gvm_connection_sendf (connection,
1450 type, extra_get_attribs ? extra_get_attribs :
"",
1455 MHD_HTTP_INTERNAL_SERVER_ERROR);
1457 credentials,
"Internal error", __FUNCTION__, __LINE__,
1458 "An internal error occurred while getting a resource. " 1459 "Diagnostics: Failure to send command to manager daemon.",
1463 xml = g_string_new (
"");
1465 g_string_append_printf (xml,
"<edit_%s>", type);
1468 g_string_append (xml, extra_xml);
1470 if (read_string_c (connection, &xml))
1472 g_string_free (xml, TRUE);
1474 MHD_HTTP_INTERNAL_SERVER_ERROR);
1476 credentials,
"Internal error", __FUNCTION__, __LINE__,
1477 "An internal error occurred while getting a resource. " 1478 "Diagnostics: Failure to receive response from manager daemon.",
1484 g_string_append_printf (xml,
"</edit_%s>", type);
1486 g_string_free (xml, FALSE), response_data);
1502 const char *type,
const char *uuid, entity_t resource_entity)
1504 gchar *creation_time, *modification_time, *name, *format_name;
1507 if (resource_entity)
1509 entity_t creation_time_entity, modification_time_entity;
1510 entity_t task_entity, format_entity, format_name_entity, name_entity;
1512 creation_time_entity = entity_child (resource_entity,
"creation_time");
1514 if (creation_time_entity)
1515 creation_time = entity_text (creation_time_entity);
1517 creation_time = NULL;
1519 modification_time_entity =
1520 entity_child (resource_entity,
"modification_time");
1522 if (modification_time_entity)
1523 modification_time = entity_text (modification_time_entity);
1525 modification_time = NULL;
1527 if (strcasecmp (type,
"report") == 0)
1529 task_entity = entity_child (resource_entity,
"task");
1531 name_entity = entity_child (task_entity,
"name");
1535 format_entity = entity_child (resource_entity,
"report_format");
1538 format_name_entity = entity_child (format_entity,
"name");
1541 format_name_entity = NULL;
1543 if (format_name_entity && strlen (entity_text (format_name_entity)))
1544 format_name = entity_text (format_name_entity);
1550 name_entity = entity_child (resource_entity,
"name");
1555 name = entity_text (name_entity);
1561 creation_time = NULL;
1562 modification_time = NULL;
1570 creation_time, modification_time, name, format_name);
1592 entity_t resource_entity;
1593 char *content = NULL;
1595 gchar *fname_format, *file_name;
1597 const char *resource_id, *subtype;
1599 xml = g_string_new (
"");
1601 id_name = g_strdup_printf (
"%s_id", type);
1605 if (resource_id == NULL)
1609 g_string_free (xml, FALSE), response_data);
1614 if (gvm_connection_sendf (connection,
1620 type, type, resource_id, subtype ?
" type=\"" :
"",
1621 subtype ? subtype :
"", subtype ?
"\"" :
"")
1624 g_string_free (xml, TRUE);
1626 MHD_HTTP_INTERNAL_SERVER_ERROR);
1628 credentials,
"Internal error", __FUNCTION__, __LINE__,
1629 "An internal error occurred while getting a resource. " 1630 "The resource could not be delivered. " 1631 "Diagnostics: Failure to send command to manager daemon.",
1636 if (read_entity_and_text_c (connection, &entity, &content))
1638 g_string_free (xml, TRUE);
1640 MHD_HTTP_INTERNAL_SERVER_ERROR);
1642 credentials,
"Internal error", __FUNCTION__, __LINE__,
1643 "An internal error occurred while getting a resource. " 1644 "The resource could not be delivered. " 1645 "Diagnostics: Failure to receive response from manager daemon.",
1652 resource_entity = entity_child (entity, type);
1654 if (resource_entity == NULL)
1657 free_entity (entity);
1658 g_string_free (xml, TRUE);
1660 MHD_HTTP_INTERNAL_SERVER_ERROR);
1662 credentials,
"Internal error", __FUNCTION__, __LINE__,
1663 "An internal error occurred while getting a resource. " 1664 "The resource could not be delivered. " 1665 "Diagnostics: Failure to receive resource from manager daemon.",
1670 &fname_format, response_data);
1674 free_entity (entity);
1675 g_string_free (xml, TRUE);
1677 MHD_HTTP_INTERNAL_SERVER_ERROR);
1682 credentials,
"Internal error", __FUNCTION__, __LINE__,
1683 "An internal error occurred while getting a setting. " 1684 "The setting could not be delivered. " 1685 "Diagnostics: Failure to send command to manager daemon.",
1689 credentials,
"Internal error", __FUNCTION__, __LINE__,
1690 "An internal error occurred while getting a setting. " 1691 "The setting could not be delivered. " 1692 "Diagnostics: Failure to receive response from manager daemon.",
1696 credentials,
"Internal error", __FUNCTION__, __LINE__,
1697 "An internal error occurred while getting a setting. " 1698 "The setting could not be delivered. " 1699 "Diagnostics: Internal error.",
1704 if (fname_format == NULL)
1706 g_warning (
"%s : File name format setting not found.", __FUNCTION__);
1707 fname_format =
"%T-%U";
1712 if (file_name == NULL)
1713 file_name = g_strdup_printf (
"%s-%s", type, resource_id);
1718 g_strdup_printf (
"attachment; filename=\"%s.xml\"", file_name));
1721 free_entity (entity);
1723 g_string_free (xml, TRUE);
1743 char *content = NULL;
1745 gchar *filter_escaped;
1747 gchar *fname_format, *file_name;
1752 filter_escaped = g_markup_escape_text (filter, -1);
1754 if (strcmp (type,
"info") == 0)
1756 if (gvm_connection_sendf (connection,
1763 filter_escaped ? filter_escaped :
"")
1766 g_free (filter_escaped);
1768 MHD_HTTP_INTERNAL_SERVER_ERROR);
1770 credentials,
"Internal error", __FUNCTION__, __LINE__,
1771 "An internal error occurred while getting a list. " 1772 "The list could not be delivered. " 1773 "Diagnostics: Failure to send command to manager daemon.",
1777 else if (strcmp (type,
"asset") == 0)
1779 if (gvm_connection_sendf (connection,
1786 filter_escaped ? filter_escaped :
"")
1789 g_free (filter_escaped);
1791 MHD_HTTP_INTERNAL_SERVER_ERROR);
1793 credentials,
"Internal error", __FUNCTION__, __LINE__,
1794 "An internal error occurred while getting a list. " 1795 "The list could not be delivered. " 1796 "Diagnostics: Failure to send command to manager daemon.",
1802 if (gvm_connection_sendf (connection,
1807 type, filter_escaped ? filter_escaped :
"")
1810 g_free (filter_escaped);
1812 MHD_HTTP_INTERNAL_SERVER_ERROR);
1814 credentials,
"Internal error", __FUNCTION__, __LINE__,
1815 "An internal error occurred while getting a list. " 1816 "The list could not be delivered. " 1817 "Diagnostics: Failure to send command to manager daemon.",
1821 g_free (filter_escaped);
1824 if (read_entity_and_text_c (connection, &entity, &content))
1827 MHD_HTTP_INTERNAL_SERVER_ERROR);
1829 credentials,
"Internal error", __FUNCTION__, __LINE__,
1830 "An internal error occurred while getting a list. " 1831 "The list could not be delivered. " 1832 "Diagnostics: Failure to receive response from manager daemon.",
1840 &fname_format, response_data);
1844 free_entity (entity);
1846 MHD_HTTP_INTERNAL_SERVER_ERROR);
1851 credentials,
"Internal error", __FUNCTION__, __LINE__,
1852 "An internal error occurred while getting a setting. " 1853 "The setting could not be delivered. " 1854 "Diagnostics: Failure to send command to manager daemon.",
1858 credentials,
"Internal error", __FUNCTION__, __LINE__,
1859 "An internal error occurred while getting a setting. " 1860 "The setting could not be delivered. " 1861 "Diagnostics: Failure to receive response from manager daemon.",
1865 credentials,
"Internal error", __FUNCTION__, __LINE__,
1866 "An internal error occurred while getting a setting. " 1867 "The setting could not be delivered. " 1868 "Diagnostics: Internal error.",
1873 if (fname_format == NULL)
1875 g_warning (
"%s : File name format setting not found.", __FUNCTION__);
1876 fname_format =
"%T-%D";
1879 if (strcmp (type,
"info") == 0)
1880 type_many = g_strdup (type);
1882 type_many = g_strdup_printf (
"%ss", type);
1886 if (file_name == NULL)
1887 file_name = g_strdup_printf (
"%s-%s", type_many,
"list");
1894 g_strdup_printf (
"attachment; filename=\"%s.xml\"", file_name));
1897 free_entity (entity);
1919 gchar *html, *response, *id_name, *resource_id, *extra_attribs;
1921 gchar *cap_type, *prev_action;
1923 id_name = g_strdup_printf (
"%s_id", type);
1925 resource_id = g_strdup (
params_value (params, id_name));
1931 credentials,
"Internal error", __FUNCTION__, __LINE__,
1932 "An internal error occurred while deleting a resource. " 1933 "The resource was not deleted. " 1934 "Diagnostics: Required parameter resource_id was NULL.",
1943 extra_attribs = NULL;
1946 if (strcmp (type,
"user") == 0)
1948 const char *inheritor_id;
1951 extra_attribs = g_strdup_printf (
"inheritor_id=\"%s\"", inheritor_id);
1954 "Invalid inheritor_id",
"Delete User");
1959 if (gvm_connection_sendf (
1960 connection,
"<delete_%s %s_id=\"%s\" ultimate=\"%i\"%s%s/>", type, type,
1961 resource_id, !!ultimate, extra_attribs ?
" " :
"",
1962 extra_attribs ? extra_attribs :
"")
1965 g_free (resource_id);
1966 g_free (extra_attribs);
1968 MHD_HTTP_INTERNAL_SERVER_ERROR);
1970 credentials,
"Internal error", __FUNCTION__, __LINE__,
1971 "An internal error occurred while deleting a resource. " 1972 "The resource is not deleted. " 1973 "Diagnostics: Failure to send command to manager daemon.",
1977 g_free (resource_id);
1978 g_free (extra_attribs);
1981 if (read_entity_and_text_c (connection, &entity, &response))
1984 MHD_HTTP_INTERNAL_SERVER_ERROR);
1986 credentials,
"Internal error", __FUNCTION__, __LINE__,
1987 "An internal error occurred while deleting a resource. " 1988 "It is unclear whether the resource has been deleted or not. " 1989 "Diagnostics: Failure to read response from manager daemon.",
1997 prev_action = g_strdup_printf (
"Delete %s", cap_type);
2000 prev_action, response_data);
2003 free_entity (entity);
2005 g_free (prev_action);
2045 const gchar *resource_type;
2047 resource_type =
params_value (params,
"resource_type");
2069 params_t *params,
const char *type,
const char *action,
2072 gchar *html, *response, *param_name;
2073 const char *resource_id;
2074 gchar *cap_action, *cap_type, *get_cmd, *prev_action;
2081 param_name = g_strdup_printf (
"%s_id", type);
2084 if (resource_id == NULL)
2087 message = g_strdup_printf (
2088 "An internal error occurred while performing an action. " 2089 "The resource remains the same. " 2090 "Diagnostics: Required parameter %s was NULL.",
2092 g_free (param_name);
2095 __LINE__, message, response_data);
2099 g_free (param_name);
2103 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
2104 "<%s_%s %s_id=\"%s\"/>", action, type, type, resource_id);
2112 MHD_HTTP_INTERNAL_SERVER_ERROR);
2114 credentials,
"Internal error", __FUNCTION__, __LINE__,
2115 "An internal error occurred while performing an action. " 2116 "The resource remains the same. " 2117 "Diagnostics: Failure to send command to manager daemon.",
2121 MHD_HTTP_INTERNAL_SERVER_ERROR);
2123 credentials,
"Internal error", __FUNCTION__, __LINE__,
2124 "An internal error occurred while performing an action. " 2125 "It is unclear whether the resource has been affected. " 2126 "Diagnostics: Failure to receive response from manager daemon.",
2130 MHD_HTTP_INTERNAL_SERVER_ERROR);
2132 credentials,
"Internal error", __FUNCTION__, __LINE__,
2133 "An internal error occurred while performing an action. " 2134 "It is unclear whether the resource has been affected. " 2135 "Diagnostics: Internal Error.",
2144 get_cmd = g_strdup_printf (
"get_%ss", type);
2145 prev_action = g_strdup_printf (
"%s %s", cap_action, cap_type);
2147 prev_action, response_data);
2150 free_entity (entity);
2151 g_free (cap_action);
2154 g_free (prev_action);
2206 #define PARAM_OR_SETTING(value, param, setting_id, cleanup) \ 2207 if (params_valid (params, param)) \ 2208 value = g_strdup (params_value (params, param)); \ 2212 message = setting_get_value_error (connection, credentials, setting_id, \ 2213 &value, response_data); \ 2250 gchar *command, *html, *response;
2251 const char *task_id, *name, *comment, *xml_file;
2252 const char *in_assets;
2260 if (task_id == NULL)
2270 if (strlen (xml_file) == 0)
2274 "Report required",
"Create Report");
2278 command = g_markup_printf_escaped (
"<create_task>" 2279 "<target id=\"0\"/>" 2281 "<comment>%s</comment>" 2287 gchar **xml_file_array, *xml_file_escaped;
2289 xml_file_array = g_strsplit (xml_file,
"%", -1);
2290 if (xml_file_array != NULL && xml_file_array[0] != NULL)
2291 xml_file_escaped = g_strjoinv (
"%%", xml_file_array);
2293 xml_file_escaped = g_strdup (xml_file);
2294 g_strfreev (xml_file_array);
2298 g_strdup_printf (
"<create_report>" 2299 "<in_assets>%s</in_assets>" 2303 in_assets ? in_assets :
"0", task_id ? task_id :
"0",
2304 xml_file_escaped ? xml_file_escaped :
"");
2307 gchar *name_escaped, *comment_escaped;
2308 name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
2309 comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
2310 command = g_strdup_printf (
"<create_report>" 2311 "<in_assets>%s</in_assets>" 2314 "<comment>%s</comment>" 2318 in_assets ? in_assets :
"", name_escaped,
2319 comment_escaped, xml_file_escaped);
2320 g_free (name_escaped);
2321 g_free (comment_escaped);
2323 g_free (xml_file_escaped);
2327 gmp (connection,
credentials, &response, &entity, response_data, command);
2339 MHD_HTTP_INTERNAL_SERVER_ERROR);
2341 credentials,
"Internal error", __FUNCTION__, __LINE__,
2342 "An internal error occurred while creating a new report. " 2343 "No new report was created. " 2344 "Diagnostics: Failure to send command to manager daemon.",
2348 MHD_HTTP_INTERNAL_SERVER_ERROR);
2350 credentials,
"Internal error", __FUNCTION__, __LINE__,
2351 "An internal error occurred while creating a new report. " 2352 "It is unclear whether the report has been created or not. " 2353 "Diagnostics: Failure to receive response from manager daemon.",
2357 MHD_HTTP_INTERNAL_SERVER_ERROR);
2359 credentials,
"Internal error", __FUNCTION__, __LINE__,
2360 "An internal error occurred while creating a new report. " 2361 "It is unclear whether the report has been created or not. " 2362 "Diagnostics: Internal Error.",
2367 "Import Report", response_data);
2368 free_entity (entity);
2407 gchar *command, *html, *response;
2408 const char *name, *comment;
2415 command = g_markup_printf_escaped (
"<create_task>" 2416 "<target id=\"0\"/>" 2418 "<comment>%s</comment>" 2422 gmp (connection,
credentials, &response, &entity, response_data, command);
2434 MHD_HTTP_INTERNAL_SERVER_ERROR);
2436 credentials,
"Internal error", __FUNCTION__, __LINE__,
2437 "An internal error occurred while creating a container task. " 2438 "No task was created. " 2439 "Diagnostics: Failure to send command to manager daemon.",
2443 MHD_HTTP_INTERNAL_SERVER_ERROR);
2445 credentials,
"Internal error", __FUNCTION__, __LINE__,
2446 "An internal error occurred while creating a container task. " 2447 "It is unclear whether the task has been created or not. " 2448 "Diagnostics: Failure to receive response from manager daemon.",
2452 MHD_HTTP_INTERNAL_SERVER_ERROR);
2454 credentials,
"Internal error", __FUNCTION__, __LINE__,
2455 "An internal error occurred while creating a container task. " 2456 "It is unclear whether the task has been created or not. " 2457 "Diagnostics: Internal Error.",
2461 if (entity_attribute (entity,
"id"))
2462 params_add (params,
"task_id", entity_attribute (entity,
"id"));
2464 "Create Container Task", response_data);
2465 free_entity (entity);
2486 gchar *schedule_element, *command;
2487 gchar *response, *html;
2488 const char *name, *comment, *config_id, *target_id, *scanner_type;
2489 const char *scanner_id, *schedule_id, *schedule_periods;
2490 const char *max_checks, *max_hosts;
2491 const char *in_assets, *hosts_ordering, *alterable, *source_iface;
2492 const char *add_tag, *tag_id, *auto_delete, *auto_delete_data;
2493 const char *apply_overrides, *min_qod;
2494 gchar *name_escaped, *comment_escaped;
2496 GString *alert_element;
2500 apply_overrides =
params_value (params,
"apply_overrides");
2502 auto_delete_data =
params_value (params,
"auto_delete_data");
2505 hosts_ordering =
params_value (params,
"hosts_ordering");
2514 schedule_periods =
params_value (params,
"schedule_periods");
2520 if (!strcmp (scanner_type,
"1"))
2522 hosts_ordering =
"";
2527 else if (!strcmp (scanner_type,
"3"))
2530 hosts_ordering =
"";
2548 "Given target_id was invalid",
"Create Task");
2556 schedule_periods =
"0";
2560 if (!strcmp (in_assets,
"1"))
2569 apply_overrides =
"";
2583 if (add_tag && strcmp (add_tag,
"1") == 0)
2588 if (schedule_id == NULL || strcmp (schedule_id,
"0") == 0)
2589 schedule_element = g_strdup (
"");
2591 schedule_element = g_strdup_printf (
"<schedule id=\"%s\"/>", schedule_id);
2593 alert_element = g_string_new (
"");
2608 g_string_append_printf (alert_element,
"<alert id=\"%s\"/>",
2612 name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
2613 comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
2615 command = g_strdup_printf (
2617 "<config id=\"%s\"/>" 2618 "<schedule_periods>%s</schedule_periods>" 2620 "<target id=\"%s\"/>" 2621 "<scanner id=\"%s\"/>" 2622 "<hosts_ordering>%s</hosts_ordering>" 2624 "<comment>%s</comment>" 2627 "<scanner_name>max_checks</scanner_name>" 2631 "<scanner_name>max_hosts</scanner_name>" 2635 "<scanner_name>in_assets</scanner_name>" 2640 "assets_apply_overrides" 2645 "<scanner_name>assets_min_qod</scanner_name>" 2649 "<scanner_name>source_iface</scanner_name>" 2653 "<scanner_name>auto_delete</scanner_name>" 2657 "<scanner_name>auto_delete_data</scanner_name>" 2661 "<alterable>%i</alterable>" 2663 config_id, schedule_periods, schedule_element, alert_element->str,
2664 target_id, scanner_id, hosts_ordering, name_escaped, comment_escaped,
2665 max_checks, max_hosts, strcmp (in_assets,
"0") ?
"yes" :
"no",
2666 strcmp (apply_overrides,
"0") ?
"yes" :
"no", min_qod, source_iface,
2667 auto_delete, auto_delete_data, alterable ? strcmp (alterable,
"0") : 0);
2669 g_free (name_escaped);
2670 g_free (comment_escaped);
2673 gmp (connection,
credentials, &response, &entity, response_data, command);
2676 g_free (schedule_element);
2677 g_string_free (alert_element, TRUE);
2688 MHD_HTTP_INTERNAL_SERVER_ERROR);
2690 credentials,
"Internal error", __FUNCTION__, __LINE__,
2691 "An internal error occurred while creating a new task. " 2692 "No new task was created. " 2693 "Diagnostics: Failure to send command to manager daemon.",
2697 MHD_HTTP_INTERNAL_SERVER_ERROR);
2699 credentials,
"Internal error", __FUNCTION__, __LINE__,
2700 "An internal error occurred while creating a new task. " 2701 "It is unclear whether the task has been created or not. " 2702 "Diagnostics: Failure to receive response from manager daemon.",
2706 MHD_HTTP_INTERNAL_SERVER_ERROR);
2708 credentials,
"Internal error", __FUNCTION__, __LINE__,
2709 "An internal error occurred while creating a new task. " 2710 "It is unclear whether the task has been created or not. " 2711 "Diagnostics: Internal Error.",
2717 if (add_tag && strcmp (add_tag,
"1") == 0)
2719 const char *new_task_id = entity_attribute (entity,
"id");
2720 gchar *tag_command, *tag_response;
2721 entity_t tag_entity;
2723 tag_command = g_markup_printf_escaped (
"<modify_tag tag_id=\"%s\">" 2724 "<resources action=\"add\">" 2725 "<resource id=\"%s\"/>" 2728 tag_id, new_task_id);
2731 response_data, tag_command);
2739 free_entity (entity);
2742 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2744 credentials,
"Internal error", __FUNCTION__, __LINE__,
2745 "An internal error occurred while creating a new tag. " 2746 "No new tag was created. " 2747 "Diagnostics: Failure to send command to manager daemon.",
2750 free_entity (entity);
2753 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2755 credentials,
"Internal error", __FUNCTION__, __LINE__,
2756 "An internal error occurred while creating a new tag. " 2757 "It is unclear whether the tag has been created or not. " 2758 "Diagnostics: Failure to receive response from manager daemon.",
2761 free_entity (entity);
2764 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2766 credentials,
"Internal error", __FUNCTION__, __LINE__,
2767 "An internal error occurred while creating a new task. " 2768 "It is unclear whether the tag has been created or not. " 2769 "Diagnostics: Internal Error.",
2773 if (entity_attribute (entity,
"id"))
2774 params_add (params,
"task_id", entity_attribute (entity,
"id"));
2777 "Create Task and Tag", response_data);
2778 free_entity (tag_entity);
2779 g_free (tag_response);
2783 if (entity_attribute (entity,
"id"))
2784 params_add (params,
"task_id", entity_attribute (entity,
"id"));
2786 "Create Task", response_data);
2792 "Create Task", response_data);
2794 free_entity (entity);
2831 gchar *html, *response, *format;
2832 const char *comment, *name, *schedule_id, *in_assets;
2833 const char *scanner_id, *task_id, *max_checks, *max_hosts;
2834 const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
2835 const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
2836 const char *apply_overrides, *min_qod;
2839 GString *alert_element;
2843 apply_overrides =
params_value (params,
"apply_overrides");
2845 auto_delete_data =
params_value (params,
"auto_delete_data");
2848 hosts_ordering =
params_value (params,
"hosts_ordering");
2857 schedule_periods =
params_value (params,
"schedule_periods");
2862 if (scanner_type != NULL)
2865 if (!strcmp (scanner_type,
"1"))
2867 hosts_ordering =
"";
2872 else if (!strcmp (scanner_type,
"3"))
2875 hosts_ordering =
"";
2893 schedule_periods =
"0";
2903 if (!strcmp (in_assets,
"1"))
2912 apply_overrides =
"";
2919 alert_element = g_string_new (
"");
2935 g_string_append_printf (alert_element,
"<alert id=\"%s\"/>",
2941 if (strcmp (alert_element->str,
"") == 0)
2942 g_string_append_printf (alert_element,
"<alert id=\"0\"/>");
2944 format = g_strdup_printf (
2945 "<modify_task task_id=\"%%s\">" 2947 "<comment>%%s</comment>" 2948 "<hosts_ordering>%s</hosts_ordering>" 2950 "<target id=\"%%s\"/>" 2951 "<config id=\"%%s\"/>" 2952 "<schedule id=\"%%s\"/>" 2953 "<schedule_periods>%%s</schedule_periods>" 2954 "<scanner id=\"%%s\"/>" 2957 "<scanner_name>max_checks</scanner_name>" 2958 "<value>%%s</value>" 2961 "<scanner_name>max_hosts</scanner_name>" 2962 "<value>%%s</value>" 2965 "<scanner_name>in_assets</scanner_name>" 2966 "<value>%%s</value>" 2969 "<scanner_name>assets_apply_overrides</scanner_name>" 2970 "<value>%%s</value>" 2973 "<scanner_name>assets_min_qod</scanner_name>" 2974 "<value>%%s</value>" 2977 "<scanner_name>source_iface</scanner_name>" 2978 "<value>%%s</value>" 2981 "<scanner_name>auto_delete</scanner_name>" 2982 "<value>%%s</value>" 2985 "<scanner_name>auto_delete_data</scanner_name>" 2986 "<value>%%s</value>" 2991 hosts_ordering, alert_element->str, alterable ?
"<alterable>" :
"",
2992 alterable ? strcmp (alterable,
"0") : 0, alterable ?
"</alterable>" :
"");
2995 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
2996 format, task_id, name, comment, target_id, config_id, schedule_id,
2997 schedule_periods, scanner_id, max_checks, max_hosts,
2998 strcmp (in_assets,
"0") ?
"yes" :
"no",
2999 strcmp (apply_overrides,
"0") ?
"yes" :
"no", min_qod,
3000 source_iface, auto_delete, auto_delete_data);
3003 g_string_free (alert_element, TRUE);
3012 MHD_HTTP_INTERNAL_SERVER_ERROR);
3014 credentials,
"Internal error", __FUNCTION__, __LINE__,
3015 "An internal error occurred while saving a task. " 3016 "The task was not saved. " 3017 "Diagnostics: Failure to send command to manager daemon.",
3021 MHD_HTTP_INTERNAL_SERVER_ERROR);
3023 credentials,
"Internal error", __FUNCTION__, __LINE__,
3024 "An internal error occurred while saving a task. " 3025 "It is unclear whether the task has been saved or not. " 3026 "Diagnostics: Failure to receive response from manager daemon.",
3030 MHD_HTTP_INTERNAL_SERVER_ERROR);
3032 credentials,
"Internal error", __FUNCTION__, __LINE__,
3033 "An internal error occurred while saving a task. " 3034 "It is unclear whether the task has been saved or not. " 3035 "Diagnostics: Internal Error.",
3040 "Save Task", response_data);
3041 free_entity (entity);
3063 gchar *format, *response, *html;
3064 const char *comment, *name, *task_id;
3065 const char *in_assets, *auto_delete, *auto_delete_data;
3074 auto_delete_data =
params_value (params,
"auto_delete_data");
3082 format = g_strdup_printf (
"<modify_task task_id=\"%%s\">" 3084 "<comment>%%s</comment>" 3087 "<scanner_name>in_assets</scanner_name>" 3088 "<value>%%s</value>" 3091 "<scanner_name>auto_delete</scanner_name>" 3092 "<value>%%s</value>" 3095 "<scanner_name>auto_delete_data</scanner_name>" 3096 "<value>%%s</value>" 3104 gmpf (connection,
credentials, &response, &entity, response_data, format,
3105 task_id, name, comment, strcmp (in_assets,
"0") ?
"yes" :
"no",
3106 auto_delete, auto_delete_data);
3115 MHD_HTTP_INTERNAL_SERVER_ERROR);
3117 credentials,
"Internal error", __FUNCTION__, __LINE__,
3118 "An internal error occurred while saving a task. " 3119 "No new task was created. " 3120 "Diagnostics: Failure to send command to manager daemon.",
3124 MHD_HTTP_INTERNAL_SERVER_ERROR);
3126 credentials,
"Internal error", __FUNCTION__, __LINE__,
3127 "An internal error occurred while saving a task. " 3128 "It is unclear whether the task has been created or not. " 3129 "Diagnostics: Failure to receive response from manager daemon.",
3133 MHD_HTTP_INTERNAL_SERVER_ERROR);
3135 credentials,
"Internal error", __FUNCTION__, __LINE__,
3136 "An internal error occurred while saving a task. " 3137 "It is unclear whether the task has been created or not. " 3138 "Diagnostics: Internal Error.",
3143 "Save Container Task", response_data);
3144 free_entity (entity);
3253 gchar *command, *response, *html;
3254 const char *task_id, *slave_id;
3261 command = g_strdup_printf (
"<move_task task_id=\"%s\" slave_id=\"%s\"/>",
3262 task_id ? task_id :
"", slave_id ? slave_id :
"");
3267 gmp (connection,
credentials, &response, &entity, response_data, command);
3278 MHD_HTTP_INTERNAL_SERVER_ERROR);
3280 credentials,
"Internal error", __FUNCTION__, __LINE__,
3281 "An internal error occurred while moving a task. " 3282 "The task was not moved. " 3283 "Diagnostics: Failure to send command to manager daemon.",
3287 MHD_HTTP_INTERNAL_SERVER_ERROR);
3289 credentials,
"Internal error", __FUNCTION__, __LINE__,
3290 "An internal error occurred while moving a task. " 3291 "It is unclear whether the task has been moved or not. " 3292 "Diagnostics: Failure to receive response from manager daemon.",
3296 MHD_HTTP_INTERNAL_SERVER_ERROR);
3298 credentials,
"Internal error", __FUNCTION__, __LINE__,
3299 "An internal error occurred while moving a task. " 3300 "It is unclear whether the task has been moved or not. " 3301 "Diagnostics: Internal Error.",
3306 "Move Task", response_data);
3308 free_entity (entity);
3326 params_t *params,
const char *extra_xml,
3330 GString *extra_attribs, *extra_response;
3331 const char *info_type;
3334 if (info_type == NULL)
3343 if (strcmp (info_type,
"nvt") && strcmp (info_type,
"cve")
3344 && strcmp (info_type,
"cpe") && strcmp (info_type,
"ovaldef")
3345 && strcmp (info_type,
"cert_bund_adv")
3346 && strcmp (info_type,
"dfn_cert_adv") && strcmp (info_type,
"allinfo")
3347 && strcmp (info_type,
"NVT") && strcmp (info_type,
"CVE")
3348 && strcmp (info_type,
"CPE") && strcmp (info_type,
"OVALDEF")
3349 && strcmp (info_type,
"CERT_BUND_ADV")
3350 && strcmp (info_type,
"DFN_CERT_ADV") && strcmp (info_type,
"ALLINFO"))
3355 "An internal error occurred while getting SecInfo. " 3356 "Diagnostics: Invalid info_type parameter value",
3365 "An internal error occurred while getting SecInfo. " 3366 "Diagnostics: Both ID and Name set.",
3369 extra_response = g_string_new (extra_xml ? extra_xml :
"");
3372 && (strcasecmp (info_type,
"NVT") == 0)
3381 " sort_field=\"notes.text\"/>",
3384 g_string_free (extra_response, TRUE);
3388 g_string_append (extra_response, response);
3392 && (strcasecmp (info_type,
"NVT") == 0)
3401 " sort_field=\"overrides.text\"/>",
3404 g_string_free (extra_response, TRUE);
3408 g_string_append (extra_response, response);
3411 extra_attribs = g_string_new (
"");
3412 g_string_append_printf (extra_attribs,
"type=\"%s\"",
3415 g_string_append_printf (extra_attribs,
" name=\"%s\"",
3418 g_string_append_printf (extra_attribs,
" info_id=\"%s\"",
3421 g_string_append_printf (extra_attribs,
" details=\"%s\"",
3424 extra_attribs->str, response_data);
3426 g_string_free (extra_response, TRUE);
3427 g_string_free (extra_attribs, TRUE);
3458 param_t *filt_id, *build_filter;
3459 const char *new_filt_id;
3461 build_filter =
params_get (params,
"build_filter");
3471 filt_id->
value = g_strdup (new_filt_id);
3479 if (build_filter == NULL)
3483 if (filter && filter->
value)
3486 old = filter->
value;
3488 g_strdup_printf (
"apply_overrides=%s %s", overrides, old);
3491 else if (strcmp (overrides,
"0"))
3492 params_add (params,
"filter",
"apply_overrides=1 rows=-2");
3494 params_add (params,
"filter",
"apply_overrides=0 rows=-2");
3511 params_t *params,
const char *extra_xml,
3514 const char *overrides, *schedules_only, *ignore_pagination;
3515 gchar *extra_attribs, *ret;
3518 schedules_only =
params_value (params,
"schedules_only");
3519 ignore_pagination =
params_value (params,
"ignore_pagination");
3525 extra_attribs = g_strdup_printf (
3528 schedules_only ?
"schedules_only=\"" :
"",
3529 schedules_only ? schedules_only :
"", schedules_only ?
"\" " :
"",
3530 ignore_pagination ?
"ignore_pagination=\"" :
"",
3531 ignore_pagination ? ignore_pagination :
"", ignore_pagination ?
"\" " :
"");
3534 extra_attribs, response_data);
3535 g_free (extra_attribs);
3589 gchar *html, *response;
3590 const char *name, *comment, *
login, *type, *password, *passphrase;
3591 const char *private_key, *public_key, *certificate, *community;
3592 const char *privacy_password, *auth_algorithm, *privacy_algorithm;
3593 const char *autogenerate, *allow_insecure;
3606 privacy_password =
params_value (params,
"privacy_password");
3607 auth_algorithm =
params_value (params,
"auth_algorithm");
3608 privacy_algorithm =
params_value (params,
"privacy_algorithm");
3609 allow_insecure =
params_value (params,
"allow_insecure");
3625 "<create_credential>" 3627 "<comment>%s</comment>" 3629 "<allow_insecure>%s</allow_insecure>" 3630 "</create_credential>",
3631 name, comment ? comment :
"", type, allow_insecure);
3640 "<create_credential>" 3642 "<comment>%s</comment>" 3645 "<allow_insecure>%s</allow_insecure>" 3646 "</create_credential>",
3647 name, comment ? comment :
"", type,
login, allow_insecure);
3659 "<create_credential>" 3661 "<comment>%s</comment>" 3664 "<password>%s</password>" 3665 "<allow_insecure>%s</allow_insecure>" 3666 "</create_credential>",
3667 name, comment ? comment :
"", type,
login ?
login :
"",
3668 password ? password :
"", allow_insecure);
3678 "<create_credential>" 3680 "<comment>%s</comment>" 3684 "<private>%s</private>" 3685 "<phrase>%s</phrase>" 3687 "<allow_insecure>%s</allow_insecure>" 3688 "</create_credential>",
3689 name, comment ? comment :
"", type,
login ?
login :
"",
3690 private_key ? private_key :
"", passphrase ? passphrase :
"",
3699 connection,
credentials, &response, &entity, response_data,
3700 "<create_credential>" 3702 "<comment>%s</comment>" 3704 "<certificate>%s</certificate>" 3706 "<private>%s</private>" 3708 "<allow_insecure>%s</allow_insecure>" 3709 "</create_credential>",
3710 name, comment ? comment :
"", type, certificate ? certificate :
"",
3711 private_key ? private_key :
"", allow_insecure);
3722 if (privacy_password && strcmp (privacy_password,
""))
3724 connection,
credentials, &response, &entity, response_data,
3725 "<create_credential>" 3727 "<comment>%s</comment>" 3729 "<community>%s</community>" 3731 "<password>%s</password>" 3733 "<password>%s</password>" 3734 "<algorithm>%s</algorithm>" 3736 "<auth_algorithm>%s</auth_algorithm>" 3737 "<allow_insecure>%s</allow_insecure>" 3738 "</create_credential>",
3739 name, comment ? comment :
"", type, community ? community :
"",
3740 login ?
login :
"", password ? password :
"",
3741 privacy_password ? privacy_password :
"",
3742 privacy_algorithm ? privacy_algorithm :
"",
3743 auth_algorithm ? auth_algorithm :
"", allow_insecure);
3746 connection,
credentials, &response, &entity, response_data,
3747 "<create_credential>" 3749 "<comment>%s</comment>" 3751 "<community>%s</community>" 3753 "<password>%s</password>" 3754 "<auth_algorithm>%s</auth_algorithm>" 3755 "<allow_insecure>%s</allow_insecure>" 3756 "</create_credential>",
3757 name, comment ? comment :
"", type, community ? community :
"",
3758 login ?
login :
"", password ? password :
"",
3759 auth_algorithm ? auth_algorithm :
"", allow_insecure);
3766 connection,
credentials, &response, &entity, response_data,
3767 "<create_credential>" 3769 "<comment>%s</comment>" 3772 "<public>%s</public>" 3774 "<allow_insecure>%s</allow_insecure>" 3775 "</create_credential>",
3776 name, comment ? comment :
"", type, public_key, allow_insecure);
3783 connection,
credentials, &response, &entity, response_data,
3784 "<create_credential>" 3786 "<comment>%s</comment>" 3788 "<certificate>%s</certificate>" 3789 "<allow_insecure>%s</allow_insecure>" 3790 "</create_credential>",
3791 name, comment ? comment :
"", type, certificate, allow_insecure);
3793 else if (type && (strcmp (type,
"pw") == 0))
3799 "<create_credential>" 3801 "<comment>%s</comment>" 3803 "<password>%s</password>" 3804 "<allow_insecure>%s</allow_insecure>" 3805 "</create_credential>",
3806 name, comment ? comment :
"", type, password ? password :
"",
3812 MHD_HTTP_INTERNAL_SERVER_ERROR);
3814 credentials,
"Internal error", __FUNCTION__, __LINE__,
3815 "An internal error occurred while creating a new credential. " 3816 "The credential could not be created. " 3817 "Diagnostics: Unrecognized credential type.",
3830 MHD_HTTP_INTERNAL_SERVER_ERROR);
3832 credentials,
"Internal error", __FUNCTION__, __LINE__,
3833 "An internal error occurred while creating a new credential. " 3834 "It is unclear whether the credential has been created or not. " 3835 "Diagnostics: Failure to send command to manager daemon.",
3839 MHD_HTTP_INTERNAL_SERVER_ERROR);
3841 credentials,
"Internal error", __FUNCTION__, __LINE__,
3842 "An internal error occurred while creating a new credential. " 3843 "It is unclear whether the credential has been created or not. " 3844 "Diagnostics: Failure to receive response from manager daemon.",
3848 MHD_HTTP_INTERNAL_SERVER_ERROR);
3850 credentials,
"Internal error", __FUNCTION__, __LINE__,
3851 "An internal error occurred while creating a new credential. " 3852 "It is unclear whether the credential has been created or not. " 3853 "Diagnostics: Internal Error.",
3857 if (entity_attribute (entity,
"id"))
3858 params_add (params,
"credential_id", entity_attribute (entity,
"id"));
3860 "Create Credential", response_data);
3861 free_entity (entity);
3879 params_t *params,
const char *extra_xml,
3883 "targets=\"1\" scanners=\"1\"", response_data);
3919 char **html,
char **
login,
3923 const char *credential_id, *format;
3929 credential_id =
params_value (params,
"credential_id");
3932 if ((credential_id == NULL) || (format == NULL))
3937 "An internal error occurred while getting a credential. " 3938 "Diagnostics: Required parameter was NULL.",
3943 if (gvm_connection_sendf (connection,
3945 " credential_id=\"%s\"" 3947 credential_id, format)
3951 MHD_HTTP_INTERNAL_SERVER_ERROR);
3954 "An internal error occurred while getting a credential. " 3955 "Diagnostics: Failure to send command to manager daemon.",
3962 if (strcmp (format,
"rpm") == 0 || strcmp (format,
"deb") == 0
3963 || strcmp (format,
"exe") == 0)
3965 gchar *package_decoded = NULL;
3966 entity_t package_entity = NULL, credential_entity;
3971 if (read_entity_c (connection, &entity))
3974 MHD_HTTP_INTERNAL_SERVER_ERROR);
3976 credentials,
"Internal error", __FUNCTION__, __LINE__,
3977 "An internal error occurred while getting a credential. " 3978 "The credential is not available. " 3979 "Diagnostics: Failure to receive response from manager daemon.",
3984 credential_entity = entity_child (entity,
"credential");
3985 if (credential_entity)
3986 package_entity = entity_child (credential_entity,
"package");
3987 if (package_entity != NULL)
3990 char *package_encoded = entity_text (package_entity);
3991 if (strlen (package_encoded))
3994 (gchar *) g_base64_decode (package_encoded, &len);
3995 if (package_decoded == NULL)
3997 package_decoded = (gchar *) g_strdup (
"");
4003 package_decoded = (gchar *) g_strdup (
"");
4009 *html = package_decoded;
4012 entity_t login_entity;
4013 login_entity = entity_child (credential_entity,
"login");
4015 *
login = g_strdup (entity_text (login_entity));
4019 free_entity (entity);
4024 free_entity (entity);
4026 MHD_HTTP_INTERNAL_SERVER_ERROR);
4028 credentials,
"Internal error", __FUNCTION__, __LINE__,
4029 "An internal error occurred while getting a credential. " 4030 "The credential could not be delivered. " 4031 "Diagnostics: Failure to receive credential from manager daemon.",
4038 entity_t credential_entity, key_entity = NULL;
4043 if (read_entity_c (connection, &entity))
4046 MHD_HTTP_INTERNAL_SERVER_ERROR);
4048 credentials,
"Internal error", __FUNCTION__, __LINE__,
4049 "An internal error occurred while getting a credential. " 4050 "The credential could not be delivered. " 4051 "Diagnostics: Failure to receive credential from manager daemon.",
4056 credential_entity = entity_child (entity,
"credential");
4057 if (credential_entity)
4059 if (strcmp (format,
"pem") == 0)
4060 key_entity = entity_child (credential_entity,
"certificate");
4062 key_entity = entity_child (credential_entity,
"public_key");
4064 if (key_entity != NULL)
4066 *html = g_strdup (entity_text (key_entity));
4069 entity_t login_entity = entity_child (credential_entity,
"login");
4071 *
login = g_strdup (entity_text (login_entity));
4075 free_entity (entity);
4079 MHD_HTTP_INTERNAL_SERVER_ERROR);
4081 credentials,
"Internal error", __FUNCTION__, __LINE__,
4082 "An internal error occurred while getting a credential. " 4083 "The credential could not be delivered. " 4084 "Diagnostics: Failure to parse credential from manager daemon.",
4086 free_entity (entity);
4144 params_t *params,
const char *extra_xml,
4148 NULL, response_data);
4200 int ret, change_password, change_ssh_passphrase;
4201 int change_community, change_privacy_password;
4202 gchar *html, *response;
4203 const char *credential_id, *public_key;
4204 const char *name, *comment, *
login, *password, *passphrase, *type;
4205 const char *private_key, *certificate, *community, *privacy_password;
4206 const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
4210 credential_id =
params_value (params,
"credential_id");
4220 privacy_password =
params_value (params,
"privacy_password");
4221 auth_algorithm =
params_value (params,
"auth_algorithm");
4222 privacy_algorithm =
params_value (params,
"privacy_algorithm");
4223 allow_insecure =
params_value (params,
"allow_insecure");
4279 command = g_string_new (
"");
4281 xml_string_append (command,
4282 "<modify_credential credential_id=\"%s\">" 4284 "<comment>%s</comment>" 4285 "<allow_insecure>%s</allow_insecure>",
4286 credential_id, name, comment, allow_insecure);
4291 change_privacy_password =
4295 xml_string_append (command,
"<auth_algorithm>%s</auth_algorithm>",
4298 if (change_community)
4299 xml_string_append (command,
"<community>%s</community>", community);
4301 if (privacy_algorithm || change_privacy_password)
4303 xml_string_append (command,
"<privacy>");
4304 if (privacy_algorithm)
4306 xml_string_append (command,
"<algorithm>%s</algorithm>",
4309 if (change_privacy_password && privacy_password)
4311 xml_string_append (command,
"<password>%s</password>",
4315 xml_string_append (command,
"</privacy>");
4320 if ((certificate && strcmp (certificate,
"")))
4322 xml_string_append (command,
"<certificate>%s</certificate>",
4326 if ((private_key && strcmp (private_key,
"")))
4328 xml_string_append (command,
"<key>");
4329 xml_string_append (command,
"<private>%s</private>", private_key);
4330 xml_string_append (command,
"</key>");
4337 if ((private_key && strcmp (private_key,
"")) || change_ssh_passphrase)
4339 xml_string_append (command,
"<key>");
4340 if (change_ssh_passphrase)
4341 xml_string_append (command,
"<phrase>%s</phrase>", passphrase);
4343 xml_string_append (command,
"<private>%s</private>", private_key);
4344 xml_string_append (command,
"</key>");
4349 if (change_password)
4350 xml_string_append (command,
"<password>%s</password>", password);
4354 if ((certificate && strcmp (certificate,
"")))
4356 xml_string_append (command,
"<certificate>%s</certificate>",
4362 if ((public_key && strcmp (public_key,
"")))
4364 xml_string_append (command,
"<key>");
4365 xml_string_append (command,
"<public>%s</public>", public_key);
4366 xml_string_append (command,
"</key>");
4371 xml_string_append (command,
"<login>%s</login>",
login);
4373 xml_string_append (command,
"</modify_credential>");
4378 ret =
gmp (connection,
credentials, &response, &entity, response_data,
4380 g_string_free (command, TRUE);
4391 MHD_HTTP_INTERNAL_SERVER_ERROR);
4393 credentials,
"Internal error", __FUNCTION__, __LINE__,
4394 "An internal error occurred while saving a Credential. " 4395 "The Credential was not saved. " 4396 "Diagnostics: Failure to send command to manager daemon.",
4400 MHD_HTTP_INTERNAL_SERVER_ERROR);
4402 credentials,
"Internal error", __FUNCTION__, __LINE__,
4403 "An internal error occurred while saving a Credential. " 4404 "It is unclear whether the Credential has been saved or not. " 4405 "Diagnostics: Failure to receive response from manager daemon.",
4409 MHD_HTTP_INTERNAL_SERVER_ERROR);
4411 credentials,
"Internal error", __FUNCTION__, __LINE__,
4412 "An internal error occurred while saving a Credential. " 4413 "It is unclear whether the Credential has been saved or not. " 4414 "Diagnostics: Internal Error.",
4419 "Save Credential", response_data);
4420 free_entity (entity);
4440 gchar *response, *html;
4441 const char *name, *comment, *installer, *installer_filename, *installer_sig;
4442 const char *howto_install, *howto_use;
4443 int installer_size, installer_sig_size, howto_install_size, howto_use_size;
4445 gchar *name_escaped, *comment_escaped;
4446 gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
4454 installer_sig =
params_value (params,
"installer_sig");
4456 howto_install =
params_value (params,
"howto_install");
4466 installer_64 = (installer_size > 0)
4467 ? g_base64_encode ((guchar *) installer, installer_size)
4471 (installer_sig_size > 0)
4472 ? g_base64_encode ((guchar *) installer_sig, installer_sig_size)
4476 (howto_install_size > 0)
4477 ? g_base64_encode ((guchar *) howto_install, howto_install_size)
4480 howto_use_64 = (howto_use_size > 0)
4481 ? g_base64_encode ((guchar *) howto_use, howto_use_size)
4484 name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
4485 comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
4487 command = g_strdup_printf (
"<create_agent>" 4492 "<signature>%s</signature>" 4493 "<filename>%s</filename>" 4495 "<howto_install>%s</howto_install>" 4496 "<howto_use>%s</howto_use>" 4498 name_escaped, comment_escaped ?
"<comment>" :
"",
4499 comment_escaped ? comment_escaped :
"",
4500 comment_escaped ?
"</comment>" :
"", installer_64,
4502 installer_filename ? installer_filename :
"",
4503 howto_install_64, howto_use_64);
4506 gmp (connection,
credentials, &response, &entity, response_data, command);
4509 g_free (installer_64);
4510 g_free (howto_install_64);
4511 g_free (howto_use_64);
4512 g_free (name_escaped);
4513 g_free (comment_escaped);
4524 MHD_HTTP_INTERNAL_SERVER_ERROR);
4526 credentials,
"Internal error", __FUNCTION__, __LINE__,
4527 "An internal error occurred while creating a new agent. " 4528 "No new agent was created. " 4529 "Diagnostics: Failure to send command to manager daemon.",
4533 MHD_HTTP_INTERNAL_SERVER_ERROR);
4535 credentials,
"Internal error", __FUNCTION__, __LINE__,
4536 "An internal error occurred while creating a new agent. " 4537 "It is unclear whether the agent has been created or not. " 4538 "Diagnostics: Failure to receive response from manager daemon.",
4542 MHD_HTTP_INTERNAL_SERVER_ERROR);
4544 credentials,
"Internal error", __FUNCTION__, __LINE__,
4545 "An internal error occurred while creating a new agent. " 4546 "It is unclear whether the agent has been created or not. " 4547 "Diagnostics: Internal Error.",
4551 if (entity_attribute (entity,
"id"))
4552 params_add (params,
"agent_id", entity_attribute (entity,
"id"));
4554 "Create Agent", response_data);
4555 free_entity (entity);
4593 params_t *params,
char **html,
char **filename,
4597 const char *agent_id, *format;
4598 gsize result_len = 0;
4603 if ((agent_id == NULL) || (format == NULL))
4608 "An internal error occurred while downloading " 4610 "Diagnostics: Required parameter was NULL.",
4617 if (gvm_connection_sendf (connection,
4618 "<get_agents agent_id=\"%s\" format=\"%s\"/>",
4623 MHD_HTTP_INTERNAL_SERVER_ERROR);
4626 "An internal error occurred while getting agent list. " 4627 "The current list of agents is not available. " 4628 "Diagnostics: Failure to send command to manager daemon.",
4635 if (strcmp (format,
"installer") == 0 || strcmp (format,
"howto_install") == 0
4636 || strcmp (format,
"howto_use") == 0)
4638 gchar *package_decoded = NULL;
4639 entity_t package_entity = NULL, agent_entity;
4644 if (read_entity_c (connection, &entity))
4647 MHD_HTTP_INTERNAL_SERVER_ERROR);
4649 credentials,
"Internal error", __FUNCTION__, __LINE__,
4650 "An internal error occurred while getting a agent. " 4651 "The agent is not available. " 4652 "Diagnostics: Failure to receive response from manager daemon.",
4657 agent_entity = entity_child (entity,
"agent");
4659 package_entity = entity_child (agent_entity,
"package");
4660 if (package_entity != NULL)
4662 char *package_encoded = entity_text (package_entity);
4663 if (strlen (package_encoded))
4666 (gchar *) g_base64_decode (package_encoded, &result_len);
4667 if (package_decoded == NULL)
4669 package_decoded = (gchar *) g_strdup (
"");
4675 package_decoded = (gchar *) g_strdup (
"");
4678 *html = package_decoded;
4681 entity_t filename_entity;
4682 filename_entity = entity_child (package_entity,
"filename");
4683 if (filename_entity)
4684 *filename = g_strdup (entity_text (filename_entity));
4687 if (!(*filename && strlen (*filename)))
4690 *filename = g_strdup_printf (
"agent-%s-%s", agent_id, format);
4694 free_entity (entity);
4699 free_entity (entity);
4701 MHD_HTTP_INTERNAL_SERVER_ERROR);
4703 credentials,
"Internal error", __FUNCTION__, __LINE__,
4704 "An internal error occurred while getting a agent. " 4705 "The agent could not be delivered. " 4706 "Diagnostics: Failure to receive agent from manager daemon.",
4716 if (read_entity_c (connection, &entity))
4719 MHD_HTTP_INTERNAL_SERVER_ERROR);
4721 credentials,
"Internal error", __FUNCTION__, __LINE__,
4722 "An internal error occurred while getting a agent. " 4723 "The agent could not be delivered. " 4724 "Diagnostics: Failure to receive agent from manager daemon.",
4729 free_entity (entity);
4731 MHD_HTTP_INTERNAL_SERVER_ERROR);
4733 credentials,
"Internal error", __FUNCTION__, __LINE__,
4734 "An internal error occurred while getting a agent. " 4735 "The agent could not be delivered. " 4736 "Diagnostics: Failure to parse agent from manager daemon.",
4757 gchar *html, *response;
4758 const char *agent_id, *name, *comment;
4773 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
4774 "<modify_agent agent_id=\"%s\">" 4776 "<comment>%s</comment>" 4778 agent_id, name, comment);
4787 MHD_HTTP_INTERNAL_SERVER_ERROR);
4789 credentials,
"Internal error", __FUNCTION__, __LINE__,
4790 "An internal error occurred while saving a agent. " 4791 "The agent was not saved. " 4792 "Diagnostics: Failure to send command to manager daemon.",
4796 MHD_HTTP_INTERNAL_SERVER_ERROR);
4798 credentials,
"Internal error", __FUNCTION__, __LINE__,
4799 "An internal error occurred while saving a agent. " 4800 "It is unclear whether the agent has been saved or not. " 4801 "Diagnostics: Failure to receive response from manager daemon.",
4805 MHD_HTTP_INTERNAL_SERVER_ERROR);
4807 credentials,
"Internal error", __FUNCTION__, __LINE__,
4808 "An internal error occurred while saving a agent. " 4809 "It is unclear whether the agent has been saved or not. " 4810 "Diagnostics: Internal Error.",
4815 "Save Agent", response_data);
4816 free_entity (entity);
4834 params_t *params,
const char *extra_xml,
4871 params_t *params,
const char *extra_xml,
4909 gchar *html, *response;
4910 const char *agent_id;
4915 if (agent_id == NULL)
4919 credentials,
"Internal error", __FUNCTION__, __LINE__,
4920 "An internal error occurred while verifying an agent. " 4921 "Diagnostics: Required parameter was NULL.",
4926 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
4927 "<verify_agent agent_id=\"%s\" />", agent_id);
4936 MHD_HTTP_INTERNAL_SERVER_ERROR);
4938 credentials,
"Internal error", __FUNCTION__, __LINE__,
4939 "An internal error occurred while verifying a agent. " 4940 "The agent was not verified. " 4941 "Diagnostics: Failure to send command to manager daemon.",
4945 MHD_HTTP_INTERNAL_SERVER_ERROR);
4947 credentials,
"Internal error", __FUNCTION__, __LINE__,
4948 "An internal error occurred while verifying a agent. " 4949 "It is unclear whether the agent was verified or not. " 4950 "Diagnostics: Failure to send command to manager daemon.",
4954 MHD_HTTP_INTERNAL_SERVER_ERROR);
4956 credentials,
"Internal error", __FUNCTION__, __LINE__,
4957 "An internal error occurred while verifying a agent. " 4958 "It is unclear whether the agent was verified or not. " 4959 "Diagnostics: Failure to send command to manager daemon.",
4964 "Verify Agent", response_data);
4965 free_entity (entity);
5020 params_t *data_columns, *text_columns;
5021 params_t *sort_fields, *sort_stats, *sort_orders;
5028 const char *data_column, *group_column, *subgroup_column, *type;
5029 const char *filter, *filt_id;
5030 const char *first_group, *max_groups;
5032 gchar *filter_escaped, *command_escaped, *response;
5034 GString *xml, *command;
5041 subgroup_column =
params_value (params,
"subgroup_column");
5051 if (filter && strcmp (filter,
""))
5052 filter_escaped = g_markup_escape_text (filter, -1);
5055 if (filt_id == NULL || strcmp (filt_id,
"") == 0
5056 || strcmp (filt_id,
"0") == 0)
5057 filter_escaped = g_strdup (
"rows=-2");
5059 filter_escaped = NULL;
5062 xml = g_string_new (
"<get_aggregate>");
5064 command = g_string_new (
"<get_aggregates");
5065 g_string_append_printf (command,
" type=\"%s\"", type);
5067 g_string_append_printf (command,
" data_column=\"%s\"", data_column);
5069 g_string_append_printf (command,
" group_column=\"%s\"", group_column);
5070 if (subgroup_column)
5071 g_string_append_printf (command,
" subgroup_column=\"%s\"",
5073 if (filter_escaped && strcmp (filter_escaped,
""))
5074 g_string_append_printf (command,
" filter=\"%s\"", filter_escaped);
5075 if (filt_id && strcmp (filt_id,
""))
5076 g_string_append_printf (command,
" filt_id=\"%s\"", filt_id);
5077 if (first_group && strcmp (first_group,
""))
5078 g_string_append_printf (command,
" first_group=\"%s\"", first_group);
5079 if (max_groups && strcmp (max_groups,
""))
5080 g_string_append_printf (command,
" max_groups=\"%s\"", max_groups);
5081 if (mode && strcmp (mode,
""))
5082 g_string_append_printf (command,
" mode=\"%s\"", mode);
5083 g_string_append (command,
">");
5085 if (sort_fields && sort_stats && sort_orders)
5087 param_t *field_param, *stat_param, *order_param;
5088 gchar *field_i, *stat_i, *order_i;
5101 xml_string_append (command,
5102 "<sort field=\"%s\"" 5105 field_param->
value ? field_param->
value :
"",
5107 order_param->
value ? order_param->
value :
"");
5119 xml_string_append (command,
"<data_column>%s</data_column>",
5132 xml_string_append (command,
"<text_column>%s</text_column>",
5138 g_string_append (command,
"</get_aggregates>");
5140 g_free (filter_escaped);
5142 command_escaped = g_markup_escape_text (command->str, -1);
5143 g_string_append (xml, command_escaped);
5144 g_free (command_escaped);
5147 ret =
gmp (connection,
credentials, &response, &entity, response_data,
5149 g_string_free (command, TRUE);
5153 free_entity (entity);
5154 g_string_free (xml, TRUE);
5163 MHD_HTTP_INTERNAL_SERVER_ERROR);
5165 credentials,
"Internal error", __FUNCTION__, __LINE__,
5166 "An internal error occurred while getting aggregates. " 5167 "Diagnostics: Failure to send command to manager daemon.",
5171 MHD_HTTP_INTERNAL_SERVER_ERROR);
5173 credentials,
"Internal error", __FUNCTION__, __LINE__,
5174 "An internal error occurred while getting aggregates. " 5175 "Diagnostics: Failure to receive response from manager daemon.",
5179 MHD_HTTP_INTERNAL_SERVER_ERROR);
5181 credentials,
"Internal error", __FUNCTION__, __LINE__,
5182 "An internal error occurred while getting aggregates. " 5183 "Diagnostics: Internal Error.",
5189 g_string_append (xml, response);
5191 g_string_append (xml,
"</get_aggregate>");
5193 free_entity (entity);
5196 g_string_free (xml, FALSE), response_data);
5212 params_t *params,
const char *extra_xml,
5220 xml = g_string_new (
"<new_alert>");
5222 g_string_append (xml, extra_xml);
5228 ret =
gmp (connection,
credentials, &response, &entity, response_data,
5229 "<get_report_formats filter=\"rows=-1\"/>");
5237 MHD_HTTP_INTERNAL_SERVER_ERROR);
5239 credentials,
"Internal error", __FUNCTION__, __LINE__,
5240 "An internal error occurred while getting Report " 5241 "Formats for new alert. " 5242 "Diagnostics: Failure to send command to manager daemon.",
5246 MHD_HTTP_INTERNAL_SERVER_ERROR);
5248 credentials,
"Internal error", __FUNCTION__, __LINE__,
5249 "An internal error occurred while getting Report " 5250 "Formats for new alert. " 5251 "Diagnostics: Failure to receive response from manager daemon.",
5255 MHD_HTTP_INTERNAL_SERVER_ERROR);
5258 "An internal error occurred while getting Report " 5259 "Formats for new alert. It is unclear whether" 5260 " the alert has been saved or not. " 5261 "Diagnostics: Internal Error.",
5264 g_string_append (xml, response);
5266 free_entity (entity);
5270 ret =
gmp (connection,
credentials, &response, &entity, response_data,
5271 "<get_filters filter=\"rows=-1\"/>");
5280 MHD_HTTP_INTERNAL_SERVER_ERROR);
5282 credentials,
"Internal error", __FUNCTION__, __LINE__,
5283 "An internal error occurred while getting Report " 5284 "Filters for new alert. " 5285 "The task was not saved. " 5286 "Diagnostics: Failure to send command to manager daemon.",
5290 MHD_HTTP_INTERNAL_SERVER_ERROR);
5292 credentials,
"Internal error", __FUNCTION__, __LINE__,
5293 "An internal error occurred while getting Report " 5294 "Filters for new alert. " 5295 "Diagnostics: Failure to receive response from manager daemon.",
5299 MHD_HTTP_INTERNAL_SERVER_ERROR);
5302 "An internal error occurred while getting Report " 5303 "Filters for new alert. " 5304 "Diagnostics: Internal Error.",
5307 g_string_append (xml, response);
5309 free_entity (entity);
5313 ret =
gmp (connection,
credentials, &response, &entity, response_data,
5315 " schedules_only=\"1\"" 5316 " filter=\"owner=any permission=start_task rows=-1\"/>");
5325 MHD_HTTP_INTERNAL_SERVER_ERROR);
5327 credentials,
"Internal error", __FUNCTION__, __LINE__,
5328 "An internal error occurred while getting Tasks" 5330 "The task was not saved. " 5331 "Diagnostics: Failure to send command to manager daemon.",
5335 MHD_HTTP_INTERNAL_SERVER_ERROR);
5337 credentials,
"Internal error", __FUNCTION__, __LINE__,
5338 "An internal error occurred while getting Tasks" 5340 "Diagnostics: Failure to receive response from manager daemon.",
5344 MHD_HTTP_INTERNAL_SERVER_ERROR);
5347 "An internal error occurred while getting Tasks" 5349 "Diagnostics: Internal Error.",
5352 g_string_append (xml, response);
5354 free_entity (entity);
5358 ret =
gmp (connection,
credentials, &response, &entity, response_data,
5360 " filter=\"type=up or type=pw" 5361 " owner=any permission=any rows=-1\"/>");
5370 MHD_HTTP_INTERNAL_SERVER_ERROR);
5372 credentials,
"Internal error", __FUNCTION__, __LINE__,
5373 "An internal error occurred while getting" 5374 " Credentials for new alert. " 5375 "The task was not saved. " 5376 "Diagnostics: Failure to send command to manager daemon.",
5380 MHD_HTTP_INTERNAL_SERVER_ERROR);
5382 credentials,
"Internal error", __FUNCTION__, __LINE__,
5383 "An internal error occurred while getting" 5384 " Credentials for new alert. " 5385 "Diagnostics: Failure to receive response from manager daemon.",
5389 MHD_HTTP_INTERNAL_SERVER_ERROR);
5392 "An internal error occurred while getting" 5393 " Credentials for new alert. " 5394 "Diagnostics: Internal Error.",
5398 g_string_append (xml, response);
5400 free_entity (entity);
5402 g_string_append (xml,
"</new_alert>");
5404 g_string_free (xml, FALSE), response_data);
5428 #define EVENT_TYPE_NEW_SECINFO "New SecInfo arrived" 5429 #define EVENT_TYPE_UPDATED_SECINFO "Updated SecInfo arrived" 5430 #define EVENT_TYPE_TASK_RUN_STATUS_CHANGED "Task run status changed" 5431 #define EVENT_TYPE_TICKET_RECEIVED "Ticket received" 5432 #define EVENT_TYPE_ASSIGNED_TICKET_CHANGED "Assigned ticket changed" 5433 #define EVENT_TYPE_OWNED_TICKET_CHANGED "Owned ticket changed" 5459 xml_string_append (xml,
"<data><name>%s</name>%s</data>", name,
5473 const char *condition)
5484 if (strcmp (condition,
"Filter count at least") == 0)
5486 if (strcmp (name,
"at_least_count") == 0)
5487 xml_string_append (xml,
"<data><name>count</name>%s</data>",
5489 if (strcmp (name,
"at_least_filter_id") == 0)
5490 xml_string_append (xml,
"<data><name>filter_id</name>%s</data>",
5493 else if (strcmp (condition,
"Filter count changed") == 0)
5495 if (strcmp (name,
"count") == 0
5496 || strcmp (name,
"filter_id") == 0)
5497 xml_string_append (xml,
"<data><name>%s</name>%s</data>", name,
5499 else if (strcmp (name,
"filter_direction") == 0)
5500 xml_string_append (xml,
"<data><name>direction</name>%s</data>",
5503 else if ((strcmp (condition,
"Severity at least") == 0
5504 && strcmp (name,
"severity") == 0)
5505 || (strcmp (condition,
"Severity changed") == 0
5506 && strcmp (name,
"direction") == 0))
5507 xml_string_append (xml,
"<data><name>%s</name>%s</data>", name,
5534 if (strcmp (method,
"Alemba vFire") == 0)
5536 g_string_append (xml,
"<data><name>report_formats</name>");
5538 if (report_formats && g_hash_table_size (report_formats))
5540 int report_formats_count = g_hash_table_size (report_formats);
5544 for (index = 1; index <= report_formats_count; index++)
5546 gchar *index_str = g_strdup_printf (
"%d", index);
5551 xml_string_append (xml,
", %s", value);
5553 xml_string_append (xml,
"%s", value);
5558 g_string_append (xml,
"</data>");
5566 if (strcmp (name,
"notice") == 0)
5572 if (strcmp (method,
"Sourcefire Connector"))
5577 if ((strcmp (method,
"HTTP Get") == 0 && strcmp (name,
"URL") == 0)
5578 || (strcmp (method,
"Send") == 0
5579 && (strcmp (name,
"send_host") == 0
5580 || strcmp (name,
"send_port") == 0
5581 || strcmp (name,
"send_report_format") == 0))
5582 || (strcmp (method,
"SCP") == 0
5583 && (strcmp (name,
"scp_credential") == 0
5584 || strcmp (name,
"scp_host") == 0
5585 || strcmp (name,
"scp_known_hosts") == 0
5586 || strcmp (name,
"scp_path") == 0
5587 || strcmp (name,
"scp_report_format") == 0))
5588 || (strcmp (method,
"SMB") == 0
5589 && (strcmp (name,
"smb_credential") == 0
5590 || strcmp (name,
"smb_file_path") == 0
5591 || strcmp (name,
"smb_report_format") == 0
5592 || strcmp (name,
"smb_share_path") == 0))
5593 || (strcmp (method,
"SNMP") == 0
5594 && (strcmp (name,
"snmp_community") == 0
5595 || strcmp (name,
"snmp_agent") == 0
5596 || strcmp (name,
"snmp_message") == 0))
5597 || (strcmp (method,
"TippingPoint SMS") == 0
5598 && (strcmp (name,
"tp_sms_credential") == 0
5599 || strcmp (name,
"tp_sms_hostname") == 0
5600 || strcmp (name,
"tp_sms_tls_certificate") == 0
5601 || strcmp (name,
"tp_sms_tls_workaround") == 0))
5602 || (strcmp (method,
"verinice Connector") == 0
5603 && (strcmp (name,
"verinice_server_credential") == 0
5604 || strcmp (name,
"verinice_server_url") == 0
5605 || strcmp (name,
"verinice_server_report_format") == 0))
5606 || (strcmp (method,
"Alemba vFire") == 0
5607 && (strcmp (name,
"vfire_base_url") == 0
5608 || strcmp (name,
"vfire_call_description") == 0
5609 || strcmp (name,
"vfire_call_impact_name") == 0
5610 || strcmp (name,
"vfire_call_partition_name") == 0
5611 || strcmp (name,
"vfire_call_template_name") == 0
5612 || strcmp (name,
"vfire_call_type_name") == 0
5613 || strcmp (name,
"vfire_call_urgency_name") == 0
5614 || strcmp (name,
"vfire_client_id") == 0
5615 || strcmp (name,
"vfire_credential") == 0
5616 || strcmp (name,
"vfire_session_type") == 0))
5617 || (strcmp (method,
"Email") == 0
5618 && (strcmp (name,
"to_address") == 0
5619 || strcmp (name,
"from_address") == 0
5620 || strcmp (name,
"subject") == 0
5621 || strcmp (name,
"notice") == 0
5622 || (strcmp (name,
"notice_report_format") == 0
5624 || (strcmp (name,
"notice_attach_format") == 0
5626 || (
str_equal (name,
"recipient_credential")
5628 || (strcmp (method,
"Syslog") == 0
5629 && strcmp (name,
"submethod") == 0)
5630 || (strcmp (method,
"Start Task") == 0
5631 && strcmp (name,
"start_task_task") == 0)
5632 || strcmp (name,
"details_url") == 0
5633 || strcmp (name,
"delta_type") == 0
5634 || strcmp (name,
"delta_report_id") == 0
5635 || strcmp (name,
"composer_include_notes") == 0
5636 || strcmp (name,
"composer_include_overrides") == 0)
5637 xml_string_append (xml,
"<data><name>%s</name>%s</data>", name,
5639 else if (strcmp (method,
"Email") == 0 && notice == 0
5640 && strcmp (name,
"message") == 0)
5641 xml_string_append (xml,
"<data><name>message</name>%s</data>",
5643 else if (strcmp (method,
"Email") == 0 && notice == 2
5644 && strcmp (name,
"message_attach") == 0)
5645 xml_string_append (xml,
"<data><name>message</name>%s</data>",
5653 if (strcmp (name,
"pkcs12"))
5655 if (strcmp (name,
"defense_center_ip") == 0
5656 || strcmp (name,
"defense_center_port") == 0
5657 || (strcmp (name,
"pkcs12_credential") == 0
5659 xml_string_append (xml,
"<data><name>%s</name>%s</data>", name,
5672 xml_string_append (xml,
"<data><name>%s</name>%s</data>", name, base64);
5692 gchar *html, *response;
5693 const char *name, *comment, *active, *condition, *event, *method, *filter_id;
5694 params_t *method_data, *event_data, *condition_data, *report_formats;
5719 report_formats =
params_values (params,
"report_format_ids:");
5721 xml = g_string_new (
"");
5739 xml_string_append (xml,
5742 "<filter id=\"%s\"/>" 5743 "<active>%s</active>" 5744 "<comment>%s</comment>" 5746 name, filter_id, active, comment ? comment :
"", event);
5750 xml_string_append (xml,
5757 xml_string_append (xml,
5764 xml_string_append (xml,
"</condition>" 5768 gmp (connection,
credentials, &response, &entity, response_data, xml->str);
5769 g_string_free (xml, TRUE);
5777 MHD_HTTP_INTERNAL_SERVER_ERROR);
5779 credentials,
"Internal error", __FUNCTION__, __LINE__,
5780 "An internal error occurred while creating a new alert. " 5781 "No new alert was created. " 5782 "Diagnostics: Failure to send command to manager daemon.",
5786 MHD_HTTP_INTERNAL_SERVER_ERROR);
5788 credentials,
"Internal error", __FUNCTION__, __LINE__,
5789 "An internal error occurred while creating a new alert. " 5790 "It is unclear whether the alert has been created or not. " 5791 "Diagnostics: Failure to receive response from manager daemon.",
5795 MHD_HTTP_INTERNAL_SERVER_ERROR);
5797 credentials,
"Internal error", __FUNCTION__, __LINE__,
5798 "An internal error occurred while creating a new alert. " 5799 "It is unclear whether the alert has been created or not. " 5800 "Diagnostics: Internal Error.",
5804 if (entity_attribute (entity,
"id"))
5805 params_add (params,
"alert_id", entity_attribute (entity,
"id"));
5807 "Create Alert", response_data);
5808 free_entity (entity);
5844 params_t *params,
const char *extra_xml,
5850 extra = g_string_new (
"");
5852 g_string_append (extra, extra_xml);
5860 switch (
gmp (connection,
credentials, &response, &entity, response_data,
5861 "<get_report_formats" 5862 " filter=\"rows=-1\"/>"))
5869 MHD_HTTP_INTERNAL_SERVER_ERROR);
5871 credentials,
"Internal error", __FUNCTION__, __LINE__,
5872 "An internal error occurred while getting Report " 5873 "Formats for the alert. " 5874 "Diagnostics: Failure to send command to manager daemon.",
5878 MHD_HTTP_INTERNAL_SERVER_ERROR);
5880 credentials,
"Internal error", __FUNCTION__, __LINE__,
5881 "An internal error occurred while getting Report " 5882 "Formats for the alert. " 5883 "Diagnostics: Failure to receive response from manager daemon.",
5887 MHD_HTTP_INTERNAL_SERVER_ERROR);
5889 credentials,
"Internal error", __FUNCTION__, __LINE__,
5890 "An internal error occurred while getting Report " 5891 "Formats for the alert. " 5892 "It is unclear whether the task has been saved or not. " 5893 "Diagnostics: Internal Error.",
5897 g_string_append (extra, response);
5899 free_entity (entity);
5910 switch (
gmp (connection,
credentials, &response, &entity, response_data,
5912 " schedules_only=\"1\"" 5913 " filter=\"owner=any permission=start_task rows=-1\"/>"))
5920 MHD_HTTP_INTERNAL_SERVER_ERROR);
5922 credentials,
"Internal error", __FUNCTION__, __LINE__,
5923 "An internal error occurred while getting Tasks " 5925 "Diagnostics: Failure to send command to manager daemon.",
5929 MHD_HTTP_INTERNAL_SERVER_ERROR);
5931 credentials,
"Internal error", __FUNCTION__, __LINE__,
5932 "An internal error occurred while getting Tasks " 5934 "Diagnostics: Failure to receive response from manager daemon.",
5938 MHD_HTTP_INTERNAL_SERVER_ERROR);
5941 "An internal error occurred while getting Tasks " 5943 "Diagnostics: Internal Error.",
5947 g_string_append (extra, response);
5949 free_entity (entity);
5962 switch (
gmp (connection,
credentials, &response, &entity, response_data,
5964 " filter=\"type=result rows=-1\"/>"))
5971 MHD_HTTP_INTERNAL_SERVER_ERROR);
5973 credentials,
"Internal error", __FUNCTION__, __LINE__,
5974 "An internal error occurred while getting filters " 5976 "Diagnostics: Failure to send command to manager daemon.",
5980 MHD_HTTP_INTERNAL_SERVER_ERROR);
5982 credentials,
"Internal error", __FUNCTION__, __LINE__,
5983 "An internal error occurred while getting filters " 5985 "Diagnostics: Failure to receive response from manager daemon.",
5989 MHD_HTTP_INTERNAL_SERVER_ERROR);
5991 credentials,
"Internal error", __FUNCTION__, __LINE__,
5992 "An internal error occurred while getting filters " 5994 "Diagnostics: Internal Error.",
5998 g_string_append (extra, response);
6000 free_entity (entity);
6005 "tasks=\"1\"", response_data);
6006 g_string_free (extra, TRUE);
6040 params_t *params,
const char *extra_xml,
6046 extra = g_string_new (
"");
6054 switch (
gmp (connection,
credentials, &response, &entity, response_data,
6056 " schedules_only=\"1\"" 6057 " filter=\"owner=any permission=start_task rows=-1\"/>"))
6064 MHD_HTTP_INTERNAL_SERVER_ERROR);
6066 credentials,
"Internal error", __FUNCTION__, __LINE__,
6067 "An internal error occurred getting the tasks. " 6068 "Diagnostics: Failure to send command to manager daemon.",
6072 MHD_HTTP_INTERNAL_SERVER_ERROR);
6074 credentials,
"Internal error", __FUNCTION__, __LINE__,
6075 "An internal error occurred getting the tasks. " 6076 "Diagnostics: Failure to receive response from manager daemon.",
6080 MHD_HTTP_INTERNAL_SERVER_ERROR);
6082 credentials,
"Internal error", __FUNCTION__, __LINE__,
6083 "An internal error occurred getting the reports. " 6084 "Diagnostics: Internal Error.",
6088 g_string_append (extra, response);
6090 free_entity (entity);
6103 switch (
gmp (connection,
credentials, &response, &entity, response_data,
6105 " filter=\"type=result rows=-1\"/>"))
6112 MHD_HTTP_INTERNAL_SERVER_ERROR);
6114 credentials,
"Internal error", __FUNCTION__, __LINE__,
6115 "An internal error occurred while getting filters " 6117 "Diagnostics: Failure to send command to manager daemon.",
6121 MHD_HTTP_INTERNAL_SERVER_ERROR);
6123 credentials,
"Internal error", __FUNCTION__, __LINE__,
6124 "An internal error occurred while getting filters " 6126 "Diagnostics: Failure to receive response from manager daemon.",
6130 MHD_HTTP_INTERNAL_SERVER_ERROR);
6132 credentials,
"Internal error", __FUNCTION__, __LINE__,
6133 "An internal error occurred while getting filters " 6135 "Diagnostics: Internal Error.",
6139 g_string_append (extra, response);
6141 free_entity (entity);
6146 g_string_append (extra, extra_xml);
6149 g_string_free (extra, TRUE);
6183 params_t *params,
const char *extra_xml,
6188 const char *alert_id, *next, *filter;
6194 if (alert_id == NULL)
6199 "An internal error occurred while editing an alert. " 6200 "The alert remains as it was. " 6201 "Diagnostics: Required parameter alert_id was NULL.",
6206 next =
"get_alerts";
6208 if (gvm_connection_sendf (connection,
6216 MHD_HTTP_INTERNAL_SERVER_ERROR);
6218 credentials,
"Internal error", __FUNCTION__, __LINE__,
6219 "An internal error occurred while getting alert info. " 6220 "Diagnostics: Failure to send command to manager daemon.",
6224 xml = g_string_new (
"<edit_alert>");
6227 g_string_append (xml, extra_xml);
6229 edit = g_markup_printf_escaped (
"<alert id=\"%s\"/>" 6233 "<filters><term>%s</term></filters>",
6234 alert_id, next, filter);
6235 g_string_append (xml, edit);
6238 if (read_string_c (connection, &xml))
6240 g_string_free (xml, TRUE);
6242 MHD_HTTP_INTERNAL_SERVER_ERROR);
6244 credentials,
"Internal error", __FUNCTION__, __LINE__,
6245 "An internal error occurred while getting alert info. " 6246 "Diagnostics: Failure to receive response from manager daemon.",
6254 if (gvm_connection_sendf (connection,
"<get_report_formats" 6255 " filter=\"rows=-1\"/>")
6258 g_string_free (xml, TRUE);
6260 MHD_HTTP_INTERNAL_SERVER_ERROR);
6262 credentials,
"Internal error", __FUNCTION__, __LINE__,
6263 "An internal error occurred while getting report formats. " 6264 "The current list of report formats is not available. " 6265 "Diagnostics: Failure to send command to manager daemon.",
6269 if (read_string_c (connection, &xml))
6271 g_string_free (xml, TRUE);
6273 MHD_HTTP_INTERNAL_SERVER_ERROR);
6275 credentials,
"Internal error", __FUNCTION__, __LINE__,
6276 "An internal error occurred while getting report formats. " 6277 "The current list of report formats is not available. " 6278 "Diagnostics: Failure to receive response from manager daemon.",
6287 if (gvm_connection_sendf (connection,
"<get_filters filter=\"rows=-1\"/>")
6290 g_string_free (xml, TRUE);
6292 MHD_HTTP_INTERNAL_SERVER_ERROR);
6294 credentials,
"Internal error", __FUNCTION__, __LINE__,
6295 "An internal error occurred while getting the list " 6297 "The current list of filters is not available. " 6298 "Diagnostics: Failure to send command to manager daemon.",
6302 if (read_string_c (connection, &xml))
6304 g_string_free (xml, TRUE);
6306 MHD_HTTP_INTERNAL_SERVER_ERROR);
6308 credentials,
"Internal error", __FUNCTION__, __LINE__,
6309 "An internal error occurred while getting the list " 6311 "The current list of filters is not available. " 6312 "Diagnostics: Failure to receive response from manager daemon.",
6321 if (gvm_connection_sendf (connection,
6323 " schedules_only=\"1\"" 6324 " filter=\"owner=any permission=start_task" 6328 g_string_free (xml, TRUE);
6330 MHD_HTTP_INTERNAL_SERVER_ERROR);
6332 credentials,
"Internal error", __FUNCTION__, __LINE__,
6333 "An internal error occurred while getting the list " 6335 "The current list of tasks is not available. " 6336 "Diagnostics: Failure to send command to manager daemon.",
6340 if (read_string_c (connection, &xml))
6342 g_string_free (xml, TRUE);
6344 MHD_HTTP_INTERNAL_SERVER_ERROR);
6346 credentials,
"Internal error", __FUNCTION__, __LINE__,
6347 "An internal error occurred while getting the list " 6349 "The current list of tasks is not available. " 6350 "Diagnostics: Failure to receive response from manager daemon.",
6359 if (gvm_connection_sendf (connection,
"<get_credentials" 6360 " filter=\"type=up or type=pw" 6361 " owner=any permission=any" 6365 g_string_free (xml, TRUE);
6367 MHD_HTTP_INTERNAL_SERVER_ERROR);
6369 credentials,
"Internal error", __FUNCTION__, __LINE__,
6370 "An internal error occurred while getting the list " 6372 "The current list of tasks is not available. " 6373 "Diagnostics: Failure to send command to manager daemon.",
6377 if (read_string_c (connection, &xml))
6379 g_string_free (xml, TRUE);
6381 MHD_HTTP_INTERNAL_SERVER_ERROR);
6383 credentials,
"Internal error", __FUNCTION__, __LINE__,
6384 "An internal error occurred while getting the list " 6386 "The current list of tasks is not available. " 6387 "Diagnostics: Failure to receive response from manager daemon.",
6394 g_string_append (xml,
"</edit_alert>");
6396 g_string_free (xml, FALSE), response_data);
6432 gchar *html, *response;
6433 const char *name, *comment, *alert_id;
6434 const char *event, *condition, *method;
6435 const char *filter_id, *active;
6436 params_t *event_data, *condition_data, *method_data, *report_formats;
6457 xml = g_string_new (
"");
6464 report_formats =
params_values (params,
"report_format_ids:");
6482 xml_string_append (xml,
6483 "<modify_alert alert_id=\"%s\">" 6485 "<filter id=\"%s\"/>" 6486 "<active>%s</active>" 6487 "<comment>%s</comment>" 6489 alert_id, name, filter_id, active, comment ? comment :
"",
6494 xml_string_append (xml,
6501 xml_string_append (xml,
6508 xml_string_append (xml,
"</condition>" 6512 gmp (connection,
credentials, &response, &entity, response_data, xml->str);
6513 g_string_free (xml, TRUE);
6521 MHD_HTTP_INTERNAL_SERVER_ERROR);
6523 credentials,
"Internal error", __FUNCTION__, __LINE__,
6524 "An internal error occurred while saving a new alert. " 6525 "No new alert was created. " 6526 "Diagnostics: Failure to send command to manager daemon.",
6530 MHD_HTTP_INTERNAL_SERVER_ERROR);
6532 credentials,
"Internal error", __FUNCTION__, __LINE__,
6533 "An internal error occurred while saving a new alert. " 6534 "It is unclear whether the alert has been created or not. " 6535 "Diagnostics: Failure to receive response from manager daemon.",
6539 MHD_HTTP_INTERNAL_SERVER_ERROR);
6541 credentials,
"Internal error", __FUNCTION__, __LINE__,
6542 "An internal error occurred while saving a new alert. " 6543 "It is unclear whether the alert has been created or not. " 6544 "Diagnostics: Internal Error.",
6549 "Save Alert", response_data);
6550 free_entity (entity);
6569 gchar *html, *response;
6570 const char *alert_id;
6575 if (alert_id == NULL)
6581 "Missing parameter alert_id." 6582 "Diagnostics: Required parameter was NULL.",
6588 if (gvm_connection_sendf (connection,
"<test_alert alert_id=\"%s\"/>",
6593 MHD_HTTP_INTERNAL_SERVER_ERROR);
6595 credentials,
"Internal error", __FUNCTION__, __LINE__,
6596 "An internal error occurred while testing an alert. " 6597 "Diagnostics: Failure to send command to manager daemon.",
6602 if (read_entity_and_text_c (connection, &entity, &response))
6605 MHD_HTTP_INTERNAL_SERVER_ERROR);
6607 credentials,
"Internal error", __FUNCTION__, __LINE__,
6608 "An internal error occurred while testing an alert. " 6609 "Diagnostics: Failure to receive response from manager daemon.",
6614 "Test Alert", response_data);
6616 free_entity (entity);
6672 gchar *html, *response, *command;
6673 const char *name, *hosts, *exclude_hosts, *comment;
6674 const char *target_ssh_credential, *port, *target_smb_credential;
6675 const char *target_esxi_credential, *target_snmp_credential, *target_source;
6676 const char *target_exclude_source;
6677 const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
6678 const char *alive_tests, *hosts_filter, *file, *exclude_file;
6679 gchar *ssh_credentials_element, *smb_credentials_element;
6680 gchar *esxi_credentials_element, *snmp_credentials_element;
6681 gchar *asset_hosts_element;
6682 gchar *comment_element = NULL;
6688 exclude_hosts =
params_value (params,
"exclude_hosts");
6689 reverse_lookup_only =
params_value (params,
"reverse_lookup_only");
6690 reverse_lookup_unify =
params_value (params,
"reverse_lookup_unify");
6691 target_source =
params_value (params,
"target_source");
6692 target_exclude_source =
params_value (params,
"target_exclude_source");
6695 target_ssh_credential =
params_value (params,
"ssh_credential_id");
6697 target_smb_credential =
params_value (params,
"smb_credential_id");
6698 target_esxi_credential =
params_value (params,
"esxi_credential_id");
6699 target_snmp_credential =
params_value (params,
"snmp_credential_id");
6707 if (strcmp (target_source,
"manual") == 0)
6709 if (strcmp (target_source,
"file") == 0)
6712 if (strcmp (target_source,
"asset_hosts") == 0)
6718 if (strcmp (target_exclude_source,
"manual") == 0
6722 if (strcmp (target_exclude_source,
"file") == 0)
6729 if (strcmp (target_ssh_credential,
"--"))
6736 if (comment != NULL)
6737 comment_element = g_strdup_printf (
"<comment>%s</comment>", comment);
6739 comment_element = g_strdup (
"");
6741 if (strcmp (target_ssh_credential,
"0") == 0)
6742 ssh_credentials_element = g_strdup (
"");
6744 ssh_credentials_element = g_strdup_printf (
"<ssh_credential id=\"%s\">" 6746 "</ssh_credential>",
6747 target_ssh_credential, port);
6749 if (strcmp (target_smb_credential,
"0") == 0)
6750 smb_credentials_element = g_strdup (
"");
6752 smb_credentials_element =
6753 g_strdup_printf (
"<smb_credential id=\"%s\"/>", target_smb_credential);
6755 if (strcmp (target_esxi_credential,
"0") == 0)
6756 esxi_credentials_element = g_strdup (
"");
6758 esxi_credentials_element =
6759 g_strdup_printf (
"<esxi_credential id=\"%s\"/>", target_esxi_credential);
6761 if (strcmp (target_snmp_credential,
"0") == 0)
6762 snmp_credentials_element = g_strdup (
"");
6764 snmp_credentials_element =
6765 g_strdup_printf (
"<snmp_credential id=\"%s\"/>", target_snmp_credential);
6767 if (strcmp (target_source,
"asset_hosts") == 0)
6768 asset_hosts_element = g_markup_printf_escaped (
"<asset_hosts" 6772 asset_hosts_element = g_strdup (
"");
6776 xml = g_string_new (
"");
6778 xml_string_append (xml,
6781 "<exclude_hosts>%s</exclude_hosts>" 6782 "<reverse_lookup_only>%s</reverse_lookup_only>" 6783 "<reverse_lookup_unify>%s</reverse_lookup_unify>" 6784 "<port_list id=\"%s\"/>" 6785 "<alive_tests>%s</alive_tests>",
6786 name, strcmp (target_source,
"file") == 0 ? file : hosts,
6787 target_exclude_source
6788 ? (strcmp (target_exclude_source,
"file") == 0
6790 : (exclude_hosts ? exclude_hosts :
""))
6792 reverse_lookup_only ? reverse_lookup_only :
"0",
6793 reverse_lookup_unify ? reverse_lookup_unify :
"0",
6794 port_list_id, alive_tests);
6796 command = g_strdup_printf (
"<create_target>" 6799 xml->str, comment_element, ssh_credentials_element,
6800 smb_credentials_element, esxi_credentials_element,
6801 snmp_credentials_element, asset_hosts_element);
6803 g_string_free (xml, TRUE);
6804 g_free (comment_element);
6805 g_free (ssh_credentials_element);
6806 g_free (smb_credentials_element);
6807 g_free (esxi_credentials_element);
6810 gmp (connection,
credentials, &response, &entity, response_data, command);
6821 MHD_HTTP_INTERNAL_SERVER_ERROR);
6823 credentials,
"Internal error", __FUNCTION__, __LINE__,
6824 "An internal error occurred while creating a new target. " 6825 "No new target was created. " 6826 "Diagnostics: Failure to send command to manager daemon.",
6830 MHD_HTTP_INTERNAL_SERVER_ERROR);
6832 credentials,
"Internal error", __FUNCTION__, __LINE__,
6833 "An internal error occurred while creating a new target. " 6834 "It is unclear whether the target has been created or not. " 6835 "Diagnostics: Failure to receive response from manager daemon.",
6839 MHD_HTTP_INTERNAL_SERVER_ERROR);
6841 credentials,
"Internal error", __FUNCTION__, __LINE__,
6842 "An internal error occurred while creating a new target. " 6843 "It is unclear whether the target has been created or not. " 6844 "Diagnostics: Internal Error.",
6848 if (entity_attribute (entity,
"id"))
6849 params_add (params,
"target_id", entity_attribute (entity,
"id"));
6851 "Create Target", response_data);
6852 free_entity (entity);
6871 gchar *html, *response;
6872 const char *id, *type, *alterable;
6884 if (alterable && strcmp (alterable,
"0"))
6886 if (gvm_connection_sendf (connection,
6889 "<alterable>1</alterable>" 6895 MHD_HTTP_INTERNAL_SERVER_ERROR);
6897 credentials,
"Internal error", __FUNCTION__, __LINE__,
6898 "An internal error occurred while cloning a resource. " 6899 "The resource was not cloned. " 6900 "Diagnostics: Failure to send command to manager daemon.",
6904 else if (gvm_connection_sendf (connection,
6912 MHD_HTTP_INTERNAL_SERVER_ERROR);
6914 credentials,
"Internal error", __FUNCTION__, __LINE__,
6915 "An internal error occurred while cloning a resource. " 6916 "The resource was not cloned. " 6917 "Diagnostics: Failure to send command to manager daemon.",
6922 if (read_entity_and_text_c (connection, &entity, &response))
6925 MHD_HTTP_INTERNAL_SERVER_ERROR);
6927 credentials,
"Internal error", __FUNCTION__, __LINE__,
6928 "An internal error occurred while cloning a resource. " 6929 "It is unclear whether the resource has been cloned or not. " 6930 "Diagnostics: Failure to read response from manager daemon.",
6938 free_entity (entity);
6980 const char *target_id;
6986 xml = g_string_new (
"");
6990 if (gvm_connection_sendf (connection,
6996 g_string_free (xml, TRUE);
6998 MHD_HTTP_INTERNAL_SERVER_ERROR);
7000 credentials,
"Internal error", __FUNCTION__, __LINE__,
7001 "An internal error occurred while restoring a resource. " 7002 "The resource was not deleted. " 7003 "Diagnostics: Failure to send command to manager daemon.",
7007 if (read_entity_and_string_c (connection, &entity, &xml))
7009 g_string_free (xml, TRUE);
7011 MHD_HTTP_INTERNAL_SERVER_ERROR);
7013 credentials,
"Internal error", __FUNCTION__, __LINE__,
7014 "An internal error occurred while restoring a resource. " 7015 "It is unclear whether the resource has been restored or not. " 7016 "Diagnostics: Failure to read response from manager daemon.",
7023 "Restore", response_data);
7024 free_entity (entity);
7025 g_string_free (xml, FALSE);
7047 xml = g_string_new (
"");
7051 if (gvm_connection_sendf (connection,
"<empty_trashcan/>") == -1)
7053 g_string_free (xml, TRUE);
7055 MHD_HTTP_INTERNAL_SERVER_ERROR);
7057 credentials,
"Internal error", __FUNCTION__, __LINE__,
7058 "An internal error occurred while emptying the trashcan. " 7059 "Diagnostics: Failure to send command to manager daemon.",
7063 if (read_entity_and_string_c (connection, &entity, &xml))
7065 g_string_free (xml, TRUE);
7067 MHD_HTTP_INTERNAL_SERVER_ERROR);
7069 credentials,
"Internal error", __FUNCTION__, __LINE__,
7070 "An internal error occurred while emptying the trashcan. " 7071 "Diagnostics: Failure to read response from manager daemon.",
7078 "Empty Trashcan", response_data);
7079 free_entity (entity);
7080 g_string_free (xml, FALSE);
7100 const char *name, *comment, *filter, *value, *resource_type, *active;
7109 resource_type =
params_value (params,
"resource_type");
7121 command = g_string_new (
"");
7123 xml_string_append (command,
7126 "<comment>%s</comment>" 7128 "<active>%s</active>" 7129 "<resources filter=\"%s\">" 7131 name, comment, value, active, filter ? filter :
"",
7143 g_string_append_printf (command,
"<resource id=\"%s\"/>",
7147 xml_string_append (command,
"</resources>" 7152 switch (
gmp (connection,
credentials, &response, &entity, response_data,
7160 MHD_HTTP_INTERNAL_SERVER_ERROR);
7161 g_string_free (command, TRUE);
7163 credentials,
"Internal error", __FUNCTION__, __LINE__,
7164 "An internal error occurred while creating a new tag. " 7165 "No new tag was created. " 7166 "Diagnostics: Failure to send command to manager daemon.",
7170 MHD_HTTP_INTERNAL_SERVER_ERROR);
7171 g_string_free (command, TRUE);
7173 credentials,
"Internal error", __FUNCTION__, __LINE__,
7174 "An internal error occurred while creating a new tag. " 7175 "It is unclear whether the tag has been created or not. " 7176 "Diagnostics: Failure to receive response from manager daemon.",
7180 MHD_HTTP_INTERNAL_SERVER_ERROR);
7181 g_string_free (command, TRUE);
7183 credentials,
"Internal error", __FUNCTION__, __LINE__,
7184 "An internal error occurred while creating a new tag. " 7185 "It is unclear whether the tag has been created or not. " 7186 "Diagnostics: Internal Error.",
7190 g_string_free (command, TRUE);
7192 "Create Tag", response_data);
7194 free_entity (entity);
7232 const char *name, *comment, *filter, *value, *resource_type, *active;
7233 const char *resources_action;
7245 resource_type =
params_value (params,
"resource_type");
7247 resources_action =
params_value (params,
"resources_action");
7261 command = g_string_new (
"");
7263 xml_string_append (command,
7264 "<modify_tag tag_id=\"%s\">" 7266 "<comment>%s</comment>" 7268 "<active>%s</active>" 7269 "<resources action=\"%s\" filter=\"%s\">" 7271 tag_id, name, comment, value, active,
7272 resources_action ? resources_action :
"",
7273 filter ? filter :
"", resource_type);
7284 g_string_append_printf (command,
"<resource id=\"%s\"/>",
7288 xml_string_append (command,
"</resources>" 7293 switch (
gmp (connection,
credentials, &response, &entity, response_data,
7301 MHD_HTTP_INTERNAL_SERVER_ERROR);
7302 g_string_free (command, TRUE);
7305 "An internal error occurred while saving a tag. " 7306 "The tag remains the same. " 7307 "Diagnostics: Failure to send command to " 7312 MHD_HTTP_INTERNAL_SERVER_ERROR);
7313 g_string_free (command, TRUE);
7316 "An internal error occurred while saving a tag. " 7317 "It is unclear whether the tag has been saved " 7319 "Diagnostics: Failure to receive response from " 7324 MHD_HTTP_INTERNAL_SERVER_ERROR);
7325 g_string_free (command, TRUE);
7328 "An internal error occurred while saving a tag. " 7329 "It is unclear whether the tag has been saved " 7331 "Diagnostics: Internal Error.",
7335 g_string_free (command, TRUE);
7337 "Save Tag", response_data);
7339 free_entity (entity);
7394 params_t *params,
const char *extra_xml,
7431 params_t *params,
const char *extra_xml,
7469 gchar *html, *response;
7470 const char *tag_id, *enable;
7481 if (gvm_connection_sendf (connection,
7482 "<modify_tag tag_id=\"%s\">" 7483 "<active>%s</active>" 7489 MHD_HTTP_INTERNAL_SERVER_ERROR);
7492 "An internal error occurred while modifying a tag. " 7493 "The tag is not modified. " 7494 "Diagnostics: Failure to send command to" 7500 if (read_entity_and_text_c (connection, &entity, &response))
7503 MHD_HTTP_INTERNAL_SERVER_ERROR);
7506 "An internal error occurred while modifying a tag. " 7507 "It is unclear whether the tag has been modified" 7509 "Diagnostics: Failure to read response from" 7515 "Toggle Tag", response_data);
7517 free_entity (entity);
7536 params_t *params,
const char *extra_xml,
7540 "tasks=\"1\"", response_data);
7573 params_t *params,
const char *extra_xml,
7611 gchar *html, *response;
7612 const char *name, *hosts, *exclude_hosts, *comment;
7613 const char *target_ssh_credential, *port, *target_smb_credential;
7614 const char *target_esxi_credential, *target_snmp_credential;
7615 const char *target_source, *target_exclude_source;
7616 const char *target_id, *port_list_id, *reverse_lookup_only;
7617 const char *reverse_lookup_unify, *alive_tests, *in_use;
7639 command = g_string_new (
"");
7640 xml_string_append (command,
7641 "<modify_target target_id=\"%s\">" 7643 "<comment>%s</comment>" 7644 "<alive_tests>%s</alive_tests>" 7646 target_id, name ? name :
"", comment ? comment :
"",
7651 ret =
gmp (connection,
credentials, &response, &entity, response_data,
7653 g_string_free (command, TRUE);
7661 MHD_HTTP_INTERNAL_SERVER_ERROR);
7663 credentials,
"Internal error", __FUNCTION__, __LINE__,
7664 "An internal error occurred while saving a target. " 7665 "The target remains the same. " 7666 "Diagnostics: Failure to send command to manager daemon.",
7670 MHD_HTTP_INTERNAL_SERVER_ERROR);
7672 credentials,
"Internal error", __FUNCTION__, __LINE__,
7673 "An internal error occurred while saving a target. " 7674 "It is unclear whether the target has been saved or not. " 7675 "Diagnostics: Failure to receive response from manager daemon.",
7679 MHD_HTTP_INTERNAL_SERVER_ERROR);
7681 credentials,
"Internal error", __FUNCTION__, __LINE__,
7682 "An internal error occurred while saving a target. " 7683 "It is unclear whether the target has been saved or not. " 7684 "Diagnostics: Internal Error.",
7689 "Save Target", response_data);
7691 free_entity (entity);
7697 exclude_hosts =
params_value (params,
"exclude_hosts");
7698 reverse_lookup_only =
params_value (params,
"reverse_lookup_only");
7699 reverse_lookup_unify =
params_value (params,
"reverse_lookup_unify");
7700 target_source =
params_value (params,
"target_source");
7701 target_exclude_source =
params_value (params,
"target_exclude_source");
7703 target_ssh_credential =
params_value (params,
"ssh_credential_id");
7705 target_smb_credential =
params_value (params,
"smb_credential_id");
7706 target_esxi_credential =
params_value (params,
"esxi_credential_id");
7707 target_snmp_credential =
params_value (params,
"snmp_credential_id");
7717 if (strcmp (target_ssh_credential,
"--")
7718 && strcmp (target_ssh_credential,
"0"))
7721 if (
str_equal (target_source,
"manual"))
7728 gchar *ssh_credentials_element, *smb_credentials_element;
7729 gchar *esxi_credentials_element, *snmp_credentials_element;
7730 gchar *comment_element;
7734 comment_element = g_strdup_printf (
"<comment>%s</comment>", comment);
7736 comment_element = g_strdup (
"");
7738 if (
str_equal (target_ssh_credential,
"--"))
7739 ssh_credentials_element = g_strdup (
"");
7741 ssh_credentials_element = g_strdup_printf (
"<ssh_credential id=\"%s\">" 7743 "</ssh_credential>",
7744 target_ssh_credential, port);
7746 if (
str_equal (target_smb_credential,
"--"))
7747 smb_credentials_element = g_strdup (
"");
7749 smb_credentials_element =
7750 g_strdup_printf (
"<smb_credential id=\"%s\"/>", target_smb_credential);
7752 if (
str_equal (target_esxi_credential,
"--"))
7753 esxi_credentials_element = g_strdup (
"");
7755 esxi_credentials_element = g_strdup_printf (
7756 "<esxi_credential id=\"%s\"/>", target_esxi_credential);
7758 if (
str_equal (target_snmp_credential,
"--"))
7759 snmp_credentials_element = g_strdup (
"");
7761 snmp_credentials_element = g_strdup_printf (
7762 "<snmp_credential id=\"%s\"/>", target_snmp_credential);
7764 command = g_string_new (
"");
7767 "<modify_target target_id=\"%s\">" 7770 "<exclude_hosts>%s</exclude_hosts>" 7771 "<reverse_lookup_only>%s</reverse_lookup_only>" 7772 "<reverse_lookup_unify>%s</reverse_lookup_unify>" 7773 "<port_list id=\"%s\"/>" 7774 "<alive_tests>%s</alive_tests>",
7777 str_equal (target_exclude_source,
"file")
7780 reverse_lookup_only ? reverse_lookup_only :
"0",
7781 reverse_lookup_unify ? reverse_lookup_unify :
"0", port_list_id,
7784 g_string_append_printf (command,
7787 comment_element, ssh_credentials_element,
7788 smb_credentials_element, esxi_credentials_element,
7789 snmp_credentials_element);
7791 g_free (comment_element);
7792 g_free (ssh_credentials_element);
7793 g_free (smb_credentials_element);
7794 g_free (esxi_credentials_element);
7795 g_free (snmp_credentials_element);
7799 ret = gvm_connection_sendf (connection,
"%s", command->str);
7800 g_string_free (command, TRUE);
7805 MHD_HTTP_INTERNAL_SERVER_ERROR);
7807 credentials,
"Internal error", __FUNCTION__, __LINE__,
7808 "An internal error occurred while modifying target. " 7809 "No target was modified. " 7810 "Diagnostics: Failure to send command to manager daemon.",
7815 if (read_entity_and_text_c (connection, &entity, &response))
7818 MHD_HTTP_INTERNAL_SERVER_ERROR);
7820 credentials,
"Internal error", __FUNCTION__, __LINE__,
7821 "An internal error occurred while modifying a target. " 7822 "It is unclear whether the target has been modified or not. " 7823 "Diagnostics: Failure to receive response from manager daemon.",
7828 "Save Target", response_data);
7887 gchar *html, *response;
7888 const char *name, *comment, *base, *scanner = NULL;
7905 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
7909 "<comment>%s</comment>" 7910 "<scanner>%s</scanner>" 7912 name, base, comment, scanner ?:
""))
7919 MHD_HTTP_INTERNAL_SERVER_ERROR);
7921 credentials,
"Internal error", __FUNCTION__, __LINE__,
7922 "An internal error occurred while creating a new config. " 7923 "No new config was created. " 7924 "Diagnostics: Failure to send command to manager daemon.",
7928 MHD_HTTP_INTERNAL_SERVER_ERROR);
7930 credentials,
"Internal error", __FUNCTION__, __LINE__,
7931 "An internal error occurred while creating a new config. " 7932 "It is unclear whether the config has been created or not. " 7933 "Diagnostics: Failure to receive response from manager daemon.",
7937 MHD_HTTP_INTERNAL_SERVER_ERROR);
7939 credentials,
"Internal error", __FUNCTION__, __LINE__,
7940 "An internal error occurred while creating a new config. " 7941 "It is unclear whether the config has been created or not. " 7942 "Diagnostics: Internal Error.",
7946 if (entity_attribute (entity,
"id"))
7947 params_add (params,
"config_id", entity_attribute (entity,
"id"));
7949 "Create Config", response_data);
7951 free_entity (entity);
7970 gchar *command, *html, *response;
7978 command = g_strdup_printf (
"<create_config>" 7983 gmp (connection,
credentials, &response, &entity, response_data, command);
7992 MHD_HTTP_INTERNAL_SERVER_ERROR);
7994 credentials,
"Internal error", __FUNCTION__, __LINE__,
7995 "An internal error occurred while importing a config. " 7996 "The schedule remains the same. " 7997 "Diagnostics: Failure to send command to manager daemon.",
8001 MHD_HTTP_INTERNAL_SERVER_ERROR);
8003 credentials,
"Internal error", __FUNCTION__, __LINE__,
8004 "An internal error occurred while importing a config. " 8005 "It is unclear whether the schedule has been saved or not. " 8006 "Diagnostics: Failure to receive response from manager daemon.",
8010 MHD_HTTP_INTERNAL_SERVER_ERROR);
8012 credentials,
"Internal error", __FUNCTION__, __LINE__,
8013 "An internal error occurred while importing a config. " 8014 "It is unclear whether the schedule has been saved or not. " 8015 "Diagnostics: Internal Error.",
8022 "Import Config", response_data);
8023 free_entity (entity);
8041 params_t *params,
const char *extra_xml,
8079 params_t *params,
const char *extra_xml,
int edit,
8083 const char *config_id;
8087 if (config_id == NULL)
8091 xml = g_string_new (
"<get_config_response>");
8093 g_string_append (xml,
"<edit/>");
8096 g_string_append (xml, extra_xml);
8099 if (gvm_connection_sendf (connection,
8104 " preferences=\"1\"/>",
8108 g_string_free (xml, TRUE);
8110 MHD_HTTP_INTERNAL_SERVER_ERROR);
8112 credentials,
"Internal error", __FUNCTION__, __LINE__,
8113 "An internal error occurred while getting the config. " 8114 "The config is not available. " 8115 "Diagnostics: Failure to send command to manager daemon.",
8119 if (read_string_c (connection, &xml))
8121 g_string_free (xml, TRUE);
8123 MHD_HTTP_INTERNAL_SERVER_ERROR);
8125 credentials,
"Internal error", __FUNCTION__, __LINE__,
8126 "An internal error occurred while getting the config. " 8127 "The config is not available. " 8128 "Diagnostics: Failure to receive response from manager daemon.",
8134 if (gvm_connection_sendf (connection,
"<get_nvt_families/>") == -1)
8136 g_string_free (xml, TRUE);
8138 MHD_HTTP_INTERNAL_SERVER_ERROR);
8140 credentials,
"Internal error", __FUNCTION__, __LINE__,
8141 "An internal error occurred while getting the config. " 8142 "The config is not available. " 8143 "Diagnostics: Failure to send command to manager daemon.",
8147 if (read_string_c (connection, &xml))
8149 g_string_free (xml, TRUE);
8151 MHD_HTTP_INTERNAL_SERVER_ERROR);
8153 credentials,
"Internal error", __FUNCTION__, __LINE__,
8154 "An internal error occurred while getting the config. " 8155 "The config is not available. " 8156 "Diagnostics: Failure to receive response from manager daemon.",
8163 if (gvm_connection_sendf (connection,
"<get_scanners filter=\"type=1\"/>")
8166 g_string_free (xml, TRUE);
8168 MHD_HTTP_INTERNAL_SERVER_ERROR);
8170 credentials,
"Internal error", __FUNCTION__, __LINE__,
8171 "An internal error occurred while getting the config. " 8172 "The config is not available. " 8173 "Diagnostics: Failure to send command to manager daemon.",
8177 if (read_string_c (connection, &xml))
8179 g_string_free (xml, TRUE);
8181 MHD_HTTP_INTERNAL_SERVER_ERROR);
8183 credentials,
"Internal error", __FUNCTION__, __LINE__,
8184 "An internal error occurred while getting the config. " 8185 "The config is not available. " 8186 "Diagnostics: Failure to receive response from manager daemon.",
8192 if (gvm_connection_sendf (connection,
"<get_credentials/>") == -1)
8194 g_string_free (xml, TRUE);
8196 MHD_HTTP_INTERNAL_SERVER_ERROR);
8198 credentials,
"Internal error", __FUNCTION__, __LINE__,
8199 "An internal error occurred while getting the config. " 8200 "The config is not available. " 8201 "Diagnostics: Failure to send command to manager daemon.",
8204 if (read_string_c (connection, &xml))
8206 g_string_free (xml, TRUE);
8208 MHD_HTTP_INTERNAL_SERVER_ERROR);
8210 credentials,
"Internal error", __FUNCTION__, __LINE__,
8211 "An internal error occurred while getting the config. " 8212 "The config is not available. " 8213 "Diagnostics: Failure to receive response from manager daemon.",
8219 g_string_append (xml,
"<permissions>");
8221 if (gvm_connection_sendf (connection,
8223 " filter=\"name:^.*(config)s?$" 8224 " and resource_uuid=%s" 8225 " first=1 rows=-1\"/>",
8229 g_string_free (xml, TRUE);
8231 MHD_HTTP_INTERNAL_SERVER_ERROR);
8233 credentials,
"Internal error", __FUNCTION__, __LINE__,
8234 "An internal error occurred while getting permissions list. " 8235 "The current list of resources is not available. " 8236 "Diagnostics: Failure to send command to manager daemon.",
8240 if (read_string_c (connection, &xml))
8242 g_string_free (xml, TRUE);
8244 MHD_HTTP_INTERNAL_SERVER_ERROR);
8246 credentials,
"Internal error", __FUNCTION__, __LINE__,
8247 "An internal error occurred while getting permissions list. " 8248 "The current list of resources is not available. " 8249 "Diagnostics: Failure to receive response from manager daemon.",
8253 g_string_append (xml,
"</permissions>");
8257 g_string_append (xml,
"</get_config_response>");
8259 g_string_free (xml, FALSE), response_data);
8291 params_t *params,
const char *extra_xml,
8330 const char *config_id;
8336 if (gvm_connection_sendf (connection,
"<sync_config config_id=\"%s\"/>",
8341 MHD_HTTP_INTERNAL_SERVER_ERROR);
8343 credentials,
"Internal error", __FUNCTION__, __LINE__,
8344 "An internal error occurred while synchronizing a config. " 8345 "The config is not synchronized. " 8346 "Diagnostics: Failure to send command to manager daemon.",
8350 xml = g_string_new (
"");
8352 if (read_string_c (connection, &xml))
8354 g_string_free (xml, TRUE);
8356 MHD_HTTP_INTERNAL_SERVER_ERROR);
8358 credentials,
"Internal error", __FUNCTION__, __LINE__,
8359 "An internal error occurred while synchronizing a config. " 8360 "It is unclear whether the config has been synchronized or not. " 8361 "Diagnostics: Failure to receive response from manager daemon.",
8368 g_string_free (xml, TRUE);
8387 params_t *params,
const char *next,
const char *fail_next,
8390 GHashTableIter iter;
8391 gpointer param_name, val;
8393 const char *config_id;
8396 g_hash_table_iter_init (&iter, params);
8398 while (g_hash_table_iter_next (&iter, ¶m_name, &val))
8406 if (!g_str_has_prefix (param_name,
"osp_pref_"))
8413 param_name = ((
char *) param_name) + 9;
8414 if (gvm_connection_sendf (connection,
8415 "<modify_config config_id=\"%s\">" 8416 "<preference><name>%s</name>" 8417 "<value>%s</value></preference>" 8419 config_id, (
char *) param_name, value)
8424 MHD_HTTP_INTERNAL_SERVER_ERROR);
8426 credentials,
"Internal error", __FUNCTION__, __LINE__,
8427 "An internal error occurred while saving a config. It is" 8428 " unclear whether the entire config has been saved. " 8429 "Diagnostics: Failure to send command to manager daemon.",
8435 fail_next, success, response_data);
8457 char *ret, *osp_ret;
8458 params_t *preferences, *selects, *trends;
8459 const char *config_id, *name, *comment, *scanner_id;
8474 gmp_ret = gvm_connection_sendf_xml (connection,
8475 "<modify_config config_id=\"%s\">" 8477 "<comment>%s</comment>" 8478 "<scanner>%s</scanner>" 8481 name, comment, scanner_id);
8483 gmp_ret = gvm_connection_sendf_xml (connection,
8484 "<modify_config config_id=\"%s\">" 8486 "<comment>%s</comment>" 8494 MHD_HTTP_INTERNAL_SERVER_ERROR);
8496 credentials,
"Internal error", __FUNCTION__, __LINE__,
8497 "An internal error occurred while saving a config. " 8498 "It is unclear whether the entire config has been saved. " 8499 "Diagnostics: Failure to send command to manager daemon.",
8504 "edit_config", &success, response_data);
8528 if (gvm_connection_sendf (connection,
8529 "<modify_config config_id=\"%s\">" 8541 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8543 credentials,
"Internal error", __FUNCTION__, __LINE__,
8544 "An internal error occurred while saving a config. " 8545 "It is unclear whether the entire config has been saved. " 8546 "Diagnostics: Failure to send command to manager daemon.",
8554 "edit_config", &success, response_data);
8564 "edit_config", &success, response_data);
8573 if (osp_ret == NULL)
8576 MHD_HTTP_INTERNAL_SERVER_ERROR);
8578 credentials,
"Internal error", __FUNCTION__, __LINE__,
8579 "An internal error occurred while saving a config. " 8580 "It is unclear whether the entire config has been saved. " 8581 "Diagnostics: save_osp_prefs returned NULL unexpectedly.",
8592 if (trends || selects ||
params_value (params,
"trend"))
8594 if (gvm_connection_sendf (
8596 "<modify_config config_id=\"%s\">" 8597 "<family_selection>" 8598 "<growing>%i</growing>",
8605 MHD_HTTP_INTERNAL_SERVER_ERROR);
8607 credentials,
"Internal error", __FUNCTION__, __LINE__,
8608 "An internal error occurred while saving a config. " 8609 "It is unclear whether the entire config has been saved. " 8610 "Diagnostics: Failure to send command to manager daemon.",
8622 if (gvm_connection_sendf (connection,
8626 "<growing>%i</growing>" 8629 trends &&
member1 (trends, family))
8633 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8635 credentials,
"Internal error", __FUNCTION__, __LINE__,
8636 "An internal error occurred while saving a config. " 8637 "It is unclear whether the entire config has been saved. " 8638 "Diagnostics: Failure to send command to manager daemon.",
8656 if (selects &&
member (selects, family))
8658 if (gvm_connection_sendf (connection,
8662 "<growing>1</growing>" 8668 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8670 credentials,
"Internal error", __FUNCTION__, __LINE__,
8671 "An internal error occurred while saving a config. " 8672 "It is unclear whether the entire config has been saved. " 8673 "Diagnostics: Failure to send command to manager daemon.",
8679 if (gvm_connection_sendf (connection,
"</family_selection>" 8684 MHD_HTTP_INTERNAL_SERVER_ERROR);
8686 credentials,
"Internal error", __FUNCTION__, __LINE__,
8687 "An internal error occurred while saving a config. " 8688 "It is unclear whether the entire config has been saved. " 8689 "Diagnostics: Failure to send command to manager daemon.",
8695 "edit_config", NULL, response_data);
8717 const char *config_id, *name, *family, *sort_field, *sort_order;
8723 if ((config_id == NULL) || (name == NULL) || (family == NULL))
8727 credentials,
"Internal error", __FUNCTION__, __LINE__,
8728 "An internal error occurred while getting config family. " 8729 "Diagnostics: Required parameter was NULL.",
8733 xml = g_string_new (
"<get_config_family_response>");
8735 g_string_append (xml,
"<edit/>");
8737 g_string_append_printf (xml,
8738 "<config id=\"%s\">" 8739 "<name>%s</name><family>%s</family>" 8741 config_id, name, family);
8748 if (gvm_connection_sendf (
8751 " config_id=\"%s\" details=\"1\"" 8752 " family=\"%s\" timeout=\"1\" preference_count=\"1\"" 8753 " sort_field=\"%s\" sort_order=\"%s\"/>",
8754 config_id, family, sort_field ? sort_field :
"nvts.name",
8755 sort_order ? sort_order :
"ascending")
8758 g_string_free (xml, TRUE);
8760 MHD_HTTP_INTERNAL_SERVER_ERROR);
8762 credentials,
"Internal error", __FUNCTION__, __LINE__,
8763 "An internal error occurred while getting list of configs. " 8764 "The current list of configs is not available. " 8765 "Diagnostics: Failure to send command to manager daemon.",
8769 if (read_string_c (connection, &xml))
8771 g_string_free (xml, TRUE);
8773 MHD_HTTP_INTERNAL_SERVER_ERROR);
8775 credentials,
"Internal error", __FUNCTION__, __LINE__,
8776 "An internal error occurred while getting list of configs. " 8777 "The current list of configs is not available. " 8778 "Diagnostics: Failure to receive response from manager daemon.",
8786 g_string_append (xml,
"<all>");
8788 if (gvm_connection_sendf (connection,
8793 " preferences_config_id=\"%s\"" 8794 " preference_count=\"1\"" 8795 " sort_field=\"%s\"" 8796 " sort_order=\"%s\"/>",
8798 sort_field ? sort_field :
"nvts.name",
8799 sort_order ? sort_order :
"ascending")
8802 g_string_free (xml, TRUE);
8804 MHD_HTTP_INTERNAL_SERVER_ERROR);
8806 credentials,
"Internal error", __FUNCTION__, __LINE__,
8807 "An internal error occurred while getting list of configs. " 8808 "The current list of configs is not available. " 8809 "Diagnostics: Failure to send command to manager daemon.",
8813 if (read_string_c (connection, &xml))
8815 g_string_free (xml, TRUE);
8817 MHD_HTTP_INTERNAL_SERVER_ERROR);
8819 credentials,
"Internal error", __FUNCTION__, __LINE__,
8820 "An internal error occurred while getting list of configs. " 8821 "The current list of configs is not available. " 8822 "Diagnostics: Failure to receive response from manager daemon.",
8826 g_string_append (xml,
"</all>");
8829 g_string_append (xml,
"</get_config_family_response>");
8831 g_string_free (xml, FALSE), response_data);
8885 const char *config_id, *family;
8896 if (gvm_connection_sendf (connection,
8897 "<modify_config config_id=\"%s\">" 8899 "<family>%s</family>",
8904 MHD_HTTP_INTERNAL_SERVER_ERROR);
8906 credentials,
"Internal error", __FUNCTION__, __LINE__,
8907 "An internal error occurred while saving a config. " 8908 "It is unclear whether the entire config has been saved. " 8909 "Diagnostics: Failure to send command to manager daemon.",
8922 if (gvm_connection_sendf (connection,
"<nvt oid=\"%s\"/>", name) == -1)
8925 MHD_HTTP_INTERNAL_SERVER_ERROR);
8927 credentials,
"Internal error", __FUNCTION__, __LINE__,
8928 "An internal error occurred while saving a config. " 8929 "It is unclear whether the entire config has been saved. " 8930 "Diagnostics: Failure to send command to manager daemon.",
8935 if (gvm_connection_sendf (connection,
"</nvt_selection>" 8940 MHD_HTTP_INTERNAL_SERVER_ERROR);
8942 credentials,
"Internal error", __FUNCTION__, __LINE__,
8943 "An internal error occurred while saving a config. " 8944 "It is unclear whether the entire config has been saved. " 8945 "Diagnostics: Failure to send command to manager daemon.",
8951 "edit_config_family", NULL, response_data);
8972 const char *config_id, *name, *family, *sort_field, *sort_order, *nvt;
8982 xml = g_string_new (
"<get_config_nvt_response>");
8984 g_string_append (xml,
"<edit/>");
8986 g_string_append_printf (xml,
8987 "<config id=\"%s\">" 8988 "<name>%s</name><family>%s</family>" 8990 config_id, name, family ? family :
"");
8995 if (gvm_connection_sendf (connection,
8997 " config_id=\"%s\" nvt_oid=\"%s\"" 8998 " details=\"1\" preferences=\"1\"" 8999 " sort_field=\"%s\" sort_order=\"%s\"/>",
9001 sort_field ? sort_field :
"nvts.name",
9002 sort_order ? sort_order :
"ascending")
9005 g_string_free (xml, TRUE);
9007 MHD_HTTP_INTERNAL_SERVER_ERROR);
9009 credentials,
"Internal error", __FUNCTION__, __LINE__,
9010 "An internal error occurred while getting list of configs. " 9011 "The current list of configs is not available. " 9012 "Diagnostics: Failure to send command to manager daemon.",
9016 if (read_string_c (connection, &xml))
9018 g_string_free (xml, TRUE);
9020 MHD_HTTP_INTERNAL_SERVER_ERROR);
9022 credentials,
"Internal error", __FUNCTION__, __LINE__,
9023 "An internal error occurred while getting list of configs. " 9024 "The current list of configs is not available. " 9025 "Diagnostics: Failure to receive response from manager daemon.",
9029 g_string_append (xml,
"</get_config_nvt_response>");
9031 if (gvm_connection_sendf (connection,
9034 " sort_field=\"notes.text\"/>",
9038 g_string_free (xml, TRUE);
9040 MHD_HTTP_INTERNAL_SERVER_ERROR);
9042 credentials,
"Internal error", __FUNCTION__, __LINE__,
9043 "An internal error occurred while getting list of notes. " 9044 "The current list of notes is not available. " 9045 "Diagnostics: Failure to send command to manager daemon.",
9049 if (read_string_c (connection, &xml))
9051 g_string_free (xml, TRUE);
9053 MHD_HTTP_INTERNAL_SERVER_ERROR);
9055 credentials,
"Internal error", __FUNCTION__, __LINE__,
9056 "An internal error occurred while getting list of notes. " 9057 "The current list of notes is not available. " 9058 "Diagnostics: Failure to receive response from manager daemon.",
9062 if (gvm_connection_sendf (connection,
9065 " sort_field=\"overrides.text\"/>",
9069 g_string_free (xml, TRUE);
9071 MHD_HTTP_INTERNAL_SERVER_ERROR);
9073 credentials,
"Internal error", __FUNCTION__, __LINE__,
9074 "An internal error occurred while getting list of overrides. " 9075 "The current list of overrides is not available. " 9076 "Diagnostics: Failure to send command to manager daemon.",
9080 if (read_string_c (connection, &xml))
9082 g_string_free (xml, TRUE);
9084 MHD_HTTP_INTERNAL_SERVER_ERROR);
9086 credentials,
"Internal error", __FUNCTION__, __LINE__,
9087 "An internal error occurred while getting list of overrides. " 9088 "The current list of overrides is not available. " 9089 "Diagnostics: Failure to receive response from manager daemon.",
9094 g_string_free (xml, FALSE), response_data);
9146 const char *config_id;
9148 char *modify_config_ret;
9150 modify_config_ret = NULL;
9157 gchar *preference_name;
9165 int type_start, type_end, count, ret, is_timeout = 0;
9168 g_free (modify_config_ret);
9169 modify_config_ret = NULL;
9176 count = sscanf (preference_name,
"%*[^[][%n%*[^]]%n]:", &type_start,
9178 if (count == 0 && type_start > 0 && type_end > 0)
9180 if (strncmp (preference_name + type_start,
"password",
9181 type_end - type_start)
9191 gchar *password_name;
9196 &password_name, &password))
9197 if (strcmp (password_name, preference_name) == 0)
9207 else if (strncmp (preference_name + type_start,
"file",
9208 type_end - type_start)
9224 if (strcmp (file_name, preference_name) == 0)
9234 else if (strncmp (preference_name + type_start,
"scanner",
9235 type_end - type_start)
9244 ? g_base64_encode ((guchar *) preference->
value,
9250 const char *timeout;
9251 gchar *preference_name_escaped;
9255 if (timeout == NULL)
9259 MHD_HTTP_BAD_REQUEST);
9261 credentials,
"Internal error", __FUNCTION__, __LINE__,
9262 "An internal error occurred while saving a config. " 9263 "It is unclear whether the entire config has been saved. " 9264 "Diagnostics: Required parameter was NULL.",
9268 preference_name_escaped =
9269 g_markup_escape_text (preference_name, -1);
9271 if (strcmp (timeout,
"0") == 0)
9273 ret = gvm_connection_sendf (connection,
9275 " config_id=\"%s\">" 9280 config_id, preference_name_escaped);
9282 ret = gvm_connection_sendf (connection,
9284 " config_id=\"%s\">" 9290 config_id, preference_name_escaped,
9293 g_free (preference_name_escaped);
9297 gchar *preference_name_escaped;
9298 preference_name_escaped =
9299 g_markup_escape_text (preference_name, -1);
9301 gvm_connection_sendf (connection,
9303 " config_id=\"%s\">" 9311 preference_name_escaped, value);
9312 g_free (preference_name_escaped);
9319 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
9321 credentials,
"Internal error", __FUNCTION__, __LINE__,
9322 "An internal error occurred while saving a config. " 9323 "It is unclear whether the entire config has been saved. " 9324 "Diagnostics: Failure to send command to manager daemon.",
9330 connection,
credentials, params,
"get_config_nvt",
9331 "edit_config_nvt", &success, response_data);
9334 return modify_config_ret;
9343 connection,
credentials, params, response_data,
"Modify Config",
9344 "All NVT preferences modified successfully", NULL, NULL);
9346 return modify_config_ret;
9530 entity_t entity, preference_entity, value_entity;
9531 const char *config_id, *oid, *preference_name;
9535 preference_name =
params_value (params,
"preference_name");
9537 xml = g_string_new (
"<get_preferences_response>");
9543 if (gvm_connection_sendf (connection,
9547 " preference=\"%s\"/>",
9548 config_id, oid, preference_name)
9551 g_string_free (xml, TRUE);
9553 MHD_HTTP_INTERNAL_SERVER_ERROR);
9555 credentials,
"Internal error", __FUNCTION__, __LINE__,
9556 "An internal error occurred while getting a preference file. " 9557 "The file could not be delivered. " 9558 "Diagnostics: Failure to send command to manager daemon.",
9563 if (read_entity_c (connection, &entity))
9565 g_string_free (xml, TRUE);
9567 MHD_HTTP_INTERNAL_SERVER_ERROR);
9569 credentials,
"Internal error", __FUNCTION__, __LINE__,
9570 "An internal error occurred while getting a preference file. " 9571 "The file could not be delivered. " 9572 "Diagnostics: Failure to receive response from manager daemon.",
9576 preference_entity = entity_child (entity,
"preference");
9577 if (preference_entity != NULL
9578 && (value_entity = entity_child (preference_entity,
"value")))
9580 char *content = strdup (entity_text (value_entity));
9585 g_strdup_printf (
"attachment; filename=\"pref_file.bin\""));
9587 free_entity (entity);
9588 g_string_free (xml, TRUE);
9593 free_entity (entity);
9594 g_string_free (xml, TRUE);
9596 MHD_HTTP_INTERNAL_SERVER_ERROR);
9598 credentials,
"Internal error", __FUNCTION__, __LINE__,
9599 "An internal error occurred while getting a preference file. " 9600 "The file could not be delivered. " 9601 "Diagnostics: Failure to receive file from manager daemon.",
9605 g_string_append (xml,
"</get_preferences_response>");
9607 g_string_free (xml, FALSE), response_data);
9683 params_t *params,
const char *extra_xml,
9688 entity_t report_entity;
9689 unsigned int first, max;
9690 GString *levels, *delta_states;
9691 const char *search_phrase, *min_qod, *zone;
9692 const char *autofp, *autofp_value, *notes, *overrides, *result_hosts_only;
9693 const char *apply_overrides;
9694 const char *report_id, *sort_field, *sort_order, *result_id, *delta_report_id;
9695 const char *format_id, *first_result, *max_results, *host, *pos;
9696 const char *filt_id, *filter, *apply_filter, *report_section;
9697 const char *build_filter, *filter_extra;
9699 int ignore_filter, ignore_pagination;
9700 gchar *built_filter;
9701 gchar *fname_format;
9702 const gchar *extension, *requested_content_type;
9710 apply_filter =
"no_pagination";
9714 report_section =
params_value (params,
"report_section");
9716 report_section =
"";
9719 (strcmp (apply_filter,
"full") && strcmp (apply_filter,
"no_pagination")
9720 && strcmp (report_section,
"") && strcmp (report_section,
"results")
9721 && strcmp (report_section,
"summary"));
9725 const char *ignore_pagination_str =
9728 (ignore_pagination_str && strcmp (ignore_pagination_str,
"")
9729 && strcmp (ignore_pagination_str,
"0"));
9734 (strcmp (apply_filter,
"full") && strcmp (report_section,
"")
9735 && strcmp (report_section,
"results")
9736 && strcmp (report_section,
"summary"));
9739 search_phrase =
params_value (params,
"search_phrase");
9740 if (search_phrase == NULL)
9741 params_given (params,
"search_phrase") || (search_phrase =
"");
9757 if (autofp_value == NULL)
9758 params_given (params,
"autofp_value") || (autofp_value =
"1");
9773 if (overrides == NULL)
9779 params_given (params,
"overrides") || (overrides =
"1");
9782 apply_overrides =
params_value (params,
"apply_overrides");
9783 if (apply_overrides == NULL)
9787 apply_overrides =
"0";
9789 params_given (params,
"apply_overrides") || (apply_overrides =
"1");
9792 result_hosts_only =
params_value (params,
"result_hosts_only");
9793 if (result_hosts_only == NULL)
9799 result_hosts_only =
"0";
9801 params_given (params,
"result_hosts_only") || (result_hosts_only =
"1");
9804 if (autofp == NULL || strlen (autofp) == 0)
9807 if (autofp_value == NULL || strlen (autofp_value) == 0)
9810 if (strcmp (autofp,
"2") == 0)
9813 if (notes == NULL || strlen (notes) == 0)
9816 if (overrides == NULL || strlen (overrides) == 0)
9819 if (result_hosts_only == NULL || strlen (result_hosts_only) == 0)
9820 result_hosts_only =
"1";
9825 delta_states = g_string_new (
params_value (params,
"delta_states"));
9828 delta_states = g_string_new (
"");
9830 && atoi (
params_value (params,
"delta_state_changed")))
9831 g_string_append (delta_states,
"c");
9834 g_string_append (delta_states,
"g");
9837 g_string_append (delta_states,
"n");
9840 g_string_append (delta_states,
"s");
9843 if (strlen (delta_states->str) == 0)
9844 g_string_append (delta_states,
"gn");
9847 levels = g_string_new (
params_value (params,
"levels"));
9850 levels = g_string_new (
"");
9853 g_string_append (levels,
"h");
9856 g_string_append (levels,
"m");
9859 g_string_append (levels,
"l");
9862 g_string_append (levels,
"g");
9864 && atoi (
params_value (params,
"level_false_positive")))
9865 g_string_append (levels,
"f");
9868 if (strlen (levels->str) == 0)
9869 g_string_append (levels,
"hml");
9878 delta_report_id =
params_value (params,
"delta_report_id");
9882 if (first_result == NULL || sscanf (first_result,
"%u", &first) != 1)
9886 if (max_results == NULL || sscanf (max_results,
"%u", &max) != 1)
9889 if (gvm_connection_sendf (
9892 " result_tags=\"0\"" 9895 delta_report_id || strcmp (report_section,
"summary"),
9896 host ?
" host=\"" :
"", host ? host :
"", host ?
"\"" :
"")
9899 g_string_free (delta_states, TRUE);
9900 g_string_free (levels, TRUE);
9902 MHD_HTTP_INTERNAL_SERVER_ERROR);
9904 credentials,
"Internal error", __FUNCTION__, __LINE__,
9905 "An internal error occurred while getting a report. " 9906 "The report could not be delivered. " 9907 "Diagnostics: Failure to send command to manager daemon.",
9918 if ((build_filter && (strcmp (build_filter,
"1") == 0))
9919 || ((filter == NULL || strcmp (filter,
"") == 0)
9920 && (filter_extra == NULL || strcmp (filter_extra,
"") == 0)))
9922 GString *filter_buffer;
9923 filter_buffer = g_string_new (
"");
9925 g_string_append_printf (
9928 " apply_overrides=%i" 9931 " result_hosts_only=%i" 9936 strcmp (autofp,
"0") ? autofp_value :
"0",
9937 apply_overrides ? (strcmp (apply_overrides,
"0") ? 1 : 0) : 1,
9938 strcmp (notes,
"0") ? 1 : 0, strcmp (overrides,
"0") ? 1 : 0,
9939 strcmp (result_hosts_only,
"0") ? 1 : 0, first_result, max_results,
9940 sort_order ? strcmp (sort_order,
"ascending") ?
"-reverse" :
"" 9941 : ((sort_field == NULL || strcmp (sort_field,
"type") == 0
9942 || strcmp (sort_field,
"severity") == 0)
9945 sort_field ? sort_field :
"severity", levels->str);
9947 if (search_phrase && strcmp (search_phrase,
""))
9949 gchar *search_phrase_escaped;
9950 search_phrase_escaped = g_markup_escape_text (search_phrase, -1);
9951 g_string_append_printf (filter_buffer,
" \"%s\"",
9952 search_phrase_escaped);
9953 g_free (search_phrase_escaped);
9956 if (delta_states->str && strcmp (delta_states->str,
"") && delta_report_id
9957 && strcmp (delta_report_id,
""))
9958 g_string_append_printf (filter_buffer,
" delta_states=%s",
9961 if (min_qod && strcmp (min_qod,
""))
9962 g_string_append_printf (filter_buffer,
" min_qod=%s", min_qod);
9964 if (zone && strcmp (zone,
""))
9965 g_string_append_printf (filter_buffer,
" timezone=%s", zone);
9967 if (filter && strcmp (filter,
""))
9968 g_string_append_printf (filter_buffer,
" %s", filter);
9970 built_filter = g_string_free (filter_buffer, FALSE);
9972 else if (filter || filter_extra)
9973 built_filter = g_strdup_printf (
"%s%s%s", filter ? filter :
"",
9974 filter && filter_extra ?
" " :
"",
9975 filter_extra ? filter_extra :
"");
9977 built_filter = NULL;
9981 if (sort_field == NULL && sort_order == NULL)
9982 if ((filt_id == NULL || strcmp (filt_id,
"") == 0)
9983 && (filter == NULL || strcmp (filter,
"") == 0))
9987 ret = gvm_connection_sendf_xml (connection,
9989 " filter=\"first=1 rows=-1" 9990 " result_hosts_only=0 apply_overrides=1" 9991 " notes=1 overrides=1" 9992 " sort-reverse=severity\"" 9994 " delta_report_id=\"%s\"" 9995 " format_id=\"%s\"/>",
9997 delta_report_id ? delta_report_id :
"0",
9998 format_id ? format_id :
"");
10000 ret = gvm_connection_sendf_xml (
10002 " ignore_pagination=\"%d\"" 10006 " notes_details=\"1\"" 10007 " overrides_details=\"1\"" 10008 " report_id=\"%s\"" 10009 " delta_report_id=\"%s\"" 10010 " format_id=\"%s\"/>",
10011 ignore_pagination, filt_id ? filt_id :
"0",
10012 built_filter ? built_filter :
"", pos ? pos :
"1", report_id,
10013 delta_report_id ? delta_report_id :
"0", format_id ? format_id :
"",
10014 first_result, max_results, sort_field ? sort_field :
"severity",
10015 sort_order ? sort_order
10016 : ((sort_field == NULL || strcmp (sort_field,
"type") == 0
10017 || strcmp (sort_field,
"severity") == 0)
10020 levels->str, delta_states->str, search_phrase, min_qod, zone);
10023 g_string_free (delta_states, TRUE);
10024 g_string_free (levels, TRUE);
10026 MHD_HTTP_INTERNAL_SERVER_ERROR);
10028 credentials,
"Internal error", __FUNCTION__, __LINE__,
10029 "An internal error occurred while getting a report. " 10030 "The report could not be delivered. " 10031 "Diagnostics: Failure to send command to manager daemon.",
10035 g_string_free (delta_states, TRUE);
10039 g_string_free (levels, TRUE);
10040 if ((strcmp (format_id,
"a994b278-1f62-11e1-96ac-406186ea4fc5") == 0)
10041 || strcmp (format_id,
"5057e5cc-b825-11e4-9d0e-28d24461215b") == 0)
10045 if (read_entity_c (connection, &entity))
10048 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10050 credentials,
"Internal error", __FUNCTION__, __LINE__,
10051 "An internal error occurred while getting a report. " 10052 "The report could not be delivered. " 10053 "Diagnostics: Failure to receive response from manager daemon.",
10056 entity_t report = entity_child (entity,
"report");
10057 if (report == NULL)
10059 free_entity (entity);
10061 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10063 credentials,
"Internal error", __FUNCTION__, __LINE__,
10064 "An internal error occurred while getting a report. " 10065 "The report could not be delivered. " 10066 "Diagnostics: Response from manager daemon did not contain a " 10070 extension = entity_attribute (report,
"extension");
10071 requested_content_type = entity_attribute (report,
"content_type");
10072 if (extension && requested_content_type)
10076 "e1a2ae0b-736e-4484-b029-330c9e15b900",
10077 &fname_format, response_data);
10084 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10086 credentials,
"Internal error", __FUNCTION__, __LINE__,
10087 "An internal error occurred while getting a setting. " 10088 "The setting could not be delivered. " 10089 "Diagnostics: Failure to send command to manager " 10094 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10096 credentials,
"Internal error", __FUNCTION__, __LINE__,
10097 "An internal error occurred while getting a setting. " 10098 "The setting could not be delivered. " 10099 "Diagnostics: Failure to receive response from manager " 10104 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10106 credentials,
"Internal error", __FUNCTION__, __LINE__,
10107 "An internal error occurred while getting a setting. " 10108 "The setting could not be delivered. " 10109 "Diagnostics: Internal error.",
10114 if (fname_format == NULL)
10116 g_warning (
"%s : File name format setting not found.",
10118 fname_format =
"%T-%U";
10122 report_id, report);
10123 if (file_name == NULL)
10124 file_name = g_strdup_printf (
"%s-%s",
"report", report_id);
10127 response_data, g_strdup (requested_content_type));
10130 g_strdup_printf (
"attachment; filename=\"%s.%s\"", file_name,
10133 g_free (file_name);
10135 xml = g_string_new (
"");
10136 print_entity_to_string (report, xml);
10137 free_entity (entity);
10138 return g_string_free (xml, FALSE);
10145 if (read_entity_c (connection, &entity))
10148 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10150 credentials,
"Internal error", __FUNCTION__, __LINE__,
10151 "An internal error occurred while getting a report. " 10152 "The report could not be delivered. " 10153 "Diagnostics: Failure to receive response from manager daemon.",
10157 report_entity = entity_child (entity,
"report");
10158 if (report_entity != NULL)
10160 char *report_encoded;
10162 gchar *report_decoded;
10163 extension = entity_attribute (report_entity,
"extension");
10164 requested_content_type =
10165 entity_attribute (report_entity,
"content_type");
10166 report_encoded = entity_text (report_entity);
10168 (gchar *) g_base64_decode (report_encoded, &report_len);
10171 if (report_decoded == NULL)
10173 report_decoded = g_strdup (
"");
10176 if (extension && requested_content_type)
10186 connection,
"e1a2ae0b-736e-4484-b029-330c9e15b900",
10187 &fname_format, response_data);
10194 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10198 "An internal error occurred while getting a " 10200 "The setting could not be delivered. " 10201 "Diagnostics: Failure to send command to manager " 10206 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10210 "An internal error occurred while getting a " 10212 "The setting could not be delivered. " 10213 "Diagnostics: Failure to receive response from " 10218 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10222 "An internal error occurred while getting a " 10224 "The setting could not be delivered. " 10225 "Diagnostics: Internal error.",
10230 if (fname_format == NULL)
10232 g_warning (
"%s : File name format setting not found.",
10234 fname_format =
"%T-%U";
10238 "report",
id, report_entity);
10239 if (file_name == NULL)
10240 file_name = g_strdup_printf (
"%s-%s",
"report",
id);
10243 response_data, g_strdup (requested_content_type));
10246 g_strdup_printf (
"attachment; filename=\"%s.%s\"",
10247 file_name, extension));
10249 g_free (file_name);
10252 free_entity (entity);
10255 return report_decoded;
10259 free_entity (entity);
10261 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10263 credentials,
"Internal error", __FUNCTION__, __LINE__,
10264 "An internal error occurred while getting a report. " 10265 "The report could not be delivered. " 10266 "Diagnostics: Failure to receive report from manager daemon.",
10275 if (delta_report_id && result_id && strcmp (result_id,
"0"))
10276 xml = g_string_new (
"<get_delta_result>");
10279 xml = g_string_new (
"<get_asset>");
10280 xml_string_append (xml,
10281 "<search_phrase>%s</search_phrase>" 10282 "<levels>%s</levels>" 10283 "<hosts start=\"%s\" max=\"%s\"/>",
10284 search_phrase, levels->str, first_result,
10288 xml = g_string_new (
"<get_report>");
10291 g_string_append (xml, extra_xml);
10293 g_string_free (levels, TRUE);
10295 if (delta_report_id)
10296 g_string_append_printf (xml,
10297 "<delta>%s</delta>" 10298 "<result id=\"%s\"/>",
10299 delta_report_id, result_id ? result_id :
"0");
10302 if (read_entity_and_string_c (connection, &entity, &xml))
10305 MHD_HTTP_INTERNAL_SERVER_ERROR);
10307 credentials,
"Internal error", __FUNCTION__, __LINE__,
10308 "An internal error occurred while getting a report. " 10309 "The report could not be delivered. " 10310 "Diagnostics: Failure to receive response from manager daemon.",
10322 entity_attribute (entity,
"status_text"), response_data);
10324 g_string_free (xml, TRUE);
10325 free_entity (entity);
10329 if ((filt_id == NULL) && (
params_value (params,
"filter") == NULL))
10336 term = entity_child (entity,
"report");
10337 if (term && ((term = entity_child (term,
"report")))
10338 && ((term = entity_child (term,
"filters")))
10339 && ((term = entity_child (term,
"term"))))
10348 report_entity = entity_child (entity,
"report");
10350 report_entity = entity_child (report_entity,
"report");
10354 entity_t task_entity, name;
10357 task_entity = entity_child (report_entity,
"task");
10360 id = entity_attribute (task_entity,
"id");
10361 name = entity_child (task_entity,
"name");
10366 if (delta_report_id && result_id &&
id && name)
10367 g_string_append_printf (xml,
10368 "<task id=\"%s\"><name>%s</name></task>",
10369 id, entity_text (name));
10371 free_entity (entity);
10374 if (delta_report_id && result_id && strcmp (result_id,
"0"))
10376 g_string_append (xml,
"</get_delta_result>");
10377 return g_string_free (xml, FALSE);
10380 g_string_append (xml,
"</get_report>");
10382 g_string_free (xml, FALSE), response_data);
10418 const char *alert_id, *report_id;
10419 const char *status, *filter;
10420 gchar *response, *html;
10426 if ((alert_id == NULL) || (report_id == NULL))
10430 "Missing parameter alert_id or report_id. " 10431 "Diagnostics: Required parameter was NULL.",
10437 if (filter == NULL && !
params_given (params,
"filter"))
10438 filter =
"first=1 rows=-1" 10439 " result_hosts_only=0" 10440 " apply_overrides=1" 10441 " notes=1 overrides=1" 10442 " sort-reverse=severity";
10444 ret = gvm_connection_sendf_xml (connection,
10446 " report_id=\"%s\"" 10447 " ignore_pagination=\"1\"" 10449 " alert_id=\"%s\"/>",
10450 report_id, filter ? filter :
"", alert_id);
10454 MHD_HTTP_INTERNAL_SERVER_ERROR);
10456 credentials,
"Internal error", __FUNCTION__, __LINE__,
10457 "An internal error occurred while getting a report. " 10458 "The report could not be delivered. " 10459 "Diagnostics: Failure to send command to manager daemon.",
10463 if (read_entity_and_text_c (connection, &entity, &response))
10466 MHD_HTTP_INTERNAL_SERVER_ERROR);
10469 "An internal error occurred while getting a report. " 10470 "The report could not be delivered. " 10471 "Diagnostics: Failure to receive response from " 10476 status = entity_attribute (entity,
"status");
10477 if ((status == NULL) || (strlen (status) == 0))
10479 free_entity (entity);
10482 MHD_HTTP_INTERNAL_SERVER_ERROR);
10484 credentials,
"Internal error", __FUNCTION__, __LINE__,
10485 "An internal error occurred while getting a report. " 10486 "The report could not be delivered. " 10487 "Diagnostics: Failure to parse response from manager daemon.",
10490 if (strcmp (status,
"200"))
10492 free_entity (entity);
10496 "Running the report alert failed." 10497 "The report could not be delivered.",
10502 "Report Alert", response_data);
10504 free_entity (entity);
10522 params_t *params,
const char *extra_xml,
10525 const char *overrides;
10567 const char *ssl_cert;
10572 if (ssl_cert == NULL)
10577 "An internal error occurred." 10578 " Diagnostics: ssl_cert was NULL.",
10582 unescaped = g_uri_unescape_string (ssl_cert, NULL);
10584 cert = g_strdup_printf (
"-----BEGIN CERTIFICATE-----\n" 10585 "%s\n-----END CERTIFICATE-----\n",
10590 g_free (unescaped);
10608 const char *ca_pub;
10612 if (ca_pub == NULL)
10617 "An internal error occurred." 10618 " Diagnostics: ca_pub was NULL.",
10622 unescaped = g_uri_unescape_string (ca_pub, NULL);
10641 const char *key_pub;
10645 if (key_pub == NULL)
10650 "An internal error occurred." 10651 " Diagnostics: key_pub was NULL.",
10656 unescaped = g_uri_unescape_string (key_pub, NULL);
10711 params_t *params,
const char *extra_xml,
10714 const char *overrides;
10773 params_t *params,
const char *extra_xml,
10810 params_t *params,
const char *extra_xml,
10814 "result=\"1\"", response_data);
10851 if (strcmp (port,
"--") == 0)
10875 if (strcmp (hosts,
"--") == 0)
10905 const char *task_id;
10909 if (task_id && (strcmp (task_id,
"0") == 0))
10925 const char *severity;
10948 const char *result_id;
10952 if (result_id && (strcmp (result_id,
"0") == 0))
10976 const char *oid, *severity, *port, *hosts;
10977 const char *text, *task_id, *result_id;
10979 const char *active, *days;
11002 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
11004 "<active>%s</active>" 11005 "<nvt oid=\"%s\"/>" 11006 "<hosts>%s</hosts>" 11008 "<severity>%s</severity>" 11010 "<task id=\"%s\"/>" 11011 "<result id=\"%s\"/>" 11013 strcmp (active,
"1") ? active : (days ? days :
"-1"), oid,
11014 hosts ? hosts :
"", port ? port :
"", severity ? severity :
"",
11015 text ? text :
"", task_id ? task_id :
"",
11016 result_id ? result_id :
""))
11023 MHD_HTTP_INTERNAL_SERVER_ERROR);
11025 credentials,
"Internal error", __FUNCTION__, __LINE__,
11026 "An internal error occurred while creating a new note. " 11027 "No new note was created. " 11028 "Diagnostics: Failure to send command to manager daemon.",
11032 MHD_HTTP_INTERNAL_SERVER_ERROR);
11034 credentials,
"Internal error", __FUNCTION__, __LINE__,
11035 "An internal error occurred while creating a new note. " 11036 "It is unclear whether the note has been created or not. " 11037 "Diagnostics: Failure to receive response from manager daemon.",
11041 MHD_HTTP_INTERNAL_SERVER_ERROR);
11043 credentials,
"Internal error", __FUNCTION__, __LINE__,
11044 "An internal error occurred while creating a new note. " 11045 "It is unclear whether the note has been created or not. " 11046 "Diagnostics: Internal Error.",
11050 if (entity_attribute (entity,
"id"))
11051 params_add (params,
"note_id", entity_attribute (entity,
"id"));
11053 "Create Note", response_data);
11054 free_entity (entity);
11093 const char *note_id, *text, *hosts, *port, *severity, *task_id;
11094 const char *result_id, *active, *days, *oid;
11121 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
11122 "<modify_note note_id=\"%s\">" 11123 "<active>%s</active>" 11124 "<hosts>%s</hosts>" 11126 "<severity>%s</severity>" 11128 "<task id=\"%s\"/>" 11129 "<result id=\"%s\"/>" 11130 "<nvt oid=\"%s\"/>" 11132 note_id, strcmp (active,
"1") ? active : (days ? days :
"-1"),
11133 hosts ? hosts :
"", port ? port :
"", severity ? severity :
"",
11134 text ? text :
"", task_id ? task_id :
"",
11135 result_id ? result_id :
"", oid))
11142 MHD_HTTP_INTERNAL_SERVER_ERROR);
11144 credentials,
"Internal error", __FUNCTION__, __LINE__,
11145 "An internal error occurred while saving a note. " 11146 "The note remains the same. " 11147 "Diagnostics: Failure to send command to manager daemon.",
11151 MHD_HTTP_INTERNAL_SERVER_ERROR);
11153 credentials,
"Internal error", __FUNCTION__, __LINE__,
11154 "An internal error occurred while saving a note. " 11155 "It is unclear whether the note has been saved or not. " 11156 "Diagnostics: Failure to receive response from manager daemon.",
11160 MHD_HTTP_INTERNAL_SERVER_ERROR);
11162 credentials,
"Internal error", __FUNCTION__, __LINE__,
11163 "An internal error occurred while saving a note. " 11164 "It is unclear whether the note has been saved or not. " 11165 "Diagnostics: Internal Error.",
11170 "Save Note", response_data);
11172 free_entity (entity);
11190 params_t *params,
const char *extra_xml,
11227 params_t *params,
const char *extra_xml,
11231 "result=\"1\"", response_data);
11267 const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
11268 const char *text, *task_id, *result_id;
11270 const char *active, *days;
11282 custom_severity =
params_value (params,
"custom_severity");
11285 if (custom_severity != NULL && strcmp (custom_severity,
"0"))
11291 new_severity = NULL;
11299 new_severity =
params_value (params,
"new_severity_from_list");
11304 new_severity = NULL;
11318 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
11319 "<create_override>" 11320 "<active>%s</active>" 11321 "<nvt oid=\"%s\"/>" 11322 "<hosts>%s</hosts>" 11324 "<severity>%s</severity>" 11325 "<new_severity>%s</new_severity>" 11327 "<task id=\"%s\"/>" 11328 "<result id=\"%s\"/>" 11329 "</create_override>",
11330 strcmp (active,
"1") ? active : (days ? days :
"-1"), oid,
11331 hosts ? hosts :
"", port ? port :
"", severity ? severity :
"",
11332 new_severity, text ? text :
"", task_id ? task_id :
"",
11333 result_id ? result_id :
""))
11340 MHD_HTTP_INTERNAL_SERVER_ERROR);
11342 credentials,
"Internal error", __FUNCTION__, __LINE__,
11343 "An internal error occurred while creating a new override. " 11344 "No new override was created. " 11345 "Diagnostics: Failure to send command to manager daemon.",
11349 MHD_HTTP_INTERNAL_SERVER_ERROR);
11351 credentials,
"Internal error", __FUNCTION__, __LINE__,
11352 "An internal error occurred while creating a new override. " 11353 "It is unclear whether the override has been created or not. " 11354 "Diagnostics: Failure to receive response from manager daemon.",
11358 MHD_HTTP_INTERNAL_SERVER_ERROR);
11360 credentials,
"Internal error", __FUNCTION__, __LINE__,
11361 "An internal error occurred while creating a new override. " 11362 "It is unclear whether the override has been created or not. " 11363 "Diagnostics: Internal Error.",
11367 if (entity_attribute (entity,
"id"))
11368 params_add (params,
"override_id", entity_attribute (entity,
"id"));
11370 "Create Override", response_data);
11371 free_entity (entity);
11410 const char *override_id, *text, *hosts, *port;
11411 const char *severity, *custom_severity, *new_severity;
11412 const char *task_id, *result_id, *active, *days, *oid;
11427 custom_severity =
params_value (params,
"custom_severity");
11428 if (custom_severity && strcmp (custom_severity,
"0") != 0)
11431 new_severity =
params_value (params,
"new_severity_from_list");
11445 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
11446 "<modify_override override_id=\"%s\">" 11447 "<active>%s</active>" 11448 "<nvt oid=\"%s\"/>" 11449 "<hosts>%s</hosts>" 11451 "<severity>%s</severity>" 11452 "<new_severity>%s</new_severity>" 11454 "<task id=\"%s\"/>" 11455 "<result id=\"%s\"/>" 11456 "</modify_override>",
11458 strcmp (active,
"1") ? active : (days ? days :
"-1"), oid,
11459 hosts ? hosts :
"", port ? port :
"", severity ? severity :
"",
11460 new_severity, text ? text :
"", task_id ? task_id :
"",
11461 result_id ? result_id :
""))
11468 MHD_HTTP_INTERNAL_SERVER_ERROR);
11470 credentials,
"Internal error", __FUNCTION__, __LINE__,
11471 "An internal error occurred while saving a override. " 11472 "The override remains the same. " 11473 "Diagnostics: Failure to send command to manager daemon.",
11477 MHD_HTTP_INTERNAL_SERVER_ERROR);
11479 credentials,
"Internal error", __FUNCTION__, __LINE__,
11480 "An internal error occurred while saving a override. " 11481 "It is unclear whether the override has been saved or not. " 11482 "Diagnostics: Failure to receive response from manager daemon.",
11486 MHD_HTTP_INTERNAL_SERVER_ERROR);
11488 credentials,
"Internal error", __FUNCTION__, __LINE__,
11489 "An internal error occurred while saving a override. " 11490 "It is unclear whether the override has been saved or not. " 11491 "Diagnostics: Internal Error.",
11496 "Save Override", response_data);
11498 free_entity (entity);
11518 params_t *params,
const char *extra_xml,
11555 params_t *params,
const char *extra_xml,
11629 gchar *html, *response;
11630 const char *scanner_id;
11637 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
11638 "<verify_scanner scanner_id=\"%s\"/>", scanner_id);
11647 MHD_HTTP_INTERNAL_SERVER_ERROR);
11649 credentials,
"Internal error", __FUNCTION__, __LINE__,
11650 "An internal error occurred while verifying a scanner. " 11651 "The scanner was not verified. " 11652 "Diagnostics: Failure to send command to manager daemon.",
11656 MHD_HTTP_INTERNAL_SERVER_ERROR);
11658 credentials,
"Internal error", __FUNCTION__, __LINE__,
11659 "An internal error occurred while verifying a scanner. " 11660 "It is unclear whether the scanner was verified or not. " 11661 "Diagnostics: Failure to send command to manager daemon.",
11665 MHD_HTTP_INTERNAL_SERVER_ERROR);
11667 credentials,
"Internal error", __FUNCTION__, __LINE__,
11668 "An internal error occurred while verifying a scanner. " 11669 "It is unclear whether the scanner was verified or not. " 11670 "Diagnostics: Failure to send command to manager daemon.",
11675 "Verify Scanner", response_data);
11676 free_entity (entity);
11697 gchar *response = NULL;
11698 const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
11699 entity_t entity = NULL;
11707 credential_id =
params_value (params,
"credential_id");
11718 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
11720 "<name>%s</name><comment>%s</comment>" 11721 "<host>%s</host><port>%s</port><type>%s</type>" 11722 "<ca_pub>%s</ca_pub>" 11723 "<credential id=\"%s\"/>" 11724 "</create_scanner>",
11725 name, comment, host, port, type, ca_pub, credential_id);
11727 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
11729 "<name>%s</name><comment>%s</comment>" 11730 "<host>%s</host><port>%s</port><type>%s</type>" 11731 "<credential id=\"%s\"/>" 11732 "</create_scanner>",
11733 name, comment, host, port, type, credential_id);
11741 MHD_HTTP_INTERNAL_SERVER_ERROR);
11743 credentials,
"Internal error", __FUNCTION__, __LINE__,
11744 "An internal error occurred while creating a new scanner. " 11745 "No new scanner was created. " 11746 "Diagnostics: Failure to send command to manager daemon.",
11750 MHD_HTTP_INTERNAL_SERVER_ERROR);
11752 credentials,
"Internal error", __FUNCTION__, __LINE__,
11753 "An internal error occurred while creating a new scanner. " 11754 "It is unclear whether the scanner has been created or not. " 11755 "Diagnostics: Failure to receive response from manager daemon.",
11759 MHD_HTTP_INTERNAL_SERVER_ERROR);
11761 credentials,
"Internal error", __FUNCTION__, __LINE__,
11762 "An internal error occurred while creating a new scanner. " 11763 "It is unclear whether the scanner has been created or not. " 11764 "Diagnostics: Internal Error.",
11768 if (entity_attribute (entity,
"id"))
11769 params_add (params,
"scanner_id", entity_attribute (entity,
"id"));
11771 "Create Scanner", response_data);
11772 free_entity (entity);
11809 gchar *response = NULL;
11810 entity_t entity = NULL;
11811 const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
11812 const char *credential_id, *which_cert;
11825 credential_id =
params_value (params,
"credential_id");
11846 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
11847 "<modify_scanner scanner_id=\"%s\">" 11849 "<comment>%s</comment>" 11850 "</modify_scanner>",
11851 scanner_id, name, comment ?:
"");
11853 else if (strcmp (which_cert,
"new") == 0
11854 || strcmp (which_cert,
"default") == 0)
11856 if (ca_pub == NULL)
11861 "<modify_scanner scanner_id=\"%s\">" 11863 "<comment>%s</comment>" 11864 "<ca_pub>%s</ca_pub>" 11865 "<credential id=\"%s\"/>" 11866 "</modify_scanner>",
11867 scanner_id, name, comment ?:
"",
11868 strcmp (which_cert,
"new") == 0 ? ca_pub :
"", credential_id);
11872 "<modify_scanner scanner_id=\"%s\">" 11874 "<comment>%s</comment>" 11878 "<ca_pub>%s</ca_pub>" 11879 "<credential id=\"%s\"/>" 11880 "</modify_scanner>",
11881 scanner_id, name, comment ?:
"", host, port, type,
11882 strcmp (which_cert,
"new") == 0 ? ca_pub :
"", credential_id);
11888 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
11889 "<modify_scanner scanner_id=\"%s\">" 11891 "<comment>%s</comment>" 11892 "<credential id=\"%s\"/>" 11893 "</modify_scanner>",
11894 scanner_id, name, comment ?:
"", credential_id);
11896 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
11897 "<modify_scanner scanner_id=\"%s\">" 11899 "<comment>%s</comment>" 11903 "<credential id=\"%s\"/>" 11904 "</modify_scanner>",
11905 scanner_id, name, comment ?:
"", host, port, type,
11916 MHD_HTTP_INTERNAL_SERVER_ERROR);
11918 credentials,
"Internal error", __FUNCTION__, __LINE__,
11919 "An internal error occurred while saving a scanner. " 11920 "The scanner remains the same. " 11921 "Diagnostics: Failure to send command to manager daemon.",
11925 MHD_HTTP_INTERNAL_SERVER_ERROR);
11927 credentials,
"Internal error", __FUNCTION__, __LINE__,
11928 "An internal error occurred while saving a scanner. " 11929 "It is unclear whether the scanner has been saved or not. " 11930 "Diagnostics: Failure to receive response from manager daemon.",
11934 MHD_HTTP_INTERNAL_SERVER_ERROR);
11936 credentials,
"Internal error", __FUNCTION__, __LINE__,
11937 "An internal error occurred while saving a scanner. " 11938 "It is unclear whether the scanner has been saved or not. " 11939 "Diagnostics: Internal Error.",
11944 "Save Scanner", response_data);
11946 free_entity (entity);
11966 params_t *params,
const char *extra_xml,
11970 "tasks=\"1\"", response_data);
12003 params_t *params,
const char *extra_xml,
12043 const char *name, *comment, *timezone, *icalendar;
12058 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
12059 "<create_schedule>" 12061 "<comment>%s</comment>" 12062 "<timezone>%s</timezone>" 12063 "<icalendar>%s</icalendar>" 12064 "</create_schedule>",
12065 name, comment, timezone, icalendar))
12072 MHD_HTTP_INTERNAL_SERVER_ERROR);
12074 credentials,
"Internal error", __FUNCTION__, __LINE__,
12075 "An internal error occurred while creating a new schedule. " 12076 "No new schedule was created. " 12077 "Diagnostics: Failure to send command to manager daemon.",
12081 MHD_HTTP_INTERNAL_SERVER_ERROR);
12083 credentials,
"Internal error", __FUNCTION__, __LINE__,
12084 "An internal error occurred while creating a new schedule. " 12085 "It is unclear whether the schedule has been created or not. " 12086 "Diagnostics: Failure to receive response from manager daemon.",
12090 MHD_HTTP_INTERNAL_SERVER_ERROR);
12092 credentials,
"Internal error", __FUNCTION__, __LINE__,
12093 "An internal error occurred while creating a new schedule. " 12094 "It is unclear whether the schedule has been created or not. " 12095 "Diagnostics: Internal Error.",
12099 if (entity_attribute (entity,
"id"))
12100 params_add (params,
"schedule_id", entity_attribute (entity,
"id"));
12102 "Create Schedule", response_data);
12103 free_entity (entity);
12142 time_t now, duration, duration_start;
12143 struct tm start_time, end_time;
12145 const char *slave_id, *given_duration, *range_type;
12146 const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
12147 const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
12156 range_type =
"duration";
12158 duration = given_duration ? atoi (given_duration) : 86400;
12159 duration_start = now - duration;
12161 xml = g_string_new (
"<get_system_reports>");
12163 g_string_append_printf (xml,
"<slave id=\"%s\"/>", slave_id ? slave_id :
"0");
12165 if (strcmp (range_type,
"duration") == 0)
12167 struct tm *time_broken;
12168 time_broken = localtime (&now);
12169 end_time.tm_year = time_broken->tm_year;
12170 end_time.tm_mon = time_broken->tm_mon;
12171 end_time.tm_mday = time_broken->tm_mday;
12172 end_time.tm_hour = time_broken->tm_hour;
12173 end_time.tm_min = time_broken->tm_min;
12175 time_broken = localtime (&duration_start);
12176 start_time.tm_year = time_broken->tm_year;
12177 start_time.tm_mon = time_broken->tm_mon;
12178 start_time.tm_mday = time_broken->tm_mday;
12179 start_time.tm_hour = time_broken->tm_hour;
12180 start_time.tm_min = time_broken->tm_min;
12182 g_string_append_printf (xml,
"<duration>%ld</duration>", duration);
12186 struct tm *time_broken;
12187 time_broken = localtime (&now);
12201 start_time.tm_year =
12202 start_year ? atoi (start_year) - 1900 : time_broken->tm_year;
12203 start_time.tm_mon =
12204 start_month ? atoi (start_month) - 1 : time_broken->tm_mon;
12205 start_time.tm_mday = start_day ? atoi (start_day) : time_broken->tm_mday;
12206 start_time.tm_hour =
12207 start_hour ? atoi (start_hour) : time_broken->tm_hour;
12208 start_time.tm_min =
12209 start_minute ? atoi (start_minute) : time_broken->tm_min;
12212 end_year ? atoi (end_year) - 1900 : time_broken->tm_year;
12213 end_time.tm_mon = end_month ? atoi (end_month) - 1 : time_broken->tm_mon;
12214 end_time.tm_mday = end_day ? atoi (end_day) : time_broken->tm_mday;
12215 end_time.tm_hour = end_hour ? atoi (end_hour) : time_broken->tm_hour;
12216 end_time.tm_min = end_minute ? atoi (end_minute) : time_broken->tm_min;
12219 g_string_append_printf (xml,
12221 "<minute>%i</minute>" 12223 "<day_of_month>%i</day_of_month>" 12224 "<month>%i</month>" 12227 start_time.tm_min, start_time.tm_hour,
12228 start_time.tm_mday, start_time.tm_mon + 1,
12229 start_time.tm_year + 1900);
12231 g_string_append_printf (xml,
12233 "<minute>%i</minute>" 12235 "<day_of_month>%i</day_of_month>" 12236 "<month>%i</month>" 12239 "<range_type>%s</range_type>",
12240 end_time.tm_min, end_time.tm_hour, end_time.tm_mday,
12241 end_time.tm_mon + 1, end_time.tm_year + 1900,
12246 if (gvm_connection_sendf (connection,
12247 "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
12248 slave_id ? slave_id :
"0")
12251 g_string_free (xml, TRUE);
12253 MHD_HTTP_INTERNAL_SERVER_ERROR);
12255 credentials,
"Internal error", __FUNCTION__, __LINE__,
12256 "An internal error occurred while getting the system reports. " 12257 "The current list of system reports is not available. " 12258 "Diagnostics: Failure to send command to manager daemon.",
12262 if (read_string_c (connection, &xml))
12264 g_string_free (xml, TRUE);
12266 MHD_HTTP_INTERNAL_SERVER_ERROR);
12268 credentials,
"Internal error", __FUNCTION__, __LINE__,
12269 "An internal error occurred while getting the system reports. " 12270 "The current list of system reports is not available. " 12271 "Diagnostics: Failure to receive response from manager daemon.",
12279 if (gvm_connection_sendf (connection,
12281 " filter=\"sort=name rows=-1 type=4\"/>")
12284 g_string_free (xml, TRUE);
12286 MHD_HTTP_INTERNAL_SERVER_ERROR);
12288 credentials,
"Internal error", __FUNCTION__, __LINE__,
12289 "An internal error occurred while getting the system reports. " 12290 "The current list of system reports is not available. " 12291 "Diagnostics: Failure to send command to manager daemon.",
12295 if (read_string_c (connection, &xml))
12297 g_string_free (xml, TRUE);
12299 MHD_HTTP_INTERNAL_SERVER_ERROR);
12301 credentials,
"Internal error", __FUNCTION__, __LINE__,
12302 "An internal error occurred while getting the system reports. " 12303 "The current list of system reports is not available. " 12304 "Diagnostics: Failure to receive response from manager daemon.",
12311 g_string_append (xml,
"</get_system_reports>");
12313 g_string_free (xml, FALSE), response_data);
12329 const char *url,
params_t *params,
12333 entity_t report_entity;
12335 gchar *gmp_command;
12337 struct tm *now_broken;
12338 const char *slave_id, *duration;
12339 const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
12340 const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
12341 struct tm start_time, end_time;
12342 gchar *start_time_str, *end_time_str;
12348 if (sscanf (url,
"%500[^ /]./report.png", name) == 1)
12354 if (duration && strcmp (duration,
""))
12357 g_markup_printf_escaped (
"<get_system_reports" 12360 " slave_id=\"%s\"/>",
12361 name, duration, slave_id ? slave_id :
"0");
12366 now_broken = localtime (&now);
12380 start_time.tm_year =
12381 start_year ? atoi (start_year) - 1900 : now_broken->tm_year;
12382 start_time.tm_mon =
12383 start_month ? atoi (start_month) - 1 : now_broken->tm_mon;
12384 start_time.tm_mday =
12385 start_day ? atoi (start_day) : now_broken->tm_mday;
12386 start_time.tm_hour =
12387 start_hour ? atoi (start_hour) : now_broken->tm_hour;
12388 start_time.tm_min =
12389 start_minute ? atoi (start_minute) : now_broken->tm_min;
12390 start_time.tm_zone = now_broken->tm_zone;
12393 end_year ? atoi (end_year) - 1900 : now_broken->tm_year;
12395 end_month ? atoi (end_month) - 1 : now_broken->tm_mon;
12396 end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
12397 end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
12398 end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
12399 end_time.tm_zone = now_broken->tm_zone;
12401 start_time_str = g_strdup_printf (
12402 "%04d-%02d-%02dT%02d:%02d:00", start_time.tm_year + 1900,
12403 start_time.tm_mon + 1, start_time.tm_mday, start_time.tm_hour,
12404 start_time.tm_min);
12406 end_time_str = g_strdup_printf (
"%04d-%02d-%02dT%02d:%02d:00",
12407 end_time.tm_year + 1900,
12408 end_time.tm_mon + 1, end_time.tm_mday,
12409 end_time.tm_hour, end_time.tm_min);
12411 gmp_command = g_markup_printf_escaped (
12412 "<get_system_reports" 12414 " start_time=\"%s\"" 12416 " slave_id=\"%s\"/>",
12417 name, start_time_str, end_time_str, slave_id ? slave_id :
"0");
12418 g_free (start_time_str);
12419 g_free (end_time_str);
12422 if (gvm_connection_sendf (connection,
"%s", gmp_command) == -1)
12424 g_free (gmp_command);
12427 g_free (gmp_command);
12430 if (read_entity_c (connection, &entity))
12435 report_entity = entity_child (entity,
"system_report");
12436 if (report_entity == NULL)
12438 free_entity (entity);
12442 report_entity = entity_child (report_entity,
"report");
12443 if (report_entity == NULL)
12445 free_entity (entity);
12450 char *content_64 = entity_text (report_entity);
12451 char *content = NULL;
12452 gsize content_length = 0;
12454 if (content_64 && strlen (content_64))
12456 content = (
char *) g_base64_decode (content_64, &content_length);
12465 content = g_strdup (
"helo");
12470 free_entity (entity);
12491 params_t *params,
const char *extra_xml,
12495 "alerts =\"1\" params=\"1\"", response_data);
12529 params_t *params,
const char *extra_xml,
12533 NULL, response_data);
12571 params, response_data);
12589 gchar *command, *html, *response;
12597 command = g_strdup_printf (
"<create_report_format>" 12599 "</create_report_format>",
12602 gmp (connection,
credentials, &response, &entity, response_data, command);
12611 MHD_HTTP_INTERNAL_SERVER_ERROR);
12613 credentials,
"Internal error", __FUNCTION__, __LINE__,
12614 "An internal error occurred while importing a report format. " 12615 "The schedule remains the same. " 12616 "Diagnostics: Failure to send command to manager daemon.",
12620 MHD_HTTP_INTERNAL_SERVER_ERROR);
12622 credentials,
"Internal error", __FUNCTION__, __LINE__,
12623 "An internal error occurred while importing a report format. " 12624 "It is unclear whether the schedule has been saved or not. " 12625 "Diagnostics: Failure to receive response from manager daemon.",
12629 MHD_HTTP_INTERNAL_SERVER_ERROR);
12631 credentials,
"Internal error", __FUNCTION__, __LINE__,
12632 "An internal error occurred while importing a report format. " 12633 "It is unclear whether the schedule has been saved or not. " 12634 "Diagnostics: Internal Error.",
12640 if (entity_attribute (entity,
"id"))
12641 params_add (params,
"report_format_id", entity_attribute (entity,
"id"));
12643 "Create Report Format", response_data);
12645 free_entity (entity);
12666 gchar *html, *response;
12667 params_t *preferences, *id_list_params, *include_id_lists;
12668 const char *report_format_id, *name, *summary, *enable;
12671 report_format_id =
params_value (params,
"report_format_id");
12682 include_id_lists =
params_values (params,
"include_id_list:");
12683 if (include_id_lists)
12685 GHashTable *id_lists;
12687 gchar *param_name, *pref_name, *value, *old_values, *new_values;
12689 GHashTableIter hash_table_iter;
12692 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
12700 g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (
""));
12709 gchar *colon_pos = strchr (
param->
value,
':');
12712 value = g_strdup (colon_pos + 1);
12714 old_values = g_hash_table_lookup (id_lists, pref_name);
12716 if (old_values && strcmp (old_values,
""))
12718 new_values = g_strdup_printf (
"%s,%s", old_values, value);
12719 g_hash_table_insert (id_lists, pref_name, new_values);
12722 else if (old_values)
12724 g_hash_table_insert (id_lists, pref_name, value);
12728 g_hash_table_iter_init (&hash_table_iter, id_lists);
12729 while (g_hash_table_iter_next (&hash_table_iter, (
void **) &pref_name,
12734 value_64 = strlen (value)
12735 ? g_base64_encode ((guchar *) value, strlen (value))
12742 "<modify_report_format" 12743 " report_format_id=\"%s\">" 12746 "<value>%s</value>" 12748 "</modify_report_format>",
12749 report_format_id, pref_name, value_64);
12757 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12759 credentials,
"Internal error", __FUNCTION__, __LINE__,
12760 "An internal error occurred while saving a Report Format. " 12761 "The Report Format was not saved. " 12762 "Diagnostics: Failure to send command to manager daemon.",
12766 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12768 credentials,
"Internal error", __FUNCTION__, __LINE__,
12769 "An internal error occurred while saving a Report Format. " 12770 "It is unclear whether the Report Format has been saved or " 12772 "Diagnostics: Failure to receive response from manager daemon.",
12777 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12779 credentials,
"Internal error", __FUNCTION__, __LINE__,
12780 "An internal error occurred while saving a Report Format. " 12781 "It is unclear whether the Report Format has been saved or " 12783 "Diagnostics: Internal Error.",
12807 int type_start, type_end, count;
12810 sscanf (param_name,
"%*[^[][%n%*[^]]%n]:", &type_start, &type_end);
12811 if (count == 0 && type_start > 0 && type_end > 0)
12824 "<modify_report_format" 12825 " report_format_id=\"%s\">" 12828 "<value>%s</value>" 12830 "</modify_report_format>",
12831 report_format_id, param_name + type_end + 2, value);
12839 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12841 credentials,
"Internal error", __FUNCTION__, __LINE__,
12842 "An internal error occurred while saving a Report Format. " 12843 "The Report Format was not saved. " 12844 "Diagnostics: Failure to send command to manager daemon.",
12848 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12850 credentials,
"Internal error", __FUNCTION__, __LINE__,
12851 "An internal error occurred while saving a Report Format. " 12852 "It is unclear whether the Report Format has been saved or " 12854 "Diagnostics: Failure to receive response from manager " 12860 response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12862 credentials,
"Internal error", __FUNCTION__, __LINE__,
12863 "An internal error occurred while saving a Report Format. " 12864 "It is unclear whether the Report Format has been saved or " 12866 "Diagnostics: Internal Error.",
12877 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
12878 "<modify_report_format" 12879 " report_format_id=\"%s\">" 12881 "<summary>%s</summary>" 12882 "<active>%s</active>" 12883 "</modify_report_format>",
12884 report_format_id, name, summary, enable);
12894 MHD_HTTP_INTERNAL_SERVER_ERROR);
12896 credentials,
"Internal error", __FUNCTION__, __LINE__,
12897 "An internal error occurred while saving a Report Format. " 12898 "The Report Format was not saved. " 12899 "Diagnostics: Failure to send command to manager daemon.",
12903 MHD_HTTP_INTERNAL_SERVER_ERROR);
12905 credentials,
"Internal error", __FUNCTION__, __LINE__,
12906 "An internal error occurred while saving a Report Format. " 12907 "It is unclear whether the Report Format has been saved or not. " 12908 "Diagnostics: Failure to receive response from manager daemon.",
12912 MHD_HTTP_INTERNAL_SERVER_ERROR);
12914 credentials,
"Internal error", __FUNCTION__, __LINE__,
12915 "An internal error occurred while saving a Report Format. " 12916 "It is unclear whether the Report Format has been saved or not. " 12917 "Diagnostics: Internal Error.",
12922 "Save Report Format", response_data);
12923 free_entity (entity);
12944 gchar *html, *response;
12945 const char *report_format_id;
12948 report_format_id =
params_value (params,
"report_format_id");
12949 if (report_format_id == NULL)
12953 credentials,
"Internal error", __FUNCTION__, __LINE__,
12954 "An internal error occurred while verifying a report format. " 12955 "Diagnostics: Required parameter was NULL.",
12965 "<verify_report_format report_format_id=\"%s\"/>", report_format_id);
12974 MHD_HTTP_INTERNAL_SERVER_ERROR);
12976 credentials,
"Internal error", __FUNCTION__, __LINE__,
12977 "An internal error occurred while verifying a report format. " 12978 "The report format was not verified. " 12979 "Diagnostics: Failure to send command to manager daemon.",
12983 MHD_HTTP_INTERNAL_SERVER_ERROR);
12985 credentials,
"Internal error", __FUNCTION__, __LINE__,
12986 "An internal error occurred while verifying a report format. " 12987 "It is unclear whether the report format was verified or not. " 12988 "Diagnostics: Failure to send command to manager daemon.",
12992 MHD_HTTP_INTERNAL_SERVER_ERROR);
12994 credentials,
"Internal error", __FUNCTION__, __LINE__,
12995 "An internal error occurred while verifying a report format. " 12996 "It is unclear whether the report format was verified or not. " 12997 "Diagnostics: Failure to send command to manager daemon.",
13002 "Verify Report Format", response_data);
13003 free_entity (entity);
13026 gchar *param_name, *html, *response;
13040 credentials,
"Internal error", __FUNCTION__, __LINE__,
13041 "An internal error occurred while trying to start a wizard. " 13042 "Diagnostics: Required parameter 'name' was NULL.",
13045 run = g_string_new (
"<run_wizard>");
13047 g_string_append_printf (run,
13057 xml_string_append (run,
13060 "<value>%s</value>" 13065 g_string_append (run,
"</params></run_wizard>");
13070 gmp (connection,
credentials, &response, &entity, response_data, run->str);
13071 g_string_free (run, TRUE);
13079 MHD_HTTP_INTERNAL_SERVER_ERROR);
13081 credentials,
"Internal error", __FUNCTION__, __LINE__,
13082 "An internal error occurred while running a wizard. " 13083 "The wizard did not start. " 13084 "Diagnostics: Failure to send command to manager daemon.",
13088 MHD_HTTP_INTERNAL_SERVER_ERROR);
13090 credentials,
"Internal error", __FUNCTION__, __LINE__,
13091 "An internal error occurred while running a wizard. " 13092 "It is unclear whether the wizard started or not. " 13093 "Diagnostics: Failure to receive response from manager daemon.",
13097 MHD_HTTP_INTERNAL_SERVER_ERROR);
13100 "An internal error occurred while running a wizard. " 13101 "It is unclear whether the wizard started or not. " 13102 "Diagnostics: Internal Error.",
13107 "Run Wizard", response_data);
13108 free_entity (entity);
13113 #define GET_TRASH_RESOURCE(capability, command, name) \ 13114 if (command_enabled (credentials, capability)) \ 13116 if (gvm_connection_sendf (connection, \ 13117 "<" command " filter=\"rows=-1 sort=name\"" \ 13118 " trash=\"1\"/>") \ 13121 g_string_free (xml, TRUE); \ 13122 cmd_response_data_set_status_code (response_data, \ 13123 MHD_HTTP_INTERNAL_SERVER_ERROR); \ 13124 return gsad_message ( \ 13125 credentials, "Internal error", __FUNCTION__, __LINE__, \ 13126 "An internal error occurred while getting " name \ 13127 " list for trash." \ 13128 "Diagnostics: Failure to send command to" \ 13129 " manager daemon.", \ 13133 if (read_string_c (connection, &xml)) \ 13135 g_string_free (xml, TRUE); \ 13136 cmd_response_data_set_status_code (response_data, \ 13137 MHD_HTTP_INTERNAL_SERVER_ERROR); \ 13138 return gsad_message ( \ 13139 credentials, "Internal error", __FUNCTION__, __LINE__, \ 13140 "An internal error occurred while getting " name " list." \ 13141 "Diagnostics: Failure to receive response from" \ 13142 " manager daemon.", \ 13160 params_t *params,
const char *extra_xml,
13165 xml = g_string_new (
"<get_trash>");
13168 g_string_append (xml, extra_xml);
13209 g_string_append (xml,
"</get_trash>");
13211 g_string_free (xml, FALSE), response_data);
13213 #undef GET_TRASH_RESOURCE 13245 params_t *changed, GString *xml,
int *modify_failed_flag,
13258 const char *changed_value =
params_value (changed, uuid);
13259 if (changed_value == NULL
13260 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13264 base64 = g_base64_encode ((guchar *)
param->
value,
13267 base64 = g_strdup (
"");
13268 if (gvm_connection_sendf_xml (connection,
13269 "<modify_setting setting_id=\"%s\">" 13270 "<value>%s</value>" 13271 "</modify_setting>",
13281 xml_string_append (xml,
"<save_setting id=\"%s\">", uuid);
13282 if (read_entity_and_string_c (connection, &entity, &xml))
13284 free_entity (entity);
13287 xml_string_append (xml,
"</save_setting>");
13291 if (modify_failed_flag)
13292 *modify_failed_flag = 1;
13294 free_entity (entity);
13318 params_t *params,
const gchar *accept_language,
13321 const char *lang, *text, *old_passwd, *passwd, *max;
13322 const char *details_fname, *list_fname, *report_fname;
13323 gchar *lang_64, *text_64, *max_64, *fname_64;
13326 params_t *changed, *defaults, *filters;
13327 int modify_failed = 0;
13328 const char *changed_value;
13329 gboolean user_changed = 0;
13340 details_fname =
params_value (params,
"details_fname");
13353 xml = g_string_new (
"");
13356 if ((strlen (passwd) || strlen (old_passwd))
13357 && (changed_value == NULL
13358 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0"))))
13361 gmp_authenticate_info_opts_t auth_opts;
13365 auth_opts = gmp_authenticate_info_opts_defaults;
13367 auth_opts.password = old_passwd;
13368 switch (gmp_authenticate_info_ext_c (connection, auth_opts))
13374 MHD_HTTP_INTERNAL_SERVER_ERROR);
13376 credentials,
"Internal error", __FUNCTION__, __LINE__,
13377 "An internal error occurred while saving settings. " 13378 "The settings remains the same. " 13379 "Diagnostics: Manager closed connection during authenticate.",
13383 MHD_HTTP_INTERNAL_SERVER_ERROR);
13385 credentials,
"Invalid Password", __FUNCTION__, __LINE__,
13386 "You tried to change your password, but the old" 13387 " password was not provided or was incorrect. " 13388 " Please enter the correct old password or remove" 13389 " old and new passwords to apply any other changes" 13390 " of your settings.",
13394 MHD_HTTP_INTERNAL_SERVER_ERROR);
13396 credentials,
"Internal error", __FUNCTION__, __LINE__,
13397 "An internal error occurred while saving settings. " 13398 "The settings remains the same. " 13399 "Diagnostics: Internal Error.",
13403 passwd_64 = g_base64_encode ((guchar *) passwd, strlen (passwd));
13405 if (gvm_connection_sendf (connection,
13407 "<name>Password</name>" 13408 "<value>%s</value>" 13409 "</modify_setting>",
13410 passwd_64 ? passwd_64 :
"")
13413 g_free (passwd_64);
13415 MHD_HTTP_INTERNAL_SERVER_ERROR);
13417 credentials,
"Internal error", __FUNCTION__, __LINE__,
13418 "An internal error occurred while saving settings. " 13419 "It is unclear whether all the settings were saved. " 13420 "Diagnostics: Failure to send command to manager daemon.",
13423 g_free (passwd_64);
13426 xml_string_append (xml,
"<save_setting name=\"Password\">");
13427 if (read_entity_and_string_c (connection, &entity, &xml))
13429 g_string_free (xml, TRUE);
13431 MHD_HTTP_INTERNAL_SERVER_ERROR);
13433 credentials,
"Internal error", __FUNCTION__, __LINE__,
13434 "An internal error occurred while saving settings. " 13435 "Diagnostics: Failure to receive response from manager daemon.",
13438 xml_string_append (xml,
"</save_setting>");
13455 if (changed_value == NULL
13456 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13458 text_64 = g_base64_encode ((guchar *) text, strlen (text));
13460 if (gvm_connection_sendf (connection,
13462 "<name>Timezone</name>" 13463 "<value>%s</value>" 13464 "</modify_setting>",
13465 text_64 ? text_64 :
"")
13470 MHD_HTTP_INTERNAL_SERVER_ERROR);
13472 credentials,
"Internal error", __FUNCTION__, __LINE__,
13473 "An internal error occurred while saving settings. " 13474 "It is unclear whether all the settings were saved. " 13475 "Diagnostics: Failure to send command to manager daemon.",
13481 xml_string_append (xml,
"<save_setting name=\"Timezone\">");
13482 if (read_entity_and_string_c (connection, &entity, &xml))
13484 g_string_free (xml, TRUE);
13486 MHD_HTTP_INTERNAL_SERVER_ERROR);
13488 credentials,
"Internal error", __FUNCTION__, __LINE__,
13489 "An internal error occurred while saving settings. " 13490 "Diagnostics: Failure to receive response from manager daemon.",
13493 xml_string_append (xml,
"</save_setting>");
13497 const gchar *timezone = strlen (text) ? text :
"UTC";
13505 if (setenv (
"TZ", timezone, 1) == -1)
13507 g_critical (
"%s: failed to set TZ\n", __FUNCTION__);
13508 exit (EXIT_FAILURE);
13521 if (changed_value == NULL
13522 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13524 max_64 = g_base64_encode ((guchar *) max, strlen (max));
13526 if (gvm_connection_sendf (connection,
13529 "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">" 13530 "<value>%s</value>" 13531 "</modify_setting>",
13532 max_64 ? max_64 :
"")
13537 MHD_HTTP_INTERNAL_SERVER_ERROR);
13539 credentials,
"Internal error", __FUNCTION__, __LINE__,
13540 "An internal error occurred while saving settings. " 13541 "It is unclear whether all the settings were saved. " 13542 "Diagnostics: Failure to send command to manager daemon.",
13548 xml_string_append (xml,
"<save_setting id=\"%s\">",
13549 "5f5a8712-8017-11e1-8556-406186ea4fc5");
13550 if (read_entity_and_string_c (connection, &entity, &xml))
13552 g_string_free (xml, TRUE);
13554 MHD_HTTP_INTERNAL_SERVER_ERROR);
13556 credentials,
"Internal error", __FUNCTION__, __LINE__,
13557 "An internal error occurred while saving settings. " 13558 "It is unclear whether all the settings were saved. " 13559 "Diagnostics: Failure to receive response from manager daemon.",
13562 xml_string_append (xml,
"</save_setting>");
13571 changed_value =
params_value (changed,
"details_fname");
13572 if (changed_value == NULL
13573 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13576 g_base64_encode ((guchar *) details_fname, strlen (details_fname));
13578 if (gvm_connection_sendf (connection,
13581 "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">" 13582 "<value>%s</value>" 13583 "</modify_setting>",
13584 fname_64 ? fname_64 :
"")
13589 MHD_HTTP_INTERNAL_SERVER_ERROR);
13591 credentials,
"Internal error", __FUNCTION__, __LINE__,
13592 "An internal error occurred while saving settings. " 13593 "It is unclear whether all the settings were saved. " 13594 "Diagnostics: Failure to send command to manager daemon.",
13600 xml_string_append (xml,
"<save_setting id=\"%s\">",
13601 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
13602 if (read_entity_and_string_c (connection, &entity, &xml))
13604 g_string_free (xml, TRUE);
13606 MHD_HTTP_INTERNAL_SERVER_ERROR);
13608 credentials,
"Internal error", __FUNCTION__, __LINE__,
13609 "An internal error occurred while saving settings. " 13610 "It is unclear whether all the settings were saved. " 13611 "Diagnostics: Failure to receive response from manager daemon.",
13614 xml_string_append (xml,
"</save_setting>");
13624 if (changed_value == NULL
13625 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13627 fname_64 = g_base64_encode ((guchar *) list_fname, strlen (list_fname));
13629 if (gvm_connection_sendf (connection,
13632 "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">" 13633 "<value>%s</value>" 13634 "</modify_setting>",
13635 fname_64 ? fname_64 :
"")
13640 MHD_HTTP_INTERNAL_SERVER_ERROR);
13642 credentials,
"Internal error", __FUNCTION__, __LINE__,
13643 "An internal error occurred while saving settings. " 13644 "It is unclear whether all the settings were saved. " 13645 "Diagnostics: Failure to send command to manager daemon.",
13651 xml_string_append (xml,
"<save_setting id=\"%s\">",
13652 "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
13653 if (read_entity_and_string_c (connection, &entity, &xml))
13655 g_string_free (xml, TRUE);
13657 MHD_HTTP_INTERNAL_SERVER_ERROR);
13659 credentials,
"Internal error", __FUNCTION__, __LINE__,
13660 "An internal error occurred while saving settings. " 13661 "It is unclear whether all the settings were saved. " 13662 "Diagnostics: Failure to receive response from manager daemon.",
13665 xml_string_append (xml,
"</save_setting>");
13674 changed_value =
params_value (changed,
"report_fname");
13675 if (changed_value == NULL
13676 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13679 g_base64_encode ((guchar *) report_fname, strlen (report_fname));
13681 if (gvm_connection_sendf (connection,
13684 "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">" 13685 "<value>%s</value>" 13686 "</modify_setting>",
13687 fname_64 ? fname_64 :
"")
13692 MHD_HTTP_INTERNAL_SERVER_ERROR);
13694 credentials,
"Internal error", __FUNCTION__, __LINE__,
13695 "An internal error occurred while saving settings. " 13696 "It is unclear whether all the settings were saved. " 13697 "Diagnostics: Failure to send command to manager daemon.",
13703 xml_string_append (xml,
"<save_setting id=\"%s\">",
13704 "e1a2ae0b-736e-4484-b029-330c9e15b900");
13705 if (read_entity_and_string_c (connection, &entity, &xml))
13707 g_string_free (xml, TRUE);
13709 MHD_HTTP_INTERNAL_SERVER_ERROR);
13711 credentials,
"Internal error", __FUNCTION__, __LINE__,
13712 "An internal error occurred while saving settings. " 13713 "It is unclear whether all the settings were saved. " 13714 "Diagnostics: Failure to receive response from manager daemon.",
13717 xml_string_append (xml,
"</save_setting>");
13727 if (changed_value == NULL
13728 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13730 lang_64 = g_base64_encode ((guchar *) lang, strlen (lang));
13732 if (gvm_connection_sendf (connection,
13735 "=\"6765549a-934e-11e3-b358-406186ea4fc5\">" 13736 "<value>%s</value>" 13737 "</modify_setting>",
13738 lang_64 ? lang_64 :
"")
13743 MHD_HTTP_INTERNAL_SERVER_ERROR);
13745 credentials,
"Internal error", __FUNCTION__, __LINE__,
13746 "An internal error occurred while saving settings. " 13747 "It is unclear whether all the settings were saved. " 13748 "Diagnostics: Failure to send command to manager daemon.",
13754 xml_string_append (xml,
"<save_setting id=\"%s\">",
13755 "6765549a-934e-11e3-b358-406186ea4fc5");
13756 if (read_entity_and_string_c (connection, &entity, &xml))
13758 g_string_free (xml, TRUE);
13760 MHD_HTTP_INTERNAL_SERVER_ERROR);
13762 credentials,
"Internal error", __FUNCTION__, __LINE__,
13763 "An internal error occurred while saving settings. " 13764 "It is unclear whether all the settings were saved. " 13765 "Diagnostics: Failure to receive response from manager daemon.",
13768 xml_string_append (xml,
"</save_setting>");
13788 MHD_HTTP_INTERNAL_SERVER_ERROR);
13790 credentials,
"Internal error", __FUNCTION__, __LINE__,
13791 "An internal error occurred while saving settings. " 13792 "It is unclear whether all the settings were saved. " 13793 "Diagnostics: Failure to send command to manager daemon.",
13804 MHD_HTTP_INTERNAL_SERVER_ERROR);
13806 credentials,
"Internal error", __FUNCTION__, __LINE__,
13807 "An internal error occurred while saving settings. " 13808 "It is unclear whether all the settings were saved. " 13809 "Diagnostics: Failure to send command to manager daemon.",
13815 changed_value =
params_value (changed,
"severity_class");
13816 if (changed_value == NULL
13817 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13820 text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13823 if (gvm_connection_sendf (connection,
13826 "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">" 13827 "<value>%s</value>" 13828 "</modify_setting>",
13829 text_64 ? text_64 :
"")
13834 MHD_HTTP_INTERNAL_SERVER_ERROR);
13836 credentials,
"Internal error", __FUNCTION__, __LINE__,
13837 "An internal error occurred while saving settings. " 13838 "It is unclear whether all the settings were saved. " 13839 "Diagnostics: Failure to send command to manager daemon.",
13845 xml_string_append (xml,
"<save_setting id=\"%s\">",
13846 "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
13847 if (read_entity_and_string_c (connection, &entity, &xml))
13849 g_string_free (xml, TRUE);
13851 MHD_HTTP_INTERNAL_SERVER_ERROR);
13853 credentials,
"Internal error", __FUNCTION__, __LINE__,
13854 "An internal error occurred while saving settings. " 13855 "It is unclear whether all the settings were saved. " 13856 "Diagnostics: Failure to receive response from manager daemon.",
13859 xml_string_append (xml,
"</save_setting>");
13863 if ((text != NULL) && (strlen (text) > 0))
13878 changed_value =
params_value (changed,
"dynamic_severity");
13879 if (changed_value == NULL
13880 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13883 text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13886 if (gvm_connection_sendf (connection,
13889 "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">" 13890 "<value>%s</value>" 13891 "</modify_setting>",
13892 text_64 ? text_64 :
"")
13897 MHD_HTTP_INTERNAL_SERVER_ERROR);
13899 credentials,
"Internal error", __FUNCTION__, __LINE__,
13900 "An internal error occurred while saving settings. " 13901 "It is unclear whether all the settings were saved. " 13902 "Diagnostics: Failure to send command to manager daemon.",
13908 xml_string_append (xml,
"<save_setting id=\"%s\">",
13909 "77ec2444-e7f2-4a80-a59b-f4237782d93f");
13910 if (read_entity_and_string_c (connection, &entity, &xml))
13912 g_string_free (xml, TRUE);
13914 MHD_HTTP_INTERNAL_SERVER_ERROR);
13916 credentials,
"Internal error", __FUNCTION__, __LINE__,
13917 "An internal error occurred while saving settings. " 13918 "It is unclear whether all the settings were saved. " 13919 "Diagnostics: Failure to receive response from manager daemon.",
13922 xml_string_append (xml,
"</save_setting>");
13931 changed_value =
params_value (changed,
"default_severity");
13932 if (changed_value == NULL
13933 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13936 text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13939 if (gvm_connection_sendf (connection,
13942 "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">" 13943 "<value>%s</value>" 13944 "</modify_setting>",
13945 text_64 ? text_64 :
"")
13950 MHD_HTTP_INTERNAL_SERVER_ERROR);
13952 credentials,
"Internal error", __FUNCTION__, __LINE__,
13953 "An internal error occurred while saving settings. " 13954 "It is unclear whether all the settings were saved. " 13955 "Diagnostics: Failure to send command to manager daemon.",
13961 xml_string_append (xml,
"<save_setting id=\"%s\">",
13962 "7eda49c5-096c-4bef-b1ab-d080d87300df");
13963 if (read_entity_and_string_c (connection, &entity, &xml))
13965 g_string_free (xml, TRUE);
13967 MHD_HTTP_INTERNAL_SERVER_ERROR);
13969 credentials,
"Internal error", __FUNCTION__, __LINE__,
13970 "An internal error occurred while saving settings. " 13971 "It is unclear whether all the settings were saved. " 13972 "Diagnostics: Failure to receive response from manager daemon.",
13975 xml_string_append (xml,
"</save_setting>");
13985 changed_value =
params_value (changed,
"auto_cache_rebuild");
13986 if (changed_value == NULL
13987 || (strcmp (changed_value,
"") && strcmp (changed_value,
"0")))
13990 text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13993 if (gvm_connection_sendf (connection,
13996 "=\"a09285b0-2d47-49b6-a4ef-946ee71f1d5c\">" 13997 "<value>%s</value>" 13998 "</modify_setting>",
13999 text_64 ? text_64 :
"")
14003 gvm_connection_close (connection);
14005 MHD_HTTP_INTERNAL_SERVER_ERROR);
14007 credentials,
"Internal error", __FUNCTION__, __LINE__,
14008 "An internal error occurred while saving settings. " 14009 "It is unclear whether all the settings were saved. " 14010 "Diagnostics: Failure to send command to manager daemon.",
14016 xml_string_append (xml,
"<save_setting id=\"%s\">",
14017 "a09285b0-2d47-49b6-a4ef-946ee71f1d5c");
14018 if (read_entity_and_string_c (connection, &entity, &xml))
14020 g_string_free (xml, TRUE);
14021 gvm_connection_close (connection);
14023 MHD_HTTP_INTERNAL_SERVER_ERROR);
14025 credentials,
"Internal error", __FUNCTION__, __LINE__,
14026 "An internal error occurred while saving settings. " 14027 "It is unclear whether all the settings were saved. " 14028 "Diagnostics: Failure to receive response from manager daemon.",
14031 xml_string_append (xml,
"</save_setting>");
14045 g_string_free (xml, FALSE), response_data);
14063 params_t *params,
const char *extra_xml,
14100 params_t *params,
const char *extra_xml,
14156 gchar *html, *response, *command, *specials_element;
14157 const char *name, *comment, *
users, *grant_full;
14173 xml = g_string_new (
"");
14175 xml_string_append (xml,
14177 "<comment>%s</comment>" 14178 "<users>%s</users>",
14179 name, comment,
users);
14182 specials_element = g_strdup_printf (
"<full/>");
14184 specials_element = NULL;
14186 command = g_strdup_printf (
"<create_group>" 14192 xml->str, specials_element);
14194 g_string_free (xml, TRUE);
14195 g_free (specials_element);
14198 gmp (connection,
credentials, &response, &entity, response_data, command);
14207 MHD_HTTP_INTERNAL_SERVER_ERROR);
14209 credentials,
"Internal error", __FUNCTION__, __LINE__,
14210 "An internal error occurred while creating a new group. " 14211 "No new group was created. " 14212 "Diagnostics: Failure to send command to manager daemon.",
14216 MHD_HTTP_INTERNAL_SERVER_ERROR);
14218 credentials,
"Internal error", __FUNCTION__, __LINE__,
14219 "An internal error occurred while creating a new group. " 14220 "It is unclear whether the group has been created or not. " 14221 "Diagnostics: Failure to receive response from manager daemon.",
14225 MHD_HTTP_INTERNAL_SERVER_ERROR);
14227 credentials,
"Internal error", __FUNCTION__, __LINE__,
14228 "An internal error occurred while creating a new group. " 14229 "It is unclear whether the group has been created or not. " 14230 "Diagnostics: Internal Error.",
14234 if (entity_attribute (entity,
"id"))
14235 params_add (params,
"group_id", entity_attribute (entity,
"id"));
14237 "Create Group", response_data);
14238 free_entity (entity);
14294 gchar *html, *response;
14295 const char *group_id, *name, *comment, *
users;
14312 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
14313 "<modify_group group_id=\"%s\">" 14315 "<comment>%s</comment>" 14316 "<users>%s</users>" 14318 group_id, name, comment,
users);
14327 MHD_HTTP_INTERNAL_SERVER_ERROR);
14329 credentials,
"Internal error", __FUNCTION__, __LINE__,
14330 "An internal error occurred while saving a group. " 14331 "The group was not saved. " 14332 "Diagnostics: Failure to send command to manager daemon.",
14336 MHD_HTTP_INTERNAL_SERVER_ERROR);
14338 credentials,
"Internal error", __FUNCTION__, __LINE__,
14339 "An internal error occurred while saving a group. " 14340 "It is unclear whether the group has been saved or not. " 14341 "Diagnostics: Failure to receive response from manager daemon.",
14345 MHD_HTTP_INTERNAL_SERVER_ERROR);
14347 credentials,
"Internal error", __FUNCTION__, __LINE__,
14348 "An internal error occurred while saving a group. " 14349 "It is unclear whether the group has been saved or not. " 14350 "Diagnostics: Internal Error.",
14355 "Save Group", response_data);
14356 free_entity (entity);
14376 params_t *params,
const char *extra_xml,
14380 "alerts=\"1\"", response_data);
14413 params_t *params,
const char *extra_xml,
14417 NULL, response_data);
14470 gchar *html, *response;
14471 const char *name, *comment, *resource_id, *resource_type;
14472 const char *subject_id, *subject_type, *subject_name;
14475 gchar *subject_response;
14476 entity_t get_subject_entity = NULL;
14477 entity_t subject_entity;
14482 resource_type =
params_value (params,
"optional_resource_type");
14499 &get_subject_entity, response_data,
14500 "<get_%ss filter=\"rows=1 name=%s\">" 14502 subject_type, subject_name, subject_type);
14511 MHD_HTTP_INTERNAL_SERVER_ERROR);
14514 "An internal error occurred while getting" 14515 " the subject for a permission. " 14516 "The permission was not created. " 14517 "Diagnostics: Failure to send command" 14518 " to manager daemon.",
14522 MHD_HTTP_INTERNAL_SERVER_ERROR);
14525 "An internal error occurred while getting" 14526 " the subject for a permission. " 14527 "The permission was not created. " 14528 "Diagnostics: Failure to receive response" 14529 " from manager daemon.",
14533 MHD_HTTP_INTERNAL_SERVER_ERROR);
14536 "An internal error occurred while getting" 14537 " the subject for a permission. " 14538 "The permission was not created. " 14539 "Diagnostics: Internal Error.",
14543 subject_entity = entity_child (get_subject_entity, subject_type);
14545 if (subject_entity)
14546 subject_id = entity_attribute (subject_entity,
"id");
14548 if (subject_id == NULL)
14551 MHD_HTTP_INTERNAL_SERVER_ERROR);
14554 "An internal error occurred while creating a " 14555 "permission. Could not find Subject." 14556 "The permission was not created. " 14557 "Diagnostics: Internal Error.",
14561 else if (strcmp (subject_type,
"user") == 0)
14562 subject_id =
params_value (params,
"permission_user_id");
14563 else if (strcmp (subject_type,
"group") == 0)
14564 subject_id =
params_value (params,
"permission_group_id");
14565 else if (strcmp (subject_type,
"role") == 0)
14566 subject_id =
params_value (params,
"permission_role_id");
14574 if (strcmp (name,
"task_proxy") == 0)
14578 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
14580 "<create_permission>" 14581 "<name>get_tasks</name>" 14582 "<comment>%s</comment>" 14583 "<resource id=\"%s\"/>" 14584 "<subject id=\"%s\"><type>%s</type></subject>" 14585 "</create_permission>" 14586 "<create_permission>" 14587 "<name>modify_task</name>" 14588 "<comment>%s</comment>" 14589 "<resource id=\"%s\"/>" 14590 "<subject id=\"%s\"><type>%s</type></subject>" 14591 "</create_permission>" 14592 "<create_permission>" 14593 "<name>start_task</name>" 14594 "<comment>%s</comment>" 14595 "<resource id=\"%s\"/>" 14596 "<subject id=\"%s\"><type>%s</type></subject>" 14597 "</create_permission>" 14598 "<create_permission>" 14599 "<name>stop_task</name>" 14600 "<comment>%s</comment>" 14601 "<resource id=\"%s\"/>" 14602 "<subject id=\"%s\"><type>%s</type></subject>" 14603 "</create_permission>" 14604 "<create_permission>" 14605 "<name>resume_task</name>" 14606 "<comment>%s</comment>" 14607 "<resource id=\"%s\"/>" 14608 "<subject id=\"%s\"><type>%s</type></subject>" 14609 "</create_permission>" 14611 comment ? comment :
"", resource_id ? resource_id :
"",
14612 subject_id, subject_type, comment ? comment :
"",
14613 resource_id ? resource_id :
"", subject_id, subject_type,
14614 comment ? comment :
"", resource_id ? resource_id :
"",
14615 subject_id, subject_type, comment ? comment :
"",
14616 resource_id ? resource_id :
"", subject_id, subject_type,
14617 comment ? comment :
"", resource_id ? resource_id :
"",
14618 subject_id, subject_type);
14620 if (get_subject_entity)
14621 free_entity (get_subject_entity);
14630 MHD_HTTP_INTERNAL_SERVER_ERROR);
14632 credentials,
"Internal error", __FUNCTION__, __LINE__,
14633 "An internal error occurred while creating a permission. " 14634 "The permission was not created. " 14635 "Diagnostics: Failure to send command to manager daemon.",
14639 MHD_HTTP_INTERNAL_SERVER_ERROR);
14641 credentials,
"Internal error", __FUNCTION__, __LINE__,
14642 "An internal error occurred while creating a permission. " 14643 "It is unclear whether the permission has been created or not. " 14644 "Diagnostics: Failure to receive response from manager daemon.",
14648 MHD_HTTP_INTERNAL_SERVER_ERROR);
14650 credentials,
"Internal error", __FUNCTION__, __LINE__,
14651 "An internal error occurred while creating a permission. " 14652 "It is unclear whether the permission has been created or not. " 14653 "Diagnostics: Internal Error.",
14657 if (entity_attribute (entity,
"id"))
14658 params_add (params,
"permission_id", entity_attribute (entity,
"id"));
14660 "Create Permission", response_data);
14666 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
14667 "<create_permission>" 14669 "<comment>%s</comment>" 14670 "<resource id=\"%s\">" 14673 "<subject id=\"%s\"><type>%s</type></subject>" 14674 "</create_permission>",
14675 name, comment ? comment :
"", resource_id ? resource_id :
"",
14676 resource_type ? resource_type :
"", subject_id, subject_type);
14678 if (get_subject_entity)
14679 free_entity (get_subject_entity);
14688 MHD_HTTP_INTERNAL_SERVER_ERROR);
14690 credentials,
"Internal error", __FUNCTION__, __LINE__,
14691 "An internal error occurred while creating a permission. " 14692 "The permission was not created. " 14693 "Diagnostics: Failure to send command to manager daemon.",
14697 MHD_HTTP_INTERNAL_SERVER_ERROR);
14699 credentials,
"Internal error", __FUNCTION__, __LINE__,
14700 "An internal error occurred while creating a permission. " 14701 "It is unclear whether the permission has been created or not. " 14702 "Diagnostics: Failure to receive response from manager daemon.",
14706 MHD_HTTP_INTERNAL_SERVER_ERROR);
14708 credentials,
"Internal error", __FUNCTION__, __LINE__,
14709 "An internal error occurred while creating a permission. " 14710 "It is unclear whether the permission has been created or not. " 14711 "Diagnostics: Internal Error.",
14715 if (entity_attribute (entity,
"id"))
14716 params_add (params,
"permission_id", entity_attribute (entity,
"id"));
14718 "Create Permission", response_data);
14720 free_entity (entity);
14725 #define CHECK_GMPF_RET \ 14732 cmd_response_data_set_status_code (response_data, \ 14733 MHD_HTTP_INTERNAL_SERVER_ERROR); \ 14734 return gsad_message ( \ 14735 credentials, "Internal error", __FUNCTION__, __LINE__, \ 14736 "An internal error occurred while creating a permission. " \ 14737 "The permission was not created. " \ 14738 "Diagnostics: Failure to send command to manager daemon.", \ 14741 cmd_response_data_set_status_code (response_data, \ 14742 MHD_HTTP_INTERNAL_SERVER_ERROR); \ 14743 return gsad_message ( \ 14744 credentials, "Internal error", __FUNCTION__, __LINE__, \ 14745 "An internal error occurred while creating a permission. " \ 14746 "It is unclear whether the permission has been created or not. " \ 14747 "Diagnostics: Failure to receive response from manager daemon.", \ 14750 cmd_response_data_set_status_code (response_data, \ 14751 MHD_HTTP_INTERNAL_SERVER_ERROR); \ 14752 return gsad_message ( \ 14753 credentials, "Internal error", __FUNCTION__, __LINE__, \ 14754 "An internal error occurred while creating a permission. " \ 14755 "It is unclear whether the permission has been created or not. " \ 14756 "Diagnostics: Internal Error.", \ 14759 if (gmp_success (entity)) \ 14762 free_entity (entity); \ 14763 g_free (response); \ 14767 html = response_from_entity (connection, credentials, params, entity, \ 14768 "Create Permissions", response_data); \ 14769 free_entity (entity); \ 14770 g_free (response); \ 14790 gchar *html, *response, *summary_response;
14792 const char *permission, *comment, *resource_id, *resource_type;
14793 const char *subject_id, *subject_type, *subject_name;
14794 const char *permission_resource_type;
14795 int include_related;
14799 gchar *subject_response;
14800 entity_t get_subject_entity = NULL;
14801 entity_t subject_entity;
14806 resource_type =
params_value (params,
"resource_type");
14811 "Create Permission");
14820 permission_resource_type =
"asset";
14823 permission_resource_type = resource_type;
14825 include_related = atoi (
params_value (params,
"include_related"));
14832 &get_subject_entity, response_data,
14833 "<get_%ss filter=\"rows=1 name=%s\">" 14835 subject_type, subject_name, subject_type);
14844 MHD_HTTP_INTERNAL_SERVER_ERROR);
14847 "An internal error occurred while getting" 14848 " the subject for a permission. " 14849 "The permission was not created. " 14850 "Diagnostics: Failure to send command" 14851 " to manager daemon.",
14855 MHD_HTTP_INTERNAL_SERVER_ERROR);
14858 "An internal error occurred while getting" 14859 " the subject for a permission. " 14860 "The permission was not created. " 14861 "Diagnostics: Failure to receive response" 14862 " from manager daemon.",
14866 MHD_HTTP_INTERNAL_SERVER_ERROR);
14869 "An internal error occurred while getting" 14870 " the subject for a permission. " 14871 "The permission was not created. " 14872 "Diagnostics: Internal Error.",
14876 subject_entity = entity_child (get_subject_entity, subject_type);
14878 if (subject_entity)
14879 subject_id = entity_attribute (subject_entity,
"id");
14881 if (subject_id == NULL)
14884 MHD_HTTP_INTERNAL_SERVER_ERROR);
14887 "An internal error occurred while creating a " 14888 "permission. Could not find Subject." 14889 "The permission was not created. " 14890 "Diagnostics: Internal Error.",
14894 else if (
str_equal (subject_type,
"user"))
14895 subject_id =
params_value (params,
"permission_user_id");
14896 else if (
str_equal (subject_type,
"group"))
14897 subject_id =
params_value (params,
"permission_group_id");
14898 else if (
str_equal (subject_type,
"role"))
14899 subject_id =
params_value (params,
"permission_role_id");
14910 if (include_related != 2)
14912 if (strcmp (permission,
"read") == 0 || strcmp (permission,
"proxy") == 0)
14918 "<create_permission>" 14919 "<name>get_%ss</name>" 14920 "<comment>%s</comment>" 14921 "<resource id=\"%s\">" 14923 "<subject id=\"%s\"><type>%s</type></subject>" 14924 "</create_permission>",
14925 permission_resource_type, comment ? comment :
"", resource_id,
14926 subject_id, subject_type);
14931 if ((strcmp (permission,
"proxy") == 0)
14932 && strcmp (permission_resource_type,
"result")
14933 && strcmp (permission_resource_type,
"report"))
14939 "<create_permission>" 14940 "<name>modify_%s</name>" 14941 "<comment>%s</comment>" 14942 "<resource id=\"%s\">" 14944 "<subject id=\"%s\"><type>%s</type></subject>" 14945 "</create_permission>",
14946 permission_resource_type, comment ? comment :
"", resource_id,
14947 subject_id, subject_type);
14951 if (strcmp (permission_resource_type,
"task") == 0)
14957 "<create_permission>" 14958 "<name>start_%s</name>" 14959 "<comment>%s</comment>" 14960 "<resource id=\"%s\">" 14962 "<subject id=\"%s\"><type>%s</type></subject>" 14963 "</create_permission>",
14964 permission_resource_type, comment ? comment :
"",
14965 resource_id, subject_id, subject_type);
14973 "<create_permission>" 14974 "<name>stop_%s</name>" 14975 "<comment>%s</comment>" 14976 "<resource id=\"%s\">" 14978 "<subject id=\"%s\"><type>%s</type></subject>" 14979 "</create_permission>",
14980 permission_resource_type, comment ? comment :
"",
14981 resource_id, subject_id, subject_type);
14989 "<create_permission>" 14990 "<name>resume_%s</name>" 14991 "<comment>%s</comment>" 14992 "<resource id=\"%s\">" 14994 "<subject id=\"%s\"><type>%s</type></subject>" 14995 "</create_permission>",
14996 permission_resource_type, comment ? comment :
"",
14997 resource_id, subject_id, subject_type);
15002 if (strcmp (permission_resource_type,
"alert") == 0)
15008 "<create_permission>" 15009 "<name>test_%s</name>" 15010 "<comment>%s</comment>" 15011 "<resource id=\"%s\">" 15013 "<subject id=\"%s\"><type>%s</type></subject>" 15014 "</create_permission>",
15015 permission_resource_type, comment ? comment :
"",
15016 resource_id, subject_id, subject_type);
15021 if (strcmp (permission_resource_type,
"agent") == 0
15022 || strcmp (permission_resource_type,
"report_format") == 0
15023 || strcmp (permission_resource_type,
"scanner") == 0)
15029 "<create_permission>" 15030 "<name>verify_%s</name>" 15031 "<comment>%s</comment>" 15032 "<resource id=\"%s\">" 15034 "<subject id=\"%s\"><type>%s</type></subject>" 15035 "</create_permission>",
15036 permission_resource_type, comment ? comment :
"",
15037 resource_id, subject_id, subject_type);
15045 if (include_related)
15058 char *related_id = name;
15059 char *related_type;
15064 related_type =
"asset";
15069 if (strcmp (permission,
"read") == 0
15070 || strcmp (permission,
"proxy") == 0)
15076 "<create_permission>" 15077 "<name>get_%ss</name>" 15078 "<comment>%s</comment>" 15079 "<resource id=\"%s\">" 15081 "<subject id=\"%s\"><type>%s</type></subject>" 15082 "</create_permission>",
15083 related_type, comment ? comment :
"", related_id,
15084 subject_id, subject_type);
15089 if ((strcmp (permission,
"proxy") == 0)
15090 && strcmp (related_type,
"result")
15091 && strcmp (related_type,
"report"))
15097 "<create_permission>" 15098 "<name>modify_%s</name>" 15099 "<comment>%s</comment>" 15100 "<resource id=\"%s\">" 15102 "<subject id=\"%s\"><type>%s</type></subject>" 15103 "</create_permission>",
15104 related_type, comment ? comment :
"", related_id,
15105 subject_id, subject_type);
15109 if (strcmp (related_type,
"task") == 0)
15115 "<create_permission>" 15116 "<name>start_%s</name>" 15117 "<comment>%s</comment>" 15118 "<resource id=\"%s\">" 15120 "<subject id=\"%s\"><type>%s</type></subject>" 15121 "</create_permission>",
15122 related_type, comment ? comment :
"",
15123 related_id, subject_id, subject_type);
15131 "<create_permission>" 15132 "<name>stop_%s</name>" 15133 "<comment>%s</comment>" 15134 "<resource id=\"%s\">" 15136 "<subject id=\"%s\"><type>%s</type></subject>" 15137 "</create_permission>",
15138 related_type, comment ? comment :
"",
15139 related_id, subject_id, subject_type);
15147 "<create_permission>" 15148 "<name>resume_%s</name>" 15149 "<comment>%s</comment>" 15150 "<resource id=\"%s\">" 15152 "<subject id=\"%s\"><type>%s</type></subject>" 15153 "</create_permission>",
15154 related_type, comment ? comment :
"",
15155 related_id, subject_id, subject_type);
15160 if (strcmp (related_type,
"alert") == 0)
15166 "<create_permission>" 15167 "<name>test_%s</name>" 15168 "<comment>%s</comment>" 15169 "<resource id=\"%s\">" 15171 "<subject id=\"%s\"><type>%s</type></subject>" 15172 "</create_permission>",
15173 related_type, comment ? comment :
"",
15174 related_id, subject_id, subject_type);
15179 if (strcmp (related_type,
"agent") == 0
15180 || strcmp (related_type,
"report_format") == 0
15181 || strcmp (related_type,
"scanner") == 0)
15187 "<create_permission>" 15188 "<name>verify_%s</name>" 15189 "<comment>%s</comment>" 15190 "<resource id=\"%s\">" 15192 "<subject id=\"%s\"><type>%s</type></subject>" 15193 "</create_permission>",
15194 related_type, comment ? comment :
"",
15195 related_id, subject_id, subject_type);
15204 if (get_subject_entity)
15205 free_entity (get_subject_entity);
15208 g_strdup_printf (
"Successfully created %i permissions", successes);
15211 "Create Permissions", summary_response, NULL, NULL);
15215 #undef CHECK_GMPF_RET 15269 gchar *html, *response;
15270 const char *permission_id, *name, *comment, *resource_id, *resource_type;
15271 const char *subject_id, *subject_type;
15275 permission_id =
params_value (params,
"permission_id");
15280 resource_type =
params_value (params,
"optional_resource_type");
15290 if (strcmp (subject_type,
"user") == 0)
15292 else if (strcmp (subject_type,
"group") == 0)
15294 else if (strcmp (subject_type,
"role") == 0)
15304 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
15305 "<modify_permission permission_id=\"%s\">" 15307 "<comment>%s</comment>" 15308 "<subject id=\"%s\">" 15311 "<resource id=\"%s\">" 15314 "</modify_permission>",
15315 permission_id, name, comment, subject_id, subject_type,
15316 (resource_id && strlen (resource_id)) ? resource_id :
"0",
15317 resource_type ? resource_type :
"");
15325 MHD_HTTP_INTERNAL_SERVER_ERROR);
15327 credentials,
"Internal error", __FUNCTION__, __LINE__,
15328 "An internal error occurred while modifying a permission. " 15329 "The permission was not modified. " 15330 "Diagnostics: Failure to send command to manager daemon.",
15334 MHD_HTTP_INTERNAL_SERVER_ERROR);
15336 credentials,
"Internal error", __FUNCTION__, __LINE__,
15337 "An internal error occurred while modifying a permission. " 15338 "It is unclear whether the permission has been modified or not. " 15339 "Diagnostics: Failure to receive response from manager daemon.",
15343 MHD_HTTP_INTERNAL_SERVER_ERROR);
15345 credentials,
"Internal error", __FUNCTION__, __LINE__,
15346 "An internal error occurred while modifying a permission. " 15347 "It is unclear whether the permission has been modified or not. " 15348 "Diagnostics: Internal Error.",
15353 "Save Permission", response_data);
15354 free_entity (entity);
15375 gchar *html, *response;
15376 const char *name, *comment, *port_range, *from_file;
15392 connection,
credentials, &response, &entity, response_data,
15393 "<create_port_list>" 15395 "<port_range>%s</port_range>" 15396 "<comment>%s</comment>" 15397 "</create_port_list>",
15398 name, strcmp (from_file,
"0") ?
params_value (params,
"file") : port_range,
15399 comment ? comment :
""))
15406 MHD_HTTP_INTERNAL_SERVER_ERROR);
15408 credentials,
"Internal error", __FUNCTION__, __LINE__,
15409 "An internal error occurred while creating a new port list. " 15410 "No new port list was created. " 15411 "Diagnostics: Failure to send command to manager daemon.",
15415 MHD_HTTP_INTERNAL_SERVER_ERROR);
15417 credentials,
"Internal error", __FUNCTION__, __LINE__,
15418 "An internal error occurred while creating a new port list. " 15419 "It is unclear whether the port list has been created or not. " 15420 "Diagnostics: Failure to receive response from manager daemon.",
15424 MHD_HTTP_INTERNAL_SERVER_ERROR);
15426 credentials,
"Internal error", __FUNCTION__, __LINE__,
15427 "An internal error occurred while creating a new port list. " 15428 "It is unclear whether the port list has been created or not. " 15429 "Diagnostics: Internal Error.",
15433 if (entity_attribute (entity,
"id"))
15434 params_add (params,
"port_list_id", entity_attribute (entity,
"id"));
15436 "Create Port List", response_data);
15437 free_entity (entity);
15457 gchar *html, *response;
15458 const char *port_list_id, *start, *end, *type;
15475 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
15476 "<create_port_range>" 15477 "<port_list id=\"%s\"/>" 15478 "<start>%s</start>" 15481 "</create_port_range>",
15482 port_list_id, start, end, type);
15491 MHD_HTTP_INTERNAL_SERVER_ERROR);
15493 credentials,
"Internal error", __FUNCTION__, __LINE__,
15494 "An internal error occurred while creating a Port Range. " 15495 "The Port Range was not created. " 15496 "Diagnostics: Failure to send command to manager daemon.",
15500 MHD_HTTP_INTERNAL_SERVER_ERROR);
15502 credentials,
"Internal error", __FUNCTION__, __LINE__,
15503 "An internal error occurred while creating a Port Range. " 15504 "It is unclear whether the Port Range has been created or not. " 15505 "Diagnostics: Failure to receive response from manager daemon.",
15509 MHD_HTTP_INTERNAL_SERVER_ERROR);
15511 credentials,
"Internal error", __FUNCTION__, __LINE__,
15512 "An internal error occurred while creating a Port Range. " 15513 "It is unclear whether the Port Range has been created or not. " 15514 "Diagnostics: Internal Error.",
15519 "Create Port Range", response_data);
15520 free_entity (entity);
15538 params_t *params,
const char *extra_xml,
15542 "targets=\"1\" details=\"1\"", response_data);
15575 params_t *params,
const char *extra_xml,
15579 NULL, response_data);
15614 gchar *html, *response;
15615 const char *port_list_id, *name, *comment;
15630 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
15631 "<modify_port_list port_list_id=\"%s\">" 15633 "<comment>%s</comment>" 15634 "</modify_port_list>",
15635 port_list_id, name, comment);
15644 MHD_HTTP_INTERNAL_SERVER_ERROR);
15646 credentials,
"Internal error", __FUNCTION__, __LINE__,
15647 "An internal error occurred while saving a Port List. " 15648 "The Port List was not saved. " 15649 "Diagnostics: Failure to send command to manager daemon.",
15653 MHD_HTTP_INTERNAL_SERVER_ERROR);
15655 credentials,
"Internal error", __FUNCTION__, __LINE__,
15656 "An internal error occurred while saving a Port List. " 15657 "It is unclear whether the Port List has been saved or not. " 15658 "Diagnostics: Failure to receive response from manager daemon.",
15662 MHD_HTTP_INTERNAL_SERVER_ERROR);
15664 credentials,
"Internal error", __FUNCTION__, __LINE__,
15665 "An internal error occurred while saving a Port List. " 15666 "It is unclear whether the Port List has been saved or not. " 15667 "Diagnostics: Internal Error.",
15672 "Save Port List", response_data);
15673 free_entity (entity);
15728 gchar *command, *html, *response;
15736 command = g_strdup_printf (
"<create_port_list>" 15738 "</create_port_list>",
15741 gmp (connection,
credentials, &response, &entity, response_data, command);
15750 MHD_HTTP_INTERNAL_SERVER_ERROR);
15752 credentials,
"Internal error", __FUNCTION__, __LINE__,
15753 "An internal error occurred while importing a port_list. " 15754 "The schedule remains the same. " 15755 "Diagnostics: Failure to send command to manager daemon.",
15759 MHD_HTTP_INTERNAL_SERVER_ERROR);
15761 credentials,
"Internal error", __FUNCTION__, __LINE__,
15762 "An internal error occurred while importing a port_list. " 15763 "It is unclear whether the schedule has been saved or not. " 15764 "Diagnostics: Failure to receive response from manager daemon.",
15768 MHD_HTTP_INTERNAL_SERVER_ERROR);
15770 credentials,
"Internal error", __FUNCTION__, __LINE__,
15771 "An internal error occurred while importing a port_list. " 15772 "It is unclear whether the schedule has been saved or not. " 15773 "Diagnostics: Internal Error.",
15780 "Import Port List", response_data);
15781 free_entity (entity);
15822 const char *name, *comment, *
users;
15835 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
15838 "<comment>%s</comment>" 15839 "<users>%s</users>" 15841 name, comment,
users))
15848 MHD_HTTP_INTERNAL_SERVER_ERROR);
15850 credentials,
"Internal error", __FUNCTION__, __LINE__,
15851 "An internal error occurred while creating a new role. " 15852 "No new role was created. " 15853 "Diagnostics: Failure to send command to manager daemon.",
15857 MHD_HTTP_INTERNAL_SERVER_ERROR);
15859 credentials,
"Internal error", __FUNCTION__, __LINE__,
15860 "An internal error occurred while creating a new role. " 15861 "It is unclear whether the role has been created or not. " 15862 "Diagnostics: Failure to receive response from manager daemon.",
15866 MHD_HTTP_INTERNAL_SERVER_ERROR);
15868 credentials,
"Internal error", __FUNCTION__, __LINE__,
15869 "An internal error occurred while creating a new role. " 15870 "It is unclear whether the role has been created or not. " 15871 "Diagnostics: Internal Error.",
15875 if (entity_attribute (entity,
"id"))
15876 params_add (params,
"role_id", entity_attribute (entity,
"id"));
15878 "Create Role", response_data);
15879 free_entity (entity);
15897 params_t *params,
const char *extra_xml,
15903 extra = g_string_new (
"");
15915 " filter=\"rows=-1 subject_type=role and subject_uuid=%s\"/>",
15923 MHD_HTTP_INTERNAL_SERVER_ERROR);
15925 credentials,
"Internal error", __FUNCTION__, __LINE__,
15926 "An internal error occurred getting the permission list. " 15927 "Diagnostics: Failure to send command to manager daemon.",
15931 MHD_HTTP_INTERNAL_SERVER_ERROR);
15933 credentials,
"Internal error", __FUNCTION__, __LINE__,
15934 "An internal error occurred getting the permission list. " 15935 "Diagnostics: Failure to receive response from manager daemon.",
15939 MHD_HTTP_INTERNAL_SERVER_ERROR);
15941 credentials,
"Internal error", __FUNCTION__, __LINE__,
15942 "An internal error occurred getting the permission list. " 15943 "Diagnostics: Internal Error.",
15947 g_string_append (extra, response);
15949 free_entity (entity);
15961 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
15963 " filter=\"rows=-1 owner=%s\"/>",
15971 MHD_HTTP_INTERNAL_SERVER_ERROR);
15973 credentials,
"Internal error", __FUNCTION__, __LINE__,
15974 "An internal error occurred getting the group list. " 15975 "Diagnostics: Failure to send command to manager daemon.",
15979 MHD_HTTP_INTERNAL_SERVER_ERROR);
15981 credentials,
"Internal error", __FUNCTION__, __LINE__,
15982 "An internal error occurred getting the group list. " 15983 "Diagnostics: Failure to receive response from manager daemon.",
15987 MHD_HTTP_INTERNAL_SERVER_ERROR);
15989 credentials,
"Internal error", __FUNCTION__, __LINE__,
15990 "An internal error occurred getting the group list. " 15991 "Diagnostics: Internal Error.",
15995 g_string_append (extra, response);
15997 free_entity (entity);
16002 g_string_append (extra, extra_xml);
16004 extra->str, response_data);
16005 g_string_free (extra, TRUE);
16039 params_t *params,
const char *extra_xml,
16076 params_t *params,
const char *extra_xml,
16151 gchar *html, *response;
16152 const char *role_id, *name, *comment, *
users;
16169 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
16170 "<modify_role role_id=\"%s\">" 16172 "<comment>%s</comment>" 16173 "<users>%s</users>" 16175 role_id, name, comment,
users);
16184 MHD_HTTP_INTERNAL_SERVER_ERROR);
16186 credentials,
"Internal error", __FUNCTION__, __LINE__,
16187 "An internal error occurred while saving a role. " 16188 "The role was not saved. " 16189 "Diagnostics: Failure to send command to manager daemon.",
16193 MHD_HTTP_INTERNAL_SERVER_ERROR);
16195 credentials,
"Internal error", __FUNCTION__, __LINE__,
16196 "An internal error occurred while saving a role. " 16197 "It is unclear whether the role has been saved or not. " 16198 "Diagnostics: Failure to receive response from manager daemon.",
16202 MHD_HTTP_INTERNAL_SERVER_ERROR);
16204 credentials,
"Internal error", __FUNCTION__, __LINE__,
16205 "An internal error occurred while saving a role. " 16206 "It is unclear whether the role has been saved or not. " 16207 "Diagnostics: Internal Error.",
16212 "Save Role", response_data);
16213 free_entity (entity);
16239 gchar current_timestamp[30];
16241 if (gvm_connection_sendf (connection,
"<get_feeds/>") == -1)
16244 MHD_HTTP_INTERNAL_SERVER_ERROR);
16246 credentials,
"Internal error", __FUNCTION__, __LINE__,
16247 "An internal error occurred while getting the feed list. " 16248 "The current list of feeds is not available. " 16249 "Diagnostics: Failure to send command to manager daemon.",
16253 if (read_entity_and_text_c (connection, &entity, &text))
16256 MHD_HTTP_INTERNAL_SERVER_ERROR);
16258 credentials,
"Internal error", __FUNCTION__, __LINE__,
16259 "An internal error occurred while getting the feed. " 16260 "The current list of feeds is not available. " 16261 "Diagnostics: Failure to receive response from manager daemon.",
16266 tm = gmtime (&now);
16268 || (strftime (current_timestamp, 29,
"%Y-%m-%dT%H:%M:%S", tm) == 0))
16270 current_timestamp[0] =
'\0';
16273 response = g_strdup_printf (
"<get_feeds>" 16275 "<current_time_utc>%s</current_time_utc>" 16277 text, current_timestamp);
16300 params_t *params,
const char *sync_cmd,
const char *action,
16307 if (gvm_connection_sendf (connection,
"<%s/>", sync_cmd) == -1)
16310 MHD_HTTP_INTERNAL_SERVER_ERROR);
16312 msg = g_strdup_printf (
16313 "An internal error occurred while synchronizing with %s. " 16314 "Feed synchronization is currently not available. " 16315 "Diagnostics: Failure to send command to manager daemon.",
16318 __LINE__, msg, response_data);
16323 if (read_entity_and_text_c (connection, &entity, &text))
16326 MHD_HTTP_INTERNAL_SERVER_ERROR);
16328 msg = g_strdup_printf (
16329 "An internal error occurred while synchronizing with %s. " 16330 "Feed synchronization is currently not available. " 16331 "Diagnostics: Failure to receive response from manager daemon.",
16334 __LINE__, msg, response_data);
16360 "Synchronize Feed",
"the NVT feed", response_data);
16378 "Synchronize Feed",
"the SCAP feed", response_data);
16396 "Synchronize CERT Feed",
"the CERT feed", response_data);
16414 params_t *params,
const char *extra_xml,
16418 "alerts=\"1\"", response_data);
16451 params_t *params,
const char *extra_xml,
16489 gchar *html, *response;
16490 const char *name, *comment, *term, *type;
16496 type =
params_value (params,
"optional_resource_type");
16503 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
16506 "<comment>%s</comment>" 16509 "</create_filter>",
16510 name, comment, term, type))
16517 MHD_HTTP_INTERNAL_SERVER_ERROR);
16519 credentials,
"Internal error", __FUNCTION__, __LINE__,
16520 "An internal error occurred while creating a new alert. " 16521 "No new alert was created. " 16522 "Diagnostics: Failure to send command to manager daemon.",
16526 MHD_HTTP_INTERNAL_SERVER_ERROR);
16528 credentials,
"Internal error", __FUNCTION__, __LINE__,
16529 "An internal error occurred while creating a new alert. " 16530 "It is unclear whether the alert has been created or not. " 16531 "Diagnostics: Failure to receive response from manager daemon.",
16535 MHD_HTTP_INTERNAL_SERVER_ERROR);
16537 credentials,
"Internal error", __FUNCTION__, __LINE__,
16538 "An internal error occurred while creating a new alert. " 16539 "It is unclear whether the alert has been created or not. " 16540 "Diagnostics: Internal Error.",
16546 const char *filter_id;
16548 filter_id = entity_attribute (entity,
"id");
16549 if (filter_id && strlen (filter_id))
16558 if (entity_attribute (entity,
"id"))
16559 params_add (params,
"filter_id", entity_attribute (entity,
"id"));
16561 "Create Filter", response_data);
16562 free_entity (entity);
16585 if (
id && id->
value && filt_id && filt_id->
value 16586 && (strcmp (id->
value, filt_id->
value) == 0))
16588 filt_id->
value = NULL;
16645 gchar *html, *response;
16646 const char *filter_id, *name, *comment, *term, *type;
16652 type =
params_value (params,
"optional_resource_type");
16665 ret = gvm_connection_sendf_xml (connection,
16666 "<modify_filter filter_id=\"%s\">" 16668 "<comment>%s</comment>" 16671 "</modify_filter>",
16672 filter_id, name, comment, term, type);
16677 MHD_HTTP_INTERNAL_SERVER_ERROR);
16679 credentials,
"Internal error", __FUNCTION__, __LINE__,
16680 "An internal error occurred while modifying a filter. " 16681 "The filter was not modified. " 16682 "Diagnostics: Failure to send command to manager daemon.",
16687 if (read_entity_and_text_c (connection, &entity, &response))
16690 MHD_HTTP_INTERNAL_SERVER_ERROR);
16692 credentials,
"Internal error", __FUNCTION__, __LINE__,
16693 "An internal error occurred while modifying a filter. " 16694 "It is unclear whether the filter has been modified or not. " 16695 "Diagnostics: Failure to receive response from manager daemon.",
16703 "Save Filter", response_data);
16705 free_entity (entity);
16764 const char *schedule_id, *name, *comment, *timezone, *icalendar;
16781 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
16782 "<modify_schedule schedule_id=\"%s\">" 16784 "<comment>%s</comment>" 16785 "<timezone>%s</timezone>" 16786 "<icalendar>%s</icalendar>" 16787 "</modify_schedule>",
16788 schedule_id, name ? name :
"", comment ? comment :
"", timezone,
16796 MHD_HTTP_INTERNAL_SERVER_ERROR);
16798 credentials,
"Internal error", __FUNCTION__, __LINE__,
16799 "An internal error occurred while saving a schedule. " 16800 "The schedule remains the same. " 16801 "Diagnostics: Failure to send command to manager daemon.",
16805 MHD_HTTP_INTERNAL_SERVER_ERROR);
16807 credentials,
"Internal error", __FUNCTION__, __LINE__,
16808 "An internal error occurred while saving a schedule. " 16809 "It is unclear whether the schedule has been saved or not. " 16810 "Diagnostics: Failure to receive response from manager daemon.",
16814 MHD_HTTP_INTERNAL_SERVER_ERROR);
16816 credentials,
"Internal error", __FUNCTION__, __LINE__,
16817 "An internal error occurred while saving a schedule. " 16818 "It is unclear whether the schedule has been saved or not. " 16819 "Diagnostics: Internal Error.",
16824 "Save Schedule", response_data);
16825 free_entity (entity);
16863 params_t *params,
const char *extra_xml,
16869 extra = g_string_new (
"");
16871 g_string_append (extra, extra_xml);
16879 switch (
gmp (connection,
credentials, &response, &entity, response_data,
16880 "<describe_auth/>"))
16887 MHD_HTTP_INTERNAL_SERVER_ERROR);
16889 credentials,
"Internal error", __FUNCTION__, __LINE__,
16890 "An internal error occurred getting the auth list. " 16891 "Diagnostics: Failure to send command to manager daemon.",
16895 MHD_HTTP_INTERNAL_SERVER_ERROR);
16897 credentials,
"Internal error", __FUNCTION__, __LINE__,
16898 "An internal error occurred getting the auth list. " 16899 "Diagnostics: Failure to receive response from manager daemon.",
16903 MHD_HTTP_INTERNAL_SERVER_ERROR);
16905 credentials,
"Internal error", __FUNCTION__, __LINE__,
16906 "An internal error occurred getting the auth list. " 16907 "Diagnostics: Internal Error.",
16911 g_string_append (extra, response);
16913 free_entity (entity);
16918 g_string_free (extra, TRUE);
16952 params_t *params,
const char *extra_xml,
16958 extra = g_string_new (
"");
16966 switch (
gmp (connection,
credentials, &response, &entity, response_data,
16967 "<describe_auth/>"))
16974 MHD_HTTP_INTERNAL_SERVER_ERROR);
16976 credentials,
"Internal error", __FUNCTION__, __LINE__,
16977 "An internal error occurred getting the auth list. " 16978 "Diagnostics: Failure to send command to manager daemon.",
16982 MHD_HTTP_INTERNAL_SERVER_ERROR);
16984 credentials,
"Internal error", __FUNCTION__, __LINE__,
16985 "An internal error occurred getting the auth list. " 16986 "Diagnostics: Failure to receive response from manager daemon.",
16990 MHD_HTTP_INTERNAL_SERVER_ERROR);
16992 credentials,
"Internal error", __FUNCTION__, __LINE__,
16993 "An internal error occurred getting the auth list. " 16994 "Diagnostics: Internal Error.",
16998 g_string_append (extra, response);
17000 free_entity (entity);
17004 g_string_append (extra, extra_xml);
17007 g_string_free (extra, TRUE);
17042 const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
17043 const char *auth_method, *comment;
17046 GString *group_elements, *role_elements, *string;
17047 gchar *buf, *response, *html;
17065 if (auth_method && strcmp (auth_method,
"1") == 0)
17077 string = g_string_new (
"<create_user>");
17078 buf = g_markup_printf_escaped (
"<name>%s</name>" 17079 "<password>%s</password>",
17080 name, password ? password :
"");
17082 g_string_append (
string, buf);
17085 group_elements = g_string_new (
"<groups>");
17101 g_string_append_printf (group_elements,
"<group id=\"%s\"/>",
17105 g_string_append (
string, group_elements->str);
17106 g_string_free (group_elements, TRUE);
17107 g_string_append (
string,
"</groups>");
17109 role_elements = g_string_new (
"");
17125 g_string_append_printf (role_elements,
"<role id=\"%s\"/>",
17129 g_string_append (
string, role_elements->str);
17130 g_string_free (role_elements, TRUE);
17132 buf = g_markup_printf_escaped (
"<hosts allow=\"%s\">%s</hosts>" 17133 "<ifaces allow=\"%s\">%s</ifaces>",
17134 hosts_allow, hosts, ifaces_allow, ifaces);
17135 g_string_append (
string, buf);
17137 if (auth_method && !strcmp (auth_method,
"1"))
17138 g_string_append (
string,
17139 "<sources><source>ldap_connect</source></sources>");
17140 else if (auth_method && !strcmp (auth_method,
"2"))
17141 g_string_append (
string,
17142 "<sources><source>radius_connect</source></sources>");
17146 xml_string_append (
string,
"<comment>%s</comment>", comment);
17149 g_string_append (
string,
"</create_user>");
17151 buf = g_string_free (
string, FALSE);
17155 ret =
gmp (connection,
credentials, &response, &entity, response_data, buf);
17164 MHD_HTTP_INTERNAL_SERVER_ERROR);
17166 credentials,
"Internal error", __FUNCTION__, __LINE__,
17167 "An internal error occurred while creating a new user. " 17168 "No new user was created. " 17169 "Diagnostics: Failure to send command to manager daemon.",
17173 MHD_HTTP_INTERNAL_SERVER_ERROR);
17175 credentials,
"Internal error", __FUNCTION__, __LINE__,
17176 "An internal error occurred while creating a new user. " 17177 "It is unclear whether the user has been created or not. " 17178 "Diagnostics: Failure to receive response from manager daemon.",
17182 MHD_HTTP_INTERNAL_SERVER_ERROR);
17184 credentials,
"Internal error", __FUNCTION__, __LINE__,
17185 "An internal error occurred while creating a new user. " 17186 "It is unclear whether the user has been created or not. " 17187 "Diagnostics: Internal Error.",
17191 if (entity_attribute (entity,
"id"))
17192 params_add (params,
"user_id", entity_attribute (entity,
"id"));
17194 "Create User", response_data);
17195 free_entity (entity);
17230 params_t *params,
const char *extra_xml,
17249 xml = g_string_new (
"");
17250 buf = g_markup_printf_escaped (
"<auth_settings name=\"%s\">", name);
17251 g_string_append (xml, buf);
17256 gchar *response = NULL;
17257 entity_t entity = NULL;
17259 switch (
gmp (connection,
credentials, &response, &entity, response_data,
17260 "<describe_auth/>"))
17267 MHD_HTTP_INTERNAL_SERVER_ERROR);
17269 credentials,
"Internal error", __FUNCTION__, __LINE__,
17270 "An internal error occurred getting the auth list. " 17271 "Diagnostics: Failure to send command to manager daemon.",
17275 MHD_HTTP_INTERNAL_SERVER_ERROR);
17277 credentials,
"Internal error", __FUNCTION__, __LINE__,
17278 "An internal error occurred getting the auth list. " 17279 "Diagnostics: Failure to receive response from manager daemon.",
17283 MHD_HTTP_INTERNAL_SERVER_ERROR);
17285 credentials,
"Internal error", __FUNCTION__, __LINE__,
17286 "An internal error occurred getting the auth list. " 17287 "Diagnostics: Internal Error.",
17291 g_string_append (xml, response);
17292 free_entity (entity);
17296 g_string_append (xml,
"</auth_settings>");
17299 g_string_free (xml, FALSE), response_data);
17317 gchar *html, *response, *buf;
17318 const char *user_id, *
login, *old_login, *modify_password, *password;
17319 const char *hosts, *hosts_allow, *ifaces, *ifaces_allow, *comment;
17321 GString *command, *group_elements, *role_elements;
17333 modify_password =
params_value (params,
"modify_password");
17347 if (modify_password &&
str_equal (modify_password,
"1"))
17360 command = g_string_new (
"");
17361 buf = g_markup_printf_escaped (
"<modify_user user_id=\"%s\">" 17362 "<password modify=\"%s\">" 17364 user_id, modify_password,
17365 password ? password :
"");
17366 g_string_append (command, buf);
17371 buf = g_markup_printf_escaped (
"<new_name>%s</new_name>",
login);
17372 g_string_append (command, buf);
17376 buf = g_markup_printf_escaped (
"<hosts allow=\"%s\">%s</hosts>" 17377 "<ifaces allow=\"%s\">%s</ifaces>",
17378 hosts_allow, hosts, ifaces_allow, ifaces);
17379 g_string_append (command, buf);
17382 if (modify_password && !strcmp (modify_password,
"2"))
17383 g_string_append (command,
17384 "<sources><source>ldap_connect</source></sources>");
17385 else if (modify_password && !strcmp (modify_password,
"3"))
17386 g_string_append (command,
17387 "<sources><source>radius_connect</source></sources>");
17389 g_string_append (command,
"<sources><source>file</source></sources>");
17391 group_elements = g_string_new (
"<groups>");
17407 g_string_append_printf (group_elements,
"<group id=\"%s\"/>",
17411 g_string_append (command, group_elements->str);
17412 g_string_free (group_elements, TRUE);
17413 g_string_append (command,
"</groups>");
17415 role_elements = g_string_new (
"");
17431 g_string_append_printf (role_elements,
"<role id=\"%s\"/>",
17436 g_string_append_printf (role_elements,
"<role id=\"0\"/>");
17438 g_string_append (command, role_elements->str);
17439 g_string_free (role_elements, TRUE);
17443 xml_string_append (command,
"<comment>%s</comment>", comment);
17446 g_string_append (command,
"</modify_user>");
17450 ret =
gmp (connection,
credentials, &response, &entity, response_data,
17452 g_string_free (command, TRUE);
17490 MHD_HTTP_INTERNAL_SERVER_ERROR);
17492 credentials,
"Internal error", __FUNCTION__, __LINE__,
17493 "An internal error occurred while saving a user. " 17494 "The user was not saved. " 17495 "Diagnostics: Failure to send command to manager daemon.",
17499 MHD_HTTP_INTERNAL_SERVER_ERROR);
17501 credentials,
"Internal error", __FUNCTION__, __LINE__,
17502 "An internal error occurred while saving a user. " 17503 "It is unclear whether the user has been saved or not. " 17504 "Diagnostics: Failure to receive response from manager daemon.",
17508 MHD_HTTP_INTERNAL_SERVER_ERROR);
17510 credentials,
"Internal error", __FUNCTION__, __LINE__,
17511 "An internal error occurred while saving a user. " 17512 "It is unclear whether the user has been saved or not. " 17513 "Diagnostics: Internal Error.",
17521 free_entity (entity);
17526 credentials,
"Authentication Required", __FUNCTION__, __LINE__,
17527 "Authentication method changed. Please login with ", response_data);
17531 "Save User", response_data);
17532 free_entity (entity);
17578 const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
17579 const char *cvss_vector, *name;
17590 xml = g_string_new (
"<cvss_calculator>");
17593 if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
17596 g_strdup_printf (
"AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c", *cvss_av, *cvss_ac,
17597 *cvss_au, *cvss_c, *cvss_i, *cvss_a);
17599 g_string_append_printf (xml,
17600 "<cvss_vector>%s</cvss_vector>" 17601 "<cvss_score>%.1f</cvss_score>",
17603 get_cvss_score_from_base_metrics (vector));
17605 g_string_append_printf (xml,
17606 "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>" 17607 "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>" 17608 "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
17609 *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i,
17614 else if (cvss_vector)
17616 double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
17618 g_string_append_printf (xml,
17619 "<cvss_vector>%s</cvss_vector>" 17620 "<cvss_score>%.1f</cvss_score>",
17621 cvss_vector, cvss_score);
17623 if (cvss_score != -1.0)
17625 cvss_av = strstr (cvss_vector,
"AV:");
17626 cvss_ac = strstr (cvss_vector,
"/AC:");
17627 cvss_au = strstr (cvss_vector,
"/Au:");
17628 if (cvss_au == NULL)
17629 cvss_au = strstr (cvss_vector,
"/AU:");
17630 cvss_c = strstr (cvss_vector,
"/C:");
17631 cvss_i = strstr (cvss_vector,
"/I:");
17632 cvss_a = strstr (cvss_vector,
"/A:");
17634 if (cvss_av && cvss_ac && cvss_au && cvss_c && cvss_i && cvss_a)
17635 g_string_append_printf (xml,
17636 "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>" 17637 "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>" 17638 "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
17639 *(cvss_av + 3), *(cvss_ac + 4),
17640 *(cvss_au + 4), *(cvss_c + 3),
17641 *(cvss_i + 3), *(cvss_a + 3));
17644 else if (name && !strcmp (
"vector", name))
17646 g_string_append_printf (xml,
"<cvss_score>%.1f</cvss_score>", -1.0);
17649 g_string_append (xml,
"</cvss_calculator>");
17651 g_string_free (xml, FALSE), response_data);
17657 #define AUTH_CONF_SETTING(key, value) \ 17658 "<auth_conf_setting>" \ 17659 "<key>" key "</key>" \ 17660 "<value>" value "</value>" \ 17661 "</auth_conf_setting>" 17678 entity_t entity = NULL;
17679 char *html, *response = NULL, *truefalse;
17680 const char *method;
17683 && (strcmp (
params_value (params,
"enable"),
"1") == 0))
17684 truefalse =
"true";
17686 truefalse =
"false";
17690 if (!strcmp (method,
"method:ldap_connect"))
17692 const char *ldaphost, *authdn, *certificate;
17699 if (
params_given (params,
"certificate") && strcmp (certificate,
""))
17711 method, truefalse, ldaphost, authdn, certificate);
17715 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
17721 method, truefalse, ldaphost, authdn);
17723 else if (!strcmp (method,
"method:radius_connect"))
17725 const char *radiushost, *radiuskey;
17732 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
17738 method, truefalse, radiushost, radiuskey);
17753 MHD_HTTP_INTERNAL_SERVER_ERROR);
17755 credentials,
"Internal error", __FUNCTION__, __LINE__,
17756 "An internal error occurred while saving the auth settings. " 17757 "The settings were not saved. " 17758 "Diagnostics: Failure to send command to manager daemon.",
17762 MHD_HTTP_INTERNAL_SERVER_ERROR);
17764 credentials,
"Internal error", __FUNCTION__, __LINE__,
17765 "An internal error occurred while saving the auth settings. " 17766 "It is unclear whether the settings have been saved or not. " 17767 "Diagnostics: Failure to receive response from manager daemon.",
17771 MHD_HTTP_INTERNAL_SERVER_ERROR);
17773 credentials,
"Internal error", __FUNCTION__, __LINE__,
17774 "An internal error occurred while saving the auth settings. " 17775 "It is unclear whether the settings have been saved or not. " 17776 "Diagnostics: Internal Error.",
17782 "Save Authentication Configuration", response_data);
17783 free_entity (entity);
17804 const gchar *filter;
17806 xml = g_string_new (
"<get_settings>");
17813 command = g_markup_printf_escaped (
"<get_settings" 17815 " sort_field=\"name\"" 17816 " sort_order=\"ascending\"/>",
17821 command = g_strdup (
"<get_settings" 17822 " sort_field=\"name\"" 17823 " sort_order=\"ascending\"/>");
17826 if (gvm_connection_sendf (connection, command))
17830 g_string_free (xml, TRUE);
17832 MHD_HTTP_INTERNAL_SERVER_ERROR);
17834 credentials,
"Internal error", __FUNCTION__, __LINE__,
17835 "An internal error occurred while getting the settings. " 17836 "The current list of settings is not available. " 17837 "Diagnostics: Failure to send command to manager daemon.",
17841 if (read_string_c (connection, &xml))
17844 g_string_free (xml, TRUE);
17846 MHD_HTTP_INTERNAL_SERVER_ERROR);
17848 credentials,
"Internal error", __FUNCTION__, __LINE__,
17849 "An internal error occurred while getting the settings. " 17850 "The current list of settings is not available. " 17851 "Diagnostics: Failure to receive response from manager daemon.",
17856 g_string_append (xml,
"</get_settings>");
17858 g_string_free (xml, FALSE), response_data);
17875 const gchar *setting_id =
params_value (params,
"setting_id");
17876 const gchar *setting_value =
params_value (params,
"setting_value");
17877 const gchar *setting_name = NULL;
17889 g_base64_encode ((guchar *) setting_value, strlen (setting_value));
17891 gchar *response = NULL;
17892 entity_t entity = NULL;
17894 GString *xml = g_string_new (
"");
17896 xml_string_append (xml,
17897 "<modify_setting setting_id=\"%s\">" 17898 "<value>%s</value>",
17899 setting_id, value_64);
17903 xml_string_append (xml,
"<name>%s</name>", setting_name);
17906 xml_string_append (xml,
"</modify_setting>");
17911 gmp (connection,
credentials, &response, &entity, response_data, xml->str);
17914 g_string_free (xml, TRUE);
17923 MHD_HTTP_INTERNAL_SERVER_ERROR);
17925 credentials,
"Internal error", __FUNCTION__, __LINE__,
17926 "An internal error occurred while saving settings. " 17927 "It is unclear whether all the settings were saved. " 17928 "Diagnostics: Failure to send command to manager daemon.",
17933 MHD_HTTP_INTERNAL_SERVER_ERROR);
17935 credentials,
"Internal error", __FUNCTION__, __LINE__,
17936 "An internal error occurred while saving settings. " 17937 "It is unclear whether all the settings were saved. " 17938 "Diagnostics: Failure to receive response from manager daemon.",
17943 MHD_HTTP_INTERNAL_SERVER_ERROR);
17946 "An internal error occurred while saving settings. " 17947 "It is unclear whether all the settings were saved. " 17948 "Diagnostics: Internal Error.",
17952 "Save Setting", response_data);
17953 free_entity (entity);
17962 const gchar *setting_id =
params_value (params,
"setting_id");
17964 GString *xml = g_string_new (
"<get_settings>");
17966 if (gvm_connection_sendf_xml (connection,
17968 " setting_id=\"%s\"/>",
17971 g_string_free (xml, TRUE);
17973 MHD_HTTP_INTERNAL_SERVER_ERROR);
17976 "An internal error occurred while getting the " 17977 "dashboard settings" 17978 "Diagnostics: Failure to send command to manager " 17983 if (read_string_c (connection, &xml))
17985 g_string_free (xml, TRUE);
17987 MHD_HTTP_INTERNAL_SERVER_ERROR);
17990 "An internal error occurred while getting the " 17991 "dashboard settings" 17992 "Diagnostics: Failure to receive response from " 17997 g_string_append (xml,
"</get_settings>");
17999 g_string_free (xml, FALSE), response_data);
18017 params_t *params,
const char *extra_xml,
18027 credentials,
"Internal error", __FUNCTION__, __LINE__,
18028 "An internal error occurred while getting the wizard. " 18029 "Given name was invalid",
18033 xml = g_string_new (
"");
18034 g_string_append_printf (xml,
"<wizard>%s<%s/>", extra_xml ? extra_xml :
"",
18038 if (gvm_connection_sendf_xml (connection,
18039 "<run_wizard read_only=\"1\">" 18041 "<mode>init</mode>" 18046 g_string_free (xml, TRUE);
18048 MHD_HTTP_INTERNAL_SERVER_ERROR);
18050 credentials,
"Internal error", __FUNCTION__, __LINE__,
18051 "An internal error occurred while getting the wizard. " 18052 "Diagnostics: Failure to send command to manager daemon.",
18056 if (read_string_c (connection, &xml))
18058 g_string_free (xml, TRUE);
18060 MHD_HTTP_INTERNAL_SERVER_ERROR);
18063 "An internal error occurred while getting the" 18065 "Diagnostics: Failure to receive response from" 18066 " manager daemon.",
18072 if (gvm_connection_sendf_xml (
18073 connection,
"<get_settings" 18074 " setting_id=\"20f3034c-e709-11e1-87e7-406186ea4fc5\"/>")
18077 g_string_free (xml, TRUE);
18079 MHD_HTTP_INTERNAL_SERVER_ERROR);
18081 credentials,
"Internal error", __FUNCTION__, __LINE__,
18082 "An internal error occurred while getting the wizard. " 18083 "Diagnostics: Failure to send command to manager daemon.",
18087 if (read_string_c (connection, &xml))
18089 g_string_free (xml, TRUE);
18091 MHD_HTTP_INTERNAL_SERVER_ERROR);
18093 credentials,
"Internal error", __FUNCTION__, __LINE__,
18094 "An internal error occurred while the wizard. " 18095 "Diagnostics: Failure to receive response from manager daemon.",
18101 g_string_append_printf (xml,
"</wizard>");
18103 g_string_free (xml, FALSE), response_data);
18136 params_t *params,
const char *extra_xml,
18143 gchar *param_name, *response;
18158 credentials,
"Internal error", __FUNCTION__, __LINE__,
18159 "An internal error occurred while trying to start a wizard. " 18160 "Diagnostics: Required parameter 'get_name' was NULL.",
18164 run = g_string_new (
"<run_wizard read_only=\"1\">");
18166 g_string_append_printf (run,
18176 xml_string_append (run,
18179 "<value>%s</value>" 18184 g_string_append (run,
"</params></run_wizard>");
18189 gmp (connection,
credentials, &response, &entity, response_data, run->str);
18190 g_string_free (run, TRUE);
18198 MHD_HTTP_INTERNAL_SERVER_ERROR);
18200 credentials,
"Internal error", __FUNCTION__, __LINE__,
18201 "An internal error occurred while running a wizard. " 18202 "The wizard did not start. " 18203 "Diagnostics: Failure to send command to manager daemon.",
18207 MHD_HTTP_INTERNAL_SERVER_ERROR);
18209 credentials,
"Internal error", __FUNCTION__, __LINE__,
18210 "An internal error occurred while running a wizard. " 18211 "It is unclear whether the wizard started or not. " 18212 "Diagnostics: Failure to receive response from manager daemon.",
18216 MHD_HTTP_INTERNAL_SERVER_ERROR);
18219 "An internal error occurred while running a wizard. " 18220 "It is unclear whether the wizard started or not. " 18221 "Diagnostics: Internal Error.",
18225 wizard_xml = g_strdup_printf (
"<wizard><%s/>%s%s</wizard>", name,
18226 extra_xml ? extra_xml :
"", response);
18264 GString *commands_xml;
18269 gchar *html, *response;
18271 gchar *extra_attribs;
18278 credentials,
"Internal error", __FUNCTION__, __LINE__,
18279 "An internal error occurred while deleting resources. " 18280 "The resources were not deleted. " 18281 "Diagnostics: Required parameter 'resource_type' was NULL.",
18286 extra_attribs = NULL;
18289 if (strcmp (type,
"user") == 0)
18291 const char *inheritor_id;
18294 extra_attribs = g_strdup_printf (
"inheritor_id=\"%s\"", inheritor_id);
18297 commands_xml = g_string_new (
"<commands>");
18305 xml_string_append (commands_xml,
18306 "<delete_%s %s_id=\"%s\" ultimate=\"0\"", type,
18309 g_string_append_printf (commands_xml,
" %s/>", extra_attribs);
18311 g_string_append (commands_xml,
"/>");
18315 g_string_append (commands_xml,
"</commands>");
18319 if (gvm_connection_sendf_xml (connection, commands_xml->str) == -1)
18321 g_string_free (commands_xml, TRUE);
18323 MHD_HTTP_INTERNAL_SERVER_ERROR);
18325 credentials,
"Internal error", __FUNCTION__, __LINE__,
18326 "An internal error occurred while deleting resources. " 18327 "The resources were not deleted. " 18328 "Diagnostics: Failure to send command to manager daemon.",
18331 g_string_free (commands_xml, TRUE);
18334 if (read_entity_and_text_c (connection, &entity, &response))
18337 MHD_HTTP_INTERNAL_SERVER_ERROR);
18339 credentials,
"Internal error", __FUNCTION__, __LINE__,
18340 "An internal error occurred while deleting resources. " 18341 "It is unclear whether the resources have been deleted or not. " 18342 "Diagnostics: Failure to read response from manager daemon.",
18348 "Bulk Delete", response_data);
18350 free_entity (entity);
18369 const gchar *type, *filter, *bulk_select;
18371 GString *bulk_string;
18383 if (bulk_select &&
str_equal (bulk_select,
"1"))
18385 bulk_string = g_string_new (
"first=1 rows=-1 uuid=");
18393 xml_string_append (bulk_string,
" uuid=%s", param_name);
18399 bulk_string = g_string_new (filter ?:
"");
18402 params_add (params,
"filter", g_string_free (bulk_string, FALSE));
18424 gchar *html, *response;
18425 const char *name, *comment;
18437 xml = g_string_new (
"");
18439 xml_string_append (xml,
18442 "<type>host</type>" 18444 "<comment>%s</comment>" 18450 gmp (connection,
credentials, &response, &entity, response_data, xml->str);
18451 g_string_free (xml, TRUE);
18459 MHD_HTTP_INTERNAL_SERVER_ERROR);
18461 credentials,
"Internal error", __FUNCTION__, __LINE__,
18462 "An internal error occurred while creating a new host. " 18463 "No new host was created. " 18464 "Diagnostics: Failure to send command to manager daemon.",
18468 MHD_HTTP_INTERNAL_SERVER_ERROR);
18470 credentials,
"Internal error", __FUNCTION__, __LINE__,
18471 "An internal error occurred while creating a new host. " 18472 "It is unclear whether the host has been created or not. " 18473 "Diagnostics: Failure to receive response from manager daemon.",
18477 MHD_HTTP_INTERNAL_SERVER_ERROR);
18479 credentials,
"Internal error", __FUNCTION__, __LINE__,
18480 "An internal error occurred while creating a new host. " 18481 "It is unclear whether the host has been created or not. " 18482 "Diagnostics: Internal Error.",
18486 if (entity_attribute (entity,
"id"))
18487 params_add (params,
"asset_id", entity_attribute (entity,
"id"));
18489 "Create Host", response_data);
18490 free_entity (entity);
18508 params_t *params,
const char *extra_xml,
18512 GString *extra_attribs, *extra_response;
18513 const char *asset_type;
18516 if (asset_type == NULL)
18525 if (strcmp (asset_type,
"host") && strcmp (asset_type,
"os"))
18530 "An internal error occurred while getting an asset. " 18531 "Diagnostics: Invalid asset_type parameter value",
18540 "An internal error occurred while getting an asset. " 18541 "Diagnostics: Both ID and Name set.",
18545 extra_response = g_string_new (extra_xml ? extra_xml :
"");
18547 extra_attribs = g_string_new (
"");
18548 g_string_append_printf (extra_attribs,
"type=\"%s\"",
18551 g_string_append_printf (extra_attribs,
" name=\"%s\"",
18554 g_string_append_printf (extra_attribs,
" asset_id=\"%s\"",
18557 g_string_append_printf (extra_attribs,
" details=\"%s\"",
18561 extra_attribs->str, response_data);
18563 g_string_free (extra_response, TRUE);
18564 g_string_free (extra_attribs, TRUE);
18599 params_t *params,
const char *extra_xml,
18603 GString *extra_attribs, *extra_response;
18604 const char *asset_type;
18607 if (asset_type == NULL)
18616 if (strcmp (asset_type,
"host") && strcmp (asset_type,
"os"))
18621 "An internal error occurred while getting Assets. " 18622 "Diagnostics: Invalid asset_type parameter value",
18626 extra_response = g_string_new (extra_xml ? extra_xml :
"");
18628 extra_attribs = g_string_new (
"");
18629 g_string_append_printf (extra_attribs,
"type=\"%s\" ignore_pagination=\"%s\"",
18635 g_string_append_printf (extra_attribs,
" details=\"%s\"",
18638 extra_attribs->str, response_data);
18640 g_string_free (extra_response, TRUE);
18641 g_string_free (extra_attribs, TRUE);
18679 const char *report_id, *filter;
18690 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
18692 "<report id=\"%s\">" 18693 "<filter><term>%s</term></filter>" 18696 report_id, filter))
18703 MHD_HTTP_INTERNAL_SERVER_ERROR);
18705 credentials,
"Internal error", __FUNCTION__, __LINE__,
18706 "An internal error occurred while creating an asset. " 18707 "No new asset was created. " 18708 "Diagnostics: Failure to send command to manager daemon.",
18712 MHD_HTTP_INTERNAL_SERVER_ERROR);
18714 credentials,
"Internal error", __FUNCTION__, __LINE__,
18715 "An internal error occurred while creating an asset. " 18716 "It is unclear whether the asset has been created or not. " 18717 "Diagnostics: Failure to receive response from manager daemon.",
18721 MHD_HTTP_INTERNAL_SERVER_ERROR);
18723 credentials,
"Internal error", __FUNCTION__, __LINE__,
18724 "An internal error occurred while creating an asset. " 18725 "It is unclear whether the asset has been created or not. " 18726 "Diagnostics: Internal Error.",
18731 "Create Asset", response_data);
18732 free_entity (entity);
18751 gchar *html, *response, *resource_id;
18752 const char *next_id;
18756 resource_id = g_strdup (
params_value (params,
"asset_id"));
18758 resource_id = g_strdup (
params_value (params,
"report_id"));
18763 credentials,
"Internal error", __FUNCTION__, __LINE__,
18764 "An internal error occurred while deleting an asset. " 18765 "The asset was not deleted. " 18766 "Diagnostics: Required parameter was NULL.",
18784 if (gvm_connection_sendf (
18785 connection,
"<delete_asset %s_id=\"%s\"/>",
18786 params_value (params,
"asset_id") ?
"asset" :
"report", resource_id)
18789 g_free (resource_id);
18791 MHD_HTTP_INTERNAL_SERVER_ERROR);
18793 credentials,
"Internal error", __FUNCTION__, __LINE__,
18794 "An internal error occurred while deleting an asset. " 18795 "The asset is not deleted. " 18796 "Diagnostics: Failure to send command to manager daemon.",
18800 g_free (resource_id);
18803 if (read_entity_and_text_c (connection, &entity, &response))
18806 MHD_HTTP_INTERNAL_SERVER_ERROR);
18808 credentials,
"Internal error", __FUNCTION__, __LINE__,
18809 "An internal error occurred while deleting an asset. " 18810 "It is unclear whether the asset has been deleted or not. " 18811 "Diagnostics: Failure to read response from manager daemon.",
18818 "Delete Asset", response_data);
18820 free_entity (entity);
18875 gchar *html, *response;
18876 const char *asset_id, *comment;
18889 ret =
gmpf (connection,
credentials, &response, &entity, response_data,
18890 "<modify_asset asset_id=\"%s\">" 18891 "<comment>%s</comment>" 18893 asset_id, comment);
18902 MHD_HTTP_INTERNAL_SERVER_ERROR);
18904 credentials,
"Internal error", __FUNCTION__, __LINE__,
18905 "An internal error occurred while saving an asset. " 18906 "The asset was not saved. " 18907 "Diagnostics: Failure to send command to manager daemon.",
18911 MHD_HTTP_INTERNAL_SERVER_ERROR);
18913 credentials,
"Internal error", __FUNCTION__, __LINE__,
18914 "An internal error occurred while saving an asset. " 18915 "It is unclear whether the asset has been saved or not. " 18916 "Diagnostics: Failure to receive response from manager daemon.",
18920 MHD_HTTP_INTERNAL_SERVER_ERROR);
18922 credentials,
"Internal error", __FUNCTION__, __LINE__,
18923 "An internal error occurred while saving an asset. " 18924 "It is unclear whether the asset has been saved or not. " 18925 "Diagnostics: Internal Error.",
18930 "Save Asset", response_data);
18931 free_entity (entity);
18986 gchar *response = NULL;
18987 entity_t entity = NULL;
18988 const gchar *result_id, *user_id, *note;
18999 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
19001 "<result id=\"%s\"/>" 19003 "<user id=\"%s\"/>" 19005 "<open_note>%s</open_note>" 19006 "</create_ticket>",
19007 result_id, user_id, note ? note :
""))
19014 MHD_HTTP_INTERNAL_SERVER_ERROR);
19016 credentials,
"Internal error", __FUNCTION__, __LINE__,
19017 "An internal error occurred while creating a ticket. " 19018 "Diagnostics: Failure to send command to manager daemon.",
19022 MHD_HTTP_INTERNAL_SERVER_ERROR);
19024 credentials,
"Internal error", __FUNCTION__, __LINE__,
19025 "An internal error occurred while creating a ticket. " 19026 "It is unclear whether the ticket has been created or not. " 19027 "Diagnostics: Failure to receive response from manager daemon.",
19031 MHD_HTTP_INTERNAL_SERVER_ERROR);
19033 credentials,
"Internal error", __FUNCTION__, __LINE__,
19034 "An internal error occurred while creating a ticket. " 19035 "It is unclear whether the ticket has been created or not. " 19036 "Diagnostics: Internal Error.",
19041 "Create Ticket", response_data);
19043 free_entity (entity);
19062 gchar *response = NULL;
19063 entity_t entity = NULL;
19064 const gchar *ticket_id, *status, *open_note, *fixed_note, *closed_note;
19065 const gchar *user_id;
19082 switch (
gmpf (connection,
credentials, &response, &entity, response_data,
19083 "<modify_ticket ticket_id=\"%s\">" 19084 "<assigned_to><user id=\"%s\"/></assigned_to>" 19085 "<status>%s</status>" 19086 "<open_note>%s</open_note>" 19087 "<fixed_note>%s</fixed_note>" 19088 "<closed_note>%s</closed_note>" 19089 "</modify_ticket>",
19090 ticket_id, user_id, status, open_note, fixed_note, closed_note))
19097 MHD_HTTP_INTERNAL_SERVER_ERROR);
19099 credentials,
"Internal error", __FUNCTION__, __LINE__,
19100 "An internal error occurred while saving a ticket. " 19101 "Diagnostics: Failure to send command to manager daemon.",
19105 MHD_HTTP_INTERNAL_SERVER_ERROR);
19107 credentials,
"Internal error", __FUNCTION__, __LINE__,
19108 "An internal error occurred while saving a ticket. " 19109 "It is unclear whether the ticket has been saved or not. " 19110 "Diagnostics: Failure to receive response from manager daemon.",
19114 MHD_HTTP_INTERNAL_SERVER_ERROR);
19116 credentials,
"Internal error", __FUNCTION__, __LINE__,
19117 "An internal error occurred while saving a ticket. " 19118 "It is unclear whether the ticket has been saved or not. " 19119 "Diagnostics: Internal Error.",
19124 "Save Ticket", response_data);
19126 free_entity (entity);
19163 "renew_session", message, NULL, NULL);
19183 "pong", NULL, NULL);
19198 struct sockaddr_un address;
19203 sock = socket (AF_UNIX, SOCK_STREAM, 0);
19206 g_warning (
"Failed to create server socket");
19212 address.sun_family = AF_UNIX;
19213 strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
19214 if (connect (sock, (
struct sockaddr *) &address,
sizeof (address)) == -1)
19216 g_warning (
"Failed to connect to server at %s: %s", path,
19238 if (address == NULL)
19245 connection->socket =
19246 gvm_server_open (&connection->session, address, port);
19247 connection->credentials = NULL;
19252 if (connection->socket == -1)
19274 gchar **timezone, gchar **severity, gchar **capabilities,
19275 gchar **language, gchar **pw_warning)
19277 gvm_connection_t connection;
19279 gmp_authenticate_info_opts_t auth_opts;
19283 g_debug (
"%s failed to acquire socket!\n", __FUNCTION__);
19287 auth_opts = gmp_authenticate_info_opts_defaults;
19288 auth_opts.username = username;
19289 auth_opts.password = password;
19290 auth_opts.role = role;
19291 auth_opts.severity = severity;
19292 auth_opts.timezone = timezone;
19293 auth_opts.pw_warning = pw_warning;
19295 auth = gmp_authenticate_info_ext_c (&connection, auth_opts);
19299 const char *status;
19307 &connection,
"6765549a-934e-11e3-b358-406186ea4fc5", language, NULL);
19315 gvm_connection_close (&connection);
19318 gvm_connection_close (&connection);
19324 ret = gvm_connection_sendf (&connection,
19325 "<help format=\"XML\" type=\"brief\"/>");
19328 gvm_connection_close (&connection);
19335 if (read_entity_and_text_c (&connection, &entity, &response))
19337 gvm_connection_close (&connection);
19343 status = entity_attribute (entity,
"status");
19344 if (status == NULL || strlen (status) == 0)
19347 free_entity (entity);
19351 free_entity (entity);
19354 *capabilities = response;
19358 gvm_connection_close (&connection);
19363 gvm_connection_close (&connection);
19368 gvm_connection_close (&connection);
19392 gchar *capabilities;
19397 const char *password =
params_value (params,
"password");
19400 if ((password == NULL)
19404 if (
login && password)
19407 &capabilities, &language, &pw_warning);
19412 status = MHD_HTTP_INTERNAL_SERVER_ERROR;
19414 status = MHD_HTTP_SERVICE_UNAVAILABLE;
19416 status = MHD_HTTP_UNAUTHORIZED;
19421 g_warning (
"Authentication failure for '%s' from %s",
login ?:
"",
19429 capabilities, language, pw_warning, client_address);
19431 g_message (
"Authentication success for '%s' from %s",
login ?:
"",
19448 g_free (capabilities);
19451 g_free (pw_warning);
19458 g_warning (
"Authentication failure for '%s' from %s",
login ?:
"",
19478 gmp_authenticate_info_opts_t auth_opts;
19483 MHD_HTTP_SERVICE_UNAVAILABLE);
19488 auth_opts = gmp_authenticate_info_opts_defaults;
19491 if (gmp_authenticate_info_ext_c (connection, auth_opts))
19493 g_debug (
"authenticate failed!\n");
19494 gvm_connection_close (connection);
19505 g_debug (
"Sleeping!");
#define GET_TRASH_RESOURCE(capability, command, name)
static char * get_assets(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Request assets.
static char * get_users(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all users, envelope the result.
static int setting_get_value(gvm_connection_t *connection, const char *setting_id, gchar **value, cmd_response_data_t *response_data)
Get a setting by UUID for the current user of an GMP connection.
char * get_targets_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all targets, envelope the result.
char * export_result_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a result.
char * create_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create config, get all configs, envelope the result.
char * report_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Run alert for a report.
const gchar * user_get_severity(user_t *user)
char * get_port_lists_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all port_lists, envelope the result.
int handler_send_reauthentication(http_connection_t *connection, int http_status_code, authentication_reason_t reason)
Allow for reauthentication of a user.
char * export_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a config.
int download_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, char **html, char **filename, cmd_response_data_t *response_data)
Get an agent, envelope the result.
char * get_scanners_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all scanners, envelope the result.
char * save_config_nvt_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save NVT prefs for a config, get NVT details, envelope result.
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
char * create_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an alert, get all alerts, envelope the result.
params_t * params_values(params_t *params, const char *name)
Get values of param.
char * get_port_list_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one port_list, envelope the result.
int manager_port
The port the manager is on.
char * get_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a config, envelope the result.
static char * wizard_get(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Returns a wizard_get page.
char * delete_schedule_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a schedule, get all schedules, envelope the result.
char * export_assets_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of assets.
char * export_credentials_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of Credentials.
char * get_users_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all users, envelope the result.
char * export_permission_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a permission.
char * download_key_pub(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a Scanner's Certificate.
char * get_ticket_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get single tickets, envelope the result.
void user_renew_session(user_t *user)
static char * get_results(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all results, envelope the result.
char * get_vulns_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get multiple vulns, envelope the result.
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
char * export_target_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a target.
char * delete_report_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete report, get task status, envelope the result.
GSAD credentials handling.
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_gmp.
char * delete_filter_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a filter, get all filters, envelope the result.
static int send_settings_filters(gvm_connection_t *connection, params_t *data, params_t *changed, GString *xml, int *modify_failed_flag, cmd_response_data_t *response_data)
Send settings resource filters.
static char * get_overrides(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all overrides, envelope the result.
char * cvss_calculator(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
#define EVENT_TYPE_UPDATED_SECINFO
char * import_port_list_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import port list, get all port_lists, envelope the result.
Structure of credential related information.
char * export_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a task.
char * bulk_delete_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete multiple resources, get next page, envelope the result.
const gchar * user_get_password_warning(user_t *user)
void user_set_severity(user_t *user, const gchar *severity)
Set severity class of user.
static int simple_gmpf(gvm_connection_t *connection, const gchar *message_operation, credentials_t *credentials, gchar **response, cmd_response_data_t *response_data, const char *format,...)
Run a single GMP command, preparing a response even on error.
char * get_config_nvt_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of an NVT for a config, envelope the result.
static char * get_credentials(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one or all credentials, envelope the result.
char * export_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a agent.
param_t * params_get(params_t *params, const char *name)
Get param.
char * export_roles_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of roles.
char * save_credential_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save credential, get next page, envelope the result.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
char * get_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a task, envelope the result.
char * delete_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gboolean ultimate, cmd_response_data_t *response_data)
Delete a resource, get all resources, envelope the result.
static char * get_vulns(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get multiple vulns, envelope the result.
void user_set_password(user_t *user, const gchar *password)
Set password of user.
void user_set_language(user_t *user, const gchar *language)
Set language of user.
char * get_agents_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all agents, envelope the result.
char * delete_role_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a role, get all roles, envelope the result.
I18n support for Greenbone Security Assistant.
char * run_wizard_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Run a wizard and envelope the result.
char * create_container_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a container task, serve next page.
char * edit_role_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_role XML, envelope the result.
user_t * user_add(const gchar *username, const gchar *password, const gchar *timezone, const gchar *severity, const gchar *role, const gchar *capabilities, const gchar *language, const gchar *pw_warning, const char *address)
Add a user.
int authenticate_gmp(const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning)
Check authentication credentials.
char * save_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify an alert, get all alerts, envelope the result.
void cmd_response_data_set_content_type_string(cmd_response_data_t *data, gchar *content_type_string)
Set a content type as string.
#define params_iterator_t
char * clone_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Clone a resource, envelope the result.
char * sync_feed_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with an NVT feed and envelope the result.
char * wizard_get_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns a wizard_get page.
char * get_system_report_gmp(gvm_connection_t *connection, credentials_t *credentials, const char *url, params_t *params, cmd_response_data_t *response_data)
Return system report image.
char * export_user_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a user.
gchar * capitalize(const char *input)
Capitalize a type or command name and replace underscores.
const char * get_port_from_params(params_t *params)
Get a port from request params.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
static char * get_role(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one role, envelope the result.
const gchar * vendor_version_get()
Get the vendor version.
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
char * delete_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete config, get all configs, envelope the result.
char * resume_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Resume a task, get all tasks, envelope the result.
static char * get_groups(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all groups, envelope the result.
char * get_alerts_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all alerts, envelope the result.
char * create_port_list_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a port list, get all port lists, envelope the result.
char * delete_credential_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete credential, get all credentials, envelope result.
static char * get_filters(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all filters, envelope the result.
GSAD user session handling.
char * edit_alert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_alert XML, envelope the result.
char * import_report_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import report, get all reports, envelope the result.
char * export_results_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of results.
char * export_scanner_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a scanner.
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
void user_set_username(user_t *user, const gchar *username)
Set username of user.
char * create_ticket_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a ticket.
static char * get_scanners(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all scanners, envelope the result.
char * get_filter_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one filter, envelope the result.
user_t * session_get_user_by_username(const gchar *username)
char * edit_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a config, envelope the result.
const char * params_filename(params_t *params, const char *name)
Get filename of param.
gboolean is_unix_socket()
char * export_users_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of users.
char * toggle_tag_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Set tag enabled status.
static char * get_override(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get a override, envelope the result.
char * get_result_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one result, envelope the result.
char * get_permission_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one permission, envelope the result.
char * create_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a task, get all tasks, envelope the result.
char * save_ticket_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a ticket.
const gchar * user_get_role(user_t *user)
char * get_report_formats_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all Report Formats, envelope the result.
void user_free(user_t *user)
char * export_asset_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export an asset.
char * export_override_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export an override.
char * restore_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Restore a resource, get all trash, envelope the result.
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
char * get_tag_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one tag, envelope the result.
char * delete_asset_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete an asset, go to the next page.
char * get_info_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get info, envelope the result.
char * export_overrides_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of overrides.
char * create_note_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a note, get report, envelope the result.
const gchar * user_get_username(user_t *user)
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA GMP library.
static char * get_agents(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all agents, envelope the result.
static void append_alert_condition_data(GString *xml, params_t *data, const char *condition)
Send condition data for an alert.
char * get_group_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one group, envelope the result.
static char * check_modify_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Check a modify_config response.
char * get_roles_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all roles, envelope the result.
char * stop_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Stop a task, get all tasks, envelope the result.
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
struct MHD_Connection http_connection_t
static char * save_osp_prefs(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Save OSP file preferences.
static char * get_tag(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one tag, envelope the result.
char * save_asset_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify an asset, get all assets, envelope the result.
char * sync_scap_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with a SCAP feed and envelope the result.
static char * new_alert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Returns page to create a new alert.
char * create_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an agent, get all agents, envelope result.
char * get_groups_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all groups, envelope the result.
char * get_config_family_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of a family for a config, envelope the result.
Headers/structs for utility functions in GSAD.
char * create_permission_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a permission, get all permissions, envelope the result.
char * export_preference_file_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a file preference.
char * get_tags_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tags, envelope the result.
char * get_aggregate_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an aggregate of resources.
char * save_tag_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a tag, get all tags, envelope the result.
const gchar * credentials_get_language(credentials_t *cred)
char * verify_scanner_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify scanner, get scanners, envelope the result.
char * verify_report_format_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify report format, get report formats, envelope the result.
int connect_unix(const gchar *path)
Connect to Greenbone Vulnerability Manager daemon.
char * create_role_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a role, get all roles, envelope the result.
static int filter_exists(gvm_connection_t *connection, const char *filt_id)
Check whether a filter exists.
void cmd_response_data_set_content_disposition(cmd_response_data_t *data, gchar *content_disposition)
Set content disposition of cmd_response_data_t struct.
char * get_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one alert, envelope the result.
char * export_configs_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of scan configs.
char * export_permissions_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of permissions.
static char * get_trash(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Setup trash page XML, envelope the result.
Response information for commands.
const gchar * user_get_token(user_t *user)
enum authentication_reason authentication_reason_t
char * verify_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Verify agent, get agents, envelope the result.
char * create_permissions_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create multiple permission, get next page, envelope the result.
char * get_report_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a report and envelope the result.
Headers for GSA's GMP communication module.
char * download_ssl_cert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an SSL Certificate.
char * auth_settings_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
#define FILT_ID_NONE
filt_id value to use term or built-in default filter.
#define EVENT_TYPE_NEW_SECINFO
static char * get_agent(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one agent, envelope the result.
char * get_schedules_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all schedules, envelope the result.
static char * get_schedule(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one schedule, envelope the result.
char * export_role_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a role.
char * export_report_formats_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of Report Formats.
char * get_permissions_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all permissions, envelope the result.
char * get_override_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get an override, envelope the result.
char * save_note_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save note, get next page, envelope the result.
const time_t user_get_session_timeout(user_t *user)
static char * get_alerts(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all alerts, envelope the result.
static void append_alert_event_data(GString *xml, params_t *data, const char *event)
Send event data for an alert.
Headers/structs used generally in GSA.
static char * get_asset(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Request an asset.
static char * get_group(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one group, envelope the result.
char * edit_config_nvt_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Edit details of an NVT for a config, envelope the result.
Http Parameter handling in GSA.
Structure to search a key by value.
char * get_feeds_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get descriptions of the feeds connected to the manager.
char * get_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one agent, envelope the result.
char * get_one(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, const char *extra_attribs, cmd_response_data_t *response_data)
Get one resource, envelope the result.
char * save_user_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a user, get all users, envelope the result.
void cmd_response_data_set_content_type(cmd_response_data_t *data, content_type_t content_type)
Set content type of cmd_response_data_t struct.
const gchar * user_get_password(user_t *user)
static char * get_note(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get a note, envelope the result.
char * get_asset_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get asset, envelope the result.
static char * get_permissions(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all permissions, envelope the result.
char * save_permission_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a permission, get all permissions, envelope the result.
static char * get_tags(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all tags, envelope the result.
gchar * message_invalid(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *op_name)
Check a param using the direct response method.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
int gvm_connection_open(gvm_connection_t *connection, const gchar *address, int port)
Connect to an address.
char * delete_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete an alert, get all alerts, envelope the result.
static char * get_user(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one user, envelope the result.
char * get_reports_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all reports, envelope the result.
char * export_tag_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a tag.
void session_add_user(const gchar *id, user_t *user)
Add user to the session "database".
char * create_override_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an override, get report, envelope the result.
char * get_notes_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all notes, envelope the result.
char * save_scanner_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save scanner, get next page, envelope the result.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
char * get_info(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Requests SecInfo.
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.
static char * get_config_nvt(gvm_connection_t *connection, credentials_t *credentials, params_t *params, int edit, cmd_response_data_t *response_data)
Get details of an NVT for a config, envelope the result.
char * create_credential_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a credential, get all credentials, envelope result.
char * export_report_format_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a report format.
char * delete_permission_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a permission, get all permissions, envelope the result.
char * save_filter_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a filter, get all filters, envelope the result.
char * create_schedule_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a schedule, get all schedules, envelope the result.
char * get_user_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one user, envelope the result.
char * delete_from_trash_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a resource from the trashcan.
gboolean params_value_bool(params_t *params, const char *name)
Get boolean value of param.
static char * get_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, const char *extra_attribs, cmd_response_data_t *response_data)
Get all of a particular type of resource, envelope the result.
static char * get_port_list(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one port_list, envelope the result.
static char * get_report_formats(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all Report Formats, envelope the result.
void gmp_init(const gchar *manager_address_unix, const gchar *manager_address_tls, int port_manager)
Init the GSA GMP library.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
credentials_t * credentials_new(user_t *user, const gchar *language)
char * save_auth_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save authentication settings.
char * save_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a agent, get all agents, envelope the result.
char * get_trash_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all trash, envelope the result.
char * save_setting_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save user setting.
static void params_toggle_overrides(params_t *params, const char *overrides)
Toggle overrides.
char * save_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save task, get next page, envelope the result.
char * create_user_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a user, get all users, envelope the result.
char * save_container_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save container task, get next page, envelope the result.
char * export_schedules_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of schedules.
static char * get_target(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one target, envelope the result.
char * save_target_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a target, get all targets, envelope the result.
char * save_my_settings_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const gchar *accept_language, cmd_response_data_t *response_data)
Returns page with user's settings, for editing.
static char * get_schedules(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all schedules, envelope the result.
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to GMP response entity.
char * get_report_format_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one report format, envelope the result.
static char * get_config(gvm_connection_t *, credentials_t *, params_t *, const char *, int, cmd_response_data_t *)
Get a config, envelope the result.
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
static gchar * action_result(gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *, const char *action, const char *message, const char *details, const char *id)
Generate a enveloped GMP XML containing an action result.
char * create_host_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a host, serve next page.
const gchar * user_get_capabilities(user_t *user)
char * export_targets_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of targets.
char * export_note_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a note.
char * save_schedule_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save schedule, get next page, envelope the result.
char * create_target_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a target, get all targets, envelope the result.
static char * edit_role(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Setup edit_role XML, envelope the result.
char * create_tag_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a tag, envelope the result.
const char * params_value(params_t *params, const char *name)
Get value of param.
double credentials_get_cmd_duration(credentials_t *cred)
char * export_tags_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of tags.
char * create_group_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a group, get all groups, envelope the result.
static char * get_report_format(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one report format, envelope the result.
char * save_config_family_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of an NVT for a config, envelope the result.
void user_set_timezone(user_t *user, const gchar *timezone)
Set timezone of user.
const char * get_severity_from_params(params_t *params)
Get severity from request params.
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
const gchar * user_get_timezone(user_t *user)
GPtrArray * users
User session data.
void session_remove_other_sessions(const gchar *id, user_t *user)
Removes all session of the user, except the one with the passed id.
char * get_results_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all results, envelope the result.
int handler_create_response(http_connection_t *connection, gchar *data, cmd_response_data_t *response_data, const gchar *sid)
Create and send a response.
char * save_report_format_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save report_format, get next page, envelope the result.
char * get_schedule_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one schedule, envelope the result.
int manager_connect(credentials_t *credentials, gvm_connection_t *connection, cmd_response_data_t *response_data)
Connect to Greenbone Vulnerability Manager daemon.
#define RESULTS_PER_PAGE
Initial filtered results per page on the report summary.
char * get_note_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a note, envelope the result.
char * save_port_list_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a port list, get all port list, envelope the result.
#define GSAD_STATUS_INVALID_REQUEST
HTTP status code for expected failure of gmp requests e.g. if some parameter was missing or invalid.
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
User information structure, for sessions.
char * export_groups_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of groups.
char * resource_action(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, envelope result.
#define params_iterator_init
char * export_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export an alert.
char * delete_user_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a user, get all users, envelope the result.
char * create_port_range_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Add a range to a port list, envelope the result.
char * edit_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_get_attribs, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit XML, envelope the result.
static char * get_credential(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one credential, envelope the result.
char * wizard_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns a wizard page.
void credentials_free(credentials_t *creds)
char * get_credential_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one credential, envelope the result.
char * create_asset_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create an asset, get report, envelope the result.
char * import_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import config, get all configs, envelope the result.
static char * get_reports(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all reports, envelope the result.
char * save_override_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save override, get next page, envelope the result.
const char * get_task_id_from_params(params_t *params)
Get task_id from request params.
static int member(params_t *params, const char *string)
Look for a param with name equal to a given string.
static char * get_configs(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all scan configs, envelope the result.
char * export_port_lists_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of Port Lists.
static char * get_targets(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all targets, envelope the result.
static char * get_permission(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one permission, envelope the result.
char * get_tickets_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tickets, envelope the result.
char * new_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new alert.
static char * get_port_lists(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all Port Lists, envelope the result.
const char * get_hosts_from_params(params_t *params)
Get hosts from request params.
char * test_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Test an alert, get all alerts envelope the result.
char * bulk_export_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export multiple resources.
gboolean user_get_guest(user_t *user)
char * create_report_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new container task.
char * delete_target_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a target, get all targets, envelope the result.
static char * edit_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Get a config, envelope the result.
char * save_group_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a group, return the next page.
gchar * manager_address
The address the manager is on.
char * empty_trashcan_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Empty the trashcan, get all trash, envelope the result.
const gchar * user_get_cookie(user_t *user)
char * get_filters_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all filters, envelope the result.
char * import_report_format_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Import report format, get all report formats, envelope result.
char * get_credentials_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one or all credentials, envelope the result.
static char * sync_feed(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *sync_cmd, const char *action, const char *feed_name, cmd_response_data_t *response_data)
Synchronize with a feed and envelope the result.
int download_credential_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, char **html, char **login, cmd_response_data_t *response_data)
Export a Credential in a defined format.
char * create_scanner_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a scanner, get all scanners, envelope the result.
char * delete_port_list_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a port list, get all port lists, envelope the result.
char * download_ca_pub(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get a Scanner's CA Certificate.
char * sync_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Sync config, get configs, envelope the result.
char * get_overrides_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all overrides, envelope the result.
char * export_schedule_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a schedule.
static char * get_alert(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one alert, envelope the result.
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
char * get_report(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Get a report and return the result.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
char * delete_scanner_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a scanner, get all scanners, envelope the result.
char * delete_report_format_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete report format, get report formats, envelope the result.
char * save_role_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Modify a role, return the next page.
static char * get_config_family(gvm_connection_t *, credentials_t *, params_t *, int, cmd_response_data_t *)
Get details of a family for a config, envelope the result.
char * get_role_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one role, envelope the result.
char * get_setting_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
char * export_tasks_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of tasks.
char * edit_config_family_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get details of a family for editing a config, envelope result.
char * delete_override_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete override, get next page, envelope the result.
char * get_configs_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all scan configs, envelope the result.
char * get_settings_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all user defined settings.
char * edit_alert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Setup edit_alert XML, envelope the result.
char * delete_group_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a group, get all groups, envelope the result.
char * ctime_r_strip_newline(time_t *time, char *string)
Return string from ctime_r with newline replaces with terminator.
char * export_filter_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a filter.
char * create_filter_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a filter, get all filters, envelope the result.
static void append_alert_method_data(GString *xml, params_t *data, const char *method, params_t *report_formats)
Send method data for an alert.
char * export_agents_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of agents.
char * delete_port_range_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a port range, get the port list, envelope the result.
char * start_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Start a task, get all tasks, envelope the result.
#define EVENT_TYPE_TASK_RUN_STATUS_CHANGED
static char * get_filter(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one filter, envelope the result.
char * delete_note_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete note, get next page, envelope the result.
user_t * credentials_get_user(credentials_t *cred)
const char * get_result_id_from_params(params_t *params)
Get result_id from request params.
char * delete_ticket_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a ticket.
char * export_notes_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of notes.
char * get_scanner_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one scanner, envelope the result.
char * ping_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get assets, envelope the result.
char * get_assets_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get assets, envelope the result.
char * export_alerts_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of alerts.
char * delete_agent_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete agent, get all agents, envelope result.
char * renew_session_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
int manager_use_tls
Whether to use TLS for Manager connections.
const gchar * user_get_client_address(user_t *user)
static char * get_roles(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all roles, envelope the result.
static char * wizard(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Returns a wizard page.
char * export_group_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a group.
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
char * get_tasks_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all tasks, envelope the result.
static char * get_scanner(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one scanner, envelope the result.
char * export_filters_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of filters.
#define FILT_ID_USER_SETTING
filt_id value to use the filter in the user setting if possible.
char * get_system_reports_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get all system reports, envelope the result.
char * export_credential_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a Credential.
static char * get_notes(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all notes, envelope the result.
char * delete_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete a task, get all tasks, envelope the result.
char * sync_cert_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Synchronize with a CERT feed and envelope the result.
char * delete_tag_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Delete note, get next page, envelope the result.
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
static char * get_tasks(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all tasks, envelope the result.
char * move_task_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Reassign a task to a new GMP slave.
char * export_scanners_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of scanners.
char * get_target_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Get one target, envelope the result.
char * export_port_list_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a Port List.
char * save_config_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Save details of an NVT for a config and return the next page.