Ah, true. If there's an effort to create a sandbox mode, please also consider time out scenarios so we don't have infite loops causing much damage.<br><br><div class="gmail_quote">On Mon, Jun 30, 2008 at 3:35 PM, Michael Foord <<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Dody Gunawinata wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
That you can filter our from the python source code or replace such call with exception ("bzz, can't load AddReference") - Yeah, it's a pretty nasty workaround, but it works.<br>
</blockquote>
<br></div>
Unfortunately not - one of the disadvantages of a highly dynamic language. There are lots of alternative ways of getting at the functionality.<br>
<br>
Using the __import__ function instead of import. Using getattr with strings instead of including the literals in the source code. etc etc<br>
<br>
It is for these reasons that the rexec module was deprecated in CPython, it is basically impossible to prevent access to certain builtin features. You have to apply the restrictions from the 'outside'.<br>
<br>
Michael<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Dody G.<div><br>
<br>
On Mon, Jun 30, 2008 at 3:26 PM, Michael Foord <<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a> <mailto:<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>>> wrote:<br>
<br>
Dody Gunawinata wrote:<br>
<br>
In the IronPython hosting API, unless you specifically load<br>
the assembly, it will not be accessible through the script. So<br>
right now restricting access means configuring the assemblies<br>
you want to expose to the script.<br>
<br>
<br>
But what is to stop the user code doing:<br>
<br>
import clr<br>
clr.AddReference('SomeAssembly')<br>
<br>
Loading the ScriptRuntime into an AppDomain and restricting the<br>
privileges on that is one way - but I don't think that IronPython<br>
will work at all unless the AppDomain has pretty much full trust.<br>
<br>
Michael Foord<br>
<br>
On Mon, Jun 30, 2008 at 3:09 PM, Ben Hall<br>
<<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a> <mailto:<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a>><br></div>
<mailto:<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a><div><br>
<mailto:<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a>>>> wrote:<br>
<br>
I thought this last night, it would be really useful if we<br>
could<br>
'sandbox' the IP engine and limit it's access to certain<br>
areas of the<br>
framework.<br>
<br>
<br>
<br>
On Mon, Jun 30, 2008 at 12:57 PM, Rainer Worbis<br>
<<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a> <mailto:<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a>><br></div><div>
<mailto:<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a> <mailto:<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a>>>> wrote:<br>
> No - for example i would like to prevent that the user loads<br>
assemblies and does own data access via System.Data.SqlClient.<br>
> Or uses specific parts of the applications. (which should be<br>
visible to other scripts). So access control per script<br>
would be<br>
optimal.<br>
><br>
> Rainer<br>
><br>
> -----Ursprüngliche Nachricht-----<br>
> Von: <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><br>
<mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>><br>
<mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><br>
<mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>>><br></div>
[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><div><div></div><div><br>
<mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>><br>
<mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><br>
<mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>>>] Im Auftrag von<br>
Korbinian Abenthum<br>
> Gesendet: Montag, 30. Juni 2008 13:47<br>
> An: Discussion of IronPython<br>
> Betreff: Re: [IronPython] restrict scripting access<br>
><br>
> Rainer Worbis wrote:<br>
>> is there a way to restrict access to objects or namespaces<br>
>> within a script? We use IronPython for providing scripting<br>
>> functionality within our .NET Application but would like to<br>
>> restrict access to certain functions. Has anybody<br>
information<br>
>> or a sample how to do that?<br>
><br>
> Can you declare the restricted objects as "internal"?<br>
><br>
> Cheers,<br>
> Korbinian<br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>>><br>
<br>
> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>>><br>
<br>
> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>><br>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br></div></div><div>
<mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>>><br>
<br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br>
<br>
<br>
<br></div>
-- <a href="http://nomadlife.org" target="_blank">nomadlife.org</a> <<a href="http://nomadlife.org" target="_blank">http://nomadlife.org</a>> <<a href="http://nomadlife.org" target="_blank">http://nomadlife.org</a>><br>
------------------------------------------------------------------------<br>
<br>
<br>
<br>
_______________________________________________<br>
Users mailing list<div><br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a> <mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br>
<br>
<br></div><div>
-- <a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br>
<a href="http://www.trypython.org/" target="_blank">http://www.trypython.org/</a><br>
<a href="http://www.ironpython.info/" target="_blank">http://www.ironpython.info/</a><br>
<a href="http://www.resolverhacks.net/" target="_blank">http://www.resolverhacks.net/</a><br>
<a href="http://www.theotherdelia.co.uk/" target="_blank">http://www.theotherdelia.co.uk/</a><br>
<br>
<br>
<br>
<br>
-- <br>
<a href="http://nomadlife.org" target="_blank">nomadlife.org</a> <<a href="http://nomadlife.org" target="_blank">http://nomadlife.org</a>><br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br>
</div></blockquote><div><div></div><div>
<br>
<br>
-- <br>
<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br>
<a href="http://www.trypython.org/" target="_blank">http://www.trypython.org/</a><br>
<a href="http://www.ironpython.info/" target="_blank">http://www.ironpython.info/</a><br>
<a href="http://www.resolverhacks.net/" target="_blank">http://www.resolverhacks.net/</a><br>
<a href="http://www.theotherdelia.co.uk/" target="_blank">http://www.theotherdelia.co.uk/</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://nomadlife.org" target="_blank">nomadlife.org</a><br>