2015-03-26 10 views
7

Я пытаюсь использовать библиотеку OWASP ESAPI в своем веб-приложении, чтобы избежать параметров запроса в JSP, как показано ниже: ESAPI.encoder(). EncodeForHTML (request.getParameter()).Где я могу найти ESAPI.properties?

Я добавил esapi-2.1.0.jar под WEB-INF/Lib, но я получаю НИЖЕ исключением

org.owasp.esapi.errors.ConfigurationException: ESAPI.properties не может быть загружен с помощью любых средств , Потерпеть неудачу. org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfiguration (DefaultSecurityConfiguration.java:439)

Но я не смог найти ESAPI.properties в файле JAR. Любая идея, где я могу это получить? Также, где я должен разместить этот файл свойств? Пожалуйста помоги.

+0

Простой [веб-поиск] (https://www.owasp.org/index.php/ESAPI_Overview) дает ответ. Пожалуйста, сделайте свое исследование перед публикацией здесь. –

+1

Спасибо. Но он все равно не отвечает на мой вопрос. Нужно ли мне самостоятельно создавать ESAPI.properties? Я думал, API предоставляет его, но не могу найти, где я могу скачать файл. – Pro

ответ

8

Вот эта ссылка: ESAPI installation guide.

Вы можете скачать ESAPI.properties от here.

Вы можете создать файл ESAPI.properties самостоятельно и разместить там такой же контент. Его следует поместить в папку «src/main/resources».

Также вам понадобится файл validation.properties для обработки XSS, который должен быть помещен в папку src/test/resources.

Пожалуйста, убедитесь, что изменить имя приложения в этих свойствах файла в приложение, как и в

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

test должны быть заменены с именем приложения.

+4

Руководство по установке для Java: https: //www.owasp.org/images/4/4c/JavaEE-ESAPI_2.0a_install.doc – anton1980

+4

Можем ли мы получить обновленную ссылку для файла ESAPI.properties, так как текущий мертв. –

+0

Подумайте о новой ссылке для ESAPI.properties: https://code.google.com/p/owasp-esapi-java/source/browse/trunk/configuration/esapi/ESAPI.properties –

2

Я искал тот же файл, как и при развертывании моего веб-приложение, я получал -

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) 

Во всяком случае для моего веб-приложение, я просто добавил ESAPI.properties в источник корневой папке (папка ЦСИ) (не добавьте его в любой пакет). И файл просто пуст. И веб-приложение работает отлично. Я вижу следующие журналы в веб-приложение, так что если вы когда-нибудь интересно, где этот файл ищется то смотрите это -

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 

Я уверен, что это конфигурируемые и другие файлы тоже можно добавить ЦСИ папку. Кроме того, я нашел этот файл -

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