summaryrefslogtreecommitdiff
path: root/test
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
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')
-rw-r--r--test/-ext-/string/test_fstring.rb30
-rw-r--r--test/-ext-/test_printf.rb9
-rw-r--r--test/bigdecimal/test_bigdecimal.rb9
-rw-r--r--test/cgi/test_cgi_util.rb7
-rw-r--r--test/drb/test_drb.rb9
-rw-r--r--test/fiddle/test_func.rb12
-rw-r--r--test/fiddle/test_handle.rb23
-rw-r--r--test/net/imap/test_imap_response_parser.rb38
-rw-r--r--test/pathname/test_pathname.rb47
-rw-r--r--test/readline/test_readline.rb15
-rw-r--r--test/rss/test_parser.rb2
-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
-rw-r--r--test/strscan/test_stringscanner.rb81
-rw-r--r--test/test_set.rb9
36 files changed, 130 insertions, 696 deletions
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(<<EOF.gsub(/\n/, "\r\n").taint)
+ parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* LIST (\\Foo#{i}) "." "INBOX"
EOF
end
end
assert_raise(Net::IMAP::FlagCountError) do
- parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* LIST (\\Foo3) "." "INBOX"
EOF
end
@@ -40,7 +40,7 @@ EOF
parser = Net::IMAP::ResponseParser.new
assert_nothing_raised do
100.times do
- parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* LIST (\\Foo) "." "INBOX"
EOF
end
@@ -49,7 +49,7 @@ EOF
def test_flag_xlist_inbox
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* XLIST (\\Inbox) "." "INBOX"
EOF
assert_equal [:Inbox], response.data.attr
@@ -57,7 +57,7 @@ EOF
def test_resp_text_code
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* OK [CLOSED] Previous mailbox closed.
EOF
assert_equal "CLOSED", response.data.code.name
@@ -65,15 +65,15 @@ EOF
def test_search_response
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* SEARCH
EOF
assert_equal [], response.data
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* SEARCH 1
EOF
assert_equal [1], response.data
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* SEARCH 1 2 3
EOF
assert_equal [1, 2, 3], response.data
@@ -81,11 +81,11 @@ EOF
def test_search_response_of_yahoo
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* SEARCH 1\s
EOF
assert_equal [1], response.data
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* SEARCH 1 2 3\s
EOF
assert_equal [1, 2, 3], response.data
@@ -93,12 +93,12 @@ EOF
def test_msg_att_extra_space
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 1 FETCH (UID 92285)
EOF
assert_equal 92285, response.data.attr["UID"]
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 1 FETCH (UID 92285 )
EOF
assert_equal 92285, response.data.attr["UID"]
@@ -107,7 +107,7 @@ EOF
def test_msg_att_parse_error
parser = Net::IMAP::ResponseParser.new
e = assert_raise(Net::IMAP::ResponseParseError) {
- parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 123 FETCH (UNKNOWN 92285)
EOF
}
@@ -116,13 +116,13 @@ EOF
def test_msg_att_rfc822_text
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 123 FETCH (RFC822 {5}
foo
)
EOF
assert_equal("foo\r\n", response.data.attr["RFC822"])
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 123 FETCH (RFC822[] {5}
foo
)
@@ -133,7 +133,7 @@ EOF
# [Bug #6397] [ruby-core:44849]
def test_body_type_attachment
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 980 FETCH (UID 2862 BODYSTRUCTURE ((("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 416 21 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 1493 32 NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "Boundary_(ID_IaecgfnXwG5bn3x8lIeGIQ)") NIL NIL)("MESSAGE" "RFC822" ("NAME" "Fw_ ____ _____ ____.eml") NIL NIL "7BIT" 1980088 NIL ("ATTACHMENT" ("FILENAME" "Fw_ ____ _____ ____.eml")) NIL) "MIXED" ("BOUNDARY" "Boundary_(ID_eDdLc/j0mBIzIlR191pHjA)") NIL NIL))
EOF
assert_equal("Fw_ ____ _____ ____.eml",
@@ -142,7 +142,7 @@ EOF
def assert_parseable(s)
parser = Net::IMAP::ResponseParser.new
- parser.parse(s.gsub(/\n/, "\r\n").taint)
+ parser.parse(s.gsub(/\n/, "\r\n"))
end
# [Bug #7146]
@@ -171,7 +171,7 @@ EOF
# [Bug #8167]
def test_msg_delivery_status_with_extra_data
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* 29021 FETCH (RFC822.SIZE 3162 UID 113622 RFC822.HEADER {1155}
Return-path: <>
Envelope-to: info@xxxxxxxx.si
@@ -214,7 +214,7 @@ EOF
# [Bug #8281]
def test_acl
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
* ACL "INBOX/share" "imshare2copy1366146467@xxxxxxxxxxxxxxxxxx.com" lrswickxteda
EOF
assert_equal("ACL", response.name)
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 4d480a50f3..792510bdfb 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -592,39 +592,6 @@ class TestPathname < Test::Unit::TestCase
assert_raise(ArgumentError) { Pathname.new("\0") }
end
- def test_taint
- obj = Pathname.new("a"); assert_same(obj, obj.taint)
- obj = Pathname.new("a"); assert_same(obj, obj.untaint)
-
- assert_equal(false, Pathname.new("a" ) .tainted?)
- assert_equal(false, Pathname.new("a" ) .to_s.tainted?)
- assert_equal(true, Pathname.new("a" ).taint .tainted?)
- assert_equal(true, Pathname.new("a" ).taint.to_s.tainted?)
- assert_equal(true, Pathname.new("a".dup.taint) .tainted?)
- assert_equal(true, Pathname.new("a".dup.taint) .to_s.tainted?)
- assert_equal(true, Pathname.new("a".dup.taint).taint .tainted?)
- assert_equal(true, Pathname.new("a".dup.taint).taint.to_s.tainted?)
-
- str = "a".dup
- path = Pathname.new(str)
- str.taint
- assert_equal(false, path .tainted?)
- assert_equal(false, path.to_s.tainted?)
- end
-
- def test_untaint
- obj = Pathname.new("a"); assert_same(obj, obj.untaint)
-
- assert_equal(false, Pathname.new("a").taint.untaint .tainted?)
- assert_equal(false, Pathname.new("a").taint.untaint.to_s.tainted?)
-
- str = "a".dup.taint
- path = Pathname.new(str)
- str.untaint
- assert_equal(true, path .tainted?)
- assert_equal(true, path.to_s.tainted?)
- end
-
def test_freeze
obj = Pathname.new("a"); assert_same(obj, obj.freeze)
@@ -638,20 +605,6 @@ class TestPathname < Test::Unit::TestCase
assert_equal(false, Pathname.new("a".freeze).freeze.to_s.frozen?)
end
- def test_freeze_and_taint
- obj = Pathname.new("a")
- obj.freeze
- assert_equal(false, obj.tainted?)
- assert_raise(FrozenError) { obj.taint }
-
- obj = Pathname.new("a")
- obj.taint
- assert_equal(true, obj.tainted?)
- obj.freeze
- assert_equal(true, obj.tainted?)
- assert_nothing_raised { obj.taint }
- end
-
def test_to_s
str = "a"
obj = Pathname.new(str)
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index f87435498c..4e82d46d91 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -41,6 +41,21 @@ module BasetestReadline
assert_equal("> ", 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<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 }
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 '#<StringScanner 0/11 @ "test ...">', s.inspect.sub(/StringScanner_C/, 'StringScanner')
s.get_byte
assert_equal '#<StringScanner 1/11 "t" @ "est s...">', s.inspect.sub(/StringScanner_C/, 'StringScanner')
- assert_equal true, s.inspect.tainted?
s = create_string_scanner("\n")
assert_equal '#<StringScanner 0/1 @ "\n">', 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(/(?<a>\w+) (?<b>\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?