Java Google AppEngine项目中的ESAPI.properties在哪里
我的项目正在开发服务器上工作。它适用于以下两种情况:Java Google AppEngine项目中的ESAPI.properties在哪里,java,google-app-engine,owasp,Java,Google App Engine,Owasp,我的项目正在开发服务器上工作。它适用于以下两种情况: 在源路径中使用.esapi目录,因此它最终位于WEB-INF/classes中 在lib根目录中使用.esapi目录,因此它最终位于WEB-INF/lib中 但是,如果部署到Google(使用上述两种策略中的任何一种),它都不起作用 我收到了关于找不到ESAPI的常见消息。属性文件,当我第一次尝试使用ESAPI部署到Google时 Attempting to load ESAPI.properties via file I/O. Attemp
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的更改
更新
问题在于org.owasp.esapi.reference.DefaultSecurityConfiguration的第603行调用了ClassLoader.getSystemClassLoader(),这在Google Appengine中是非法的。这会导致上面的异常(很抱歉被裁剪)。
在代码尝试获取资源之前,有三个类加载器预先加载到一个数组中
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"
};
具有讽刺意味的是,因为他们通过循环类加载器使代码易于阅读/扩展(IMHO),所以这种方法失败了。我很想提交一个带有内部类的补丁来延迟对getSystemClassLoader的调用(这在AppEngine上是做不到的)
有趣的是,这是可行的,因为esapi罐没有密封。
我原以为应该密封一个安全图书馆罐。也许我用错了
更新
我正在通过maven使用esapi jar,它已经重新打包,没有签名。不理想,但它的安全性不亚于我从maven获得的其他40个开源JAR 在我们的项目中,该文件位于WEB-INF/classes文件夹中。我们不使用.esapi子文件夹 Esapi版本=2.0.1
但是部署在jboss中。您用自己的实现覆盖DefaultSecurityConfiguration类的解决方案正是解决此问题的正确方法。这正是它这样设计的原因。在Google App Engine tho上使用ESAPI还存在一些其他固有的问题,主要涉及加密/哈希。根据对此线程的评论,此问题已“部分”解决(http://code.google.com/p/googleappengine/issues/detail?id=1612)但是在GAE中使用加密仍然存在严重限制。您可以将文件放入
META-INF/
目录,然后将org.owasp.esapi.resources
系统属性更改为META-INF/
inappengine web.xml中的META-INF/
,如下所示:
<system-properties>
<property name="org.owasp.esapi.resources" value="META-INF/" />
</system-properties>
因为
DefaultSecurityConfiguration
首先在资源目录中查找配置文件,然后在类路径中查找配置文件。我刚刚在Google App Engine项目上成功集成了ESAPI 2.1.0,甚至没有使用Maven
将ESAPI.properties&validation.properties放入目录[gae project]/war/ESAPI/
。
因此,ESAPI.properties的完整路径将是
[gae-project]/war/ESAPI/ESAPI.properties
将其置于war/下可确保文件将上载到谷歌
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
编辑您的appengine-web.xml,在
中添加以下行。以下步骤对我很有效
拔出罐子
创建一个文件夹。esapi
下载ESAPI.properties
创建jar
使用它,它将不再抱怨缺少属性文件
是的,我已经试过了,我会更新上面的策略列表。我不是在面向对象的意义上重写,我已经用我自己的克隆和两行更改替换了这个类。即相同的类名相同的包。它只有在EASPI.jar未密封的情况下才能工作。我并不为这种黑客行为感到自豪,但我会活下去:-/这是否意味着ESAPI 2.1.0目前无法在AppEngine上实现,而不改变jar@Chrischmidt将回答这个问题。很抱歉这里的回复太晚了-过去几个月我一直被关在地窖里,他们今天终于让我出去透透气了!:)为了解决您的问题,您不需要更改JAR来将ESAPI 2.1.0部署到GAE应用程序中,但根据我的经验,您必须编写一个不使用任何加密库(基本上是无操作加密器)的自定义加密器实现。我没有签入任何现代版本的GAE,因此这可能自上次签入以来发生了更改。在App Engine中,WEB-INF目录的路径为[project]/war/WEB-INF
,而META-INF目录的路径通常为[project]/war/WEB-INF/classes/META-INF
。它不应该是
?