我的项目正在开发服务器上工作。它适用于以下两种情况:
但是,当部署到Google (使用上述2种策略中的任何一种)时,它不起作用。
我收到一些关于找不到ESAPI的信息。属性文件时,我第一次尝试使用ESAPI一旦部署到谷歌。
Attempting to load ESAPI.properties via file I/O.
Attempting to load ESAPI.properties as resource file via file I/O.
Not found in 'org.owasp.esapi.resources' directory or file not readable: /base/data/home/ap
Not found in SystemResource Directory/resourceDirectory: .esapi/ESAPI.properties
Loading ESAPI.properties via file I/O failed. Exception was: java.io.FileNotFoundException
Attempting to load ESAPI.properties via the classpath.
ESAPI.properties could not be loaded by any means. Fail. Exception was: java.security.Acces
ESAPI似乎包含支持AppEngine http://goo.gl/rD8dz的更改。
org.owasp.esapi.reference.DefaultSecurityConfiguration的第603行调用ClassLoader.getSystemClassLoader(),这在Google中是非法的。这将导致上述异常(很抱歉被裁剪)。在代码试图获取资源之前,有三个ClassLoaders预先加载到数组中。
ClassLoader[] loaders = new ClassLoader[] {
Thread.currentThread().getContextClassLoader(),
ClassLoader.getSystemClassLoader(),
getClass().getClassLoader()
};
String[] classLoaderNames = {
"current thread context class loader",
"system class loader",
"class loader for DefaultSecurityConfiguration class"
};
在我自己的DefaultSecurityConfiguration副本中,我从loadConfigurationFromClasspath方法中删除了SystemClassLoader (以及相应的classLoaderName)。
ClassLoader[] loaders = new ClassLoader[] {
Thread.currentThread().getContextClassLoader(),
getClass().getClassLoader()
};
String[] classLoaderNames = {
"current thread context class loader",
"class loader for DefaultSecurityConfiguration class"
};
具有讽刺意味的是,正是因为他们通过遍历Classloaders使代码易于阅读/扩展(IMHO),所以这种方法失败了。我很想提交一个带有内部类的修补程序,以延迟对getSystemClassLoader的调用(在AppEngine上不能这样做)。
有趣的是,这是可能的,因为esapi jar没有被密封。我本以为应该密封一个安全库的罐子。也许我用错了!
更新我正在通过maven使用esapi,它已经被重新打包,并且没有签名。不太理想,但它与我从maven获得的其他40个开源jars一样安全!
发布于 2012-03-07 23:59:21
用自己的实现覆盖DefaultSecurityConfiguration类的解决方案正是解决问题的正确方法。这正是为什么它是这样设计的。在tho上使用ESAPI还有其他一些固有的问题,主要是在加密/散列方面。这个问题已经根据这个线程(http://code.google.com/p/googleappengine/issues/detail?id=1612)上的注释“部分”解决了,但是在GAE中使用加密仍然存在严重的限制。
发布于 2014-01-09 07:40:59
我刚刚成功地将ESAPI 2.1.0集成到Google项目中,而且我甚至没有使用Maven。
将 ESAPI.properties & validation.properties放在[gae-project]/war/ESAPI/
目录中。因此,ESAPI.properties的完整路径将是
[gae-project]/war/ESAPI/ESAPI.properties
把它放在war/下可以确保文件被上传到Google。
编辑您的appengine-web.xml,在<appengine-web-app>
根节点中添加以下行
...
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
<property name="org.owasp.esapi.resources" value="ESAPI" />
</system-properties>
<static-files>
<exclude path="/ESAPI**properties" />
</static-files>
...
这将允许App将.properties文件识别为项目文件。
有关更详细的讨论,您还可以阅读ESAPI用于Google集成教程
发布于 2013-06-05 15:36:57
您可以将文件放在appengine-web.xml目录中,然后将org.owasp.esapi.resources
system属性更改为META-INF/
,如下所示:
<system-properties>
<property name="org.owasp.esapi.resources" value="META-INF/" />
</system-properties>
因为DefaultSecurityConfiguration
首先在资源目录中查找配置文件,然后在类路径中查找配置文件。
https://stackoverflow.com/questions/9384489
复制相似问题