mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 1264831 - Add a few presumably harmless builtins to the sandbox. r=gps
as well as os.path.normcase.
This commit is contained in:
parent
7c9ca07087
commit
5ac7830115
@ -346,7 +346,6 @@ def old_configure_options(*options):
|
||||
)
|
||||
@imports(_from='__builtin__', _import='compile')
|
||||
@imports(_from='__builtin__', _import='open')
|
||||
@imports(_from='__builtin__', _import='zip')
|
||||
@imports('logging')
|
||||
@imports('os')
|
||||
@imports('subprocess')
|
||||
|
@ -100,7 +100,6 @@ def namespace(**kwargs):
|
||||
@template
|
||||
def delayed_getattr(func, key):
|
||||
@depends(func)
|
||||
@imports(_from='__builtin__', _import='getattr')
|
||||
def result(value):
|
||||
# The @depends function we're being passed may have returned
|
||||
# None, or an object that simply doesn't have the wanted key.
|
||||
|
@ -93,14 +93,16 @@ class ConfigureSandbox(dict):
|
||||
BUILTINS = ReadOnlyDict({
|
||||
b: __builtins__[b]
|
||||
for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len',
|
||||
'list', 'tuple', 'set', 'dict', 'isinstance')
|
||||
'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
|
||||
'hasattr', 'enumerate', 'range', 'zip')
|
||||
}, __import__=forbidden_import, str=unicode)
|
||||
|
||||
# Expose a limited set of functions from os.path
|
||||
OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{
|
||||
k: getattr(mozpath, k, getattr(os.path, k))
|
||||
for k in ('abspath', 'basename', 'dirname', 'exists', 'isabs', 'isdir',
|
||||
'isfile', 'join', 'normpath', 'realpath', 'relpath')
|
||||
'isfile', 'join', 'normcase', 'normpath', 'realpath',
|
||||
'relpath')
|
||||
}))
|
||||
|
||||
def __init__(self, config, environ=os.environ, argv=sys.argv,
|
||||
|
@ -160,7 +160,6 @@ set_config('IS_FILE', with_imports)
|
||||
# It is also possible to cherry-pick builtins.
|
||||
@depends('--with-imports')
|
||||
@imports('os.path')
|
||||
@imports(_from='__builtin__', _import='hasattr')
|
||||
def with_imports(value):
|
||||
if len(value):
|
||||
return hasattr(os.path, 'getatime')
|
||||
@ -168,7 +167,6 @@ def with_imports(value):
|
||||
set_config('HAS_GETATIME', with_imports)
|
||||
|
||||
@depends('--with-imports')
|
||||
@imports(_from='__builtin__', _import='hasattr')
|
||||
def with_imports(value):
|
||||
if len(value):
|
||||
return hasattr(os.path, 'getatime')
|
||||
|
Loading…
x
Reference in New Issue
Block a user