From 108c4e4495385ccb5cab87dd723f27ef0ab52049 Mon Sep 17 00:00:00 2001 From: suke Date: Mon, 25 Aug 2014 11:18:17 +0000 Subject: * ext/win32ole/win32ole.c(fole_s_connect, fole_initialize): raise a security error with the tainted string object. * ext/win32ole/win32ole_event.c(ev_advise): ditto. * test/win32ole/test_win32ole.rb(test_s_new_exc_svr_tainted, test_s_new_exc_host_tainted): ditto. * test/win32ole/test_win32ole_event.rb(test_s_new_exc_tainted): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/win32ole/test_win32ole.rb | 40 ++++++++++++++++++++++++++++++++++++ test/win32ole/test_win32ole_event.rb | 13 ++++++++++++ 2 files changed, 53 insertions(+) (limited to 'test') diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb index 71026d48c6..b41fd591fe 100644 --- a/test/win32ole/test_win32ole.rb +++ b/test/win32ole/test_win32ole.rb @@ -169,6 +169,33 @@ if defined?(WIN32OLE) } end + def test_s_new_exc_svr_tainted + th = Thread.start { + $SAFE = 1 + svr = "Scripting.Dictionary" + svr.taint + WIN32OLE.new(svr) + } + exc = assert_raise(SecurityError) { + th.join + } + assert_match(/insecure object creation - `Scripting.Dictionary'/, exc.message) + end + + def test_s_new_exc_host_tainted + th = Thread.start { + $SAFE = 1 + svr = "Scripting.Dictionary" + host = "localhost" + host.taint + WIN32OLE.new(svr, host) + } + exc = assert_raise(SecurityError) { + th.join + } + assert_match(/insecure object creation - `localhost'/, exc.message) + end + def test_s_new_DCOM rshell = WIN32OLE.new("Shell.Application") assert_instance_of(WIN32OLE, rshell) @@ -194,6 +221,19 @@ if defined?(WIN32OLE) } end + def test_s_coonect_exc_tainted + th = Thread.start { + $SAFE = 1 + svr = "winmgmts:" + svr.taint + WIN32OLE.connect(svr) + } + exc = assert_raise(SecurityError) { + th.join + } + assert_match(/insecure connection - `winmgmts:'/, exc.message) + end + def test_invoke_accept_symbol_hash_key fso = WIN32OLE.new('Scripting.FileSystemObject') afolder = fso.getFolder(".") diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb index 8e3915ec17..f486749113 100644 --- a/test/win32ole/test_win32ole_event.rb +++ b/test/win32ole/test_win32ole_event.rb @@ -329,6 +329,19 @@ if defined?(WIN32OLE_EVENT) message_loop assert(h2.ev != "") end + + def test_s_new_exc_tainted + th = Thread.new { + $SAFE=1 + str = 'ConnectionEvents' + str.taint + ev = WIN32OLE_EVENT.new(@db, str) + } + exc = assert_raise(SecurityError) { + th.join + } + assert_match(/insecure event creation - `ConnectionEvents'/, exc.message) + end end end end -- cgit v1.2.3