root/CPS3/products/CPSCore/trunk/AllowModules.py

Revision 52712, 3.2 kB (checked in by madarche, 1 year ago)

- Allowed the use of operator.itemgetter and operator.attrgetter in restricted

code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 # (C) Copyright 2003-2005 Nuxeo SARL <http://nuxeo.com>
2 # Author: Florent Guillaume <fg@nuxeo.com>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 2 as published
6 # by the Free Software Foundation.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16 # 02111-1307, USA.
17 #
18 # $Id$
19 """
20 Allow standard modules to be imported from restricted code.
21 """
22 # (see lib/python/Products/PythonScripts/module_access_example.py)
23
24 from AccessControl import allow_type, allow_class
25 from AccessControl import ModuleSecurityInfo
26
27 ModuleSecurityInfo('re').declarePublic('compile', 'findall',
28   'match', 'search', 'split', 'sub', 'subn', 'error',
29   'I', 'L', 'M', 'S', 'X')
30 import re
31 allow_type(type(re.compile('')))
32 allow_type(type(re.compile('x')))
33 allow_type(type(re.match('x', 'x')))
34 allow_type(type(re.sub('x', 'x', 'x')))
35
36 ModuleSecurityInfo('operator').declarePublic('attrgetter')
37 ModuleSecurityInfo('operator').declarePublic('itemgetter')
38 ModuleSecurityInfo('urllib').declarePublic('urlencode')
39 ModuleSecurityInfo('urllib').declarePublic('quote')
40 ModuleSecurityInfo('urllib').declarePublic('unquote')
41 ModuleSecurityInfo('cgi').declarePublic('escape')
42 ModuleSecurityInfo('zLOG').declarePublic('LOG', 'DEBUG', 'INFO')
43 ModuleSecurityInfo('zExceptions').declarePublic('Forbidden')
44 from logging import Logger
45 allow_class(Logger)
46 ModuleSecurityInfo('logging').declarePublic('getLogger')
47 ModuleSecurityInfo('logging').declarePublic('Logger')
48 ModuleSecurityInfo('AccessControl').declarePublic('Unauthorized')
49 ModuleSecurityInfo('types').declarePublic('IntType', 'StringType',
50                                           'ListType', 'DictType',
51                                           'TupleType')
52 ModuleSecurityInfo('DateTime.DateTime').declarePublic('DateTimeError')
53 ModuleSecurityInfo(
54     'Products.CMFCore.WorkflowCore').declarePublic('WorkflowException')
55 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
56         'resetSessionLanguageSelection')
57
58 try:
59     ModuleSecurityInfo(
60         'Products.TextIndexNG2.BaseParser').declarePublic('QueryParserError')
61 except ImportError:
62     pass
63
64 try:
65     from mx import Tidy
66     allow_class(Tidy)
67     ModuleSecurityInfo('mx').declarePublic('Tidy')
68 except ImportError:
69     pass
70
71 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
72     'KEYWORD_DOWNLOAD_FILE')
73 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
74     'KEYWORD_ARCHIVED_REVISION')
75 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
76     'KEYWORD_SWITCH_LANGUAGE')
77 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
78     'KEYWORD_VIEW_LANGUAGE')
79 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
80     'KEYWORD_VIEW_ZIP')
81 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
82     'SESSION_LANGUAGE_KEY')
83 ModuleSecurityInfo('Products.CPSCore.utils').declarePublic(
84     'REQUEST_LANGUAGE_KEY')
Note: See TracBrowser for help on using the browser.