summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--test/ruby/test_marshal.rb42
2 files changed, 48 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bc6167dcf4..933c343d4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,11 @@
+Mon Dec 28 22:01:58 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * test/ruby/test_marshal.rb: added tests for taintness propagation.
+
Thu Dec 24 12:08:00 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
- * 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@ruby-lang.org>
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index d40c9da4d4..e51e5a5417 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -108,4 +108,46 @@ class TestMarshal < Test::Unit::TestCase
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