I embed IronPython in my game engine, where you can attach scripts to objects. I do not want scripts to be able to simply access the CLR whenever they want, because then they could do something.
Having random scripts, especially if they are downloaded from the Internet, the ability to open Internet connections, access to users' hard drives or change the internal game state is very bad.
Usually people just suggest "Use a separate AppDomain." However, if I'm not mistaken, cross-AppDomains is slow. Very slow. Too slow for the game engine. Therefore, I am considering alternatives.
I was thinking of compiling a custom version of IronPython that is stopping you from importing clr or any namespace, thereby limiting it to a standard library.
The option I'd rather go with goes along the following lines:
__builtins__.__import__ = None #Stops imports working reload = None #Stops reloading working (specifically stops them reloading builtins #giving back an unbroken __import___!
I read this in another overflow column. Suppose that instead of setting __ builtins _._ import__ to none, instead I set it to a user-defined function that allows loading the standard API.
The question is, using the method described above, will there be any way for the script to be able to access the clr module, BCL BCnet, or anything else that could potentially do bad things? Or do I need to change the source? Third option?
source share