Skip to content
代码片段 群组 项目
提交 b634712f 编辑于 作者: Luke Duncalfe's avatar Luke Duncalfe
浏览文件

Improve inclusive language

Fixes some `Naming/InclusiveLanguage` offenses.
上级 c6b5dcc4
No related branches found
No related tags found
无相关合并请求
显示
46 个添加68 个删除
--- ---
Naming/InclusiveLanguage: Naming/InclusiveLanguage:
Exclude: Exclude:
- 'app/controllers/admin/application_settings/appearances_controller.rb' - 'app/controllers/concerns/requires_allowlisted_monitoring_client.rb'
- 'app/controllers/concerns/requires_whitelisted_monitoring_client.rb'
- 'app/controllers/health_check_controller.rb'
- 'app/controllers/health_controller.rb'
- 'app/controllers/metrics_controller.rb'
- 'app/helpers/application_settings_helper.rb' - 'app/helpers/application_settings_helper.rb'
- 'app/helpers/blob_helper.rb'
- 'app/helpers/markup_helper.rb' - 'app/helpers/markup_helper.rb'
- 'app/models/application_setting.rb' - 'app/models/application_setting.rb'
- 'app/models/application_setting_implementation.rb' - 'app/models/application_setting_implementation.rb'
- 'app/models/concerns/cache_markdown_field.rb' - 'app/models/concerns/cache_markdown_field.rb'
- 'app/services/application_settings/update_service.rb' - 'app/services/application_settings/update_service.rb'
- 'app/services/projects/download_service.rb'
- 'app/uploaders/avatar_uploader.rb' - 'app/uploaders/avatar_uploader.rb'
- 'app/uploaders/content_type_whitelist.rb' - 'app/uploaders/content_type_whitelist.rb'
- 'app/uploaders/design_management/design_v432x230_uploader.rb' - 'app/uploaders/design_management/design_v432x230_uploader.rb'
- 'app/uploaders/favicon_uploader.rb' - 'app/uploaders/favicon_uploader.rb'
- 'app/uploaders/gitlab_uploader.rb' - 'app/uploaders/gitlab_uploader.rb'
- 'app/uploaders/import_export_uploader.rb' - 'app/uploaders/import_export_uploader.rb'
- 'app/validators/cron_validator.rb'
- 'app/validators/qualified_domain_array_validator.rb' - 'app/validators/qualified_domain_array_validator.rb'
- 'config/initializers/1_settings.rb' - 'config/initializers/1_settings.rb'
- 'config/initializers/doorkeeper.rb' - 'config/initializers/doorkeeper.rb'
...@@ -28,14 +21,12 @@ Naming/InclusiveLanguage: ...@@ -28,14 +21,12 @@ Naming/InclusiveLanguage:
- 'ee/app/controllers/projects/push_rules_controller.rb' - 'ee/app/controllers/projects/push_rules_controller.rb'
- 'ee/lib/arkose/verify_response.rb' - 'ee/lib/arkose/verify_response.rb'
- 'ee/lib/system_check/geo/http_connection_check.rb' - 'ee/lib/system_check/geo/http_connection_check.rb'
- 'ee/spec/models/dora/lead_time_for_changes_metric_spec.rb'
- 'lib/api/entities/application_setting.rb' - 'lib/api/entities/application_setting.rb'
- 'lib/api/settings.rb' - 'lib/api/settings.rb'
- 'lib/banzai/filter/asset_proxy_filter.rb' - 'lib/banzai/filter/asset_proxy_filter.rb'
- 'lib/gitlab/asset_proxy.rb' - 'lib/gitlab/asset_proxy.rb'
- 'lib/gitlab/auth/ip_rate_limiter.rb' - 'lib/gitlab/auth/ip_rate_limiter.rb'
- 'lib/gitlab/ci/config/external/file/base.rb' - 'lib/gitlab/ci/config/external/file/base.rb'
- 'lib/gitlab/git/hook_env.rb'
- 'lib/gitlab/github_import/markdown/attachment.rb' - 'lib/gitlab/github_import/markdown/attachment.rb'
- 'lib/gitlab/markdown_cache/active_record/extension.rb' - 'lib/gitlab/markdown_cache/active_record/extension.rb'
- 'lib/gitlab/markdown_cache/field_data.rb' - 'lib/gitlab/markdown_cache/field_data.rb'
...@@ -44,9 +35,6 @@ Naming/InclusiveLanguage: ...@@ -44,9 +35,6 @@ Naming/InclusiveLanguage:
- 'lib/gitlab/sanitizers/svg.rb' - 'lib/gitlab/sanitizers/svg.rb'
- 'lib/gitlab/sanitizers/svg/whitelist.rb' - 'lib/gitlab/sanitizers/svg/whitelist.rb'
- 'lib/system_check/app/git_user_default_ssh_config_check.rb' - 'lib/system_check/app/git_user_default_ssh_config_check.rb'
- 'rubocop/cop/avoid_return_from_blocks.rb'
- 'rubocop/cop/graphql/id_type.rb'
- 'spec/controllers/concerns/issuable_collections_spec.rb'
- 'spec/controllers/health_check_controller_spec.rb' - 'spec/controllers/health_check_controller_spec.rb'
- 'spec/controllers/metrics_controller_spec.rb' - 'spec/controllers/metrics_controller_spec.rb'
- 'spec/helpers/markup_helper_spec.rb' - 'spec/helpers/markup_helper_spec.rb'
...@@ -61,17 +49,7 @@ Naming/InclusiveLanguage: ...@@ -61,17 +49,7 @@ Naming/InclusiveLanguage:
- 'spec/models/application_setting_spec.rb' - 'spec/models/application_setting_spec.rb'
- 'spec/requests/api/settings_spec.rb' - 'spec/requests/api/settings_spec.rb'
- 'spec/requests/health_controller_spec.rb' - 'spec/requests/health_controller_spec.rb'
- 'spec/rubocop/cop/avoid_return_from_blocks_spec.rb'
- 'spec/rubocop/cop/graphql/id_type_spec.rb'
- 'spec/services/application_settings/update_service_spec.rb' - 'spec/services/application_settings/update_service_spec.rb'
- 'spec/services/design_management/generate_image_versions_service_spec.rb'
- 'spec/services/projects/download_service_spec.rb'
- 'spec/support/import_export/export_file_helper.rb'
- 'spec/support/shared_contexts/upload_type_check_shared_context.rb' - 'spec/support/shared_contexts/upload_type_check_shared_context.rb'
- 'spec/support/shared_examples/lib/banzai/filters/sanitization_filter_shared_examples.rb'
- 'spec/support/shared_examples/models/application_setting_shared_examples.rb' - 'spec/support/shared_examples/models/application_setting_shared_examples.rb'
- 'spec/uploaders/avatar_uploader_spec.rb'
- 'spec/uploaders/content_type_whitelist_spec.rb' - 'spec/uploaders/content_type_whitelist_spec.rb'
- 'spec/uploaders/design_management/design_v432x230_uploader_spec.rb'
- 'spec/uploaders/favicon_uploader_spec.rb'
- 'spec/validators/cron_validator_spec.rb'
...@@ -69,7 +69,7 @@ def set_appearance ...@@ -69,7 +69,7 @@ def set_appearance
@appearance = Appearance.current || Appearance.new @appearance = Appearance.current || Appearance.new
end end
# Only allow a trusted parameter "white list" through. # Only allow a trusted parameter "allow list" through.
def appearance_params def appearance_params
params.require(:appearance).permit(allowed_appearance_params) params.require(:appearance).permit(allowed_appearance_params)
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module RequiresWhitelistedMonitoringClient module RequiresAllowlistedMonitoringClient
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
before_action :validate_ip_whitelisted_or_valid_token! before_action :validate_ip_allowlisted_or_valid_token!
end end
private private
def validate_ip_whitelisted_or_valid_token! def validate_ip_allowlisted_or_valid_token!
render_404 unless client_ip_whitelisted? || valid_token? render_404 unless client_ip_allowlisted? || valid_token?
end end
def client_ip_whitelisted? def client_ip_allowlisted?
# Always allow developers to access http://localhost:3000/-/metrics for # Always allow developers to access http://localhost:3000/-/metrics for
# debugging purposes # debugging purposes
return true if Rails.env.development? && request.local? return true if Rails.env.development? && request.local?
ip_whitelist.any? { |e| e.include?(Gitlab::RequestContext.instance.client_ip) } ip_allowlist.any? { |e| e.include?(Gitlab::RequestContext.instance.client_ip) }
end end
def ip_whitelist def ip_allowlist
@ip_whitelist ||= Settings.monitoring.ip_whitelist.map { |ip| IPAddr.new(ip) } @ip_allowlist ||= Settings.monitoring.ip_whitelist.map { |ip| IPAddr.new(ip) }
end end
def valid_token? def valid_token?
......
# frozen_string_literal: true # frozen_string_literal: true
class HealthCheckController < HealthCheck::HealthCheckController class HealthCheckController < HealthCheck::HealthCheckController
include RequiresWhitelistedMonitoringClient include RequiresAllowlistedMonitoringClient
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# rubocop:disable Rails/ApplicationController # rubocop:disable Rails/ApplicationController
class HealthController < ActionController::Base class HealthController < ActionController::Base
protect_from_forgery with: :exception, prepend: true protect_from_forgery with: :exception, prepend: true
include RequiresWhitelistedMonitoringClient include RequiresAllowlistedMonitoringClient
CHECKS = [ CHECKS = [
Gitlab::HealthChecks::MasterCheck Gitlab::HealthChecks::MasterCheck
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# rubocop:disable Rails/ApplicationController # rubocop:disable Rails/ApplicationController
class MetricsController < ActionController::Base class MetricsController < ActionController::Base
include RequiresWhitelistedMonitoringClient include RequiresAllowlistedMonitoringClient
protect_from_forgery with: :exception, prepend: true protect_from_forgery with: :exception, prepend: true
......
...@@ -118,8 +118,8 @@ def parent_dir_raw_path ...@@ -118,8 +118,8 @@ def parent_dir_raw_path
"#{blob_raw_path.rpartition('/').first}/" "#{blob_raw_path.rpartition('/').first}/"
end end
# SVGs can contain malicious JavaScript; only include whitelisted # SVGs can contain malicious JavaScript; only include allowlisted
# elements and attributes. Note that this whitelist is by no means complete # elements and attributes. Note that this allowlist is by no means complete
# and may omit some elements. # and may omit some elements.
def sanitize_svg_data(data) def sanitize_svg_data(data)
Gitlab::Sanitizers::SVG.clean(data) Gitlab::Sanitizers::SVG.clean(data)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Projects module Projects
class DownloadService < BaseService class DownloadService < BaseService
WHITELIST = [ ALLOWLIST = [
/^[^.]+\.fogbugz.com$/ /^[^.]+\.fogbugz.com$/
].freeze ].freeze
...@@ -33,7 +33,7 @@ def http?(url) ...@@ -33,7 +33,7 @@ def http?(url)
def valid_domain?(url) def valid_domain?(url)
host = URI.parse(url).host host = URI.parse(url).host
WHITELIST.any? { |entry| entry === host } ALLOWLIST.any? { |entry| entry === host }
end end
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
class CronValidator < ActiveModel::EachValidator class CronValidator < ActiveModel::EachValidator
ATTRIBUTE_WHITELIST = %i[cron freeze_start freeze_end].freeze ATTRIBUTE_ALLOWLIST = %i[cron freeze_start freeze_end].freeze
NonWhitelistedAttributeError = Class.new(StandardError) NonAllowlistedAttributeError = Class.new(StandardError)
def validate_each(record, attribute, value) def validate_each(record, attribute, value)
if ATTRIBUTE_WHITELIST.include?(attribute) if ATTRIBUTE_ALLOWLIST.include?(attribute)
cron_parser = Gitlab::Ci::CronParser.new(record.public_send(attribute), record.cron_timezone) # rubocop:disable GitlabSecurity/PublicSend cron_parser = Gitlab::Ci::CronParser.new(record.public_send(attribute), record.cron_timezone) # rubocop:disable GitlabSecurity/PublicSend
record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_valid? record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_valid?
else else
raise NonWhitelistedAttributeError, "Non-whitelisted attribute" raise NonAllowlistedAttributeError, "Non-allowlisted attribute"
end end
end end
end end
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
create :dora_configuration, project: project, branches_for_lead_time_for_changes: %w[main staging] create :dora_configuration, project: project, branches_for_lead_time_for_changes: %w[main staging]
end end
it 'returns median of time between merge and deployment for MRs with target branch from configuration whitelist' do it 'returns median of time between merge and deployment for MRs with target branch from configuration allowlist' do
expect(query_result).to eql 3.days.to_f expect(query_result).to eql 3.days.to_f
end end
end end
......
...@@ -14,7 +14,7 @@ module Git ...@@ -14,7 +14,7 @@ module Git
# #
# This class is thread-safe via RequestStore. # This class is thread-safe via RequestStore.
class HookEnv class HookEnv
WHITELISTED_VARIABLES = %w[ ALLOWLISTED_VARIABLES = %w[
GIT_OBJECT_DIRECTORY_RELATIVE GIT_OBJECT_DIRECTORY_RELATIVE
GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE
].freeze ].freeze
...@@ -25,7 +25,7 @@ def self.set(gl_repository, env) ...@@ -25,7 +25,7 @@ def self.set(gl_repository, env)
raise "missing gl_repository" if gl_repository.blank? raise "missing gl_repository" if gl_repository.blank?
Gitlab::SafeRequestStore[:gitlab_git_env] ||= {} Gitlab::SafeRequestStore[:gitlab_git_env] ||= {}
Gitlab::SafeRequestStore[:gitlab_git_env][gl_repository] = whitelist_git_env(env) Gitlab::SafeRequestStore[:gitlab_git_env][gl_repository] = allowlist_git_env(env)
end end
def self.all(gl_repository) def self.all(gl_repository)
...@@ -46,8 +46,8 @@ def self.to_env_hash(gl_repository) ...@@ -46,8 +46,8 @@ def self.to_env_hash(gl_repository)
env env
end end
def self.whitelist_git_env(env) def self.allowlist_git_env(env)
env.select { |key, _| WHITELISTED_VARIABLES.include?(key.to_s) }.with_indifferent_access env.select { |key, _| ALLOWLISTED_VARIABLES.include?(key.to_s) }.with_indifferent_access
end end
end end
end end
......
...@@ -23,7 +23,7 @@ module Cop ...@@ -23,7 +23,7 @@ module Cop
class AvoidReturnFromBlocks < RuboCop::Cop::Base class AvoidReturnFromBlocks < RuboCop::Cop::Base
MSG = 'Do not return from a block, use next or break instead.' MSG = 'Do not return from a block, use next or break instead.'
DEF_METHODS = %i[define_method lambda].freeze DEF_METHODS = %i[define_method lambda].freeze
WHITELISTED_METHODS = %i[each each_filename times loop].freeze ALLOWLISTED_METHODS = %i[each each_filename times loop].freeze
def on_block(node) def on_block(node)
block_body = node.body block_body = node.body
...@@ -32,7 +32,7 @@ def on_block(node) ...@@ -32,7 +32,7 @@ def on_block(node)
return unless top_block?(node) return unless top_block?(node)
block_body.each_node(:return) do |return_node| block_body.each_node(:return) do |return_node|
next if parent_blocks(node, return_node).all? { |block_node| whitelisted?(block_node) } next if parent_blocks(node, return_node).all? { |block_node| allowlisted?(block_node) }
add_offense(return_node) add_offense(return_node)
end end
...@@ -69,8 +69,8 @@ def def?(node) ...@@ -69,8 +69,8 @@ def def?(node)
(node.type == :block && DEF_METHODS.include?(node.method_name)) (node.type == :block && DEF_METHODS.include?(node.method_name))
end end
def whitelisted?(block_node) def allowlisted?(block_node)
WHITELISTED_METHODS.include?(block_node.method_name) ALLOWLISTED_METHODS.include?(block_node.method_name)
end end
end end
end end
......
...@@ -6,7 +6,7 @@ module Graphql ...@@ -6,7 +6,7 @@ module Graphql
class IDType < RuboCop::Cop::Base class IDType < RuboCop::Cop::Base
MSG = 'Do not use GraphQL::Types::ID, use a specific GlobalIDType instead' MSG = 'Do not use GraphQL::Types::ID, use a specific GlobalIDType instead'
WHITELISTED_ARGUMENTS = %i[iid full_path project_path group_path target_project_path namespace_path].freeze ALLOWLISTED_ARGUMENTS = %i[iid full_path project_path group_path target_project_path namespace_path].freeze
def_node_search :graphql_id_type?, <<~PATTERN def_node_search :graphql_id_type?, <<~PATTERN
(send nil? :argument (_ #does_not_match?) (const (const (const nil? :GraphQL) :Types) :ID) ...) (send nil? :argument (_ #does_not_match?) (const (const (const nil? :GraphQL) :Types) :ID) ...)
...@@ -21,7 +21,7 @@ def on_send(node) ...@@ -21,7 +21,7 @@ def on_send(node)
private private
def does_not_match?(arg) def does_not_match?(arg)
!WHITELISTED_ARGUMENTS.include?(arg) # rubocop:disable Rails/NegateInclude !ALLOWLISTED_ARGUMENTS.include?(arg) # rubocop:disable Rails/NegateInclude
end end
end end
end end
......
...@@ -92,7 +92,7 @@ def finder_type ...@@ -92,7 +92,7 @@ def finder_type
} }
end end
it 'only allows whitelisted params' do it 'only allows allowlisted params' do
is_expected.to include({ is_expected.to include({
'assignee_id' => '1', 'assignee_id' => '1',
'assignee_username' => 'user1', 'assignee_username' => 'user1',
...@@ -123,7 +123,7 @@ def finder_type ...@@ -123,7 +123,7 @@ def finder_type
} }
end end
it 'only allows whitelisted params' do it 'only allows allowlisted params' do
is_expected.to include({ is_expected.to include({
'label_name' => %w[label1 label2], 'label_name' => %w[label1 label2],
'assignee_username' => %w[user1 user2] 'assignee_username' => %w[user1 user2]
......
...@@ -41,10 +41,10 @@ def a_method ...@@ -41,10 +41,10 @@ def a_method
RUBY RUBY
end end
shared_examples 'examples with whitelisted method' do |whitelisted_method| shared_examples 'examples with allowlisted method' do |allowlisted_method|
it "doesn't flag violation for return inside #{whitelisted_method}" do it "doesn't flag violation for return inside #{allowlisted_method}" do
expect_no_offenses(<<~RUBY) expect_no_offenses(<<~RUBY)
items.#{whitelisted_method} do |item| items.#{allowlisted_method} do |item|
do_something do_something
return if something_else return if something_else
end end
...@@ -52,8 +52,8 @@ def a_method ...@@ -52,8 +52,8 @@ def a_method
end end
end end
%i[each each_filename times loop].each do |whitelisted_method| %i[each each_filename times loop].each do |allowlisted_method|
it_behaves_like 'examples with whitelisted method', whitelisted_method it_behaves_like 'examples with allowlisted method', allowlisted_method
end end
shared_examples 'examples with def methods' do |def_method| shared_examples 'examples with def methods' do |def_method|
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
TYPE TYPE
end end
context 'whitelisted arguments' do context 'allowlisted arguments' do
RuboCop::Cop::Graphql::IDType::WHITELISTED_ARGUMENTS.each do |arg| RuboCop::Cop::Graphql::IDType::ALLOWLISTED_ARGUMENTS.each do |arg|
it "does not add an offense for calls to #argument with #{arg} as argument name" do it "does not add an offense for calls to #argument with #{arg} as argument name" do
expect_no_offenses(<<~TYPE.strip) expect_no_offenses(<<~TYPE.strip)
argument #{arg}, GraphQL::Types::ID, some: other, params: do_not_matter argument #{arg}, GraphQL::Types::ID, some: other, params: do_not_matter
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
.from(nil).to(CarrierWave::SanitizedFile) .from(nil).to(CarrierWave::SanitizedFile)
end end
it 'skips generating image versions if the mime type is not whitelisted' do it 'skips generating image versions if the mime type is not allowlisted' do
stub_const('DesignManagement::DesignV432x230Uploader::MIME_TYPE_ALLOWLIST', []) stub_const('DesignManagement::DesignV432x230Uploader::MIME_TYPE_ALLOWLIST', [])
described_class.new(version).execute described_class.new(version).execute
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
@project = create(:project, creator_id: @user.id, namespace: @user.namespace) @project = create(:project, creator_id: @user.id, namespace: @user.namespace)
end end
context 'for a URL that is not on whitelist' do context 'for a URL that is not on allowlist' do
before do before do
url = 'https://code.jquery.com/jquery-2.1.4.min.js' url = 'https://code.jquery.com/jquery-2.1.4.min.js'
@link_to_file = download_file(@project, url) @link_to_file = download_file(@project, url)
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
it { expect(@link_to_file).to eq(nil) } it { expect(@link_to_file).to eq(nil) }
end end
context 'for URLs that are on the whitelist' do context 'for URLs that are on the allowlist' do
before do before do
# `ssrf_filter` resolves the hostname. See https://github.com/carrierwaveuploader/carrierwave/commit/91714adda998bc9e8decf5b1f5d260d808761304 # `ssrf_filter` resolves the hostname. See https://github.com/carrierwaveuploader/carrierwave/commit/91714adda998bc9e8decf5b1f5d260d808761304
stub_request(:get, %r{http://[\d.]+/rails_sample.jpg}).to_return(body: File.read(Rails.root + 'spec/fixtures/rails_sample.jpg')) stub_request(:get, %r{http://[\d.]+/rails_sample.jpg}).to_return(body: File.read(Rails.root + 'spec/fixtures/rails_sample.jpg'))
......
...@@ -92,7 +92,7 @@ def object_contains_key?(object, sensitive_key_word) ...@@ -92,7 +92,7 @@ def object_contains_key?(object, sensitive_key_word)
end end
# Returns the offended ObjectWithParent object if a sensitive word is found inside a hash, # Returns the offended ObjectWithParent object if a sensitive word is found inside a hash,
# excluding the whitelisted safe hashes. # excluding the allowlisted safe hashes.
def find_sensitive_attributes(sensitive_word, project_hash) def find_sensitive_attributes(sensitive_word, project_hash)
loop do loop do
object_with_parent = deep_find_with_parent(sensitive_word, project_hash) object_with_parent = deep_find_with_parent(sensitive_word, project_hash)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
expect(filter(act).to_html).to eq exp expect(filter(act).to_html).to eq exp
end end
it 'allows whitelisted HTML tags from the user' do it 'allows allowlisted HTML tags from the user' do
exp = act = "<dl>\n<dt>Term</dt>\n<dd>Definition</dd>\n</dl>" exp = act = "<dl>\n<dt>Term</dt>\n<dd>Definition</dd>\n</dl>"
expect(filter(act).to_html).to eq exp expect(filter(act).to_html).to eq exp
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册