1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Convert remaining usage of whitelist and blacklist

This commit is contained in:
Kevin Deisz 2018-08-24 16:16:41 -04:00
parent cac2bb7f44
commit 0efecd913c
No known key found for this signature in database
GPG key ID: D78C2D8FB232C59C
5 changed files with 14 additions and 14 deletions

View file

@ -86,7 +86,7 @@ module ActionController
# Note: SSEs are not currently supported by IE. However, they are supported
# by Chrome, Firefox, Opera, and Safari.
class SSE
WHITELISTED_OPTIONS = %w( retry event id )
PERMITTED_OPTIONS = %w( retry event id )
def initialize(stream, options = {})
@stream = stream
@ -111,7 +111,7 @@ module ActionController
def perform_write(json, options)
current_options = @options.merge(options).stringify_keys
WHITELISTED_OPTIONS.each do |option_name|
PERMITTED_OPTIONS.each do |option_name|
if (option_value = current_options[option_name])
@stream.write "#{option_name}: #{option_value}\n"
end

View file

@ -553,10 +553,10 @@ module ActionDispatch
#
# match 'json_only', constraints: { format: 'json' }, via: :get
#
# class Whitelist
# class PermitList
# def matches?(request) request.remote_ip == '1.2.3.4' end
# end
# match 'path', to: 'c#a', constraints: Whitelist.new, via: :get
# match 'path', to: 'c#a', constraints: PermitList.new, via: :get
#
# See <tt>Scoping#constraints</tt> for more examples with its scope
# equivalent.

View file

@ -24,16 +24,16 @@ module ActiveJob
module Arguments
extend self
# :nodoc:
TYPE_WHITELIST = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
PERMITTED_TYPES = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
# Serializes a set of arguments. Whitelisted types are returned
# Serializes a set of arguments. Permitted types are returned
# as-is. Arrays/Hashes are serialized element by element.
# All other types are serialized using GlobalID.
def serialize(arguments)
arguments.map { |argument| serialize_argument(argument) }
end
# Deserializes a set of arguments. Whitelisted types are returned
# Deserializes a set of arguments. Permitted types are returned
# as-is. Arrays/Hashes are deserialized element by element.
# All other types are deserialized using GlobalID.
def deserialize(arguments)
@ -64,7 +64,7 @@ module ActiveJob
def serialize_argument(argument)
case argument
when *TYPE_WHITELIST
when *PERMITTED_TYPES
argument
when GlobalID::Identification
convert_to_global_id_hash(argument)
@ -88,7 +88,7 @@ module ActiveJob
case argument
when String
GlobalID::Locator.locate(argument) || argument
when *TYPE_WHITELIST
when *PERMITTED_TYPES
argument
when Array
argument.map { |arg| deserialize_argument(arg) }

View file

@ -31,7 +31,7 @@ module ActiveRecord
end
}
BLACKLISTED_CLASS_METHODS = %w(private public protected allocate new name parent superclass)
RESTRICTED_CLASS_METHODS = %w(private public protected allocate new name parent superclass)
class GeneratedAttributeMethods < Module #:nodoc:
include Mutex_m
@ -123,7 +123,7 @@ module ActiveRecord
# A class method is 'dangerous' if it is already (re)defined by Active Record, but
# not by any ancestors. (So 'puts' is not dangerous but 'new' is.)
def dangerous_class_method?(method_name)
BLACKLISTED_CLASS_METHODS.include?(method_name.to_s) || class_method_defined_within?(method_name, Base)
RESTRICTED_CLASS_METHODS.include?(method_name.to_s) || class_method_defined_within?(method_name, Base)
end
def class_method_defined_within?(name, klass, superklass = klass.superclass) # :nodoc:

View file

@ -5,7 +5,7 @@ require "models/post"
require "models/comment"
module ActiveRecord
module DelegationWhitelistTests
module DelegationPermitListTests
ARRAY_DELEGATES = [
:+, :-, :|, :&, :[], :shuffle,
:all?, :collect, :compact, :detect, :each, :each_cons, :each_with_index,
@ -38,7 +38,7 @@ module ActiveRecord
end
class DelegationAssociationTest < ActiveRecord::TestCase
include DelegationWhitelistTests
include DelegationPermitListTests
include DeprecatedArelDelegationTests
def target
@ -47,7 +47,7 @@ module ActiveRecord
end
class DelegationRelationTest < ActiveRecord::TestCase
include DelegationWhitelistTests
include DelegationPermitListTests
include DeprecatedArelDelegationTests
def target