Skip to content

Commit f05ac78

Browse files
committed
Merge branch '6-1-sec' into 6-1-stable
* 6-1-sec: Preparing for 6.1.6.1 release updating version and changelog Change ActiveRecord::Coders::YAMLColumn default to safe_load Preparing for 6.1.6 release
2 parents d571efb + dc1242f commit f05ac78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+938
-524
lines changed

RAILS_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.1.6
1+
6.1.6.1

actioncable/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

actioncable/lib/action_cable/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

actioncable/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rails/actioncable",
3-
"version": "6.1.6",
3+
"version": "6.1.6-1",
44
"description": "WebSocket framework for Ruby on Rails.",
55
"main": "app/assets/javascripts/action_cable.js",
66
"files": [

actionmailbox/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

actionmailbox/lib/action_mailbox/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

actionmailer/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

actionmailer/lib/action_mailer/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

actionpack/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

actionpack/lib/action_pack/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

actiontext/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

actiontext/lib/action_text/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

actiontext/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rails/actiontext",
3-
"version": "6.1.6",
3+
"version": "6.1.6-1",
44
"description": "Edit and display rich text in Rails applications",
55
"main": "app/javascript/actiontext/index.js",
66
"files": [

actionview/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

actionview/lib/action_view/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

actionview/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rails/ujs",
3-
"version": "6.1.6",
3+
"version": "6.1.6-1",
44
"description": "Ruby on Rails unobtrusive scripting adapter",
55
"main": "lib/assets/compiled/rails-ujs.js",
66
"files": [

activejob/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

activejob/lib/active_job/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

activemodel/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Rails 6.1.6.1 (July 12, 2022) ##
2+
3+
* No changes.
4+
5+
16
## Rails 6.1.6 (May 09, 2022) ##
27

38
* No changes.

activemodel/lib/active_model/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

activerecord/CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@
44

55
*Nikita Vasilevsky*
66

7+
## Rails 6.1.6.1 (July 12, 2022) ##
8+
9+
* Change ActiveRecord::Coders::YAMLColumn default to safe_load
10+
11+
This adds two new configuration options The configuration options are as
12+
follows:
13+
14+
* `config.active_storage.use_yaml_unsafe_load`
15+
16+
When set to true, this configuration option tells Rails to use the old
17+
"unsafe" YAML loading strategy, maintaining the existing behavior but leaving
18+
the possible escalation vulnerability in place. Setting this option to true
19+
is *not* recommended, but can aid in upgrading.
20+
21+
* `config.active_record.yaml_column_permitted_classes`
22+
23+
The "safe YAML" loading method does not allow all classes to be deserialized
24+
by default. This option allows you to specify classes deemed "safe" in your
25+
application. For example, if your application uses Symbol and Time in
26+
serialized data, you can add Symbol and Time to the allowed list as follows:
27+
28+
```
29+
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
30+
```
31+
32+
[CVE-2022-32224]
33+
34+
735
## Rails 6.1.6 (May 09, 2022) ##
836
937
* No changes.

activerecord/lib/active_record/coders/yaml_column.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ def check_arity_of_constructor
4545
raise ArgumentError, "Cannot serialize #{object_class}. Classes passed to `serialize` must have a 0 argument constructor."
4646
end
4747

48-
if YAML.respond_to?(:unsafe_load)
49-
def yaml_load(payload)
50-
YAML.unsafe_load(payload)
51-
end
52-
else
53-
def yaml_load(payload)
54-
YAML.load(payload)
48+
def yaml_load(payload)
49+
if !ActiveRecord::Base.use_yaml_unsafe_load
50+
YAML.safe_load(payload, permitted_classes: ActiveRecord::Base.yaml_column_permitted_classes, aliases: true)
51+
else
52+
if YAML.respond_to?(:unsafe_load)
53+
YAML.unsafe_load(payload)
54+
else
55+
YAML.load(payload)
56+
end
5557
end
5658
end
5759
end

activerecord/lib/active_record/core.rb

+8
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ def self.configurations
155155

156156
mattr_accessor :legacy_connection_handling, instance_writer: false, default: true
157157

158+
# Application configurable boolean that instructs the YAML Coder to use
159+
# an unsafe load if set to true.
160+
mattr_accessor :use_yaml_unsafe_load, instance_writer: false, default: false
161+
162+
# Application configurable array that provides additional permitted classes
163+
# to Psych safe_load in the YAML Coder
164+
mattr_accessor :yaml_column_permitted_classes, instance_writer: false, default: []
165+
158166
self.filter_attributes = []
159167

160168
def self.connection_handler

activerecord/lib/active_record/gem_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module VERSION
1010
MAJOR = 6
1111
MINOR = 1
1212
TINY = 6
13-
PRE = nil
13+
PRE = "1"
1414

1515
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
1616
end

activerecord/lib/active_record/railtie.rb

+18
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,23 @@ class Railtie < Rails::Railtie # :nodoc:
279279
self.signed_id_verifier_secret ||= -> { Rails.application.key_generator.generate_key("active_record/signed_id") }
280280
end
281281
end
282+
283+
initializer "active_record.use_yaml_unsafe_load" do |app|
284+
config.after_initialize do
285+
unless app.config.active_record.use_yaml_unsafe_load.nil?
286+
ActiveRecord::Base.use_yaml_unsafe_load =
287+
app.config.active_record.use_yaml_unsafe_load
288+
end
289+
end
290+
end
291+
292+
initializer "active_record.yaml_column_permitted_classes" do |app|
293+
config.after_initialize do
294+
unless app.config.active_record.yaml_column_permitted_classes.nil?
295+
ActiveRecord::Base.yaml_column_permitted_classes =
296+
app.config.active_record.yaml_column_permitted_classes
297+
end
298+
end
299+
end
282300
end
283301
end

activerecord/test/cases/attribute_methods_test.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def setup
4646

4747
test "attribute_for_inspect with an array" do
4848
t = topics(:first)
49-
t.content = [Object.new]
49+
t.content = ["some_value"]
5050

51-
assert_match %r(\[#<Object:0x[0-9a-f]+>\]), t.attribute_for_inspect(:content)
51+
assert_match %r(\[\"some_value\"\]), t.attribute_for_inspect(:content)
5252
end
5353

5454
test "attribute_for_inspect with a long array" do
@@ -279,16 +279,16 @@ def setup
279279
end
280280

281281
test "hashes are not mangled" do
282-
new_topic = { title: "New Topic", content: { key: "First value" } }
283-
new_topic_values = { title: "AnotherTopic", content: { key: "Second value" } }
282+
new_topic = { "title" => "New Topic", "content" => { "key" => "First value" } }
283+
new_topic_values = { "title" => "AnotherTopic", "content" => { "key" => "Second value" } }
284284

285285
topic = Topic.new(new_topic)
286-
assert_equal new_topic[:title], topic.title
287-
assert_equal new_topic[:content], topic.content
286+
assert_equal new_topic["title"], topic.title
287+
assert_equal new_topic["content"], topic.content
288288

289289
topic.attributes = new_topic_values
290-
assert_equal new_topic_values[:title], topic.title
291-
assert_equal new_topic_values[:content], topic.content
290+
assert_equal new_topic_values["title"], topic.title
291+
assert_equal new_topic_values["content"], topic.content
292292
end
293293

294294
test "create through factory" do
@@ -602,7 +602,7 @@ def topic.title() "b" end
602602
end
603603

604604
test "should unserialize attributes for frozen records" do
605-
myobj = { value1: :value2 }
605+
myobj = { "value1" => "value2" }
606606
topic = Topic.create(content: myobj)
607607
topic.freeze
608608
assert_equal myobj, topic.content

activerecord/test/cases/base_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_deprecated_arel_attribute_on_relation
108108

109109
def test_incomplete_schema_loading
110110
topic = Topic.first
111-
payload = { foo: 42 }
111+
payload = { "foo" => 42 }
112112
topic.update!(content: payload)
113113

114114
Topic.reset_column_information

activerecord/test/cases/calculations_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ def test_pluck_on_aliased_attribute
809809
end
810810

811811
def test_pluck_with_serialization
812-
t = Topic.create!(content: { foo: :bar })
813-
assert_equal [{ foo: :bar }], Topic.where(id: t.id).pluck(:content)
812+
t = Topic.create!(content: { "foo" => "bar" })
813+
assert_equal [{ "foo" => "bar" }], Topic.where(id: t.id).pluck(:content)
814814
end
815815

816816
def test_pluck_with_qualified_column_name

activerecord/test/cases/coders/yaml_column_test.rb

+34
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
module ActiveRecord
66
module Coders
77
class YAMLColumnTest < ActiveRecord::TestCase
8+
setup do
9+
ActiveRecord::Base.use_yaml_unsafe_load = true
10+
end
11+
812
def test_initialize_takes_class
913
coder = YAMLColumn.new("attr_name", Object)
1014
assert_equal Object, coder.object_class
@@ -62,5 +66,35 @@ def test_load_doesnt_handle_undefined_class_or_module
6266
end
6367
end
6468
end
69+
70+
class YAMLColumnTestWithSafeLoad < YAMLColumnTest
71+
setup do
72+
@yaml_column_permitted_classes_default = ActiveRecord::Base.yaml_column_permitted_classes
73+
ActiveRecord::Base.use_yaml_unsafe_load = false
74+
end
75+
76+
def test_yaml_column_permitted_classes_are_consumed_by_safe_load
77+
ActiveRecord::Base.yaml_column_permitted_classes = [Symbol, Time]
78+
79+
coder = YAMLColumn.new("attr_name")
80+
time_yaml = YAML.dump(Time.new)
81+
symbol_yaml = YAML.dump(:somesymbol)
82+
83+
assert_nothing_raised do
84+
coder.load(time_yaml)
85+
coder.load(symbol_yaml)
86+
end
87+
88+
ActiveRecord::Base.yaml_column_permitted_classes = @yaml_column_permitted_classes_default
89+
end
90+
91+
def test_load_doesnt_handle_undefined_class_or_module
92+
coder = YAMLColumn.new("attr_name")
93+
missing_class_yaml = '--- !ruby/object:DoesNotExistAndShouldntEver {}\n'
94+
assert_raises(Psych::DisallowedClass) do
95+
coder.load(missing_class_yaml)
96+
end
97+
end
98+
end
6599
end
66100
end

0 commit comments

Comments
 (0)