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

时间:2015-03-26 03:25:27

标签: java escaping owasp esapi

我试图在我的网络应用程序中使用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。知道我能在哪里得到这个吗?我还应该在哪里放置这个属性文件?请帮忙。

3 个答案:

答案 0 :(得分:11)

以下是参考:ESAPI installation guide

您可以从here下载ESAPI.properties。

您可以自己创建ESAPI.properties文件并在其中放置相同的内容。它应该放在你的'src / main / resources'文件夹中。

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

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

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

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

答案 1 :(得分:2)

我正在寻找与部署我正在使用的webapp时相同的文件 -

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文件夹。我也在 -

中找到了这个文件

https://github.com/OWASP/EJSF/blob/master/esapi_master_FULL/WebContent/ESAPI.properties

这个文件在这里粘贴它的内容非常大,但是基于默认值,它根据上面的日志设置,需要以下内容 -

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

答案 2 :(得分:1)

好的,因为以上链接都已损坏或者会在一段时间内过时(例如指向特定版本的链接),这里是Github链接:

https://github.com/ESAPI/esapi-java-legacy/tree/develop/configuration/esapi