From ffd0820ab317542f8780aac475da590a4bdbc7a8 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 24 Sep 2019 20:59:12 -0700 Subject: 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. --- test/-ext-/string/test_fstring.rb | 30 ----------- test/-ext-/test_printf.rb | 9 ---- test/bigdecimal/test_bigdecimal.rb | 9 ++++ test/cgi/test_cgi_util.rb | 7 --- test/drb/test_drb.rb | 9 ---- test/fiddle/test_func.rb | 12 +++++ test/fiddle/test_handle.rb | 23 +++++++++ test/net/imap/test_imap_response_parser.rb | 38 +++++++------- test/pathname/test_pathname.rb | 47 ----------------- test/readline/test_readline.rb | 15 ++++++ test/rss/test_parser.rb | 2 +- test/ruby/test_array.rb | 68 ++++++------------------- test/ruby/test_econv.rb | 1 - test/ruby/test_encoding.rb | 3 -- test/ruby/test_env.rb | 7 --- test/ruby/test_exception.rb | 22 -------- test/ruby/test_file.rb | 20 -------- test/ruby/test_file_exhaustive.rb | 44 ---------------- test/ruby/test_hash.rb | 62 ++++++----------------- test/ruby/test_io.rb | 7 --- test/ruby/test_m17n.rb | 15 ------ test/ruby/test_marshal.rb | 70 -------------------------- test/ruby/test_method.rb | 3 -- test/ruby/test_object.rb | 48 +----------------- test/ruby/test_pack.rb | 16 ------ test/ruby/test_proc.rb | 3 -- test/ruby/test_range.rb | 10 ---- test/ruby/test_refinement.rb | 1 - test/ruby/test_require.rb | 25 --------- test/ruby/test_rubyoptions.rb | 7 --- test/ruby/test_signal.rb | 5 -- test/ruby/test_string.rb | 79 +++++++---------------------- test/ruby/test_symbol.rb | 8 --- test/ruby/test_trace.rb | 11 ---- test/strscan/test_stringscanner.rb | 81 ------------------------------ test/test_set.rb | 9 ---- 36 files changed, 130 insertions(+), 696 deletions(-) (limited to 'test') diff --git a/test/-ext-/string/test_fstring.rb b/test/-ext-/string/test_fstring.rb index 71b12e9cce..d51bb033d3 100644 --- a/test/-ext-/string/test_fstring.rb +++ b/test/-ext-/string/test_fstring.rb @@ -12,36 +12,6 @@ class Test_String_Fstring < Test::Unit::TestCase yield fstr end - def test_taint_shared_string - str = __method__.to_s.dup - str.taint - assert_fstring(str) {|s| assert_predicate(s, :tainted?)} - end - - def test_taint_normal_string - str = __method__.to_s * 3 - str.taint - assert_fstring(str) {|s| assert_predicate(s, :tainted?)} - end - - def test_taint_registered_tainted - str = __method__.to_s * 3 - str.taint - assert_fstring(str) {|s| assert_predicate(s, :tainted?)} - - str = __method__.to_s * 3 - assert_fstring(str) {|s| assert_not_predicate(s, :tainted?)} - end - - def test_taint_registered_untainted - str = __method__.to_s * 3 - assert_fstring(str) {|s| assert_not_predicate(s, :tainted?)} - - str = __method__.to_s * 3 - str.taint - assert_fstring(str) {|s| assert_predicate(s, :tainted?)} - end - def test_instance_variable str = __method__.to_s * 3 str.instance_variable_set(:@test, 42) diff --git a/test/-ext-/test_printf.rb b/test/-ext-/test_printf.rb index feaeadd975..cfec388e8c 100644 --- a/test/-ext-/test_printf.rb +++ b/test/-ext-/test_printf.rb @@ -35,15 +35,6 @@ class Test_SPrintf < Test::Unit::TestCase assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self)) end - def test_taint - obj = Object.new.taint - assert_equal({to_s: true, inspect: true}, - { - to_s: Bug::Printf.s(obj).tainted?, - inspect: Bug::Printf.v(obj).tainted?, - }) - end - VS = [ #-0x1000000000000000000000000000000000000000000000002, #-0x1000000000000000000000000000000000000000000000001, diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index dff390b0cc..f6ef88e3f5 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -155,6 +155,15 @@ class TestBigDecimal < Test::Unit::TestCase end end + def test_BigDecimal_with_tainted_string + Thread.new { + $SAFE = 1 + BigDecimal('1'.taint) + }.join + ensure + $SAFE = 0 + end + def test_BigDecimal_with_exception_keyword assert_raise(ArgumentError) { BigDecimal('.', exception: true) diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb index fa1c1e5959..b7bb7b8eae 100644 --- a/test/cgi/test_cgi_util.rb +++ b/test/cgi/test_cgi_util.rb @@ -99,13 +99,6 @@ class CGIUtilTest < Test::Unit::TestCase end end - def test_cgi_escape_html_preserve_tainted - assert_not_predicate CGI.escapeHTML("'&\"><"), :tainted? - assert_predicate CGI.escapeHTML("'&\"><".dup.taint), :tainted? - assert_not_predicate CGI.escapeHTML("Ruby"), :tainted? - assert_predicate CGI.escapeHTML("Ruby".dup.taint), :tainted? - end - def test_cgi_escape_html_dont_freeze assert_not_predicate CGI.escapeHTML("'&\"><".dup), :frozen? assert_not_predicate CGI.escapeHTML("'&\"><".freeze), :frozen? diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb index 15e40ac596..9242a22543 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -103,15 +103,6 @@ module DRbYield @there.xarray_each {|x| assert_kind_of(XArray, x)} @there.xarray_each {|*x| assert_kind_of(XArray, x[0])} end - - def test_06_taint - x = proc {} - assert_not_predicate(x, :tainted?) - @there.echo_yield(x) {|o| - assert_equal(x, o) - assert_not_predicate(x, :tainted?) - } - end end class TestDRbYield < Test::Unit::TestCase diff --git a/test/fiddle/test_func.rb b/test/fiddle/test_func.rb index ca89173766..d170c59a75 100644 --- a/test/fiddle/test_func.rb +++ b/test/fiddle/test_func.rb @@ -11,6 +11,18 @@ module Fiddle assert_nil f.call(10) end + def test_syscall_with_tainted_string + f = Function.new(@libc['system'], [TYPE_VOIDP], TYPE_INT) + Thread.new { + $SAFE = 1 + assert_raise(SecurityError) do + f.call("uname -rs".dup.taint) + end + }.join + ensure + $SAFE = 0 + end + def test_sinf begin f = Function.new(@libm['sinf'], [TYPE_FLOAT], TYPE_FLOAT) diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index 17f9c92a11..c0fac39908 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -8,6 +8,29 @@ module Fiddle class TestHandle < TestCase include Fiddle + def test_safe_handle_open + Thread.new do + $SAFE = 1 + assert_raise(SecurityError) { + Fiddle::Handle.new(LIBC_SO.dup.taint) + } + end.join + ensure + $SAFE = 0 + end + + def test_safe_function_lookup + Thread.new do + h = Fiddle::Handle.new(LIBC_SO) + $SAFE = 1 + assert_raise(SecurityError) { + h["qsort".dup.taint] + } + end.join + ensure + $SAFE = 0 + end + def test_to_i handle = Fiddle::Handle.new(LIBC_SO) assert_kind_of Integer, handle.to_i diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb index 5c2d54566d..4e470459c9 100644 --- a/test/net/imap/test_imap_response_parser.rb +++ b/test/net/imap/test_imap_response_parser.rb @@ -24,13 +24,13 @@ class IMAPResponseParserTest < Test::Unit::TestCase parser = Net::IMAP::ResponseParser.new assert_nothing_raised do 3.times do |i| - parser.parse(< Envelope-to: info@xxxxxxxx.si @@ -214,7 +214,7 @@ EOF # [Bug #8281] def test_acl parser = Net::IMAP::ResponseParser.new - response = parser.parse(< ", stdout.read(2)) assert_equal(1, Readline::HISTORY.length) assert_equal("hello", Readline::HISTORY[0]) + + # Work around lack of SecurityError in Reline + # test mode with tainted prompt + return if kind_of?(TestRelineAsReadline) + + Thread.start { + $SAFE = 1 + assert_raise(SecurityError) do + replace_stdio(stdin.path, stdout.path) do + Readline.readline("> ".taint) + end + end + }.join + ensure + $SAFE = 0 end end diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb index 4e7cc1b963..19344a0643 100644 --- a/test/rss/test_parser.rb +++ b/test/rss/test_parser.rb @@ -19,7 +19,7 @@ EOR @rss_tmp = Tempfile.new(%w"rss10- .rdf") @rss_tmp.print(@rss10) @rss_tmp.close - @rss_file = @rss_tmp.path.untaint + @rss_file = @rss_tmp.path end def teardown 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", 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("#", 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<$/, proc {}.to_s) assert_match(/^#$/, lambda {}.to_s) assert_match(/^#$/, 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 } diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb index 5e798028b7..4b001b317e 100644 --- a/test/strscan/test_stringscanner.rb +++ b/test/strscan/test_stringscanner.rb @@ -16,20 +16,12 @@ class TestStringScanner < Test::Unit::TestCase s = create_string_scanner('test string') assert_instance_of StringScanner, s assert_equal false, s.eos? - assert_equal false, s.tainted? str = 'test string'.dup - str.taint s = create_string_scanner(str, false) assert_instance_of StringScanner, s assert_equal false, s.eos? assert_same str, s.string - assert_equal true, s.string.tainted? - - str = 'test string'.dup - str.taint - s = create_string_scanner(str) - assert_equal true, s.string.tainted? end UNINIT_ERROR = ArgumentError @@ -101,14 +93,12 @@ class TestStringScanner < Test::Unit::TestCase def test_inspect str = 'test string'.dup - str.taint s = create_string_scanner(str, false) assert_instance_of String, s.inspect assert_equal s.inspect, s.inspect assert_equal '#', s.inspect.sub(/StringScanner_C/, 'StringScanner') s.get_byte assert_equal '#', s.inspect.sub(/StringScanner_C/, 'StringScanner') - assert_equal true, s.inspect.tainted? s = create_string_scanner("\n") assert_equal '#', s.inspect @@ -233,40 +223,33 @@ class TestStringScanner < Test::Unit::TestCase s = create_string_scanner('stra strb strc', true) tmp = s.scan(/\w+/) assert_equal 'stra', tmp - assert_equal false, tmp.tainted? tmp = s.scan(/\s+/) assert_equal ' ', tmp - assert_equal false, tmp.tainted? assert_equal 'strb', s.scan(/\w+/) assert_equal ' ', s.scan(/\s+/) tmp = s.scan(/\w+/) assert_equal 'strc', tmp - assert_equal false, tmp.tainted? assert_nil s.scan(/\w+/) assert_nil s.scan(/\w+/) str = 'stra strb strc'.dup - str.taint s = create_string_scanner(str, false) tmp = s.scan(/\w+/) assert_equal 'stra', tmp - assert_equal true, tmp.tainted? tmp = s.scan(/\s+/) assert_equal ' ', tmp - assert_equal true, tmp.tainted? assert_equal 'strb', s.scan(/\w+/) assert_equal ' ', s.scan(/\s+/) tmp = s.scan(/\w+/) assert_equal 'strc', tmp - assert_equal true, tmp.tainted? assert_nil s.scan(/\w+/) assert_nil s.scan(/\w+/) @@ -291,15 +274,12 @@ class TestStringScanner < Test::Unit::TestCase assert_equal 'str', s.scan('str') assert_equal 'str', s[0] assert_equal 3, s.pos - assert_equal false, s.tainted? assert_equal 'a ', s.scan('a ') str = 'stra strb strc'.dup - str.taint s = create_string_scanner(str, false) matched = s.scan('str') assert_equal 'str', matched - assert_equal true, matched.tainted? end def test_skip @@ -346,14 +326,6 @@ class TestStringScanner < Test::Unit::TestCase assert_equal 'e', s.getch assert_nil s.getch - str = 'abc'.dup - str.taint - s = create_string_scanner(str) - assert_equal true, s.getch.tainted? - assert_equal true, s.getch.tainted? - assert_equal true, s.getch.tainted? - assert_nil s.getch - s = create_string_scanner("\244\242".dup.force_encoding("euc-jp")) assert_equal "\244\242".dup.force_encoding("euc-jp"), s.getch assert_nil s.getch @@ -374,14 +346,6 @@ class TestStringScanner < Test::Unit::TestCase assert_nil s.get_byte assert_nil s.get_byte - str = 'abc'.dup - str.taint - s = create_string_scanner(str) - assert_equal true, s.get_byte.tainted? - assert_equal true, s.get_byte.tainted? - assert_equal true, s.get_byte.tainted? - assert_nil s.get_byte - s = create_string_scanner("\244\242".dup.force_encoding("euc-jp")) assert_equal "\244".dup.force_encoding("euc-jp"), s.get_byte assert_equal "\242".dup.force_encoding("euc-jp"), s.get_byte @@ -397,7 +361,6 @@ class TestStringScanner < Test::Unit::TestCase s = create_string_scanner('stra strb strc') s.scan(/\w+/) assert_equal 'stra', s.matched - assert_equal false, s.matched.tainted? s.scan(/\s+/) assert_equal ' ', s.matched s.scan('st') @@ -416,18 +379,9 @@ class TestStringScanner < Test::Unit::TestCase s = create_string_scanner('stra strb strc') s.getch assert_equal 's', s.matched - assert_equal false, s.matched.tainted? s.get_byte assert_equal 't', s.matched assert_equal 't', s.matched - assert_equal false, s.matched.tainted? - - str = 'test'.dup - str.taint - s = create_string_scanner(str) - s.scan(/\w+/) - assert_equal true, s.matched.tainted? - assert_equal true, s.matched.tainted? end def test_AREF @@ -441,9 +395,6 @@ class TestStringScanner < Test::Unit::TestCase assert_raise(IndexError) { s[:c] } assert_raise(IndexError) { s['c'] } - assert_equal false, s[-1].tainted? - assert_equal false, s[0].tainted? - s.skip(/\s+/) assert_nil s[-2] assert_equal ' ', s[-1] @@ -486,16 +437,6 @@ class TestStringScanner < Test::Unit::TestCase s.getch assert_equal "\244\242".dup.force_encoding("euc-jp"), s[0] - str = 'test'.dup - str.taint - s = create_string_scanner(str) - s.scan(/(t)(e)(s)(t)/) - assert_equal true, s[0].tainted? - assert_equal true, s[1].tainted? - assert_equal true, s[2].tainted? - assert_equal true, s[3].tainted? - assert_equal true, s[4].tainted? - s = create_string_scanner("foo bar baz") s.scan(/(?\w+) (?\w+) (\w+)/) assert_equal 'foo', s[1] @@ -514,10 +455,8 @@ class TestStringScanner < Test::Unit::TestCase s = create_string_scanner('a b c d e') s.scan(/\w/) assert_equal '', s.pre_match - assert_equal false, s.pre_match.tainted? s.skip(/\s/) assert_equal 'a', s.pre_match - assert_equal false, s.pre_match.tainted? s.scan('b') assert_equal 'a ', s.pre_match s.scan_until(/c/) @@ -530,16 +469,6 @@ class TestStringScanner < Test::Unit::TestCase assert_equal 'a b c d', s.pre_match s.scan(/never match/) assert_nil s.pre_match - - str = 'test string'.dup - str.taint - s = create_string_scanner(str) - s.scan(/\w+/) - assert_equal true, s.pre_match.tainted? - s.scan(/\s+/) - assert_equal true, s.pre_match.tainted? - s.scan(/\w+/) - assert_equal true, s.pre_match.tainted? end def test_post_match @@ -564,16 +493,6 @@ class TestStringScanner < Test::Unit::TestCase assert_equal '', s.post_match s.scan(/./) assert_nil s.post_match - - str = 'test string'.dup - str.taint - s = create_string_scanner(str) - s.scan(/\w+/) - assert_equal true, s.post_match.tainted? - s.scan(/\s+/) - assert_equal true, s.post_match.tainted? - s.scan(/\w+/) - assert_equal true, s.post_match.tainted? end def test_terminate diff --git a/test/test_set.rb b/test/test_set.rb index b20920e63e..b0f669ce86 100644 --- a/test/test_set.rb +++ b/test/test_set.rb @@ -696,15 +696,6 @@ class TC_Set < Test::Unit::TestCase assert_equal(set, ret.flatten) end - def test_taintness - orig = set = Set[1,2,3] - assert_equal false, set.tainted? - assert_same orig, set.taint - assert_equal true, set.tainted? - assert_same orig, set.untaint - assert_equal false, set.tainted? - end - def test_freeze orig = set = Set[1,2,3] assert_equal false, set.frozen? -- cgit v1.2.3