raw_input自然是一种收集用户输入的安全方法吗



基本上,有人能通过在raw_input中输入代码来危害我的程序吗?

i.e.
##instead of entering their name below, could they enter some compromising code?
name = raw_input('what is your name?: ')

raw_input在直接意义上是安全的,这一行:

name = raw_input('what is your name?: ')

本身不能触发代码注入。但在那之后,你可能会打开其他漏洞,这取决于你对字符串的处理。例如,如果您将其用于数据库查找,您仍然必须单独防范SQL注入,通常是通过使用参数化查询。

最新更新