Re: limited python virtual machine

From: Aahz (aahz_at_pythoncraft.com)
Date: 01/29/05


Date: 29 Jan 2005 06:31:45 -0500

In article <1gr3mwj.1mhbjao122j7fxN%aleaxit@yahoo.com>,
Alex Martelli <aleaxit@yahoo.com> wrote:
>Steven Bethard <steven.bethard@gmail.com> wrote:
>>
>> If I could see how to go from 'object' (or 'int', 'str', 'file', etc.)
>> to 'eval' or '__import__', that would help out a lot...
>
>>>> object.__subclasses__()
>[<type 'type'>, <type 'weakref'>, <type 'int'>, <type 'basestring'>,
><type 'list'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type
>'module'>, <type 'zipimport.zipimporter'>, <type 'posix.stat_result'>,
><type 'posix.statvfs_result'>, <type 'dict'>, <type 'function'>, <class
>'site._Printer'>, <class 'site._Helper'>, <type 'set'>, <type 'file'>]
>
>Traipse through these, find one class that has an unbound method, get
>that unbound method's func_globals, bingo.

One thing my company has done is written a ``safe_eval()`` that uses a
regex to disable double-underscore access.

-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/
"19. A language that doesn't affect the way you think about programming,
is not worth knowing."  --Alan Perlis


Relevant Pages

  • Re: limited python virtual machine
    ... Alex Martelli wrote: ... > Traipse through these, find one class that has an unbound method, get ... bingo. ...
    (comp.lang.python)
  • Re: limited python virtual machine
    ... Traipse through these, find one class that has an unbound method, get ... that unbound method's func_globals, bingo. ... Alex ...
    (comp.lang.python)
  • Re: limited python virtual machine
    ... > Traipse through these, find one class that has an unbound method, get ... bingo. ... So long as any Python modules are imported using the same restricted environment ... However, we're talking about building a custom interpreter here, so there's no ...
    (comp.lang.python)
  • Re: new.instancemethod as a form of partial()
    ... Alex Martelli wrote: ... the im_self of an unbound method is None, ... > the im_self of a bound method is anything else. ... > actually achieved your goal (you must still pass the first parameter ...
    (comp.lang.python)