3

我的项目正在开发服务器上工作。它适用于以下两种情况:

  1. 使用源路径中的 .esapi 目录,使其最终位于 WEB-INF/classes
  2. 使用 lib 根目录中的 .esapi 目录,使其最终位于 WEB-INF/lib

但是,它在部署到 Google 时不起作用(使用上述两种策略中的任何一种)。

我收到关于无法找到 ESAPI 的常见消息。我第一次尝试使用 ESAPI 部署到 Google 时的属性文件。

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 Appengine 中是非法的。这会导致上面的异常(对不起,它被裁剪了)。在代码尝试获取资源之前,预先将三个 ClassLoader 加载到一个数组中。

    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"
    };

具有讽刺意味的是,这是因为他们通过循环通过类加载器使代码易于阅读/扩展(恕我直言),这种方法失败了。我很想提交一个带有内部类的补丁来延迟对 getSystemClassLoader 的调用(这在 AppEngine 上是做不到的)。

有趣的是,这之所以可行,是因为 esapi jar 没有密封。我原以为应该密封一个安全库 jar。也许我用错了!

更新 我通过 maven 使用 esapi jar,它已经被重新打包并且没有签名。不理想,但它的安全性不亚于我从 maven 获得的其他 40 个开源 jar!

4

5 回答 5

3

您使用自己的实现覆盖 DefaultSecurityConfiguration 类的解决方案正是解决问题的正确方法。这正是它如此设计的原因。在 Google App-Engine 上使用 ESAPI 还存在一些其他固有问题,主要与加密/散列有关。此问题已根据此线程 (http://code.google.com/p/googleappengine/issues/detail?id=1612) 的评论“部分”解决,但在 GAE 中使用加密仍然存在严重限制。

于 2012-03-07T23:59:21.710 回答
3

我刚刚在 Google App Engine 项目中成功集成了ESAPI 2.1.0,我什至没有使用 Maven。

ESAPI.properties & validation.properties放在目录中。因此,ESAPI.properties的完整路径将是[gae-project]/war/ESAPI/

[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 Engine 将.properties文件识别为项目文件。

有关更详细的讨论,您还可以阅读ESAPI for Google App Engine 集成教程

于 2014-01-09T07:40:59.747 回答
1

以下步骤对我有用。

  1. 提取罐子
  2. 创建一个文件夹 .esapi
  3. 下载 ESAPI.properties
  4. 创建罐子。
  5. 使用它,它不会再抱怨缺少属性文件了。
于 2014-07-01T20:08:51.913 回答
1

您可以将文件放在META-INF/目录中,然后将org.owasp.esapi.resources系统属性更改META-INF/appengine-web.xml中,如下所示:

    <system-properties>
      <property name="org.owasp.esapi.resources" value="META-INF/" />
    </system-properties>

因为DefaultSecurityConfiguration首先在资源目录中寻找配置文件,然后在类路径中。

于 2013-06-05T15:36:57.853 回答
0

在我们的项目中,该文件位于 WEB-INF/classes 文件夹中。我们不使用 .esapi 子文件夹。

esapi 版本=2.0.1

虽然部署在 jboss 中。

于 2012-02-21T20:19:16.557 回答