我使用sybase数据库。
如果我想使用OWASP ESAPI来阻止SQL注入
我应该使用哪种编解码器?
OracleCodec? MySQLCodec? DB2Codec? https://static.javadoc.io/org.owasp.esapi/esapi/2.0.1/org/owasp/esapi/codecs/package-summary.html
谢谢!
答案 0 :(得分:1)
首先,不要使用ESAPI来阻止SQL注入。存在的所有SQL编码编解码器的设计意图是在网站遭到黑客入侵的事件中提供紧急措施,并且当您重写所有查询以使用Prepared Statements. <时,您需要快速和脏的东西。 / p>
Here's an excerpt of documentation for the OracleCodec:
/**
* Implementation of the Codec interface for Oracle strings. This function will only protect you from SQLi in the case of user data
* bring placed within an Oracle quoted string such as:
*
* select * from table where user_name=' USERDATA ';
忽略Sybase手册中的以下词语:
不要准备仅使用一次的语句
对 所有 数据库事务使用准备语句或存储过程。在近十年的工程设计中,我从未真正看到过使用预备声明的实际性能损失。在大多数语言中,性能都会提高这肯定是Java的情况。
这是预备声明的样子:
[2019年编辑]
下面的代码在技术上可能是一个SQLi本身,当我写这篇文章时,我想指出当服务器具有绝对控制权时,dbName
参数可以安全地以这种方式使用 价值。 [/ 2019]
String updateString =
"update " + dbName + ".COFFEES " +
"set SALES = ? where COF_NAME = ?";
updateSales = con.prepareStatement(updateString);
ESAPI目前没有提供Sybase编解码器,目前还没有计划开发一个。
资料来源:我目前是ESAPI的共同负责人。