mysql selectprovider_使用Mybatis的@SelectProvide会不会导致注入攻击?
各位前輩,最近我在用mybatis注解開發(fā),在使用動態(tài)sql的時候,是這樣用的:
@SelectProvider(type = SqlProvider.class, method = "countByDate")
int countVoucherByDate(@Param("pre_date") String pre_date,
@Param("post_date") String post_date,
@Param("merchant_id") int merchant_id);
在SqlProvider類中的方法是:
public String countByDate(Map param){
String pre_date = (String) param.get("pre_date");
String post_date = (String) param.get("post_date");
int merchant_id = (int) param.get("merchant_id");
String sql = " select count(*) from voucher_t" +
" where 1 = 1";
if(!StringUtils.isEmpty(pre_date) && !StringUtils.isEmpty(post_date)){
sql += " and create_date > " + "\"" + pre_date + "\"";
sql += " and create_date < " + "\"" + post_date + " 23:59:59" + "\"";
}
sql += " and merchant_id = " + merchant_id;
return sql;
}
如果用這種方法,會不會導致sql注入攻擊?因為返回的是完整的sql執(zhí)行語句,沒有經(jīng)過mybatis的preparedstatement處理。
如何改進?
總結
以上是生活随笔為你收集整理的mysql selectprovider_使用Mybatis的@SelectProvide会不会导致注入攻击?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opensuse 42.2 mysql_
- 下一篇: mysql存储过程打不开了_请问mysq