Java 在哪里可以找到ESAPI.properties?

Java 在哪里可以找到ESAPI.properties?,java,escaping,owasp,esapi,Java,Escaping,Owasp,Esapi,我试图在我的web应用程序中使用OWASP ESAPI库来转义JSP中的请求参数,如下所示 ESAPI.encoder().encodeForHTML(request.getParameter()) 我已经在WEB-INF/lib下添加了esapi-2.1.0.jar,但是我得到了以下异常 org.owasp.esapi.errors.ConfigurationException:无法以任何方式加载esapi.properties。失败。 org.owasp.esapi.reference.De

我试图在我的web应用程序中使用OWASP ESAPI库来转义JSP中的请求参数,如下所示 ESAPI.encoder().encodeForHTML(request.getParameter())

我已经在WEB-INF/lib下添加了esapi-2.1.0.jar,但是我得到了以下异常

org.owasp.esapi.errors.ConfigurationException:无法以任何方式加载esapi.properties。失败。 org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfiguration(DefaultSecurityConfiguration.java:439)

但是我在JAR文件中找不到ESAPI.properties。你知道我在哪里可以买到这个吗?我应该把这个属性文件放在哪里?请帮助。

这是参考资料:

您可以从下载ESAPI.properties

您可以自己创建ESAPI.properties文件并将相同的内容放在那里。它应该放在“src/main/resources”文件夹中

您还需要validation.properties文件来处理XSS,该文件应放在“src/test/resources”文件夹中

请确保将这些属性文件中的应用程序名称更改为您的应用程序,如中所示

Validator.Redirect=^\\/test.*$

test
应替换为您的应用程序名。

我正在查找与部署我的Web应用程序时得到的文件相同的文件-

Mar 08, 2017 1:23:12 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/WebDynamo] threw exception [org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException SecurityConfiguration class (org.owasp.esapi.reference.DefaultSecurityConfiguration) CTOR threw exception.] with root cause
java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource.
    at org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfigurationFromClasspath(DefaultSecurityConfiguration.java:667)
无论如何,对于我的webapp,我只是在源根文件夹(src文件夹)中添加了ESAPI.properties(不要在任何包中添加它)。文件是空的。而且网络应用程序工作得很好。我在webapp中看到以下日志,因此如果您想知道该文件在哪里被搜索,请参考此-

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: /Applications/Eclipse.app/Contents/MacOS/ESAPI.properties
Not found in SystemResource Directory/resourceDirectory: .esapi/ESAPI.properties
Not found in 'user.home' (/Users/athakur) directory: /Users/athakur/esapi/ESAPI.properties
Loading ESAPI.properties via file I/O failed. Exception was: java.io.FileNotFoundException
Attempting to load ESAPI.properties via the classpath.
SUCCESSFULLY LOADED ESAPI.properties via the CLASSPATH from '/ (root)' using current thread context class loader!
SecurityConfiguration for Validator.ConfigurationFile not found in ESAPI.properties. Using default: validation.properties
Attempting to load validation.properties via file I/O.
Attempting to load validation.properties as resource file via file I/O.
Not found in 'org.owasp.esapi.resources' directory or file not readable: /Applications/Eclipse.app/Contents/MacOS/validation.properties
Not found in SystemResource Directory/resourceDirectory: .esapi/validation.properties
Not found in 'user.home' (/Users/athakur) directory: /Users/athakur/esapi/validation.properties
Loading validation.properties via file I/O failed.
Attempting to load validation.properties via the classpath.
validation.properties could not be loaded by any means. fail. Exception was: java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource.
SecurityConfiguration for ESAPI.printProperties not found in ESAPI.properties. Using default: false
SecurityConfiguration for Encryptor.CipherTransformation not found in ESAPI.properties. Using default: AES/CBC/PKCS5Padding
SecurityConfiguration for ESAPI.Encoder not found in ESAPI.properties. Using default: org.owasp.esapi.reference.DefaultEncoder
SecurityConfiguration for ESAPI.Logger not found in ESAPI.properties. Using default: org.owasp.esapi.reference.JavaLogFactory
SecurityConfiguration for Logger.LogApplicationName not found in ESAPI.properties. Using default: true
SecurityConfiguration for Logger.LogServerIP not found in ESAPI.properties. Using default: true
SecurityConfiguration for Logger.ApplicationName not found in ESAPI.properties. Using default: DefaultName
我相信这些文件是可配置的,其他文件也可以添加到src文件夹中。我在中也找到了这个文件-

该文件非常大,可以将其内容粘贴到此处,但基于默认值,它将根据上面的日志进行设置,需要执行以下操作-

ESAPI.printProperties=true
Encryptor.CipherTransformation=AES/CBC/PKCS5Padding
ESAPI.Encoder=org.owasp.esapi.reference.DefaultEncoder
# Log4JFactory Requires log4j.xml or log4j.properties in classpath - http://www.laliluna.de/log4j-tutorial.html
ESAPI.Logger=org.owasp.esapi.reference.Log4JLogFactory
# Determines whether ESAPI should log the application name. This might be clutter in some single-server/single-app environments.
Logger.LogApplicationName=true
# Determines whether ESAPI should log the server IP and port. This might be clutter in some single-server environments.
Logger.LogServerIP=true
# Set the application name if these logs are combined with other applications
Logger.ApplicationName=ExampleApplication

好的,因为上面的链接都已断开或将在一段时间内过时(例如链接到特定版本),下面是Github链接:


谢谢。但它仍然不能回答我的问题。我需要自己创建ESAPI.properties吗?我以为API提供了它,但找不到可以下载该文件的地方。Java安装指南:我们可以获得ESAPI.properties文件的更新链接吗,因为当前的一个已经死了。想想ESAPI.properties的新链接是:上面回答和评论中指向ESAPI.properties的链接都被破坏了。我在分发文件中找到了它,谢谢我找到了必需的文件