[Python-ideas] Another way to avoid clumsy lambdas, while adding new functionality

David Mertz mertz at gnosis.cx
Wed Mar 5 22:40:25 CET 2014


On Wed, Mar 5, 2014 at 1:31 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Thu, Mar 6, 2014 at 8:20 AM, David Mertz <mertz at gnosis.cx> wrote:
> > The literal hardly saves you from injection attacks.  I could write this
> too
> > under the proposed idea:
> >
> >   foo = get_string_from_attacker()
> >   a = $(foo)
> >   b = a.eval()
> >
> > Now one can say "don't do that!" ... but that advice applies just as
> well to
> > 'compile(unsafe_string, ...)'
>
> That'll just be like doing:
>
> b = foo
>
> So it's still safe. That's the point.
>

Doh! You are right.  The literal does make it somewhat harder to shoot
yourself in the foot with code injection, I had a thinko there.  Still,
advice in the docs not to do 'compile(untrusted_string, ...)' feels like it
pretty much does what we actually need.

-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140305/a1946eea/attachment-0001.html>


More information about the Python-ideas mailing list