<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Don&#8217;t be lazy. Don&#8217;t use eval().</title>
	<atom:link href="http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval</link>
	<description></description>
	<lastBuildDate>Wed, 28 Apr 2010 01:17:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Carlos Ribeiro</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-362</link>
		<dc:creator>Carlos Ribeiro</dc:creator>
		<pubDate>Wed, 04 Nov 2009 10:49:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-362</guid>
		<description>&lt;a href=&quot;#comment-361&quot; rel=&quot;nofollow&quot;&gt;@Carlos Ribeiro &lt;/a&gt; 
Oops. Two typos above: problemas -&gt; problems, halt baked -&gt; half baked. Sorry.</description>
		<content:encoded><![CDATA[<p><a href="#comment-361" rel="nofollow">@Carlos Ribeiro </a><br />
Oops. Two typos above: problemas -&gt; problems, halt baked -&gt; half baked. Sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos Ribeiro</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-361</link>
		<dc:creator>Carlos Ribeiro</dc:creator>
		<pubDate>Wed, 04 Nov 2009 10:47:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-361</guid>
		<description>I&#039;m sure you can find quotes by GvR himself suggesting not to use eval(). And in fact it pisses me off to have a professor write a long rant (in the third comment) full of theorethical stuff that has close to nothing to do with the particular problema. It&#039;s a kind of FUD, one of the worst: look knowledgeable by quoting people who are respected, and then make a halt baked argument.

The problem with eval() is not a theorethical one - it&#039;s just that the implementation is inherently unsafe. Python&#039;s introspection features make it *impossible* to guarantee that eval() is safe. It&#039;s fairly easy to jump off the sandbox. By the way - they had to rewrite a lot of the standard library code to support Python in Google&#039;s App Engine. And that was GvR himself working there. They had to make sure that none of the modules that are authorized allowed calls to use any of the available techniques to break out of the sandbox.

BTW: Next time a professor or a Nobel prize winner have something to say - please say it directly. Borrowing credentials from Turing are no help here.</description>
		<content:encoded><![CDATA[<p>I&#8217;m sure you can find quotes by GvR himself suggesting not to use eval(). And in fact it pisses me off to have a professor write a long rant (in the third comment) full of theorethical stuff that has close to nothing to do with the particular problema. It&#8217;s a kind of FUD, one of the worst: look knowledgeable by quoting people who are respected, and then make a halt baked argument.</p>
<p>The problem with eval() is not a theorethical one &#8211; it&#8217;s just that the implementation is inherently unsafe. Python&#8217;s introspection features make it *impossible* to guarantee that eval() is safe. It&#8217;s fairly easy to jump off the sandbox. By the way &#8211; they had to rewrite a lot of the standard library code to support Python in Google&#8217;s App Engine. And that was GvR himself working there. They had to make sure that none of the modules that are authorized allowed calls to use any of the available techniques to break out of the sandbox.</p>
<p>BTW: Next time a professor or a Nobel prize winner have something to say &#8211; please say it directly. Borrowing credentials from Turing are no help here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Riley</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-51</link>
		<dc:creator>Mike Riley</dc:creator>
		<pubDate>Sat, 13 Jun 2009 17:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-51</guid>
		<description>I have to agree with @Brian, FireBug extensively uses eval and in my profession it&#039;s one of the most useful tools available.</description>
		<content:encoded><![CDATA[<p>I have to agree with @Brian, FireBug extensively uses eval and in my profession it&#8217;s one of the most useful tools available.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PeeJ</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-50</link>
		<dc:creator>PeeJ</dc:creator>
		<pubDate>Fri, 12 Jun 2009 17:31:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-50</guid>
		<description>Michael:
To be sure, actually doing something malicious would get someone fired.  In the case I was thinking about, I&#039;d likely sign the whole crew up for an ethics course. I say this not to offend - I think you have also missed the point.

Just as the prof was trying to broaden the perspective within the art and science, I was extending (trying to, anyway) to the bigger picture of working in our profession.  The prof said &quot;In this profession, you need to become more than the sum of the artifacts that you manipulate.&quot;  We are also more than manipulators of artifacts and we need to understand that fact and talk about it.

I firmly believe that our &quot;profession&quot; needs to address the issue of ethics, ethical standards, responsibility. We have, as a profession, largely ignored it and it&#039;s been to our detriment.  The ACM&#039;s Code of Ethics (http://www.acm.org/about/code-of-ethics) is a great place to start but we never talk about things like that.

When I was in school back in the 70&#039;s, we joked that computer programmers were going to take over the world.  It seems we were more right than we knew.  What we do is, in many respects, what runs the world - business, communications, entertainment, learning and just about everything else works the way it does because of us.  We have an awesome power and should be awed at the conjugate responsibilty.

The &quot;It would be his fault&quot; attitude seems to me to derive from the same sloppy &quot;thinking&quot; that gives rise to statements like &quot;she should not have worn that slinky outfit, it&#039;s no surprise she got raped.&quot;  NB: I&#039;m saying those notions arise from the same source; of course I&#039;m not trying to draw some equivalence with rape. How about we make it &quot;If I punched you in the nose, it would be your fault for not ducking?&quot;

This isn&#039;t about me, about the blogger, about anyone in particular.  This long comment is about recognizing that we are more than programmers. We are the folks who people the world over have to trust both implicitly and explicitly.  We have to trust _each other_.  Ken Thompson said “You can’t trust code that you didn’t totally write yourself.”  In other words, you bascially can&#039;t trust *any* code.  The scenario Chris concocted would be a sore violation of trust.

Again, I&#039;m not talking about one&#039;s repsonsibility when using eval() or whatever.  I&#039;m talking about the underlying attitudes and assumptions, the self reinforcing tunnel vision that&#039;s going on here and throughout our profession.

I want to say as well that I&#039;m not accusing Chris of anything in particular. I&#039;m not saying he&#039;s a malicious shit. It&#039;s the total lack of discussion - among us self-identifying &quot;professionals&quot; - about being malicious, and shifting (intentionally or not) the blame, that makes it clear that we need to formally introduce a code of ethics, and education to go with it.  We need it desperately.</description>
		<content:encoded><![CDATA[<p>Michael:<br />
To be sure, actually doing something malicious would get someone fired.  In the case I was thinking about, I&#8217;d likely sign the whole crew up for an ethics course. I say this not to offend &#8211; I think you have also missed the point.</p>
<p>Just as the prof was trying to broaden the perspective within the art and science, I was extending (trying to, anyway) to the bigger picture of working in our profession.  The prof said &#8220;In this profession, you need to become more than the sum of the artifacts that you manipulate.&#8221;  We are also more than manipulators of artifacts and we need to understand that fact and talk about it.</p>
<p>I firmly believe that our &#8220;profession&#8221; needs to address the issue of ethics, ethical standards, responsibility. We have, as a profession, largely ignored it and it&#8217;s been to our detriment.  The ACM&#8217;s Code of Ethics (<a href="http://www.acm.org/about/code-of-ethics" rel="nofollow">http://www.acm.org/about/code-of-ethics</a>) is a great place to start but we never talk about things like that.</p>
<p>When I was in school back in the 70&#8242;s, we joked that computer programmers were going to take over the world.  It seems we were more right than we knew.  What we do is, in many respects, what runs the world &#8211; business, communications, entertainment, learning and just about everything else works the way it does because of us.  We have an awesome power and should be awed at the conjugate responsibilty.</p>
<p>The &#8220;It would be his fault&#8221; attitude seems to me to derive from the same sloppy &#8220;thinking&#8221; that gives rise to statements like &#8220;she should not have worn that slinky outfit, it&#8217;s no surprise she got raped.&#8221;  NB: I&#8217;m saying those notions arise from the same source; of course I&#8217;m not trying to draw some equivalence with rape. How about we make it &#8220;If I punched you in the nose, it would be your fault for not ducking?&#8221;</p>
<p>This isn&#8217;t about me, about the blogger, about anyone in particular.  This long comment is about recognizing that we are more than programmers. We are the folks who people the world over have to trust both implicitly and explicitly.  We have to trust _each other_.  Ken Thompson said “You can’t trust code that you didn’t totally write yourself.”  In other words, you bascially can&#8217;t trust *any* code.  The scenario Chris concocted would be a sore violation of trust.</p>
<p>Again, I&#8217;m not talking about one&#8217;s repsonsibility when using eval() or whatever.  I&#8217;m talking about the underlying attitudes and assumptions, the self reinforcing tunnel vision that&#8217;s going on here and throughout our profession.</p>
<p>I want to say as well that I&#8217;m not accusing Chris of anything in particular. I&#8217;m not saying he&#8217;s a malicious shit. It&#8217;s the total lack of discussion &#8211; among us self-identifying &#8220;professionals&#8221; &#8211; about being malicious, and shifting (intentionally or not) the blame, that makes it clear that we need to formally introduce a code of ethics, and education to go with it.  We need it desperately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: emmelaich</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-49</link>
		<dc:creator>emmelaich</dc:creator>
		<pubDate>Fri, 12 Jun 2009 16:05:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-49</guid>
		<description>&quot;Don’t be lazy. Don’t use eval().&quot; is fine advice.
You could add &quot;unless necessary&quot; but this is a blog
for crying out loud.
The Dr. generalises the advice to the point of
unrecognisability then criticises the generalisation.

Here&#039;s an exercise for you: for what is eval() in
python absolutely required? I&#039;ll guess nothing.
So the advice stands up well, even though it might be
in some cases safe enough and efficient enough to
do an eval().</description>
		<content:encoded><![CDATA[<p>&#8220;Don’t be lazy. Don’t use eval().&#8221; is fine advice.<br />
You could add &#8220;unless necessary&#8221; but this is a blog<br />
for crying out loud.<br />
The Dr. generalises the advice to the point of<br />
unrecognisability then criticises the generalisation.</p>
<p>Here&#8217;s an exercise for you: for what is eval() in<br />
python absolutely required? I&#8217;ll guess nothing.<br />
So the advice stands up well, even though it might be<br />
in some cases safe enough and efficient enough to<br />
do an eval().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-48</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 12 Jun 2009 13:44:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-48</guid>
		<description>RE: PeeJ

If I were fired by you for that reason, I&#039;d be relieved to no longer be employed by you.

Yes, it was the attacker who committed a ethical violation, but that being said, it is still the victim who has the responsibility to prevent such an attack.  That is our job.  We must assume that all inputs are adversarial and do everything within our power to ensure security.  To do otherwise is a violation of our obligations.

Saying &quot;it&#039;s the victim&#039;s fault&quot; is a bit severe without qualification, but it&#039;s not too far off.  If you want to use eval(), you must accept the consequences and factor them into your design.  You can&#039;t directly be held accountable for the unethical actions of those abusing your decision, but having known in advance that someone would most certainly try, you can certainly be held professionally accountable for the decision to use such a mechanism by your employer.</description>
		<content:encoded><![CDATA[<p>RE: PeeJ</p>
<p>If I were fired by you for that reason, I&#8217;d be relieved to no longer be employed by you.</p>
<p>Yes, it was the attacker who committed a ethical violation, but that being said, it is still the victim who has the responsibility to prevent such an attack.  That is our job.  We must assume that all inputs are adversarial and do everything within our power to ensure security.  To do otherwise is a violation of our obligations.</p>
<p>Saying &#8220;it&#8217;s the victim&#8217;s fault&#8221; is a bit severe without qualification, but it&#8217;s not too far off.  If you want to use eval(), you must accept the consequences and factor them into your design.  You can&#8217;t directly be held accountable for the unethical actions of those abusing your decision, but having known in advance that someone would most certainly try, you can certainly be held professionally accountable for the decision to use such a mechanism by your employer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hodrige</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-61</link>
		<dc:creator>Hodrige</dc:creator>
		<pubDate>Fri, 12 Jun 2009 11:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-61</guid>
		<description>http://mrldust.files.wordpress.com/2009/02/professor-of-cool.jpg?w=376&amp;h=469

Photo of Dr. Dale Parson</description>
		<content:encoded><![CDATA[<p><a href="http://mrldust.files.wordpress.com/2009/02/professor-of-cool.jpg?w=376&amp;h=469" rel="nofollow">http://mrldust.files.wordpress.com/2009/02/professor-of-cool.jpg?w=376&amp;h=469</a></p>
<p>Photo of Dr. Dale Parson</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marvin gardens</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-2#comment-60</link>
		<dc:creator>marvin gardens</dc:creator>
		<pubDate>Fri, 12 Jun 2009 10:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-60</guid>
		<description>@Ethan

Yes, you&#039;re correct. Inserting malicious code to be run by some professor who is assumed to be totally not careful about running random code, would not require use of eval. This is what makes that whole bit silly.</description>
		<content:encoded><![CDATA[<p>@Ethan</p>
<p>Yes, you&#8217;re correct. Inserting malicious code to be run by some professor who is assumed to be totally not careful about running random code, would not require use of eval. This is what makes that whole bit silly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Twitted by emorozov</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-1#comment-59</link>
		<dc:creator>Twitted by emorozov</dc:creator>
		<pubDate>Fri, 12 Jun 2009 10:16:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-59</guid>
		<description>[...] This post was Twitted by emorozov - Real-url.org [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was Twitted by emorozov &#8211; Real-url.org [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Finite</title>
		<link>http://blog.thetonk.com/archives/dont-be-lazy-dont-use-eval/comment-page-1#comment-58</link>
		<dc:creator>Finite</dc:creator>
		<pubDate>Fri, 12 Jun 2009 08:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.thetonk.com/?p=190#comment-58</guid>
		<description>Python&#039;s &quot;apply&quot; function has been deprecated in favor of the extended calling syntax since version 2.3, which was released in 2003. Instead of apply(func, args) we just write func(*args) these days.

Eval is very useful, but it provides none of the safety the professor thinks it does. A false sense of security is much worse than having no security at all.

For the example given, however, eval is not the right tool for the job. If you expect the argument to eval to be the name of a function, it would make more sense to just look for the function name in the symbol table and not have to worry about evaluating arbitrary expressions. Read up about the builtins called globals, locals, and vars.

sortfunc=vars()[sys.argv[1]]

This thread makes me really glad that I learned to program on the interwebs instead of in a classroom!</description>
		<content:encoded><![CDATA[<p>Python&#8217;s &#8220;apply&#8221; function has been deprecated in favor of the extended calling syntax since version 2.3, which was released in 2003. Instead of apply(func, args) we just write func(*args) these days.</p>
<p>Eval is very useful, but it provides none of the safety the professor thinks it does. A false sense of security is much worse than having no security at all.</p>
<p>For the example given, however, eval is not the right tool for the job. If you expect the argument to eval to be the name of a function, it would make more sense to just look for the function name in the symbol table and not have to worry about evaluating arbitrary expressions. Read up about the builtins called globals, locals, and vars.</p>
<p>sortfunc=vars()[sys.argv[1]]</p>
<p>This thread makes me really glad that I learned to program on the interwebs instead of in a classroom!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
