[前][次][番号順一覧][スレッド一覧]

ruby-changes:14361

From: nahi <ko1@a...>
Date: Mon, 28 Dec 2009 22:02:47 +0900 (JST)
Subject: [ruby-changes:14361] Ruby:r26190 (ruby_1_8): * test/ruby/test_marshal.rb: added tests for taintness propagation.

nahi	2009-12-28 22:02:34 +0900 (Mon, 28 Dec 2009)

  New Revision: 26190

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26190

  Log:
    * test/ruby/test_marshal.rb: added tests for taintness propagation.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/test/ruby/test_marshal.rb

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 26189)
+++ ruby_1_8/ChangeLog	(revision 26190)
@@ -1,7 +1,11 @@
+Mon Dec 28 22:01:58 2009  NAKAMURA, Hiroshi  <nahi@r...>
+
+	* test/ruby/test_marshal.rb: added tests for taintness propagation.
+
 Thu Dec 24 12:08:00 2009  Marc-Andre Lafortune  <ruby-core@m...>
 
-  * lib/delegate.rb (marshal_dump/load): dump & load instance variables
-    by default [ruby-core:24211]
+	* lib/delegate.rb (marshal_dump/load): dump & load instance variables
+	  by default [ruby-core:24211]
 
 Wed Dec 23 20:48:52 2009  Nobuyoshi Nakada  <nobu@r...>
 
Index: ruby_1_8/test/ruby/test_marshal.rb
===================================================================
--- ruby_1_8/test/ruby/test_marshal.rb	(revision 26189)
+++ ruby_1_8/test/ruby/test_marshal.rb	(revision 26190)
@@ -108,4 +108,46 @@
     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
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]