lib

Kross::Python::PythonSecurity Class Reference

#include <pythonsecurity.h>

List of all members.


Detailed Description

This class handles the used Zope3 RestrictedPython package to spend a restricted sandbox for scripting code.

The RestrictedPython code is avaible as Python files. So, this class takes care of loading them and spending the functions we need to access the functionality from within Kross. That way it's easy to update the module with a newer version if some security issues show up.

What the RestrictedPython code does is to compile the plain python code (py) into compiled python code (pyc) and manipulate those compiled code by replacing unsafe code with own wrapped code. As example a simple "x = y.z" would be transfered to "x = _getattr_(y, 'z')". The _getattr_ is defined in the RestrictedPython module and will take care of applied restrictions.

See also:
http://www.zope.org

http://svn.zope.org/Zope3/trunk/src/RestrictedPython/

Definition at line 56 of file pythonsecurity.h.


Public Member Functions

 PythonSecurity (PythonInterpreter *interpreter)
virtual ~PythonSecurity ()
PyObject * compile_restricted (const QString &source, const QString &filename, const QString &mode)

Constructor & Destructor Documentation

PythonSecurity::PythonSecurity ( PythonInterpreter interpreter  )  [explicit]

Constructor.

Parameters:
interpreter The PythonInterpreter instance used to create this Module.

Definition at line 28 of file pythonsecurity.cpp.

PythonSecurity::~PythonSecurity (  )  [virtual]

Destructor.

Definition at line 52 of file pythonsecurity.cpp.


Member Function Documentation

PyObject * PythonSecurity::compile_restricted ( const QString &  source,
const QString &  filename,
const QString &  mode 
)

Compile python scripting code and return a restricted code object.

Parameters:
source The python scripting code.
filename The filename used on errormessages.
mode Compilemode, could be 'exec' or 'eval' or 'single'.
Returns:
The compiled python code object on success else NULL. The caller owns the resulting object and needs to take care to decrease the ref-counter it not needed any longer.

Definition at line 109 of file pythonsecurity.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys