使用druid连接池,配置sql防火墙发现的sql注入问题
druid
阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
项目地址:https://gitcode.com/gh_mirrors/druid/druid
·
最近在使用druid连接池,同时也配置了web和spring的关联监控,检测到select * from tables param like #{param1} “%”的语句被拦截了。做个笔记。
解决方法有两种:
一、 select * from tables param like concat(${param1},”%”)。
二、传入 参数的时候动态拼接 param1=param1+”%”;
select * from tables param like #{param1}。
Mybatis3 防止SQL注入
#{xxx},使用的是PreparedStatement,会有类型转换,所以比较安全;
${xxx},使用字符串拼接,可以SQL注入;
like查询不小心会有漏动,正确写法如下:
Mysql: select * from tables where param like concat(‘%’, #{param1}, ‘%’)
Oracle: select * from t_user where param like ‘%’ || #{param1} || ‘%’
SQLServer: select * from t_user where param like ‘%’ + #{param1} + ‘%’
阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
最近提交(Master分支:2 个月前 )
b94e843e
10 天前
559f17d1 - 24 天前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)