I need to set up this lib to encode the SQL queries. In my Spring Boot app (11th Java) I added to POM.xml the following dependency:
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.2.0.0</version>
</dependency>
Added to the resources the ESAPI.properties file w/ the following content:
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
And during the unit test execution i catch this exception:
java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
BTW as a logging subsystem I use logback.
Adding stacktrace
"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
Why this exception is thrown? Did I missed some steps in configuration? Are there smth. like a Spring Boot starter for esapi library?
CodePudding user response:
What is wrong is actually in plain sight.
stackTrace":"org.owasp.esapi.errors.ConfigurationException: SecurityConfiguration for Logger.LogEncodingRequired not found in ESAPI.properties
You are missing a property in your ESAPI.properties
file, the Logger.LogEncodingRequired
property is missing. Which is this message telling you (quite explicitly if I might add).
Add
Logger.LogEncodingRequired=false # Or true if you need this
to your properties and this error should be gone.