Skip to content

Commit 4262179

Browse files
committed
Call inspect on ids in RecordNotFound error
[CVE-2025-55193]
1 parent 63e8efe commit 4262179

File tree

1 file changed

+17
-17
lines changed
  • activerecord/lib/active_record

1 file changed

+17
-17
lines changed

activerecord/lib/active_record/base.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def initialize(errors)
392392
# So it's possible to assign a logger to the class through <tt>Base.logger=</tt> which will then be used by all
393393
# instances in the current object space.
394394
class Base
395-
##
395+
##
396396
# :singleton-method:
397397
# Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed
398398
# on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+.
@@ -426,11 +426,11 @@ def self.reset_subclasses #:nodoc:
426426
# as a Hash.
427427
#
428428
# For example, the following database.yml...
429-
#
429+
#
430430
# development:
431431
# adapter: sqlite3
432432
# database: db/development.sqlite3
433-
#
433+
#
434434
# production:
435435
# adapter: sqlite3
436436
# database: db/production.sqlite3
@@ -1411,7 +1411,7 @@ def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodo
14111411
def self_and_descendants_from_active_record#nodoc:
14121412
klass = self
14131413
classes = [klass]
1414-
while klass != klass.base_class
1414+
while klass != klass.base_class
14151415
classes << klass = klass.superclass
14161416
end
14171417
classes
@@ -1652,7 +1652,7 @@ def find_one(id, options)
16521652
if result = find_every(options).first
16531653
result
16541654
else
1655-
raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}"
1655+
raise RecordNotFound, "Couldn't find #{name} with ID=#{id.inspect}#{conditions}"
16561656
end
16571657
end
16581658

@@ -1679,7 +1679,7 @@ def find_some(ids, options)
16791679
if result.size == expected_size
16801680
result
16811681
else
1682-
raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})"
1682+
raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list.inspect})#{conditions} (found #{result.size} results, but was looking for #{expected_size})"
16831683
end
16841684
end
16851685

@@ -2027,7 +2027,7 @@ def self.#{method_id}(*args) # def self.scoped_by_user_na
20272027
attributes = construct_attributes_from_arguments( # attributes = construct_attributes_from_arguments(
20282028
[:#{attribute_names.join(',:')}], args # [:user_name, :password], args
20292029
) # )
2030-
#
2030+
#
20312031
scoped(:conditions => attributes) # scoped(:conditions => attributes)
20322032
end # end
20332033
EOS
@@ -2582,7 +2582,7 @@ def id
25822582
# name
25832583
# end
25842584
# end
2585-
#
2585+
#
25862586
# user = User.find_by_name('Phusion')
25872587
# user_path(user) # => "/users/Phusion"
25882588
def to_param
@@ -2637,12 +2637,12 @@ def new_record?
26372637
# If +perform_validation+ is true validations run. If any of them fail
26382638
# the action is cancelled and +save+ returns +false+. If the flag is
26392639
# false validations are bypassed altogether. See
2640-
# ActiveRecord::Validations for more information.
2640+
# ActiveRecord::Validations for more information.
26412641
#
26422642
# There's a series of callbacks associated with +save+. If any of the
26432643
# <tt>before_*</tt> callbacks return +false+ the action is cancelled and
26442644
# +save+ returns +false+. See ActiveRecord::Callbacks for further
2645-
# details.
2645+
# details.
26462646
def save
26472647
create_or_update
26482648
end
@@ -2654,12 +2654,12 @@ def save
26542654
#
26552655
# With <tt>save!</tt> validations always run. If any of them fail
26562656
# ActiveRecord::RecordInvalid gets raised. See ActiveRecord::Validations
2657-
# for more information.
2657+
# for more information.
26582658
#
26592659
# There's a series of callbacks associated with <tt>save!</tt>. If any of
26602660
# the <tt>before_*</tt> callbacks return +false+ the action is cancelled
26612661
# and <tt>save!</tt> raises ActiveRecord::RecordNotSaved. See
2662-
# ActiveRecord::Callbacks for further details.
2662+
# ActiveRecord::Callbacks for further details.
26632663
def save!
26642664
create_or_update || raise(RecordNotSaved)
26652665
end
@@ -2840,12 +2840,12 @@ def []=(attr_name, value)
28402840
# class User < ActiveRecord::Base
28412841
# attr_protected :is_admin
28422842
# end
2843-
#
2843+
#
28442844
# user = User.new
28452845
# user.attributes = { :username => 'Phusion', :is_admin => true }
28462846
# user.username # => "Phusion"
28472847
# user.is_admin? # => false
2848-
#
2848+
#
28492849
# user.send(:attributes=, { :username => 'Phusion', :is_admin => true }, false)
28502850
# user.is_admin? # => true
28512851
def attributes=(new_attributes, guard_protected_attributes = true)
@@ -2980,7 +2980,7 @@ def inspect
29802980

29812981
def assign_attributes(attributes={})
29822982
multiparameter_attributes = []
2983-
2983+
29842984
attributes.each do |k, v|
29852985
if k.to_s.include?("(")
29862986
multiparameter_attributes << [ k, v ]
@@ -2990,9 +2990,9 @@ def assign_attributes(attributes={})
29902990
end
29912991
end
29922992

2993-
assign_multiparameter_attributes(multiparameter_attributes) unless multiparameter_attributes.empty?
2993+
assign_multiparameter_attributes(multiparameter_attributes) unless multiparameter_attributes.empty?
29942994
end
2995-
2995+
29962996
def create_or_update
29972997
raise ReadOnlyRecord if readonly?
29982998
result = new_record? ? create : update

0 commit comments

Comments
 (0)