Commit 7ed4be90 authored by Philip Jenvey's avatar Philip Jenvey

fix a hole in sandboxing allowing builtin file to write outside of the sandbox

--HG--
branch : distribute
extra : rebase_source : 5ff181b30f41080ec0e0628c96abf270ffe1a730
parent 568eb8de
...@@ -6,6 +6,8 @@ CHANGES ...@@ -6,6 +6,8 @@ CHANGES
0.6.5 0.6.5
----- -----
* Fixed a hole in sandboxing allowing builtin file to write outside of
the sandbox.
----- -----
0.6.4 0.6.4
......
...@@ -168,6 +168,12 @@ class DirectorySandbox(AbstractSandbox): ...@@ -168,6 +168,12 @@ class DirectorySandbox(AbstractSandbox):
def _violation(self, operation, *args, **kw): def _violation(self, operation, *args, **kw):
raise SandboxViolation(operation, args, kw) raise SandboxViolation(operation, args, kw)
if _file:
def _file(self, path, mode='r', *args, **kw):
if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
self._violation("file", path, mode, *args, **kw)
return _file(path,mode,*args,**kw)
def _open(self, path, mode='r', *args, **kw): def _open(self, path, mode='r', *args, **kw):
if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
self._violation("open", path, mode, *args, **kw) self._violation("open", path, mode, *args, **kw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment