我使用sybase数据库。
如果我想使用 OWASP ESAPI 来防止 SQL 注入(inject)
我应该使用哪种编解码器?
Oracle 编解码器? MySQL 编解码器? DB2 编解码器? https://static.javadoc.io/org.owasp.esapi/esapi/2.0.1/org/owasp/esapi/codecs/package-summary.html
谢谢!
最佳答案
首先,不要使用 ESAPI 来防止 SQL 注入(inject)。所有现有 SQL 编码编解码器的设计意图是在网站遭到黑客攻击的事件中提供紧急措施,并且在重写所有查询以使用 Prepared Statements. 时,您需要一些快速而肮脏的东西。
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
参数可以安全地以这种方式使用仅当服务器具有对值(value)的绝对控制。[/2019]
String updateString =
"update " + dbName + ".COFFEES " +
"set SALES = ? where COF_NAME = ?";
updateSales = con.prepareStatement(updateString);
目前ESAPI没有提供Sybase编解码器,目前也没有开发计划。
来源:我目前是 ESAPI 的项目联合负责人。
关于java - OSWAP ESAPI 的 Sybase 编解码器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49375983/