【发布时间】:2015-08-24 00:11:01
【问题描述】:
我在How to prevent SQL Injection in hibernate? 看到了 HQL SQL 注入主题。但是我不明白Query.setParameter("<parameter name>",<parameter value>)是怎么回事
消除 SQL 注入,
如果恶意用户将true = true传递给关注HQL,String hqlString = "from Item item where name= '"+nameValue+"'";
那么他也可以将它传递给query.setString("name"+ nameValue)!
setString() 及其所有姊妹方法是否有任何过滤器来检查 SQL 注入?
【问题讨论】:
-
Query在休眠中与传统 jdbc 中的PreparedStatement完全相同。它实际上是Builds你的查询和执行