2

有没有办法让 ESAPI 从数据库表中读取验证属性,而不是使用默认的 validation.properties 文件?

4

1 回答 1

2

简短的回答:不。

在这里查看代码。

相关答案在文档中:

/**
 * The SecurityConfiguration manages all the settings used by the ESAPI in a single place. In this reference
 * implementation, resources can be put in several locations, which are searched in the following order:
 * <p>
 * 1) Inside a directory set with a call to SecurityConfiguration.setResourceDirectory( "C:\temp\resources" ).
 * <p>
 * 2) Inside the System.getProperty( "org.owasp.esapi.resources" ) directory.
 * You can set this on the java command line
 * as follows (for example): java -Dorg.owasp.esapi.resources="C:\temp\resources". You may have to add this
 * to the batch script that starts your web server. For example, in the "catalina" script that
 * starts Tomcat, you can set the JAVA_OPTS variable to the -D string above.
 * <p>
 * 3) Inside the System.getProperty( "user.home" ) + "/.esapi" directory
 * <p>
 * 4) In an ".esapi" directory on the classpath
 * <p>
 * Once the Configuration is initialized with a resource directory, you can edit it to set things like master
 * keys and passwords, logging locations, error thresholds, and allowed file extensions.
 * <p>
 * WARNING: Do not forget to update ESAPI.properties to change the master key and other security critical settings.
 *
 * @author Mike Fauzy (mike.fauzy@aspectsecurity.com)
 * @author Jim Manico (jim.manico@aspectsecurity.com)
 * @author Jeff Williams (jeff.williams .at. aspectsecurity.com) <a
 *         href="http://www.aspectsecurity.com">Aspect Security</a>
 */

如果您想要这种行为,您将不得不手动更改 esapi 源并且(希望)以一种可以忽略特定数据库实现的方式这样做。

还要考虑到对于安全库,在数据库中管理许多这些东西的安全性稍差。OWASP 的建议是使用 src/main/resources 目录中的属性文件自己手动编译这个库。那样的话,如果外部参与者能够更改您的配置,他们必须在您的机器上拥有一个 unix 帐户,假设您遵守 Java 标准。(WEB-INF/ 自然受到保护。)如果你把它放在数据库中,那么理论上你的安全配置对 SQL 注入威胁是开放的......为什么要冒险呢?

将这些文件放在库本身中会将它们直接放在类路径上,这使得更改变得更加困难。如果您决定在数据库中实现此功能,请特别注意 TOCTOU 错误(检查时间到使用时间)。

于 2014-10-15T21:50:41.943 回答