[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/component/ Ensure that the global service service is not security proxied when returned

Albertas Agejevas alga at pov.lt
Wed May 26 08:40:52 EDT 2004


Log message for revision 25002:
Ensure that the global service service is not security proxied when returned
by getNextServices().



-=-
Modified: Zope3/trunk/src/zope/app/component/localservice.py
===================================================================
--- Zope3/trunk/src/zope/app/component/localservice.py	2004-05-26 11:30:37 UTC (rev 25001)
+++ Zope3/trunk/src/zope/app/component/localservice.py	2004-05-26 12:40:51 UTC (rev 25002)
@@ -25,6 +25,8 @@
 from zope.app.event.interfaces import ISubscriber
 from zope.testing.cleanup import addCleanUp
 from zope.app.component.hooks import setSite
+from zope.component.service import IGlobalServiceManager
+from zope.security.proxy import trustedRemoveSecurityProxy
 
 # placeful service manager convenience tools
 
@@ -79,7 +81,10 @@
 def getNextServices(context):
     """Returns the next service manager to the one that contains 'context'.
     """
-    return getLocalServices(context).next
+    services = getLocalServices(context).next
+    if IGlobalServiceManager.providedBy(services):
+        services = trustedRemoveSecurityProxy(services)
+    return services
 
 def queryNextServices(context, default=None):
     try:

Modified: Zope3/trunk/src/zope/app/component/tests/test_localservice.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_localservice.py	2004-05-26 11:30:37 UTC (rev 25001)
+++ Zope3/trunk/src/zope/app/component/tests/test_localservice.py	2004-05-26 12:40:51 UTC (rev 25002)
@@ -134,6 +134,7 @@
         self.assertRaises(ComponentLookupError,
                           getNextService, self.p1, 'dummy')
 
+
     def test_queryNextServices(self):
         from zope.app.component.localservice import queryNextServices
         marker = object()
@@ -168,6 +169,13 @@
         self.assertRaises(ComponentLookupError,
                           getNextServices, self.unrooted_subfolder)
 
+    def test_getNextServices_security(self):
+        from zope.app.component.localservice import getNextServices
+        from zope.security.checker import ProxyFactory, NamesChecker
+        sm = ProxyFactory(self.sm1, NamesChecker(('next',)))
+        # Check that serviceManager is not proxied
+        self.assert_(getNextServices(sm) is serviceManager)
+
     def test_queryLocalServices(self):
         from zope.app.component.localservice import queryLocalServices
         marker = object()




More information about the Zope3-Checkins mailing list