IronPython disable Import after use -
Once I have finished using it, is there any way to disable the use of import? I am using IronPython as a scripting engine and I do not want users to be able to import anything. This can be done in LuaInterface using the setfen:
luanet.load_assembly ("System.Windows.Forms") luanet.load_assembly ("System.Drawing") form = luanet.import_type ( "System.Windows.Forms.Form") - Allow the use of the form class local env = {form = _G.Form} setfenv (1, env)
or setting script file To parse the import job before parsing:
luanet.load_assembly = zero luanet.import_type = nil
whether it is possible in IronPython ?
One option is to pre-check those scripts that you are performing and those who have Import
statements (or from ... import
statement).
foreach (line in script) {if (line.TrimeStart (.) Start ("import"); line.remeststart (). Start ("to") {throw ...; }}
This is not stupid ( __ import____
is still an issue), but it will cover the VA in most cases.
Comments
Post a Comment