summaryrefslogtreecommitdiff
path: root/test/ruby
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 /test/ruby
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 'test/ruby')
-rw-r--r--test/ruby/test_array.rb68
-rw-r--r--test/ruby/test_econv.rb1
-rw-r--r--test/ruby/test_encoding.rb3
-rw-r--r--test/ruby/test_env.rb7
-rw-r--r--test/ruby/test_exception.rb22
-rw-r--r--test/ruby/test_file.rb20
-rw-r--r--test/ruby/test_file_exhaustive.rb44
-rw-r--r--test/ruby/test_hash.rb62
-rw-r--r--test/ruby/test_io.rb7
-rw-r--r--test/ruby/test_m17n.rb15
-rw-r--r--test/ruby/test_marshal.rb70
-rw-r--r--test/ruby/test_method.rb3
-rw-r--r--test/ruby/test_object.rb48
-rw-r--r--test/ruby/test_pack.rb16
-rw-r--r--test/ruby/test_proc.rb3
-rw-r--r--test/ruby/test_range.rb10
-rw-r--r--test/ruby/test_refinement.rb1
-rw-r--r--test/ruby/test_require.rb25
-rw-r--r--test/ruby/test_rubyoptions.rb7
-rw-r--r--test/ruby/test_signal.rb5
-rw-r--r--test/ruby/test_string.rb79
-rw-r--r--test/ruby/test_symbol.rb8
-rw-r--r--test/ruby/test_trace.rb11
23 files changed, 51 insertions, 484 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 6d730db4ae..476cf795f0 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -556,18 +556,14 @@ class TestArray < Test::Unit::TestCase
end
def test_clone
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = @cls[*(0..99).to_a]
- a.taint if taint
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert_not_equal(a.__id__, b.__id__)
- assert_equal(a.frozen?, b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
+ for frozen in [ false, true ]
+ a = @cls[*(0..99).to_a]
+ a.freeze if frozen
+ b = a.clone
+
+ assert_equal(a, b)
+ assert_not_equal(a.__id__, b.__id__)
+ assert_equal(a.frozen?, b.frozen?)
end
end
@@ -754,18 +750,14 @@ class TestArray < Test::Unit::TestCase
end
def test_dup
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = @cls[*(0..99).to_a]
- a.taint if taint
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert_not_equal(a.__id__, b.__id__)
- assert_equal(false, b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
+ for frozen in [ false, true ]
+ a = @cls[*(0..99).to_a]
+ a.freeze if frozen
+ b = a.dup
+
+ assert_equal(a, b)
+ assert_not_equal(a.__id__, b.__id__)
+ assert_equal(false, b.frozen?)
end
end
@@ -865,13 +857,6 @@ class TestArray < Test::Unit::TestCase
assert_raise(TypeError, "[ruby-dev:31197]") { [[]].flatten("") }
end
- def test_flatten_taint
- a6 = @cls[[1, 2], 3]
- a6.taint
- a7 = a6.flatten
- assert_equal(true, a7.tainted?)
- end
-
def test_flatten_level0
a8 = @cls[[1, 2], 3]
a9 = a8.flatten(0)
@@ -1132,20 +1117,6 @@ class TestArray < Test::Unit::TestCase
assert_equal("1,2,3", a.join(','))
$, = ""
- a = @cls[1, 2, 3]
- a.taint
- s = a.join
- assert_equal(true, s.tainted?)
-
- bug5902 = '[ruby-core:42161]'
- sep = ":".taint
-
- s = @cls[].join(sep)
- assert_equal(false, s.tainted?, bug5902)
- s = @cls[1].join(sep)
- assert_equal(false, s.tainted?, bug5902)
- s = @cls[1, 2].join(sep)
- assert_equal(true, s.tainted?, bug5902)
e = ''.force_encoding('EUC-JP')
u = ''.force_encoding('UTF-8')
@@ -2899,13 +2870,6 @@ class TestArray < Test::Unit::TestCase
assert_equal(Array2, Array2[*(1..100)][1..99].class) #not embedded
end
- def test_inspect
- a = @cls[1, 2, 3]
- a.taint
- s = a.inspect
- assert_equal(true, s.tainted?)
- end
-
def test_initialize2
a = [1] * 1000
a.instance_eval { initialize }
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index 115ff73ea8..a469614d84 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -685,7 +685,6 @@ class TestEncodingConverter < Test::Unit::TestCase
ec = Encoding::Converter.new("utf-8", "euc-jp")
assert_raise(Encoding::InvalidByteSequenceError) { ec.convert("a\x80") }
assert_raise(Encoding::UndefinedConversionError) { ec.convert("\ufffd") }
- assert_predicate(ec.convert("abc".taint), :tainted?)
ret = ec.primitive_convert(nil, "", nil, nil)
assert_equal(:finished, ret)
assert_raise(ArgumentError) { ec.convert("a") }
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb
index a088fe1aa4..40fd302c07 100644
--- a/test/ruby/test_encoding.rb
+++ b/test/ruby/test_encoding.rb
@@ -34,9 +34,6 @@ class TestEncoding < Test::Unit::TestCase
assert_raise(TypeError) { e.dup }
assert_raise(TypeError) { e.clone }
assert_equal(e.object_id, Marshal.load(Marshal.dump(e)).object_id)
- assert_not_predicate(e, :tainted?)
- Marshal.load(Marshal.dump(e).taint)
- assert_not_predicate(e, :tainted?, '[ruby-core:71793] [Bug #11760]')
end
end
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index b01c3b12ee..d9301ff76c 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -46,7 +46,6 @@ class TestEnv < Test::Unit::TestCase
end
ENV['TEST'] = 'bar'
assert_equal('bar', ENV['TEST'])
- assert_predicate(ENV['TEST'], :tainted?)
if IGNORE_CASE
assert_equal('bar', ENV['test'])
else
@@ -113,7 +112,6 @@ class TestEnv < Test::Unit::TestCase
assert_invalid_env {|v| ENV[v]}
ENV[PATH_ENV] = ""
assert_equal("", ENV[PATH_ENV])
- assert_predicate(ENV[PATH_ENV], :tainted?)
assert_nil(ENV[""])
end
@@ -136,7 +134,6 @@ class TestEnv < Test::Unit::TestCase
assert_nothing_raised { ENV.fetch(PATH_ENV, "foo") }
ENV[PATH_ENV] = ""
assert_equal("", ENV.fetch(PATH_ENV))
- assert_predicate(ENV.fetch(PATH_ENV), :tainted?)
end
def test_aset
@@ -154,9 +151,6 @@ class TestEnv < Test::Unit::TestCase
assert_equal("test", ENV["foo"])
rescue Errno::EINVAL
end
-
- ENV[PATH_ENV] = "/tmp/".taint
- assert_equal("/tmp/", ENV[PATH_ENV])
end
def test_keys
@@ -364,7 +358,6 @@ class TestEnv < Test::Unit::TestCase
assert_equal("foo", v)
end
assert_invalid_env {|var| ENV.assoc(var)}
- assert_predicate(v, :tainted?)
assert_equal(Encoding.find("locale"), v.encoding)
end
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 442a36b2fd..05cc109b48 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -550,28 +550,6 @@ end.join
end
end
- def test_to_s_taintness_propagation
- for exc in [Exception, NameError]
- m = "abcdefg"
- e = exc.new(m)
- e.taint
- s = e.to_s
- assert_equal(false, m.tainted?,
- "#{exc}#to_s should not propagate taintness")
- assert_equal(false, s.tainted?,
- "#{exc}#to_s should not propagate taintness")
- end
-
- o = Object.new
- def o.to_str
- "foo"
- end
- o.taint
- e = NameError.new(o)
- s = e.to_s
- assert_equal(false, s.tainted?)
- end
-
def m
m(&->{return 0})
42
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 5599040e1e..9153298fd0 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -287,26 +287,6 @@ class TestFile < Test::Unit::TestCase
}
end
- def test_realpath_taintedness
- Dir.mktmpdir('rubytest-realpath') {|tmpdir|
- dir = File.realpath(tmpdir).untaint
- File.write(File.join(dir, base = "test.file"), '')
- base.taint
- dir.taint
- assert_predicate(File.realpath(base, dir), :tainted?)
- base.untaint
- dir.taint
- assert_predicate(File.realpath(base, dir), :tainted?)
- base.taint
- dir.untaint
- assert_predicate(File.realpath(base, dir), :tainted?)
- base.untaint
- dir.untaint
- assert_predicate(File.realpath(base, dir), :tainted?)
- assert_predicate(Dir.chdir(dir) {File.realpath(base)}, :tainted?)
- }
- end
-
def test_realpath_special_symlink
IO.pipe do |r, w|
if File.pipe?(path = "/dev/fd/#{r.fileno}")
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 4bb5479303..b96b727349 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -187,24 +187,6 @@ class TestFileExhaustive < Test::Unit::TestCase
end
end
- def test_path_taint
- [regular_file, utf8_file].each do |file|
- file.untaint
- assert_equal(false, File.open(file) {|f| f.path}.tainted?)
- assert_equal(true, File.open(file.dup.taint) {|f| f.path}.tainted?)
- o = Object.new
- class << o; self; end.class_eval do
- define_method(:to_path) { file }
- end
- assert_equal(false, File.open(o) {|f| f.path}.tainted?)
- class << o; self; end.class_eval do
- remove_method(:to_path)
- define_method(:to_path) { file.dup.taint }
- end
- assert_equal(true, File.open(o) {|f| f.path}.tainted?)
- end
- end
-
def assert_integer(n)
assert_kind_of(Integer, n)
end
@@ -1077,32 +1059,6 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo'))
end
- def test_expand_path_returns_tainted_strings_or_not
- assert_equal(true, File.expand_path('foo').tainted?)
- assert_equal(true, File.expand_path('foo'.taint).tainted?)
- assert_equal(true, File.expand_path('/foo'.taint).tainted?)
- assert_equal(true, File.expand_path('foo', 'bar').tainted?)
- assert_equal(true, File.expand_path('foo', '/bar'.taint).tainted?)
- assert_equal(true, File.expand_path('foo'.taint, '/bar').tainted?)
- assert_equal(true, File.expand_path('~').tainted?) if ENV["HOME"]
-
- if DRIVE
- assert_equal(true, File.expand_path('/foo').tainted?)
- assert_equal(false, File.expand_path('//foo').tainted?)
- assert_equal(true, File.expand_path('C:/foo'.taint).tainted?)
- assert_equal(false, File.expand_path('C:/foo').tainted?)
- assert_equal(true, File.expand_path('foo', '/bar').tainted?)
- assert_equal(true, File.expand_path('foo', 'C:/bar'.taint).tainted?)
- assert_equal(true, File.expand_path('foo'.taint, 'C:/bar').tainted?)
- assert_equal(false, File.expand_path('foo', 'C:/bar').tainted?)
- assert_equal(false, File.expand_path('C:/foo/../bar').tainted?)
- assert_equal(false, File.expand_path('foo', '//bar').tainted?)
- else
- assert_equal(false, File.expand_path('/foo').tainted?)
- assert_equal(false, File.expand_path('foo', '/bar').tainted?)
- end
- end
-
def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_home_as_base
old_home = ENV["HOME"]
home = ENV["HOME"] = "#{DRIVE}/UserHome"
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 8f6d782af4..ccc3355930 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -320,17 +320,6 @@ class TestHash < Test::Unit::TestCase
assert_same "ABC".freeze, c.keys[0]
end
- def test_tainted_string_key
- str = 'str'.taint
- h = {}
- h[str] = nil
- key = h.keys.first
- assert_predicate str, :tainted?
- assert_not_predicate str, :frozen?
- assert_predicate key, :tainted?
- assert_predicate key, :frozen?
- end
-
def test_EQUAL # '=='
h1 = @cls[ "a" => 1, "c" => 2 ]
h2 = @cls[ "a" => 1, "c" => 2, 7 => 35 ]
@@ -353,18 +342,14 @@ class TestHash < Test::Unit::TestCase
end
def test_clone
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = @h.clone
- a.taint if taint
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_equal(a.frozen?, b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
+ for frozen in [ false, true ]
+ a = @h.clone
+ a.freeze if frozen
+ b = a.clone
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_equal(a.frozen?, b.frozen?)
end
end
@@ -451,18 +436,14 @@ class TestHash < Test::Unit::TestCase
end
def test_dup
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = @h.dup
- a.taint if taint
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_equal(false, b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
+ for frozen in [ false, true ]
+ a = @h.dup
+ a.freeze if frozen
+ b = a.dup
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_equal(false, b.frozen?)
end
end
@@ -712,10 +693,8 @@ class TestHash < Test::Unit::TestCase
h.instance_variable_set(:@foo, :foo)
h.default = 42
- h.taint
h = EnvUtil.suppress_warning {h.reject {false}}
assert_instance_of(Hash, h)
- assert_not_predicate(h, :tainted?)
assert_nil(h.default)
assert_not_send([h, :instance_variable_defined?, :@foo])
end
@@ -840,11 +819,6 @@ class TestHash < Test::Unit::TestCase
assert_equal([3,4], a.delete([3,4]))
assert_equal([5,6], a.delete([5,6]))
assert_equal(0, a.length)
-
- h = @cls[ 1=>2, 3=>4, 5=>6 ]
- h.taint
- a = h.to_a
- assert_equal(true, a.tainted?)
end
def test_to_hash
@@ -1037,10 +1011,8 @@ class TestHash < Test::Unit::TestCase
h.instance_variable_set(:@foo, :foo)
h.default = 42
- h.taint
h = h.select {true}
assert_instance_of(Hash, h)
- assert_not_predicate(h, :tainted?)
assert_nil(h.default)
assert_not_send([h, :instance_variable_defined?, :@foo])
end
@@ -1083,10 +1055,8 @@ class TestHash < Test::Unit::TestCase
h.instance_variable_set(:@foo, :foo)
h.default = 42
- h.taint
h = h.filter {true}
assert_instance_of(Hash, h)
- assert_not_predicate(h, :tainted?)
assert_nil(h.default)
assert_not_send([h, :instance_variable_defined?, :@foo])
end
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index cabcc652c1..f3b08154c8 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2768,13 +2768,6 @@ class TestIO < Test::Unit::TestCase
}
end if /freebsd|linux/ =~ RUBY_PLATFORM and defined? File::NOFOLLOW
- def test_tainted
- make_tempfile {|t|
- assert_predicate(File.read(t.path, 4), :tainted?, '[ruby-dev:38826]')
- assert_predicate(File.open(t.path) {|f| f.read(4)}, :tainted?, '[ruby-dev:38826]')
- }
- end
-
def test_binmode_after_closed
make_tempfile {|t|
assert_raise(IOError) {t.binmode}
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 44f3cc97a9..6c7d0e6bae 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1582,8 +1582,6 @@ class TestM17N < Test::Unit::TestCase
s = "\u3042"
assert_equal(a("\xE3\x81\x82"), s.b)
assert_equal(Encoding::ASCII_8BIT, s.b.encoding)
- s.taint
- assert_predicate(s.b, :tainted?)
s = "abc".b
assert_predicate(s.b, :ascii_only?)
end
@@ -1592,16 +1590,13 @@ class TestM17N < Test::Unit::TestCase
str = "foo"
assert_equal(str, str.scrub)
assert_not_same(str, str.scrub)
- assert_predicate(str.dup.taint.scrub, :tainted?)
str = "\u3042\u3044"
assert_equal(str, str.scrub)
assert_not_same(str, str.scrub)
- assert_predicate(str.dup.taint.scrub, :tainted?)
str.force_encoding(Encoding::ISO_2022_JP) # dummy encoding
assert_equal(str, str.scrub)
assert_not_same(str, str.scrub)
assert_nothing_raised(ArgumentError) {str.scrub(nil)}
- assert_predicate(str.dup.taint.scrub, :tainted?)
end
def test_scrub_modification_inside_block
@@ -1620,8 +1615,6 @@ class TestM17N < Test::Unit::TestCase
def test_scrub_replace_default
assert_equal("\uFFFD\uFFFD\uFFFD", u("\x80\x80\x80").scrub)
assert_equal("\uFFFDA", u("\xF4\x80\x80A").scrub)
- assert_predicate(u("\x80\x80\x80").taint.scrub, :tainted?)
- assert_predicate(u("\xF4\x80\x80A").taint.scrub, :tainted?)
# examples in Unicode 6.1.0 D93b
assert_equal("\x41\uFFFD\uFFFD\x41\uFFFD\x41",
@@ -1636,14 +1629,8 @@ class TestM17N < Test::Unit::TestCase
def test_scrub_replace_argument
assert_equal("foo", u("foo").scrub("\u3013"))
- assert_predicate(u("foo").taint.scrub("\u3013"), :tainted?)
- assert_not_predicate(u("foo").scrub("\u3013".taint), :tainted?)
assert_equal("\u3042\u3044", u("\xE3\x81\x82\xE3\x81\x84").scrub("\u3013"))
- assert_predicate(u("\xE3\x81\x82\xE3\x81\x84").taint.scrub("\u3013"), :tainted?)
- assert_not_predicate(u("\xE3\x81\x82\xE3\x81\x84").scrub("\u3013".taint), :tainted?)
assert_equal("\u3042\u3013", u("\xE3\x81\x82\xE3\x81").scrub("\u3013"))
- assert_predicate(u("\xE3\x81\x82\xE3\x81").taint.scrub("\u3013"), :tainted?)
- assert_predicate(u("\xE3\x81\x82\xE3\x81").scrub("\u3013".taint), :tainted?)
assert_raise(Encoding::CompatibilityError){ u("\xE3\x81\x82\xE3\x81").scrub(e("\xA4\xA2")) }
assert_raise(TypeError){ u("\xE3\x81\x82\xE3\x81").scrub(1) }
assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub(u("\x81")) }
@@ -1652,8 +1639,6 @@ class TestM17N < Test::Unit::TestCase
def test_scrub_replace_block
assert_equal("\u3042<e381>", u("\xE3\x81\x82\xE3\x81").scrub{|x|'<'+x.unpack('H*')[0]+'>'})
- assert_predicate(u("\xE3\x81\x82\xE3\x81").taint.scrub{|x|'<'+x.unpack('H*')[0]+'>'}, :tainted?)
- assert_predicate(u("\xE3\x81\x82\xE3\x81").scrub{|x|('<'+x.unpack('H*')[0]+'>').taint}, :tainted?)
assert_raise(Encoding::CompatibilityError){ u("\xE3\x81\x82\xE3\x81").scrub{e("\xA4\xA2")} }
assert_raise(TypeError){ u("\xE3\x81\x82\xE3\x81").scrub{1} }
assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} }
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index f6d84d181a..f300710d2c 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -189,57 +189,6 @@ class TestMarshal < Test::Unit::TestCase
end
end
- def test_taint
- x = Object.new
- x.taint
- s = Marshal.dump(x)
- assert_equal(true, s.tainted?)
- y = Marshal.load(s)
- assert_equal(true, y.tainted?)
- end
-
- def test_taint_each_object
- x = Object.new
- obj = [[x]]
-
- # clean object causes crean stream
- assert_equal(false, obj.tainted?)
- assert_equal(false, obj.first.tainted?)
- assert_equal(false, obj.first.first.tainted?)
- s = Marshal.dump(obj)
- assert_equal(false, s.tainted?)
-
- # tainted object causes tainted stream
- x.taint
- assert_equal(false, obj.tainted?)
- assert_equal(false, obj.first.tainted?)
- assert_equal(true, obj.first.first.tainted?)
- t = Marshal.dump(obj)
- assert_equal(true, t.tainted?)
-
- # clean stream causes clean objects
- assert_equal(false, s.tainted?)
- y = Marshal.load(s)
- assert_equal(false, y.tainted?)
- assert_equal(false, y.first.tainted?)
- assert_equal(false, y.first.first.tainted?)
-
- # tainted stream causes tainted objects
- assert_equal(true, t.tainted?)
- y = Marshal.load(t)
- assert_equal(true, y.tainted?)
- assert_equal(true, y.first.tainted?)
- assert_equal(true, y.first.first.tainted?)
-
- # same tests by different senario
- s.taint
- assert_equal(true, s.tainted?)
- y = Marshal.load(s)
- assert_equal(true, y.tainted?)
- assert_equal(true, y.first.tainted?)
- assert_equal(true, y.first.first.tainted?)
- end
-
def test_symbol2
[:ruby, :"\u{7d05}\u{7389}"].each do |sym|
assert_equal(sym, Marshal.load(Marshal.dump(sym)), '[ruby-core:24788]')
@@ -499,16 +448,6 @@ class TestMarshal < Test::Unit::TestCase
module TestModule
end
- def test_marshal_load_should_not_taint_classes
- bug7325 = '[ruby-core:49198]'
- for c in [TestClass, TestModule]
- assert_not_predicate(c, :tainted?)
- c2 = Marshal.load(Marshal.dump(c).taint)
- assert_same(c, c2)
- assert_not_predicate(c, :tainted?, bug7325)
- end
- end
-
class Bug7627 < Struct.new(:bar)
attr_accessor :foo
@@ -620,15 +559,6 @@ class TestMarshal < Test::Unit::TestCase
assert_equal(Marshal.dump(bare), Marshal.dump(packed))
end
- def test_untainted_numeric
- bug8945 = '[ruby-core:57346] [Bug #8945] Numerics never be tainted'
- b = RbConfig::LIMITS['FIXNUM_MAX'] + 1
- tainted = [0, 1.0, 1.72723e-77, b].select do |x|
- Marshal.load(Marshal.dump(x).taint).tainted?
- end
- assert_empty(tainted.map {|x| [x, x.class]}, bug8945)
- end
-
class Bug9523
attr_reader :cc
def marshal_dump
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index afab7eb900..3942e047e8 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -456,9 +456,6 @@ class TestMethod < Test::Unit::TestCase
c3.class_eval { alias bar foo }
m3 = c3.new.method(:bar)
assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo) #{__FILE__}:#{line_no}>", m3.inspect, bug7806)
-
- m.taint
- assert_predicate(m.inspect, :tainted?, "inspect result should be infected")
end
def test_callee_top_level
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 013b3f01f5..add5b9fb15 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -96,17 +96,6 @@ class TestObject < Test::Unit::TestCase
assert_raise(TypeError) { 1.kind_of?(1) }
end
- def test_taint_frozen_obj
- o = Object.new
- o.freeze
- assert_raise(FrozenError) { o.taint }
-
- o = Object.new
- o.taint
- o.freeze
- assert_raise(FrozenError) { o.untaint }
- end
-
def test_freeze_immediate
assert_equal(true, 1.frozen?)
1.freeze
@@ -794,36 +783,7 @@ class TestObject < Test::Unit::TestCase
end
end
- def test_untrusted
- verbose = $VERBOSE
- $VERBOSE = false
- begin
- obj = Object.new
- assert_equal(false, obj.untrusted?)
- assert_equal(false, obj.tainted?)
- obj.untrust
- assert_equal(true, obj.untrusted?)
- assert_equal(true, obj.tainted?)
- obj.trust
- assert_equal(false, obj.untrusted?)
- assert_equal(false, obj.tainted?)
- obj.taint
- assert_equal(true, obj.untrusted?)
- assert_equal(true, obj.tainted?)
- obj.untaint
- assert_equal(false, obj.untrusted?)
- assert_equal(false, obj.tainted?)
- ensure
- $VERBOSE = verbose
- end
- end
-
def test_to_s
- x = Object.new
- x.taint
- s = x.to_s
- assert_equal(true, s.tainted?)
-
x = eval(<<-EOS)
class ToS\u{3042}
new.to_s
@@ -832,14 +792,10 @@ class TestObject < Test::Unit::TestCase
assert_match(/\bToS\u{3042}:/, x)
name = "X".freeze
- x = Object.new.taint
+ x = Object.new
class<<x;self;end.class_eval {define_method(:to_s) {name}}
assert_same(name, x.to_s)
- assert_not_predicate(name, :tainted?)
- assert_raise(FrozenError) {name.taint}
assert_equal("X", [x].join(""))
- assert_not_predicate(name, :tainted?)
- assert_not_predicate(eval('"X".freeze'), :tainted?)
end
def test_inspect
@@ -953,7 +909,7 @@ class TestObject < Test::Unit::TestCase
assert_nothing_raised("copy") {a.instance_eval {initialize_copy(b)}}
c = a.dup.freeze
assert_raise(FrozenError, "frozen") {c.instance_eval {initialize_copy(b)}}
- d = a.dup.trust
+ d = a.dup
[a, b, c, d]
end
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 658208d9df..60edd00186 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -869,20 +869,4 @@ EXPECTED
assert_equal "hogefuga", "aG9nZWZ1Z2E=".unpack1("m")
assert_equal "01000001", "A".unpack1("B*")
end
-
- def test_pack_infection
- tainted_array_string = ["123456"]
- tainted_array_string.first.taint
- ['a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm', 'P', 'p'].each do |f|
- assert_predicate(tainted_array_string.pack(f), :tainted?)
- end
- end
-
- def test_unpack_infection
- tainted_string = "123456"
- tainted_string.taint
- ['a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm'].each do |f|
- assert_predicate(tainted_string.unpack(f).first, :tainted?)
- end
- end
end
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 0e0b5c7b8b..ea3fe823f0 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -1158,9 +1158,6 @@ class TestProc < Test::Unit::TestCase
assert_match(/^#<Proc:0x\h+ #{ Regexp.quote(__FILE__) }:\d+>$/, proc {}.to_s)
assert_match(/^#<Proc:0x\h+ #{ Regexp.quote(__FILE__) }:\d+ \(lambda\)>$/, lambda {}.to_s)
assert_match(/^#<Proc:0x\h+ \(lambda\)>$/, method(:p).to_proc.to_s)
- x = proc {}
- x.taint
- assert_predicate(x.to_s, :tainted?)
name = "Proc\u{1f37b}"
assert_include(EnvUtil.labeled_class(name, Proc).new {}.to_s, name)
end
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index 0dee88e7f9..4df14539a9 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -499,11 +499,6 @@ class TestRange < Test::Unit::TestCase
assert_equal("0...1", (0...1).to_s)
assert_equal("0..", (0..nil).to_s)
assert_equal("0...", (0...nil).to_s)
-
- bug11767 = '[ruby-core:71811] [Bug #11767]'
- assert_predicate(("0".taint.."1").to_s, :tainted?, bug11767)
- assert_predicate(("0".."1".taint).to_s, :tainted?, bug11767)
- assert_predicate(("0".."1").taint.to_s, :tainted?, bug11767)
end
def test_inspect
@@ -515,11 +510,6 @@ class TestRange < Test::Unit::TestCase
assert_equal("...1", (nil...1).inspect)
assert_equal("nil..nil", (nil..nil).inspect)
assert_equal("nil...nil", (nil...nil).inspect)
-
- bug11767 = '[ruby-core:71811] [Bug #11767]'
- assert_predicate(("0".taint.."1").inspect, :tainted?, bug11767)
- assert_predicate(("0".."1".taint).inspect, :tainted?, bug11767)
- assert_predicate(("0".."1").taint.inspect, :tainted?, bug11767)
end
def test_eqq
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 34451de482..9d8bb92648 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -2064,7 +2064,6 @@ class TestRefinement < Test::Unit::TestCase
def test_tostring
assert_equal("ok", ToString.new.string)
- assert_predicate(ToString.new.taint.string, :tainted?)
end
class ToSymbol
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index e21ed88e47..e310ac7c70 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -379,31 +379,6 @@ class TestRequire < Test::Unit::TestCase
end
end
- def test_tainted_loadpath
- Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
- abs_dir, file = File.split(t.path)
- abs_dir = File.expand_path(abs_dir).untaint
-
- assert_separately([], <<-INPUT)
- abs_dir = "#{ abs_dir }"
- $: << abs_dir
- assert_nothing_raised {require "#{ file }"}
- INPUT
-
- assert_separately([], <<-INPUT)
- abs_dir = "#{ abs_dir }"
- $: << abs_dir.taint
- assert_nothing_raised {require "#{ file }"}
- INPUT
-
- assert_separately([], <<-INPUT)
- abs_dir = "#{ abs_dir }"
- $: << abs_dir << 'elsewhere'.taint
- assert_nothing_raised {require "#{ file }"}
- INPUT
- }
- end
-
def test_relative
load_path = $:.dup
$:.delete(".")
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 27a9434a5c..10d54550c1 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -1043,13 +1043,6 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err([IO::NULL], success: true)
end
- def test_argv_tainted
- assert_separately(%w[- arg], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- assert_predicate(ARGV[0], :tainted?, '[ruby-dev:50596] [Bug #14941]')
- end;
- end
-
private
def mjit_force_enabled?
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index 48cb60cb77..a62537d59d 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -137,11 +137,6 @@ class TestSignal < Test::Unit::TestCase
assert_raise(ArgumentError) { Signal.trap }
- assert_raise(SecurityError) do
- s = proc {}.taint
- Signal.trap(:INT, s)
- end
-
# FIXME!
Signal.trap(:INT, nil)
Signal.trap(:INT, "")
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 41d4871379..a86e26c774 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -607,18 +607,14 @@ CODE
end
def test_clone
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = S("Cool")
- a.taint if taint
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_equal(a.frozen?, b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
+ for frozen in [ false, true ]
+ a = S("Cool")
+ a.freeze if frozen
+ b = a.clone
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_equal(a.frozen?, b.frozen?)
end
assert_equal("", File.read(IO::NULL).clone, '[ruby-dev:32819] reported by Kazuhiro NISHIYAMA')
@@ -851,18 +847,14 @@ CODE
end
def test_dup
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = S("hello")
- a.taint if taint
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_not_predicate(b, :frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
+ for frozen in [ false, true ]
+ a = S("hello")
+ a.freeze if frozen
+ b = a.dup
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_not_predicate(b, :frozen?)
end
end
@@ -1005,7 +997,6 @@ CODE
].each do |g|
assert_equal [g], g.each_grapheme_cluster.to_a
assert_equal 1, g.each_grapheme_cluster.size
- assert_predicate g.dup.taint.each_grapheme_cluster.to_a[0], :tainted?
end
[
@@ -1015,9 +1006,6 @@ CODE
].each do |str, grapheme_clusters|
assert_equal grapheme_clusters, str.each_grapheme_cluster.to_a
assert_equal grapheme_clusters.size, str.each_grapheme_cluster.size
- str.dup.taint.each_grapheme_cluster do |g|
- assert_predicate g, :tainted?
- end
end
s = ("x"+"\u{10ABCD}"*250000)
@@ -1039,7 +1027,6 @@ CODE
].product([Encoding::UTF_8, *WIDE_ENCODINGS]) do |g, enc|
g = g.encode(enc)
assert_equal [g], g.grapheme_clusters
- assert_predicate g.taint.grapheme_clusters[0], :tainted?
end
[
@@ -1057,14 +1044,13 @@ CODE
assert_equal ["A", "B", "C"], "ABC".grapheme_clusters {}
}
else
- s = "ABC".b.taint
+ s = "ABC".b
res = []
assert_same s, s.grapheme_clusters {|x| res << x }
assert_equal(3, res.size)
assert_equal("A", res[0])
assert_equal("B", res[1])
assert_equal("C", res[2])
- res.each {|g| assert_predicate(g, :tainted?)}
end
end
@@ -1213,10 +1199,6 @@ CODE
S("hello").gsub(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 })
assert_equal(S("<>h<>e<>l<>l<>o<>"), S("hello").gsub(S(''), S('<\0>')))
- a = S("hello")
- a.taint
- assert_predicate(a.gsub(/./, S('X')), :tainted?)
-
assert_equal("z", "abc".gsub(/./, "a" => "z"), "moved from btest/knownbug")
assert_raise(ArgumentError) { "foo".gsub }
@@ -1261,11 +1243,6 @@ CODE
a.gsub!(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 }
assert_equal(S("HELL-o"), a)
- r = S('X')
- r.taint
- a.gsub!(/./, r)
- assert_predicate(a, :tainted?)
-
a = S("hello")
assert_nil(a.sub!(S('X'), S('Y')))
end
@@ -1457,10 +1434,8 @@ CODE
assert_equal(S("foobar"), a.replace(S("foobar")))
a = S("foo")
- a.taint
b = a.replace(S("xyz"))
assert_equal(S("xyz"), b)
- assert_predicate(b, :tainted?)
s = "foo" * 100
s2 = ("bar" * 100).dup
@@ -1555,12 +1530,6 @@ CODE
a.scan(/(...)/) { |w| res << w }
assert_equal([[S("cru")], [S("el ")], [S("wor")]],res)
- a = S("hello")
- a.taint
- res = []
- a.scan(/./) { |w| res << w }
- assert_predicate(res[0], :tainted?, '[ruby-core:33338] #4087')
-
/h/ =~ a
a.scan(/x/)
assert_nil($~)
@@ -1569,8 +1538,6 @@ CODE
a.scan('x')
assert_nil($~)
- assert_equal(3, S("hello hello hello").scan("hello".taint).count(&:tainted?))
-
assert_equal(%w[1 2 3], S("a1 a2 a3").scan(/a\K./))
end
@@ -1954,11 +1921,6 @@ CODE
assert_equal(S("a\\&aba"), S("ababa").sub(/b/, '\\\\&'))
assert_equal(S("a\\baba"), S("ababa").sub(/b/, '\\\\\&'))
- a = S("hello")
- a.taint
- x = a.sub(/./, S('X'))
- assert_predicate(x, :tainted?)
-
o = Object.new
def o.to_str; "bar"; end
assert_equal("fooBARbaz", "foobarbaz".sub(o, "BAR"))
@@ -2006,11 +1968,6 @@ CODE
a=S("hello")
assert_nil(a.sub!(/X/, S('Y')))
- r = S('X')
- r.taint
- a.sub!(/./, r)
- assert_predicate(a, :tainted?)
-
bug16105 = '[Bug #16105] heap-use-after-free'
a = S("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345678")
b = a.dup
@@ -3201,10 +3158,8 @@ CODE
assert_equal(1, str.instance_variable_get(:@iv))
str = @cls.new("foo")
- str.taint
assert_instance_of(@cls, -str)
assert_equal(false, str.frozen?)
- assert_predicate(str, :tainted?)
end
def test_ord
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index d657f1aae6..c47cadf4bb 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -538,14 +538,6 @@ class TestSymbol < Test::Unit::TestCase
end;
end
- def test_not_freeze
- bug11721 = '[ruby-core:71611] [Bug #11721]'
- str = "\u{1f363}".taint
- assert_not_predicate(str, :frozen?)
- assert_equal str, str.to_sym.to_s
- assert_not_predicate(str, :frozen?, bug11721)
- end
-
def test_hash_nondeterministic
ruby = EnvUtil.rubybin
assert_not_equal :foo.hash, `#{ruby} -e 'puts :foo.hash'`.to_i,
diff --git a/test/ruby/test_trace.rb b/test/ruby/test_trace.rb
index 77be94e9be..5842f11aee 100644
--- a/test/ruby/test_trace.rb
+++ b/test/ruby/test_trace.rb
@@ -20,17 +20,6 @@ class TestTrace < Test::Unit::TestCase
untrace_var :$x
end
- def test_trace_tainted_proc
- $x = 1234
- s = proc { $y = :foo }
- trace_var :$x, s
- s.taint
- $x = 42
- assert_equal(:foo, $y)
- ensure
- untrace_var :$x
- end
-
def test_trace_proc_that_raises_exception
$x = 1234
trace_var :$x, proc { raise }