web-dev-qa-db-ja.com

ESAPI.propertiesはどこにありますか?

WebアプリでOWASP ESAPIライブラリを使用して、ESAPI.encoder()。encodeForHTML(request.getParameter())のようにJSPの要求パラメーターをエスケープしようとしています。

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が見つかりませんでした。これをどこで手に入れることができますか?また、このプロパティファイルはどこに配置する必要がありますか?助けてください。

10
Pro

リファレンスは次のとおりです。 ESAPIインストールガイド

ESAPI.propertiesは here からダウンロードできます。

ESAPI.propertiesファイルを自分で作成して、そこに同じコンテンツを配置できます。 「src/main/resources」フォルダーに配置する必要があります。

また、XSSを処理するためにvalidation.propertiesファイルが必要になります。このファイルは「src/test/resources」フォルダーに配置する必要があります。

これらのプロパティファイルのアプリケーション名を、次のようにアプリケーションに変更してください。

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

testはアプリケーション名に置き換える必要があります。

12
Deepesh verma

取得していた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を追加しました(どのパッケージにも追加しないでください)。そして、ファイルは空です。また、Webアプリは正常に機能します。 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
Aniket Thakur

上記のリンクはすべて壊れているか、しばらくして古くなるので(たとえば、特定のバージョンへのリンク)、Githubリンクは次のとおりです。

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

1
Lonzak