From 01abd04455815b1de19c2f1b15be8a8b9d1861fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 09:13:28 +0200 Subject: [PATCH 1/8] Remove unused task_proxy case from create_permission Remove task_proxy special case from create_permission in gsad. --- gsad/src/gsad_gmp.c | 191 ++++++++++++-------------------------------- 1 file changed, 51 insertions(+), 140 deletions(-) diff --git a/gsad/src/gsad_gmp.c b/gsad/src/gsad_gmp.c index c9054d8a6e..d1fc867922 100644 --- a/gsad/src/gsad_gmp.c +++ b/gsad/src/gsad_gmp.c @@ -14240,152 +14240,63 @@ create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, /* Create the permission(s). */ - if (strcmp (name, "task_proxy") == 0) - { - response = NULL; - entity = NULL; - ret = gmpf (connection, credentials, &response, &entity, response_data, - "" - "" - "get_tasks" - "%s" - "" - "%s" - "" - "" - "modify_task" - "%s" - "" - "%s" - "" - "" - "start_task" - "%s" - "" - "%s" - "" - "" - "stop_task" - "%s" - "" - "%s" - "" - "" - "resume_task" - "%s" - "" - "%s" - "" - "", - comment ? comment : "", resource_id ? resource_id : "", - subject_id, subject_type, comment ? comment : "", - resource_id ? resource_id : "", subject_id, subject_type, - comment ? comment : "", resource_id ? resource_id : "", - subject_id, subject_type, comment ? comment : "", - resource_id ? resource_id : "", subject_id, subject_type, - comment ? comment : "", resource_id ? resource_id : "", - subject_id, subject_type); - - if (get_subject_entity) - free_entity (get_subject_entity); + response = NULL; + entity = NULL; + ret = gmpf (connection, credentials, &response, &entity, response_data, + "" + "%s" + "%s" + "" + "%s" + "" + "%s" + "", + name, comment ? comment : "", resource_id ? resource_id : "", + resource_type ? resource_type : "", subject_id, subject_type); - switch (ret) - { - case 0: - case -1: - break; - case 1: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message ( - credentials, "Internal error", __FUNCTION__, __LINE__, - "An internal error occurred while creating a permission. " - "The permission was not created. " - "Diagnostics: Failure to send command to manager daemon.", - response_data); - case 2: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message ( - credentials, "Internal error", __FUNCTION__, __LINE__, - "An internal error occurred while creating a permission. " - "It is unclear whether the permission has been created or not. " - "Diagnostics: Failure to receive response from manager daemon.", - response_data); - default: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message ( - credentials, "Internal error", __FUNCTION__, __LINE__, - "An internal error occurred while creating a permission. " - "It is unclear whether the permission has been created or not. " - "Diagnostics: Internal Error.", - response_data); - } + if (get_subject_entity) + free_entity (get_subject_entity); - if (entity_attribute (entity, "id")) - params_add (params, "permission_id", entity_attribute (entity, "id")); - html = response_from_entity (connection, credentials, params, entity, - "Create Permission", response_data); - } - else + switch (ret) { - response = NULL; - entity = NULL; - ret = gmpf (connection, credentials, &response, &entity, response_data, - "" - "%s" - "%s" - "" - "%s" - "" - "%s" - "", - name, comment ? comment : "", resource_id ? resource_id : "", - resource_type ? resource_type : "", subject_id, subject_type); + case 0: + case -1: + break; + case 1: + cmd_response_data_set_status_code (response_data, + MHD_HTTP_INTERNAL_SERVER_ERROR); + return gsad_message ( + credentials, "Internal error", __FUNCTION__, __LINE__, + "An internal error occurred while creating a permission. " + "The permission was not created. " + "Diagnostics: Failure to send command to manager daemon.", + response_data); + case 2: + cmd_response_data_set_status_code (response_data, + MHD_HTTP_INTERNAL_SERVER_ERROR); + return gsad_message ( + credentials, "Internal error", __FUNCTION__, __LINE__, + "An internal error occurred while creating a permission. " + "It is unclear whether the permission has been created or not. " + "Diagnostics: Failure to receive response from manager daemon.", + response_data); + default: + cmd_response_data_set_status_code (response_data, + MHD_HTTP_INTERNAL_SERVER_ERROR); + return gsad_message ( + credentials, "Internal error", __FUNCTION__, __LINE__, + "An internal error occurred while creating a permission. " + "It is unclear whether the permission has been created or not. " + "Diagnostics: Internal Error.", + response_data); + } - if (get_subject_entity) - free_entity (get_subject_entity); + if (entity_attribute (entity, "id")) + params_add (params, "permission_id", entity_attribute (entity, "id")); - switch (ret) - { - case 0: - case -1: - break; - case 1: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message ( - credentials, "Internal error", __FUNCTION__, __LINE__, - "An internal error occurred while creating a permission. " - "The permission was not created. " - "Diagnostics: Failure to send command to manager daemon.", - response_data); - case 2: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message ( - credentials, "Internal error", __FUNCTION__, __LINE__, - "An internal error occurred while creating a permission. " - "It is unclear whether the permission has been created or not. " - "Diagnostics: Failure to receive response from manager daemon.", - response_data); - default: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message ( - credentials, "Internal error", __FUNCTION__, __LINE__, - "An internal error occurred while creating a permission. " - "It is unclear whether the permission has been created or not. " - "Diagnostics: Internal Error.", - response_data); - } + html = response_from_entity (connection, credentials, params, entity, + "Create Permission", response_data); - if (entity_attribute (entity, "id")) - params_add (params, "permission_id", entity_attribute (entity, "id")); - html = response_from_entity (connection, credentials, params, entity, - "Create Permission", response_data); - } free_entity (entity); g_free (response); return html; From ac2f4eda95d41d4a1951e4aa4adc582fe68363ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 10:30:29 +0200 Subject: [PATCH 2/8] Add defines for include releated value in gsad Using ints for comparision isn't readable at all. Therefoe add defines to combare the actual meaning of the values. --- gsad/src/gsad_gmp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gsad/src/gsad_gmp.c b/gsad/src/gsad_gmp.c index d1fc867922..555d13151a 100644 --- a/gsad/src/gsad_gmp.c +++ b/gsad/src/gsad_gmp.c @@ -14351,6 +14351,10 @@ create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, return html; \ } +#define INCLUDE_RELATED_CURRENT_RESOURCE_ONLY 0 +#define INCLUDE_RELATED_ALL_RESOURCES 1 +#define INCLUDE_RELATED_RESOURCES_ONLY 2 + /** * @brief Create multiple permission, get next page, envelope the result. * @@ -14487,7 +14491,7 @@ create_permissions_gmp (gvm_connection_t *connection, /* Create the permission(s). */ // Main resource permissions - if (include_related != 2) + if (include_related != INCLUDE_RELATED_RESOURCES_ONLY) { if (strcmp (permission, "read") == 0 || strcmp (permission, "proxy") == 0) { @@ -14622,7 +14626,7 @@ create_permissions_gmp (gvm_connection_t *connection, } // Related permissions - if (include_related) + if (include_related != INCLUDE_RELATED_CURRENT_RESOURCE_ONLY) { params_t *related; related = params_values (params, "related:"); From c58715179287b3a7401cb397e57a9fe8b0a0c29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 10:33:43 +0200 Subject: [PATCH 3/8] Remove subject_name from create_permission functions The subject_name param isn't used in gsa anymore. Therefore these code paths can be removed from create_permission_gmp and create_permissions_gmp functions. --- gsad/src/gsad.c | 1 - gsad/src/gsad_gmp.c | 158 ++------------------------------------------ 2 files changed, 4 insertions(+), 155 deletions(-) diff --git a/gsad/src/gsad.c b/gsad/src/gsad.c index deda8d3f6b..0faf9b2400 100644 --- a/gsad/src/gsad.c +++ b/gsad/src/gsad.c @@ -916,7 +916,6 @@ init_validator () gvm_validator_alias (validator, "subgroup_column", "group_column"); gvm_validator_alias (validator, "subject_id", "id"); gvm_validator_alias (validator, "subject_id_optional", "id_optional"); - gvm_validator_alias (validator, "subject_name", "name"); gvm_validator_alias (validator, "subtype", "asset_type"); gvm_validator_alias (validator, "task_filter", "filter"); gvm_validator_alias (validator, "task_filt_id", "filt_id"); diff --git a/gsad/src/gsad_gmp.c b/gsad/src/gsad_gmp.c index 555d13151a..95e52a021c 100644 --- a/gsad/src/gsad_gmp.c +++ b/gsad/src/gsad_gmp.c @@ -14138,19 +14138,14 @@ create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, int ret; gchar *html, *response; const char *name, *comment, *resource_id, *resource_type; - const char *subject_id, *subject_type, *subject_name; + const char *subject_id, *subject_type; entity_t entity; - gchar *subject_response; - entity_t get_subject_entity = NULL; - entity_t subject_entity; - name = params_value (params, "permission"); comment = params_value (params, "comment"); resource_id = params_value (params, "id_or_empty"); resource_type = params_value (params, "optional_resource_type"); subject_type = params_value (params, "subject_type"); - subject_name = params_value (params, "subject_name"); CHECK_VARIABLE_INVALID (name, "Create Permission"); CHECK_VARIABLE_INVALID (comment, "Create Permission"); @@ -14160,74 +14155,7 @@ create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, if (params_given (params, "optional_resource_type")) CHECK_VARIABLE_INVALID (resource_type, "Create Permission"); - if (params_given (params, "subject_name")) - { - CHECK_VARIABLE_INVALID (subject_name, "Create Permission"); - subject_id = NULL; - ret = gmpf (connection, credentials, &subject_response, - &get_subject_entity, response_data, - "" - "", - subject_type, subject_name, subject_type); - - switch (ret) - { - case 0: - case -1: - break; - case 1: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while getting" - " the subject for a permission. " - "The permission was not created. " - "Diagnostics: Failure to send command" - " to manager daemon.", - response_data); - case 2: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while getting" - " the subject for a permission. " - "The permission was not created. " - "Diagnostics: Failure to receive response" - " from manager daemon.", - response_data); - default: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while getting" - " the subject for a permission. " - "The permission was not created. " - "Diagnostics: Internal Error.", - response_data); - } - - subject_entity = entity_child (get_subject_entity, subject_type); - - if (subject_entity) - subject_id = entity_attribute (subject_entity, "id"); - - if (subject_id == NULL) - { - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while creating a " - "permission. Could not find Subject." - "The permission was not created. " - "Diagnostics: Internal Error.", - response_data); - } - } - else if (strcmp (subject_type, "user") == 0) + if (strcmp (subject_type, "user") == 0) subject_id = params_value (params, "permission_user_id"); else if (strcmp (subject_type, "group") == 0) subject_id = params_value (params, "permission_group_id"); @@ -14254,9 +14182,6 @@ create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, name, comment ? comment : "", resource_id ? resource_id : "", resource_type ? resource_type : "", subject_id, subject_type); - if (get_subject_entity) - free_entity (get_subject_entity); - switch (ret) { case 0: @@ -14374,22 +14299,17 @@ create_permissions_gmp (gvm_connection_t *connection, gchar *html, *response, *summary_response; int successes; const char *permission, *comment, *resource_id, *resource_type; - const char *subject_id, *subject_type, *subject_name; + const char *subject_id, *subject_type; const char *permission_resource_type; int include_related; entity_t entity; - gchar *subject_response; - entity_t get_subject_entity = NULL; - entity_t subject_entity; - permission = params_value (params, "permission"); comment = params_value (params, "comment"); resource_id = params_value (params, "resource_id"); resource_type = params_value (params, "resource_type"); subject_type = params_value (params, "subject_type"); - subject_name = params_value (params, "subject_name"); CHECK_VARIABLE_INVALID (params_value (params, "include_related"), "Create Permission"); @@ -14408,74 +14328,7 @@ create_permissions_gmp (gvm_connection_t *connection, include_related = atoi (params_value (params, "include_related")); - if (params_given (params, "subject_name")) - { - CHECK_VARIABLE_INVALID (subject_name, "Create Permission"); - subject_id = NULL; - ret = gmpf (connection, credentials, &subject_response, - &get_subject_entity, response_data, - "" - "", - subject_type, subject_name, subject_type); - - switch (ret) - { - case 0: - case -1: - break; - case 1: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while getting" - " the subject for a permission. " - "The permission was not created. " - "Diagnostics: Failure to send command" - " to manager daemon.", - response_data); - case 2: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while getting" - " the subject for a permission. " - "The permission was not created. " - "Diagnostics: Failure to receive response" - " from manager daemon.", - response_data); - default: - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while getting" - " the subject for a permission. " - "The permission was not created. " - "Diagnostics: Internal Error.", - response_data); - } - - subject_entity = entity_child (get_subject_entity, subject_type); - - if (subject_entity) - subject_id = entity_attribute (subject_entity, "id"); - - if (subject_id == NULL) - { - cmd_response_data_set_status_code (response_data, - MHD_HTTP_INTERNAL_SERVER_ERROR); - return gsad_message (credentials, "Internal error", __FUNCTION__, - __LINE__, - "An internal error occurred while creating a " - "permission. Could not find Subject." - "The permission was not created. " - "Diagnostics: Internal Error.", - response_data); - } - } - else if (str_equal (subject_type, "user")) + if (str_equal (subject_type, "user")) subject_id = params_value (params, "permission_user_id"); else if (str_equal (subject_type, "group")) subject_id = params_value (params, "permission_group_id"); @@ -14785,9 +14638,6 @@ create_permissions_gmp (gvm_connection_t *connection, } } - if (get_subject_entity) - free_entity (get_subject_entity); - summary_response = g_strdup_printf ("Successfully created %i permissions", successes); From 50ad592670a89a940e57204568ea4ef4bc98e457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 10:38:26 +0200 Subject: [PATCH 4/8] Change proxy permission to write We use read and write in GSA. Therefore adjust gsad to recognize write instead of proxy. --- gsad/src/gsad_gmp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gsad/src/gsad_gmp.c b/gsad/src/gsad_gmp.c index 95e52a021c..8f334266c3 100644 --- a/gsad/src/gsad_gmp.c +++ b/gsad/src/gsad_gmp.c @@ -14346,7 +14346,7 @@ create_permissions_gmp (gvm_connection_t *connection, // Main resource permissions if (include_related != INCLUDE_RELATED_RESOURCES_ONLY) { - if (strcmp (permission, "read") == 0 || strcmp (permission, "proxy") == 0) + if (str_equal (permission, "read") || str_equal (permission, "write")) { response = NULL; entity = NULL; @@ -14365,7 +14365,7 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET } - if ((strcmp (permission, "proxy") == 0) + if ((str_equal (permission, "write")) && strcmp (permission_resource_type, "result") && strcmp (permission_resource_type, "report")) { @@ -14503,8 +14503,8 @@ create_permissions_gmp (gvm_connection_t *connection, else related_type = param->value; - if (strcmp (permission, "read") == 0 - || strcmp (permission, "proxy") == 0) + if (str_equal (permission, "read") == 0 + || str_equal (permission, "write") == 0) { response = NULL; entity = NULL; @@ -14523,7 +14523,7 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET } - if ((strcmp (permission, "proxy") == 0) + if ((str_equal (permission, "write")) && strcmp (related_type, "result") && strcmp (related_type, "report")) { From 725934c85581f31909b1446b39919c54a1e38ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 10:51:05 +0200 Subject: [PATCH 5/8] Change gsad to user permission_type parameter When creating multiple permissions use permission_type parameter and only allow read or write. --- gsa/src/gmp/commands/permissions.js | 4 ++-- gsad/src/gsad.c | 1 + gsad/src/gsad_gmp.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gsa/src/gmp/commands/permissions.js b/gsa/src/gmp/commands/permissions.js index 2eefa5aa21..2e35c75466 100644 --- a/gsa/src/gmp/commands/permissions.js +++ b/gsa/src/gmp/commands/permissions.js @@ -99,7 +99,7 @@ class PermissionsCommand extends EntitiesCommand { create({ id, - permission, + permission, // permission is read or write here entityType, comment = '', groupId, @@ -112,7 +112,7 @@ class PermissionsCommand extends EntitiesCommand { const data = { cmd: 'create_permissions', comment, - permission, + permission_type: permission, permission_group_id: groupId, permission_role_id: roleId, permission_user_id: userId, diff --git a/gsad/src/gsad.c b/gsad/src/gsad.c index 0faf9b2400..6cdafa3eb6 100644 --- a/gsad/src/gsad.c +++ b/gsad/src/gsad.c @@ -659,6 +659,7 @@ init_validator () gvm_validator_add (validator, "result_id", "^[a-z0-9\\-]+$"); gvm_validator_add (validator, "role", "^[[:alnum:] ]+$"); gvm_validator_add (validator, "permission", "^([_a-z]+|Super)$"); + gvm_validator_add (validator, "permission_type", "^(read|write)$"); gvm_validator_add (validator, "port_list_id", "^[a-z0-9\\-]+$"); gvm_validator_add (validator, "port_range_id", "^[a-z0-9\\-]+$"); gvm_validator_add ( diff --git a/gsad/src/gsad_gmp.c b/gsad/src/gsad_gmp.c index 8f334266c3..2aaa2ab8b6 100644 --- a/gsad/src/gsad_gmp.c +++ b/gsad/src/gsad_gmp.c @@ -14305,7 +14305,7 @@ create_permissions_gmp (gvm_connection_t *connection, entity_t entity; - permission = params_value (params, "permission"); + permission = params_value (params, "permission_type"); comment = params_value (params, "comment"); resource_id = params_value (params, "resource_id"); resource_type = params_value (params, "resource_type"); From 9efa662c622595bcf2472cb644ee864f4222a133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 11:20:32 +0200 Subject: [PATCH 6/8] Improve readability in gsad by using str_equal Update create_permission functions to use str_equal instead of strcmp. --- gsad/src/gsad_gmp.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/gsad/src/gsad_gmp.c b/gsad/src/gsad_gmp.c index 2aaa2ab8b6..64fff661d0 100644 --- a/gsad/src/gsad_gmp.c +++ b/gsad/src/gsad_gmp.c @@ -14155,11 +14155,11 @@ create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, if (params_given (params, "optional_resource_type")) CHECK_VARIABLE_INVALID (resource_type, "Create Permission"); - if (strcmp (subject_type, "user") == 0) + if (str_equal (subject_type, "user")) subject_id = params_value (params, "permission_user_id"); - else if (strcmp (subject_type, "group") == 0) + else if (str_equal (subject_type, "group")) subject_id = params_value (params, "permission_group_id"); - else if (strcmp (subject_type, "role") == 0) + else if (str_equal (subject_type, "role")) subject_id = params_value (params, "permission_role_id"); else subject_id = NULL; @@ -14366,9 +14366,10 @@ create_permissions_gmp (gvm_connection_t *connection, } if ((str_equal (permission, "write")) - && strcmp (permission_resource_type, "result") - && strcmp (permission_resource_type, "report")) + && !str_equal (permission_resource_type, "result") + && !str_equal (permission_resource_type, "report")) { + // create modify permission for resource response = NULL; entity = NULL; ret = @@ -14385,8 +14386,9 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET - if (strcmp (permission_resource_type, "task") == 0) + if (str_equal (permission_resource_type, "task")) { + // create start_task, stop_task and resume_task permission response = NULL; entity = NULL; ret = gmpf (connection, credentials, &response, &entity, @@ -14436,8 +14438,9 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET } - if (strcmp (permission_resource_type, "alert") == 0) + if (str_equal (permission_resource_type, "alert")) { + // create test permission response = NULL; entity = NULL; ret = gmpf (connection, credentials, &response, &entity, @@ -14455,10 +14458,11 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET } - if (strcmp (permission_resource_type, "agent") == 0 - || strcmp (permission_resource_type, "report_format") == 0 - || strcmp (permission_resource_type, "scanner") == 0) + if (str_equal (permission_resource_type, "agent") + || str_equal (permission_resource_type, "report_format") + || str_equal (permission_resource_type, "scanner")) { + // create verify permission response = NULL; entity = NULL; ret = gmpf (connection, credentials, &response, &entity, @@ -14524,8 +14528,8 @@ create_permissions_gmp (gvm_connection_t *connection, } if ((str_equal (permission, "write")) - && strcmp (related_type, "result") - && strcmp (related_type, "report")) + && !str_equal (related_type, "result") + && !str_equal (related_type, "report")) { response = NULL; entity = NULL; @@ -14543,7 +14547,7 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET - if (strcmp (related_type, "task") == 0) + if (str_equal (related_type, "task")) { response = NULL; entity = NULL; @@ -14594,7 +14598,7 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET } - if (strcmp (related_type, "alert") == 0) + if (str_equal (related_type, "alert")) { response = NULL; entity = NULL; @@ -14613,9 +14617,9 @@ create_permissions_gmp (gvm_connection_t *connection, CHECK_GMPF_RET } - if (strcmp (related_type, "agent") == 0 - || strcmp (related_type, "report_format") == 0 - || strcmp (related_type, "scanner") == 0) + if (str_equal (related_type, "agent") + || str_equal (related_type, "report_format") + || str_equal (related_type, "scanner")) { response = NULL; entity = NULL; From c62fc8b4896eff4fb5145d141bb21879f6b424a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 11:22:17 +0200 Subject: [PATCH 7/8] Fix proptype of permission at MultiplePermissionDialog It must be read or write. --- gsa/src/web/pages/permissions/multipledialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsa/src/web/pages/permissions/multipledialog.js b/gsa/src/web/pages/permissions/multipledialog.js index 4b29aab3b8..a3fd396688 100644 --- a/gsa/src/web/pages/permissions/multipledialog.js +++ b/gsa/src/web/pages/permissions/multipledialog.js @@ -228,7 +228,7 @@ MultiplePermissionDialog.propTypes = { INCLUDE_RELATED_RESOURCES, RELATED_RESOURCES_ONLY, ]), - permission: PropTypes.oneOf(['read', 'proxy']), + permission: PropTypes.oneOf(['read', 'write']), related: PropTypes.array, // array of models roleId: PropTypes.id, roles: PropTypes.array, From 6c80ed16c1e97a763d88f27914cc82f480d0a7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 24 Apr 2019 11:35:42 +0200 Subject: [PATCH 8/8] Add changelog entry for multiple permission creating fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da6f4e358e..7c0ba9acce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Cleanup get_report function in gsad [#1263](https://github.com/greenbone/gsa/pull/1263) ### Fixed +- Fix creating permissions via the create multiple permissions dialog [#1302](https://github.com/greenbone/gsa/pull/1302) - Fix showing host in Scanner dialog [#1301](https://github.com/greenbone/gsa/pull/1301) - Fix detailslinks in AllSecInfo [#1299](https://github.com/greenbone/gsa/pull/1299) - Only run libmicrohttp in debug mode if gsad build type is debug [#1295](https://github.com/greenbone/gsa/pull/1295)