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

ruby-changes:14359

From: nahi <ko1@a...>
Date: Mon, 28 Dec 2009 22:01:47 +0900 (JST)
Subject: [ruby-changes:14359] Ruby:r26189 (trunk): * test/ruby/test_marshal.rb: added tests for taintness/untrustness

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

  New Revision: 26189

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

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

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_marshal.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26188)
+++ ChangeLog	(revision 26189)
@@ -1,3 +1,8 @@
+Mon Dec 28 22:00:10 2009  NAKAMURA, Hiroshi  <nahi@r...>
+
+	* test/ruby/test_marshal.rb: added tests for taintness/untrustness
+	  propagation.
+
 Mon Dec 28 18:13:26 2009  Yuki Sonoda (Yugui)  <yugui@y...>
 
 	* sample/occur2.rb: reimplemented in modern style. [ruby-dev:39927].
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 26188)
+++ test/ruby/test_marshal.rb	(revision 26189)
@@ -193,6 +193,70 @@
     assert_equal(true, y.untrusted?)
   end
 
+  def test_taint_and_untrust_each_object
+    x = Object.new
+    obj = [[x]]
+
+    # clean object causes crean stream
+    assert_equal(false, obj.tainted?)
+    assert_equal(false, obj.untrusted?)
+    assert_equal(false, obj.first.tainted?)
+    assert_equal(false, obj.first.untrusted?)
+    assert_equal(false, obj.first.first.tainted?)
+    assert_equal(false, obj.first.first.untrusted?)
+    s = Marshal.dump(obj)
+    assert_equal(false, s.tainted?)
+    assert_equal(false, s.untrusted?)
+
+    # tainted/untrusted object causes tainted/untrusted stream
+    x.taint
+    x.untrust
+    assert_equal(false, obj.tainted?)
+    assert_equal(false, obj.untrusted?)
+    assert_equal(false, obj.first.tainted?)
+    assert_equal(false, obj.first.untrusted?)
+    assert_equal(true, obj.first.first.tainted?)
+    assert_equal(true, obj.first.first.untrusted?)
+    t = Marshal.dump(obj)
+    assert_equal(true, t.tainted?)
+    assert_equal(true, t.untrusted?)
+
+    # clean stream causes clean objects
+    assert_equal(false, s.tainted?)
+    assert_equal(false, s.untrusted?)
+    y = Marshal.load(s)
+    assert_equal(false, y.tainted?)
+    assert_equal(false, y.untrusted?)
+    assert_equal(false, y.first.tainted?)
+    assert_equal(false, y.first.untrusted?)
+    assert_equal(false, y.first.first.tainted?)
+    assert_equal(false, y.first.first.untrusted?)
+
+    # tainted/untrusted stream causes tainted/untrusted objects
+    assert_equal(true, t.tainted?)
+    assert_equal(true, t.untrusted?)
+    y = Marshal.load(t)
+    assert_equal(true, y.tainted?)
+    assert_equal(true, y.untrusted?)
+    assert_equal(true, y.first.tainted?)
+    assert_equal(true, y.first.untrusted?)
+    assert_equal(true, y.first.first.tainted?)
+    assert_equal(true, y.first.first.untrusted?)
+
+    # same tests by different senario
+    s.taint
+    s.untrust
+    assert_equal(true, s.tainted?)
+    assert_equal(true, s.untrusted?)
+    y = Marshal.load(s)
+    assert_equal(true, y.tainted?)
+    assert_equal(true, y.untrusted?)
+    assert_equal(true, y.first.tainted?)
+    assert_equal(true, y.first.untrusted?)
+    assert_equal(true, y.first.first.tainted?)
+    assert_equal(true, y.first.first.untrusted?)
+  end
+
   def test_symbol
     [:ruby, :"\u{7d05}\u{7389}"].each do |sym|
       assert_equal(sym, Marshal.load(Marshal.dump(sym)), '[ruby-core:24788]')

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

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