summaryrefslogtreecommitdiff
path: root/spec/ruby/core/marshal/shared/load.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-24 20:59:12 -0700
committerJeremy Evans <code@jeremyevans.net>2019-11-18 01:00:25 +0200
commitffd0820ab317542f8780aac475da590a4bdbc7a8 (patch)
tree6a5d774933c15fd2b9ea948bd3ae2fa587faaf82 /spec/ruby/core/marshal/shared/load.rb
parentc5c05460ac20abcbc0ed686eb4acf06da7a39a79 (diff)
Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2476
Diffstat (limited to 'spec/ruby/core/marshal/shared/load.rb')
-rw-r--r--spec/ruby/core/marshal/shared/load.rb136
1 files changed, 69 insertions, 67 deletions
diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb
index f92d49c68c..b90a6a99ce 100644
--- a/spec/ruby/core/marshal/shared/load.rb
+++ b/spec/ruby/core/marshal/shared/load.rb
@@ -182,85 +182,87 @@ describe :marshal_load, shared: true do
end
end
- it "returns an untainted object if source is untainted" do
- x = Object.new
- y = Marshal.send(@method, Marshal.dump(x))
- y.tainted?.should be_false
- end
-
- describe "when source is tainted" do
- it "returns a tainted object" do
+ ruby_version_is ''...'2.7' do
+ it "returns an untainted object if source is untainted" do
x = Object.new
- x.taint
- s = Marshal.dump(x)
- y = Marshal.send(@method, s)
- y.tainted?.should be_true
+ y = Marshal.send(@method, Marshal.dump(x))
+ y.tainted?.should be_false
+ end
+
+ describe "when source is tainted" do
+ it "returns a tainted object" do
+ x = Object.new
+ x.taint
+ s = Marshal.dump(x)
+ y = Marshal.send(@method, s)
+ y.tainted?.should be_true
+
+ # note that round-trip via Marshal does not preserve
+ # the taintedness at each level of the nested structure
+ y = Marshal.send(@method, Marshal.dump([[x]]))
+ y.tainted?.should be_true
+ y.first.tainted?.should be_true
+ y.first.first.tainted?.should be_true
+ end
- # note that round-trip via Marshal does not preserve
- # the taintedness at each level of the nested structure
- y = Marshal.send(@method, Marshal.dump([[x]]))
- y.tainted?.should be_true
- y.first.tainted?.should be_true
- y.first.first.tainted?.should be_true
- end
+ it "does not taint Symbols" do
+ x = [:x]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
+ end
- it "does not taint Symbols" do
- x = [:x]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
- end
+ it "does not taint Fixnums" do
+ x = [1]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
+ end
- it "does not taint Fixnums" do
- x = [1]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
- end
+ it "does not taint Bignums" do
+ x = [bignum_value]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
+ end
- it "does not taint Bignums" do
- x = [bignum_value]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
+ it "does not taint Floats" do
+ x = [1.2]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
+ end
end
- it "does not taint Floats" do
- x = [1.2]
- y = Marshal.send(@method, Marshal.dump(x).taint)
+ it "preserves taintedness of nested structure" do
+ x = Object.new
+ a = [[x]]
+ x.taint
+ y = Marshal.send(@method, Marshal.dump(a))
y.tainted?.should be_true
- y.first.tainted?.should be_false
+ y.first.tainted?.should be_true
+ y.first.first.tainted?.should be_true
end
- end
- it "preserves taintedness of nested structure" do
- x = Object.new
- a = [[x]]
- x.taint
- y = Marshal.send(@method, Marshal.dump(a))
- y.tainted?.should be_true
- y.first.tainted?.should be_true
- y.first.first.tainted?.should be_true
- end
-
- it "returns a trusted object if source is trusted" do
- x = Object.new
- y = Marshal.send(@method, Marshal.dump(x))
- y.untrusted?.should be_false
- end
+ it "returns a trusted object if source is trusted" do
+ x = Object.new
+ y = Marshal.send(@method, Marshal.dump(x))
+ y.untrusted?.should be_false
+ end
- it "returns an untrusted object if source is untrusted" do
- x = Object.new
- x.untrust
- y = Marshal.send(@method, Marshal.dump(x))
- y.untrusted?.should be_true
+ it "returns an untrusted object if source is untrusted" do
+ x = Object.new
+ x.untrust
+ y = Marshal.send(@method, Marshal.dump(x))
+ y.untrusted?.should be_true
- # note that round-trip via Marshal does not preserve
- # the untrustedness at each level of the nested structure
- y = Marshal.send(@method, Marshal.dump([[x]]))
- y.untrusted?.should be_true
- y.first.untrusted?.should be_true
- y.first.first.untrusted?.should be_true
+ # note that round-trip via Marshal does not preserve
+ # the untrustedness at each level of the nested structure
+ y = Marshal.send(@method, Marshal.dump([[x]]))
+ y.untrusted?.should be_true
+ y.first.untrusted?.should be_true
+ y.first.first.untrusted?.should be_true
+ end
end
# Note: Ruby 1.9 should be compatible with older marshal format