<div dir="ltr">I had an issue once that i was getting true and false statements in text and needed to convert them into Python boolean objects. So i wrote a function to parse the text. and return True or False based on the text.<br>
<br><div class="gmail_quote">On Thu, Aug 28, 2008 at 3:09 PM, Guilherme Polo <span dir="ltr"><<a href="mailto:ggpolo@gmail.com">ggpolo@gmail.com</a>></span> 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><div></div><div class="Wj3C7c">On Thu, Aug 28, 2008 at 6:51 PM, Fett <<a href="mailto:FettManChu@gmail.com">FettManChu@gmail.com</a>> wrote:<br>
> I am creating a program that requires some data that must be kept up<br>
> to date. What I plan is to put this data up on a web-site then have<br>
> the program periodically pull the data off the web-site.<br>
><br>
> My problem is that when I pull the data (currently stored as a<br>
> dictionary on the site) off the site, it is a string, I can use eval()<br>
> to make that string into a dictionary, and everything is great.<br>
> However, this means that I am using eval() on some string on a web-<br>
> site, which seems pretty un-safe.<br>
><br>
> I read that by using eval(code,{"__builtins__":None},{}) I can prevent<br>
> them from using pretty much anything, and my nested dictionary of<br>
> strings is still allowable. What I want to know is:<br>
><br>
> What are the dangers of eval?<br>
> - I originally was using exec() but switched to eval() because I<br>
> didn't want some hacker to be able to delete/steal files off my<br>
> clients computers. I assume this is not an issue with eval(), since<br>
> eval wont execute commands.<br>
> - What exactly can someone do by modifying my code string in a command<br>
> like: thing = eval(code{"__builtins__":None},{}), anything other than<br>
> assign their own values to the object thing?<br>
<br>
</div></div>By "disabling" __builtins__ you indeed cut some obvious tricks, but<br>
someone still could send you a string like "10 ** 10 ** 10".<br>
<div class="Ih2E3d"><br>
> --<br>
> <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
><br>
<br>
<br>
</div><font color="#888888">--<br>
-- Guilherme H. Polo Goncalves<br>
</font><div><div></div><div class="Wj3C7c">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.goldwatches.com/">http://www.goldwatches.com/</a><br>
</div>