FIX: `include_` serializer methods must end with ? (#14407)

Otherwise, they are simply dead code and the attribute is visible by
default. These bugs did not expose any sensitive information.
This commit is contained in:
Dan Ungureanu 2021-09-22 16:01:25 +03:00 committed by GitHub
parent dd091fbf36
commit 2e085915cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 21 deletions

View File

@ -75,7 +75,7 @@ class CategorySerializer < SiteCategorySerializer
scope && scope.cannot_delete_category_reason(object) scope && scope.cannot_delete_category_reason(object)
end end
def include_cannot_delete_reason def include_cannot_delete_reason?
!include_can_delete? && scope && scope.can_edit?(object) !include_can_delete? && scope && scope.can_edit?(object)
end end

View File

@ -10,7 +10,7 @@ class GroupUserSerializer < BasicUserSerializer
:added_at, :added_at,
:timezone :timezone
def include_added_at def include_added_at?
object.respond_to? :added_at object.respond_to? :added_at
end end

View File

@ -47,7 +47,7 @@ class InvitedUserRecordSerializer < BasicUserSerializer
((Time.now - object.created_at) / 60 / 60 / 24).ceil ((Time.now - object.created_at) / 60 / 60 / 24).ceil
end end
def include_days_since_created def include_days_since_created?
can_see_invite_details? can_see_invite_details?
end end

View File

@ -107,10 +107,6 @@ class UserCardSerializer < BasicUserSerializer
uri.host.sub(/^www\./, '') + uri.path uri.host.sub(/^www\./, '') + uri.path
end end
def include_website_name
website.present?
end
def ignored def ignored
scope_ignored_user_ids = scope.user&.ignored_user_ids || [] scope_ignored_user_ids = scope.user&.ignored_user_ids || []
scope_ignored_user_ids.include?(object.id) scope_ignored_user_ids.include?(object.id)

View File

@ -215,12 +215,6 @@
"can_delete": { "can_delete": {
"type": "boolean" "type": "boolean"
}, },
"cannot_delete_reason": {
"type": [
"string",
"null"
]
},
"allow_badges": { "allow_badges": {
"type": "boolean" "type": "boolean"
}, },
@ -287,7 +281,6 @@
"mailinglist_mirror", "mailinglist_mirror",
"all_topics_wiki", "all_topics_wiki",
"can_delete", "can_delete",
"cannot_delete_reason",
"allow_badges", "allow_badges",
"topic_featured_link_allowed", "topic_featured_link_allowed",
"search_priority", "search_priority",

View File

@ -218,12 +218,6 @@
"can_delete": { "can_delete": {
"type": "boolean" "type": "boolean"
}, },
"cannot_delete_reason": {
"type": [
"string",
"null"
]
},
"allow_badges": { "allow_badges": {
"type": "boolean" "type": "boolean"
}, },
@ -290,7 +284,6 @@
"mailinglist_mirror", "mailinglist_mirror",
"all_topics_wiki", "all_topics_wiki",
"can_delete", "can_delete",
"cannot_delete_reason",
"allow_badges", "allow_badges",
"topic_featured_link_allowed", "topic_featured_link_allowed",
"search_priority", "search_priority",