summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-30 12:22:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-30 12:22:09 +0000
commiteba52140851d2fb08665119c0a3997d0612ccb88 (patch)
tree4bc562fadc518009435642e0bd265c8fb5bdc5a5 /app
parent2da7c8579601c14a93d4291b8cf5fa39c6eeabd8 (diff)
downloadgitlab-ce-eba52140851d2fb08665119c0a3997d0612ccb88.tar.gz
Add latest changes from gitlab-org/security/gitlab@14-2-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/helpers/integrations_helper.rb2
-rw-r--r--app/models/design_management/design.rb2
-rw-r--r--app/models/integrations/datadog.rb9
-rw-r--r--app/services/groups/destroy_service.rb35
4 files changed, 29 insertions, 19 deletions
diff --git a/app/helpers/integrations_helper.rb b/app/helpers/integrations_helper.rb
index f15566a551a..904508867d3 100644
--- a/app/helpers/integrations_helper.rb
+++ b/app/helpers/integrations_helper.rb
@@ -137,7 +137,7 @@ module IntegrationsHelper
def jira_issue_breadcrumb_link(issue_reference)
link_to '', { class: 'gl-display-flex gl-align-items-center gl-white-space-nowrap' } do
icon = image_tag image_path('illustrations/logos/jira.svg'), width: 15, height: 15, class: 'gl-mr-2'
- [icon, issue_reference].join.html_safe
+ [icon, html_escape(issue_reference)].join.html_safe
end
end
diff --git a/app/models/design_management/design.rb b/app/models/design_management/design.rb
index 79f5a63bcb6..feb1bf5438c 100644
--- a/app/models/design_management/design.rb
+++ b/app/models/design_management/design.rb
@@ -169,7 +169,7 @@ module DesignManagement
@link_reference_pattern ||= begin
path_segment = %r{issues/#{Gitlab::Regex.issue}/designs}
ext = Regexp.new(Regexp.union(SAFE_IMAGE_EXT + DANGEROUS_IMAGE_EXT).source, Regexp::IGNORECASE)
- valid_char = %r{[^/\s]} # any char that is not a forward slash or whitespace
+ valid_char = %r{[[:word:]\.\-\+]}
filename_pattern = %r{
(?<url_filename> #{valid_char}+ \. #{ext})
}x
diff --git a/app/models/integrations/datadog.rb b/app/models/integrations/datadog.rb
index 5516e6bc2c0..6422f6bddab 100644
--- a/app/models/integrations/datadog.rb
+++ b/app/models/integrations/datadog.rb
@@ -8,7 +8,6 @@ module Integrations
DEFAULT_DOMAIN = 'datadoghq.com'
URL_TEMPLATE = 'https://webhooks-http-intake.logs.%{datadog_domain}/api/v2/webhook'
- URL_TEMPLATE_API_KEYS = 'https://app.%{datadog_domain}/account/settings#api'
URL_API_KEYS_DOCS = "https://docs.#{DEFAULT_DOMAIN}/account_management/api-app-keys/"
SUPPORTED_EVENTS = %w[
@@ -90,7 +89,7 @@ module Integrations
help: ERB::Util.html_escape(
s_('DatadogIntegration|%{linkOpen}API key%{linkClose} used for authentication with Datadog.')
) % {
- linkOpen: '<a href="%s" target="_blank" rel="noopener noreferrer">'.html_safe % api_keys_url,
+ linkOpen: %Q{<a href="#{URL_API_KEYS_DOCS}" target="_blank" rel="noopener noreferrer">}.html_safe,
linkClose: '</a>'.html_safe
},
required: true
@@ -132,12 +131,6 @@ module Integrations
url.to_s
end
- def api_keys_url
- return URL_API_KEYS_DOCS unless datadog_site.presence
-
- sprintf(URL_TEMPLATE_API_KEYS, datadog_domain: datadog_domain)
- end
-
def execute(data)
object_kind = data[:object_kind]
object_kind = 'job' if object_kind == 'build'
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb
index 08c4e0231e7..5ffa746e109 100644
--- a/app/services/groups/destroy_service.rb
+++ b/app/services/groups/destroy_service.rb
@@ -29,14 +29,7 @@ module Groups
group.chat_team&.remove_mattermost_team(current_user)
- # If any other groups are shared with the group that is being destroyed,
- # we should specifically trigger update of all project authorizations
- # for users that are the direct members of this group.
- # If not, the project authorization records of these users to projects within the shared groups
- # will never be removed, causing inconsistencies with access permissions.
- if any_other_groups_are_shared_with_this_group?
- user_ids_for_project_authorizations_refresh = group.users_ids_of_direct_members
- end
+ user_ids_for_project_authorizations_refresh = obtain_user_ids_for_project_authorizations_refresh
group.destroy
@@ -52,9 +45,33 @@ module Groups
private
- def any_other_groups_are_shared_with_this_group?
+ def any_groups_shared_with_this_group?
group.shared_group_links.any?
end
+
+ def any_projects_shared_with_this_group?
+ group.project_group_links.any?
+ end
+
+ # Destroying a group automatically destroys all project authorizations directly
+ # associated with the group and descendents. However, project authorizations
+ # for projects and groups this group is shared with are not. Without a manual
+ # refresh, the project authorization records of these users to shared projects
+ # and projects within the shared groups will never be removed, causing
+ # inconsistencies with access permissions.
+ #
+ # This method retrieves the user IDs that need to be refreshed. If only
+ # groups are shared with this group, only direct members need to be refreshed.
+ # If projects are also shared with the group, direct members *and* shared
+ # members of other groups need to be refreshed.
+ # `Group#user_ids_for_project_authorizations` returns both direct and shared
+ # members' user IDs.
+ def obtain_user_ids_for_project_authorizations_refresh
+ return unless any_projects_shared_with_this_group? || any_groups_shared_with_this_group?
+ return group.user_ids_for_project_authorizations if any_projects_shared_with_this_group?
+
+ group.users_ids_of_direct_members
+ end
end
end