diff options
| author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-28 13:02:34 +0000 |
|---|---|---|
| committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-28 13:02:34 +0000 |
| commit | ec5a11dd0ab282db074138ff40a100bf050e2504 (patch) | |
| tree | 2190f8f535f2e7c01652ebd3a656891198401284 | |
| parent | e39eb4423fd0210490113809c8eca4adf8efc064 (diff) | |
* test/ruby/test_marshal.rb: added tests for taintness propagation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 8 | ||||
| -rw-r--r-- | test/ruby/test_marshal.rb | 42 |
2 files changed, 48 insertions, 2 deletions
@@ -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 |
