<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Arial Black";
panose-1:2 11 10 4 2 1 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Arial","sans-serif";
color:windowtext;
font-weight:normal;
font-style:normal;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">We’re using IronPython as a hosted script engine in our application.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">Now, we want to restrict the assemblies a user can reference from its python script,
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">Currently, we just forbid “import clr”, by wrapping the import() method, but this is a bit harsh, and the side-effects are a little bit to strong (e. G. it causes
“import minidom.py” to fail…)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">However, there seems to be no event or other hook available for AddReference which I could use. It may be possible to add an AssemblyLoading event to the ScriptDomainManager
in Microsoft.Scripting.Runtime, which allows to cancel the assembly loading by throwing an exception. Would such a patch be accepted upstream?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">An alternative (not-so-elegant) idea is that I just wrap all the AddReference() & Co calls inside the clr module, but there may be a more elegant way.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">Isolating Ironpython in its own AppDomain is not an option, as this would require major rework of our Scripting API implementation, and also break backwards compatibility
for 3<sup>rd</sup> party plugins which contribute API for the scripts.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">(We don’t need a 100% waterproof method - we know that the user can use cTypes, System.Reflection, or whatever to circumvent everything - we just want to restrict
the obvious ways to access some APIs we consider to be internal.)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">Best regards<br>
<br>
Markus Schaber<br>
<span style="color:white">-- </span><br>
</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:#9C9C9F;mso-fareast-language:DE">___________________________</span><span style="font-size:12.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-top:6.0pt;mso-margin-bottom-alt:auto"><span style="font-size:9.0pt;font-family:"Arial Black","sans-serif";color:#9C9C9F;mso-fareast-language:DE">We software Automation.<br>
<br>
</span><span style="font-size:9.0pt;font-family:"Arial Black","sans-serif";color:#C40020;mso-fareast-language:DE">3S-Smart Software Solutions GmbH<br>
</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">Markus Schaber | Developer<br>
Memminger Str. 151 | 87439 Kempten | Germany | Tel. </span><span lang="EN-US" style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">+49-831-54031-0 | Fax +49-831-54031-50<br>
<br>
Email: </span><u><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:blue;mso-fareast-language:DE"><a href="mailto:m.schaber@3s-software.com"><span lang="EN-US" style="color:blue">m.schaber@3s-software.com</span></a></span></u><span lang="EN-US" style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">
| Web: </span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><a href="http://www.3s-software.com/"><span lang="EN-US" style="color:blue">http://www.3s-software.com
</span></a></span><span lang="EN-US" style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><br>
CoDeSys internet forum:</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><a href="http://forum-en.3s-software.com/"><span lang="EN-US" style="color:blue"> http://forum.3s-software.com</span></a></span><span lang="EN-US" style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><br>
Download CoDeSys sample projects: </span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><a href="http://www.3s-software.com/index.shtml?sample_projects"><span lang="EN-US" style="color:blue">http://www.3s-software.com/index.shtml?sample_projects</span></a></span><span lang="EN-US" style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><br>
<br>
</span><i><span lang="EN-US" style="font-size:7.5pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner</span></i><span lang="EN-US" style="font-size:7.5pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">
| <i>Trade register: Kempten HRB 6186</i> | <i>Tax ID No.: DE 167014915</i></span><i><span lang="EN-US" style="font-size:12.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE">
</span></i><span lang="EN-US" style="font-size:9.0pt;font-family:"Arial","sans-serif";mso-fareast-language:DE"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>