Ah, true. If there&#39;s an effort to create a sandbox mode, please also consider time out scenarios so we don&#39;t have infite loops causing much damage.<br><br><div class="gmail_quote">On Mon, Jun 30, 2008 at 3:35 PM, Michael Foord &lt;<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>&gt; 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 (&quot;bzz, can&#39;t load AddReference&quot;) - Yeah, it&#39;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 &#39;outside&#39;.<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 &lt;<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a> &lt;mailto:<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>&gt;&gt; wrote:<br>


<br>
 &nbsp; &nbsp;Dody Gunawinata wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;In the IronPython hosting API, unless you specifically load<br>
 &nbsp; &nbsp; &nbsp; &nbsp;the assembly, it will not be accessible through the script. So<br>
 &nbsp; &nbsp; &nbsp; &nbsp;right now restricting access means configuring the assemblies<br>
 &nbsp; &nbsp; &nbsp; &nbsp;you want to expose to the script.<br>
<br>
<br>
 &nbsp; &nbsp;But what is to stop the user code doing:<br>
<br>
 &nbsp; &nbsp;import clr<br>
 &nbsp; &nbsp;clr.AddReference(&#39;SomeAssembly&#39;)<br>
<br>
 &nbsp; &nbsp;Loading the ScriptRuntime into an AppDomain and restricting the<br>
 &nbsp; &nbsp;privileges on that is one way - but I don&#39;t think that IronPython<br>
 &nbsp; &nbsp;will work at all unless the AppDomain has pretty much full trust.<br>
<br>
 &nbsp; &nbsp;Michael Foord<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;On Mon, Jun 30, 2008 at 3:09 PM, Ben Hall<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a> &lt;mailto:<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a>&gt;<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a><div><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:ben2004uk@googlemail.com" target="_blank">ben2004uk@googlemail.com</a>&gt;&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I thought this last night, it would be really useful if we<br>
 &nbsp; &nbsp; &nbsp; &nbsp;could<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;sandbox&#39; the IP engine and limit it&#39;s access to certain<br>
 &nbsp; &nbsp; &nbsp; &nbsp;areas of the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; framework.<br>
<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; On Mon, Jun 30, 2008 at 12:57 PM, Rainer Worbis<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a> &lt;mailto:<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a>&gt;<br></div><div>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a> &lt;mailto:<a href="mailto:r.worbis@cubido.at" target="_blank">r.worbis@cubido.at</a>&gt;&gt;&gt; wrote:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; No - for example i would like to prevent that the user loads<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assemblies and does own data access via System.Data.SqlClient.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Or uses specific parts of the applications. (which should be<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; visible to other scripts). So access control per script<br>
 &nbsp; &nbsp; &nbsp; &nbsp;would be<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; optimal.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Rainer<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; -----Ursprüngliche Nachricht-----<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Von: <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>&gt;&gt;<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><div><div></div><div><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>&gt;&gt;] Im Auftrag von<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Korbinian Abenthum<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Gesendet: Montag, 30. Juni 2008 13:47<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; An: Discussion of IronPython<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Betreff: Re: [IronPython] restrict scripting access<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Rainer Worbis wrote:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; is there a way to restrict access to objects or namespaces<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; within a script? We use IronPython for providing scripting<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; functionality within our .NET Application but would like to<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; restrict access to certain functions. Has anybody<br>
 &nbsp; &nbsp; &nbsp; &nbsp;information<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; or a sample how to do that?<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Can you declare the restricted objects as &quot;internal&quot;?<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Cheers,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp;Korbinian<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; _______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Users mailing list<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; <a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; _______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Users mailing list<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; <a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Users mailing list<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br></div></div><div>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <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>
 &nbsp; &nbsp; &nbsp; &nbsp;--  &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://nomadlife.org" target="_blank">nomadlife.org</a> &lt;<a href="http://nomadlife.org" target="_blank">http://nomadlife.org</a>&gt; &lt;<a href="http://nomadlife.org" target="_blank">http://nomadlife.org</a>&gt;<br>


 &nbsp; &nbsp; &nbsp; &nbsp;------------------------------------------------------------------------<br>
<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;_______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Users mailing list<div><br>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a> &lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; <br>
<br>
<br></div><div>
 &nbsp; &nbsp;--  &nbsp; &nbsp;<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
 &nbsp; &nbsp;<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br>
 &nbsp; &nbsp;<a href="http://www.trypython.org/" target="_blank">http://www.trypython.org/</a><br>
 &nbsp; &nbsp;<a href="http://www.ironpython.info/" target="_blank">http://www.ironpython.info/</a><br>
 &nbsp; &nbsp;<a href="http://www.resolverhacks.net/" target="_blank">http://www.resolverhacks.net/</a><br>
 &nbsp; &nbsp;<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> &lt;<a href="http://nomadlife.org" target="_blank">http://nomadlife.org</a>&gt;<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>
 &nbsp;<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>