简体   繁体   English

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

[英]Where can I find ESAPI.properties?

Am trying to use OWASP ESAPI library in my web app to escape request parameters in JSPs as below ESAPI.encoder().encodeForHTML(request.getParameter()). 我试图在我的Web应用程序中使用OWASP ESAPI库来转义JSP中的请求参数,如下面的ESAPI.encoder()。encodeForHTML(request.getParameter())。

I have added esapi-2.1.0.jar under WEB-INF/lib but I get the below exception 我在WEB-INF / lib下添加了esapi-2.1.0.jar,但是我得到了以下异常

org.owasp.esapi.errors.ConfigurationException: ESAPI.properties could not be loaded by any means. org.owasp.esapi.errors.ConfigurationException:无法以任何方式加载ESAPI.properties。 Fail. 失败。 org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfiguration(DefaultSecurityConfiguration.java:439) org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfiguration(DefaultSecurityConfiguration.java:439)

But I couldnt find ESAPI.properties in the JAR file. 但我无法在JAR文件中找到ESAPI.properties。 Any idea where I can get this? 知道我能在哪里得到这个吗? Also where should I place this properties file? 我还应该在哪里放置这个属性文件? Please help. 请帮忙。

Here is the reference: ESAPI installation guide . 以下是参考: ESAPI安装指南

You can download ESAPI.properties from here . 您可以从此处下载ESAPI.properties。

You can create ESAPI.properties file yourself and place the same content there. 您可以自己创建ESAPI.properties文件并在其中放置相同的内容。 It should be placed in your 'src/main/resources' folder. 它应该放在你的'src / main / resources'文件夹中。

Also you will need validation.properties file to handle XSS, which should be placed in 'src/test/resources' folder. 您还需要validation.properties文件来处理XSS,它应该放在'src / test / resources'文件夹中。

Please make sure to change the application name in these properties file to your application as in 请确保将这些属性文件中的应用程序名称更改为您的应用程序,如下所示

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

test should be replaced with your application name. test应替换为您的应用程序名称。

I was looking for the same file as while deploying my webapp I was getting - 我正在寻找相同的文件,因为我正在部署我的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)

Anyway for my webapp I just added ESAPI.properties in source root folder (src folder) (don't add it in any package) . 无论如何,对于我的webapp,我刚刚在源根文件夹(src文件夹)中添加了ESAPI.properties(不要在任何包中添加它) And the file is just empty. 该文件只是空的。 And web app works just fine. 并且网络应用程序工作得很好。 I see following logs in the webapp so if you are ever wondering where this file is being searched then refer this - 我在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

I am sure these are configurable and other files too you can add it src folder. 我相信这些是可配置的,其他文件也可以添加src文件夹。 Also I found this file in - 我也找到了这个文件 -

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

The file is pretty big to paste it's contents here but based on default values it is setting as per logs above following things are required - 这个文件在这里粘贴它的内容非常大,但根据默认值,它按照上面的日志设置以下内容 -

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

Ok since the above links are all broken or will be outdated in a while (eg link to a specific version) here is the Github Link: 好的,因为上面的链接都被破坏了或者会在一段时间内过时(例如链接到特定版本),这里是Github链接:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM