无法使 OWASP.ESAPI 库启动。配置问题?
Cannot make the OWASP.ESAPI library to start up. Configuration issue?
我需要设置这个库来编码 SQL 查询。在我的 Spring 引导应用程序(第 11 个 Java)中,我向 POM.xml 添加了以下依赖项:
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.2.0.0</version>
</dependency>
已将 ESAPI.properties 文件添加到资源中,其中包含以下内容:
ESAPI.Encoder=org.owasp.esapi.reference.DefaultEncoder
Encoder.AllowMultipleEncoding=false
Encoder.AllowMixedEncoding=false
Encoder.DefaultCodecList=HTMLEntityCodec,PercentCodec,JavaScriptCodec
ESAPI.Logger=org.owasp.esapi.logging.slf4j.Slf4JLogFactory
并且在单元测试执行期间我捕获了这个异常:
java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
顺便说一句,我使用 logback 作为日志子系统。
添加堆栈跟踪
"2021-12-07T14:18:54.298+03:00","level":"ERROR","logger_name":"bankclient.controller.GlobalControllerExceptionHandler","application":"BANKCLIENT","app_version":"undefined","thread_name":"main","message":"Undefined request processing error",
"stackTrace":"org.owasp.esapi.errors.ConfigurationException: SecurityConfiguration for Logger.LogEncodingRequired not found in ESAPI.properties
\org.owasp.esapi.reference.DefaultSecurityConfiguration.getBooleanProp(DefaultSecurityConfiguration.java:1354)
at
org.owasp.esapi.logging.slf4j.Slf4JLogFactory.<clinit>(Slf4JLogFactory.java:53)
... 147 common frames omitted
Wrapped by: java.lang.ExceptionInInitializerError: null
at
java.lang.Class.forName0(Class.java)
at
java.lang.Class.forName(Class.java:315)
at org.owasp.esapi.util.ObjFactory.loadClassByStringName(ObjFactory.java:158)
at
org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:81)
at
org.owasp.esapi.ESAPI.logFactory(ESAPI.java:137)
at org.owasp.esapi.ESAPI.getLogger(ESAPI.java:153)
at org.owasp.esapi.reference.DefaultEncoder.<init>(DefaultEncoder.java:83)
at org.owasp.esapi.reference.DefaultEncoder.getInstance(DefaultEncoder.java:67)
...
139 common frames omitted
Wrapped by: java.lang.reflect.InvocationTargetException: null
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:566)
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:86)
...
134 common frames omitted
Wrapped by: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
at
org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:129)
at org.owasp.esapi.ESAPI.encoder(ESAPI.java:99)
at bankclient.repository.currency.JdbcCurrencyOperationRepository.findOperationsWithDateAndDocType(JdbcCurrencyOperationRepository.java:220)
at bankclient.interactors.documents.currency.operations.CurrencyDocumentViewer.execute(CurrencyDocumentViewer.java:25)
at
为什么会抛出这个异常?我错过了一些配置步骤吗?
有没有像 Spring esapi 库的引导程序?
问题其实一目了然。
stackTrace":"org.owasp.esapi.errors.ConfigurationException: SecurityConfiguration for Logger.LogEncodingRequired not found in ESAPI.properties
您的 ESAPI.properties
文件中缺少 属性,缺少 Logger.LogEncodingRequired
属性。这条消息告诉你什么(非常明确,如果我可以添加的话)。
添加
Logger.LogEncodingRequired=false # Or true if you need this
到您的属性,此错误应该消失。
我需要设置这个库来编码 SQL 查询。在我的 Spring 引导应用程序(第 11 个 Java)中,我向 POM.xml 添加了以下依赖项:
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.2.0.0</version>
</dependency>
已将 ESAPI.properties 文件添加到资源中,其中包含以下内容:
ESAPI.Encoder=org.owasp.esapi.reference.DefaultEncoder
Encoder.AllowMultipleEncoding=false
Encoder.AllowMixedEncoding=false
Encoder.DefaultCodecList=HTMLEntityCodec,PercentCodec,JavaScriptCodec
ESAPI.Logger=org.owasp.esapi.logging.slf4j.Slf4JLogFactory
并且在单元测试执行期间我捕获了这个异常:
java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
顺便说一句,我使用 logback 作为日志子系统。
添加堆栈跟踪
"2021-12-07T14:18:54.298+03:00","level":"ERROR","logger_name":"bankclient.controller.GlobalControllerExceptionHandler","application":"BANKCLIENT","app_version":"undefined","thread_name":"main","message":"Undefined request processing error",
"stackTrace":"org.owasp.esapi.errors.ConfigurationException: SecurityConfiguration for Logger.LogEncodingRequired not found in ESAPI.properties
\org.owasp.esapi.reference.DefaultSecurityConfiguration.getBooleanProp(DefaultSecurityConfiguration.java:1354)
at
org.owasp.esapi.logging.slf4j.Slf4JLogFactory.<clinit>(Slf4JLogFactory.java:53)
... 147 common frames omitted
Wrapped by: java.lang.ExceptionInInitializerError: null
at
java.lang.Class.forName0(Class.java)
at
java.lang.Class.forName(Class.java:315)
at org.owasp.esapi.util.ObjFactory.loadClassByStringName(ObjFactory.java:158)
at
org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:81)
at
org.owasp.esapi.ESAPI.logFactory(ESAPI.java:137)
at org.owasp.esapi.ESAPI.getLogger(ESAPI.java:153)
at org.owasp.esapi.reference.DefaultEncoder.<init>(DefaultEncoder.java:83)
at org.owasp.esapi.reference.DefaultEncoder.getInstance(DefaultEncoder.java:67)
...
139 common frames omitted
Wrapped by: java.lang.reflect.InvocationTargetException: null
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:566)
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:86)
...
134 common frames omitted
Wrapped by: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
at
org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:129)
at org.owasp.esapi.ESAPI.encoder(ESAPI.java:99)
at bankclient.repository.currency.JdbcCurrencyOperationRepository.findOperationsWithDateAndDocType(JdbcCurrencyOperationRepository.java:220)
at bankclient.interactors.documents.currency.operations.CurrencyDocumentViewer.execute(CurrencyDocumentViewer.java:25)
at
为什么会抛出这个异常?我错过了一些配置步骤吗? 有没有像 Spring esapi 库的引导程序?
问题其实一目了然。
stackTrace":"org.owasp.esapi.errors.ConfigurationException: SecurityConfiguration for Logger.LogEncodingRequired not found in ESAPI.properties
您的 ESAPI.properties
文件中缺少 属性,缺少 Logger.LogEncodingRequired
属性。这条消息告诉你什么(非常明确,如果我可以添加的话)。
添加
Logger.LogEncodingRequired=false # Or true if you need this
到您的属性,此错误应该消失。