Simple eval

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Nov 19 04:20:42 EST 2007


On Sun, 18 Nov 2007 21:46:49 -0800, MonkeeSage wrote:

> As I see it, just as a matter of common sense, there will be no way to
> match the performance of the backend eval() with any interpreted code.
> At best, performance-wise, a preprocessor for the built-in eval() would
> be in order, filtering out the "unsafe" cases and passing the rest
> through. But what do I know, I could be dead wrong. :)


In general, there are two approaches to security.

The first is "Anything not explicitly permitted is forbidden".

The second is "Anything not explicitly forbidden is permitted".


The first is used when you actually want security. The second is when you 
are only pretending to care about security.

Valuing convenience and ease of use over security is a reasonable thing 
to do, but only so long as you know that you are putting security second 
and are prepared to face the consequences. I for one don't surround 
myself with a team of crack British ex-SAS officers as body guards, but 
that's because I'm prepared to run the risk of Russian ex-KGB special 
forces attacking.

On the other hand... I do lock my house. Rather than providing a list of 
people not allowed into the house, only those with a key are permitted.


-- 
Steven.



More information about the Python-list mailing list