summaryrefslogtreecommitdiff
path: root/test/drb
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-13 15:13:54 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-13 15:13:54 +0000
commit2681be1eed16ad862b3dd2d1a317e154b80f1148 (patch)
treecf0aad4a3b460cb158507f93ca2c5c8d43aa73bc /test/drb
parent1a22e46d60bd43bd19a089bd52fe4ee36518fe2c (diff)
add safe_leve, default_safe_level ([druby-ja:120])
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/drb')
-rw-r--r--test/drb/test_drb.rb15
-rw-r--r--test/drb/ut_eval.rb10
-rw-r--r--test/drb/ut_safe1.rb4
3 files changed, 25 insertions, 4 deletions
diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb
index d86bce8..a6b83d2 100644
--- a/test/drb/test_drb.rb
+++ b/test/drb/test_drb.rb
@@ -209,7 +209,7 @@ class TestDRbEval < Test::Unit::TestCase
@ext.stop_service if @ext
end
- def test_01_safe1_eval
+ def test_01_safe1_safe4_eval
assert_raises(SecurityError) do
@there.method_missing(:instance_eval, 'ENV.inspect')
end
@@ -227,6 +227,19 @@ class TestDRbEval < Test::Unit::TestCase
assert_raises(SecurityError) do
remote_class.module_eval('ENV.inspect')
end
+
+ four = @there.four
+ assert_equal(1, four.method_missing(:send, :eval, '1'))
+
+ remote_class = four.remote_class
+
+ assert_raises(SecurityError) do
+ remote_class.class_eval('ENV.inspect')
+ end
+
+ assert_raises(SecurityError) do
+ remote_class.module_eval('ENV.inspect')
+ end
end
end
diff --git a/test/drb/ut_eval.rb b/test/drb/ut_eval.rb
index 6a81e17..4df963e 100644
--- a/test/drb/ut_eval.rb
+++ b/test/drb/ut_eval.rb
@@ -2,6 +2,14 @@ require 'drb/drb'
require 'drb/extserv'
class EvalAttack
+ def initialize
+ @four = DRb::DRbServer.new('druby://localhost:0', self, {:safe_level => 4})
+ end
+
+ def four
+ DRbObject.new_with_uri(@four.uri)
+ end
+
def remote_class
DRbObject.new(self.class)
end
@@ -17,7 +25,7 @@ if __FILE__ == $0
$SAFE = 1
- DRb.start_service('druby://localhost:0', EvalAttack.new)
+ DRb.start_service('druby://localhost:0', EvalAttack.new, {:safe_level => 2})
es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
DRb.thread.join
end
diff --git a/test/drb/ut_safe1.rb b/test/drb/ut_safe1.rb
index 761bdff..3ff8b4d 100644
--- a/test/drb/ut_safe1.rb
+++ b/test/drb/ut_safe1.rb
@@ -9,8 +9,8 @@ if __FILE__ == $0
end
$SAFE = 1
-
- DRb.start_service('druby://localhost:0', [1, 2, 'III', 4, "five", 6])
+ DRb.start_service('druby://localhost:0', [1, 2, 'III', 4, "five", 6],
+ {:safe_level => 1})
es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
DRb.thread.join
end