记得flask文档说我们可以专注于开发,安全问题不怎么需要担心?
用peewee或者其他orm就不用管这个问题了吧,如果我直接g.db.execu呢
用peewee或者其他orm就不用管这个问题了吧,如果我直接g.db.execu呢
|
1
http://flask.pocoo.org/docs/patterns/sqlite3/#easy-querying
To pass variable parts to the SQL statement, use a question mark in the statement and pass in the arguments as a list. Never directly add them to the SQL statement with string formatting because this makes it possible to attack the application using SQL Injections. |
|
BrutalSep 21, 2012
2
我现在在犹豫要不要用ORM。。。
|
|
3
@fanzheng 下面这样就不会被注入了么?
user = query_db('select * from users where username = ?', [the_username], one=True) 请问怎么写的才是能被注入的,上面的我看起来像可以被注入的。。。 例如the_username=";delete * from users" |
|
fanzhengSep 21, 2012
4
|
|
fanzhengSep 21, 2012
5
他说不要这样
user = query_db('select * from users where username = %s' % 请求的参数) 因为%s 里面可以另外构造一个SQL语句。 |
|
7
user = query_db('select * from users where username = ?',
[the_username], one=True) 这里系统会自动对危险字符进行转义。一般将客户端输入的内容作为 query_db 之类函数参数进行提交的都不用担心注入,而自己通过 %s 之类的构建查询字符串就要小心了。 |
|
stackpopSep 22, 2012
8
我用django是自己实现了一个简单的db类
|