Skip to content
Snippets Groups Projects
Commit 650f3b57 authored by Luke Duncalfe's avatar Luke Duncalfe
Browse files

Rename QueryLimiting.whitelist to .disable!

Rename `QueryLimiting.whitelist` to `QueryLimiting.disable!` as
whitelist has racist connotations.

https://gitlab.com/gitlab-org/gitlab/-/issues/324285
parent 9de9e35a
No related branches found
No related tags found
No related merge requests found
Showing
with 61 additions and 57 deletions
Loading
Loading
@@ -11,7 +11,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
# https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/30233
before_action :set_application_setting, except: :integrations
 
before_action :whitelist_query_limiting, only: [:usage_data]
before_action :disable_query_limiting, only: [:usage_data]
 
before_action only: [:ci_cd] do
push_frontend_feature_flag(:ci_instance_variables_ui, default_enabled: true)
Loading
Loading
@@ -194,8 +194,8 @@ def set_application_setting
@plans = Plan.all
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/63107')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/63107')
end
 
def application_setting_params
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class Admin::ServicesController < Admin::ApplicationController
include ServiceParams
 
before_action :service, only: [:edit, :update]
before_action :whitelist_query_limiting, only: [:index]
before_action :disable_query_limiting, only: [:index]
 
feature_category :integrations
 
Loading
Loading
@@ -39,7 +39,7 @@ def service
end
# rubocop: enable CodeReuse/ActiveRecord
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/220357')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/220357')
end
end
Loading
Loading
@@ -13,7 +13,7 @@ class IssuesController < Boards::ApplicationController
 
requires_cross_project_access if: -> { board&.group_board? }
 
before_action :whitelist_query_limiting, only: [:bulk_move]
before_action :disable_query_limiting, only: [:bulk_move]
before_action :authorize_read_issue, only: [:index]
before_action :authorize_create_issue, only: [:create]
before_action :authorize_update_issue, only: [:update]
Loading
Loading
@@ -147,8 +147,8 @@ def serialize_as_json(resource, opts: {})
serializer.represent(resource, opts)
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/issues/35174')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/issues/35174')
end
 
def validate_id_list
Loading
Loading
Loading
Loading
@@ -4,7 +4,8 @@ class GraphqlController < ApplicationController
# Unauthenticated users have access to the API for public data
skip_before_action :authenticate_user!
 
WHITELIST_HEADER = 'HTTP_X_GITLAB_QUERY_WHITELIST_ISSUE'
# Header can be passed by tests to disable SQL query limits.
DISABLE_SQL_QUERY_LIMIT_HEADER = 'HTTP_X_GITLAB_DISABLE_SQL_QUERY_LIMIT'
 
# If a user is using their session to access GraphQL, we need to have session
# storage, since the admin-mode check is session wide.
Loading
Loading
@@ -23,7 +24,7 @@ class GraphqlController < ApplicationController
before_action(only: [:execute]) { authenticate_sessionless_user!(:api) }
before_action :set_user_last_activity
before_action :track_vs_code_usage
before_action :whitelist_query!
before_action :disable_query_limiting
 
# Since we deactivate authentication from the main ApplicationController and
# defer it to :authorize_access_api!, we need to override the bypass session
Loading
Loading
@@ -62,12 +63,14 @@ def execute
 
private
 
# Tests may mark some queries as exempt from query limits
def whitelist_query!
whitelist_issue = request.headers[WHITELIST_HEADER]
return unless whitelist_issue
# Tests may mark some GraphQL queries as exempt from SQL query limits
def disable_query_limiting
return unless GitLab::QueryLimiting.enabled_for_env?
 
Gitlab::QueryLimiting.whitelist(whitelist_issue)
disable_issue = request.headers[DISABLE_SQL_QUERY_LIMIT_HEADER]
return unless disable_issue
Gitlab::QueryLimiting.disable!(disable_issue)
end
 
def set_user_last_activity
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
class Import::GitlabProjectsController < Import::BaseController
include WorkhorseAuthorization
 
before_action :whitelist_query_limiting, only: [:create]
before_action :disable_query_limiting, only: [:create]
before_action :verify_gitlab_project_import_enabled
 
def new
Loading
Loading
@@ -42,8 +42,8 @@ def project_params
)
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42437')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42437')
end
 
def uploader_class
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
class Import::ManifestController < Import::BaseController
extend ::Gitlab::Utils::Override
 
before_action :whitelist_query_limiting, only: [:create]
before_action :disable_query_limiting, only: [:create]
before_action :verify_import_enabled
before_action :ensure_import_vars, only: [:create, :status]
 
Loading
Loading
@@ -115,7 +115,7 @@ def verify_import_enabled
render_404 unless manifest_import_enabled?
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/48939')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/48939')
end
end
Loading
Loading
@@ -8,7 +8,7 @@ class Projects::CommitsController < Projects::ApplicationController
 
prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) }
around_action :allow_gitaly_ref_name_caching
before_action :whitelist_query_limiting, except: :commits_root
before_action :disable_query_limiting, except: :commits_root
before_action :require_non_empty_project
before_action :assign_ref_vars, except: :commits_root
before_action :authorize_download_code!
Loading
Loading
@@ -83,7 +83,7 @@ def set_commits
@commits = set_commits_for_rendering(@commits)
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42330')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42330')
end
end
Loading
Loading
@@ -7,7 +7,7 @@ class Projects::ForksController < Projects::ApplicationController
include Gitlab::Utils::StrongMemoize
 
# Authorize
before_action :whitelist_query_limiting, only: [:create]
before_action :disable_query_limiting, only: [:create]
before_action :require_non_empty_project
before_action :authorize_download_code!
before_action :authenticate_user!, only: [:new, :create]
Loading
Loading
@@ -110,8 +110,8 @@ def authorize_fork_namespace!
access_denied! unless fork_namespace && fork_service.valid_fork_target?
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42335')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42335')
end
 
def load_namespaces_with_associations
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ class Projects::IssuesController < Projects::ApplicationController
prepend_before_action :authenticate_user!, only: [:new, :export_csv]
prepend_before_action :store_uri, only: [:new, :show, :designs]
 
before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update]
before_action :disable_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update]
before_action :check_issues_available!
before_action :issue, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) }
after_action :log_issue_show, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) }
Loading
Loading
@@ -344,13 +344,13 @@ def finder_type
IssuesFinder
end
 
def whitelist_query_limiting
def disable_query_limiting
# Also see the following issues:
#
# 1. https://gitlab.com/gitlab-org/gitlab-foss/issues/42423
# 2. https://gitlab.com/gitlab-org/gitlab-foss/issues/42424
# 3. https://gitlab.com/gitlab-org/gitlab-foss/issues/42426
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42422')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42422')
end
 
private
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
include RendersCommits
 
skip_before_action :merge_request
before_action :whitelist_query_limiting, only: [:create]
before_action :disable_query_limiting, only: [:create]
before_action :authorize_create_merge_request_from!
before_action :apply_diff_view_cookie!, only: [:diffs, :diff_for_path]
before_action :build_merge_request, except: [:create]
Loading
Loading
@@ -133,8 +133,8 @@ def selected_target_project
end
# rubocop: enable CodeReuse/ActiveRecord
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42384')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42384')
end
 
def incr_count_webide_merge_request
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
 
skip_before_action :merge_request, only: [:index, :bulk_update, :export_csv]
before_action :apply_diff_view_cookie!, only: [:show]
before_action :whitelist_query_limiting, only: [:assign_related_issues, :update]
before_action :disable_query_limiting, only: [:assign_related_issues, :update]
before_action :authorize_update_issuable!, only: [:close, :edit, :update, :remove_wip, :sort]
before_action :authorize_read_actual_head_pipeline!, only: [
:test_reports,
Loading
Loading
@@ -459,9 +459,9 @@ def merge_access_check
access_denied! unless @merge_request.can_be_merged_by?(current_user)
end
 
def whitelist_query_limiting
def disable_query_limiting
# Also see https://gitlab.com/gitlab-org/gitlab-foss/issues/42441
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42438')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42438')
end
 
def reports_response(report_comparison, pipeline = nil)
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class Projects::NetworkController < Projects::ApplicationController
include ExtractsPath
include ApplicationHelper
 
before_action :whitelist_query_limiting
before_action :disable_query_limiting
before_action :require_non_empty_project
before_action :assign_ref_vars
before_action :authorize_download_code!
Loading
Loading
@@ -42,7 +42,7 @@ def assign_commit
@commit = @repo.commit(@options[:extended_sha1])
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42333')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42333')
end
end
Loading
Loading
@@ -6,7 +6,7 @@ class Projects::NotesController < Projects::ApplicationController
include NotesHelper
include ToggleAwardEmoji
 
before_action :whitelist_query_limiting, only: [:create, :update]
before_action :disable_query_limiting, only: [:create, :update]
before_action :authorize_read_note!
before_action :authorize_create_note!, only: [:create]
before_action :authorize_resolve_note!, only: [:resolve, :unresolve]
Loading
Loading
@@ -87,7 +87,7 @@ def authorize_create_note!
access_denied! unless can?(current_user, :create_note, noteable)
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42383')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42383')
end
end
Loading
Loading
@@ -4,7 +4,7 @@ class Projects::PipelinesController < Projects::ApplicationController
include ::Gitlab::Utils::StrongMemoize
include Analytics::UniqueVisitsHelper
 
before_action :whitelist_query_limiting, only: [:create, :retry]
before_action :disable_query_limiting, only: [:create, :retry]
before_action :pipeline, except: [:index, :new, :create, :charts, :config_variables]
before_action :set_pipeline_path, only: [:show]
before_action :authorize_read_pipeline!
Loading
Loading
@@ -92,7 +92,7 @@ def create
end
 
def show
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/26657')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/26657')
 
respond_to do |format|
format.html
Loading
Loading
@@ -269,9 +269,9 @@ def latest_pipeline
&.present(current_user: current_user)
end
 
def whitelist_query_limiting
def disable_query_limiting
# Also see https://gitlab.com/gitlab-org/gitlab-foss/issues/42343
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42339')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42339')
end
 
def authorize_update_pipeline!
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ class ProjectsController < Projects::ApplicationController
 
around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
 
before_action :whitelist_query_limiting, only: [:show, :create]
before_action :disable_query_limiting, only: [:show, :create]
before_action :authenticate_user!, except: [:index, :show, :activity, :refs, :resolve, :unfoldered_environment_names]
before_action :redirect_git_extension, only: [:show]
before_action :project, except: [:index, :new, :create, :resolve]
Loading
Loading
@@ -510,8 +510,8 @@ def redirect_git_extension
redirect_to(request.original_url.sub(%r{\.git/?\Z}, ''))
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/20826')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20826')
end
 
def present_project
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ class RegistrationsController < Devise::RegistrationsController
layout 'devise'
 
prepend_before_action :check_captcha, only: :create
before_action :whitelist_query_limiting, :ensure_destroy_prerequisites_met, only: [:destroy]
before_action :disable_query_limiting, :ensure_destroy_prerequisites_met, only: [:destroy]
before_action :load_recaptcha, only: :new
before_action :set_invite_params, only: :new
 
Loading
Loading
@@ -162,8 +162,8 @@ def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
 
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42380')
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42380')
end
 
def load_recaptcha
Loading
Loading
Loading
Loading
@@ -53,7 +53,7 @@ def ready?(**args)
end
 
def resolve(board:, **args)
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/247861')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/247861')
 
raise_resource_not_available_error! unless board
authorize_board!(board)
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ module Assignable
def resolve(project_path:, iid:, assignee_usernames:, operation_mode: Types::MutationOperationModeEnum.enum[:replace])
resource = authorized_find!(project_path: project_path, iid: iid)
 
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/issues/36098') if resource.is_a?(MergeRequest)
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/issues/36098') if resource.is_a?(MergeRequest)
 
update_service_class.new(
resource.project,
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ class Move < Base
description: 'The project to move the issue to.'
 
def resolve(project_path:, iid:, target_project_path:)
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/267762')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/267762')
 
issue = authorized_find!(project_path: project_path, iid: iid)
source_project = issue.project
Loading
Loading
Loading
Loading
@@ -42,7 +42,8 @@ class Accept < Base
description: 'Squash commits on the source branch before merge.'
 
def resolve(project_path:, iid:, **args)
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42317')
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab-foss/issues/42317')
merge_request = authorized_find!(project_path: project_path, iid: iid)
project = merge_request.target_project
merge_params = args.compact.with_indifferent_access
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment