[ 
https://issues.apache.org/jira/browse/JEXL-443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18008454#comment-18008454
 ] 

Henri Biestro commented on JEXL-443:
------------------------------------

I'm sorry [~arysin] experience with JEXL was so... non-obvious.

On changing the error message, this is probably hard since, by design, there is 
no difference from the introspection perspective between a non existent 
method/constructor/field and a not visible/allowed one.

One could try and introduce check/error messages on specific unambiguous cases 
to clearly state that permissions should be set for these classes to behave as 
intended but it is really not easy to distinguish valid cases from 
configuration 'mistakes'. Or one could try and add JEXL builder caller class 
loader package as being allowed by default but that (re)opens the door to 
potential (bogus) CVE; user exposes a class that can create processes, can 
instantiate from JEXL by default, security issue ensues. 

As an experiment, I asked Gemini 'how do I configure JEXL to access my own 
classes ?
' and it generated code that sets up permissions correctly. I also prompted 
'JEXL ObjectMapper does not see my methods' and it did generate an extensive 
solution.
Since 3.3 release - 30 months ago -, there have been 3 permissions 
configuration related questions including this one.
The information on the first page 
(https://commons.apache.org/proper/commons-jexl/index.html) before the Detailed 
Example warns about permissions, the release notes warn about them as well.

I honestly dont think there is anything that can/should be done code wise; 
documentation can always be improved but must be read.


> ObjectContext can't find fields with jexl3 >= 3.3
> -------------------------------------------------
>
>                 Key: JEXL-443
>                 URL: https://issues.apache.org/jira/browse/JEXL-443
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.3, 3.4.0, 3.5.0
>         Environment: Linux / JDK 21
> Windows / JDK 17
>            Reporter: Andriy Rysin
>            Assignee: Henri Biestro
>            Priority: Major
>
> I'm creating simple ObjectContext and with jexl3 >= 3.3 I am getting 
> "variable 'param1' is undefined". This example works on jexl3 3.2.1.
> Surprisingly neither version can find "param0" even though getParam0() works.
>  
> {code:java}
> public class JexlTest {
>     @Test
>     public void testJexlFields() throws Exception {
>         JexlEngine jexl = new JexlBuilder()
>                 .cache(0)
>                 .strict(true)
>                 .silent(false)
>                 .create();
>         
>         Parameters object = new Parameters();
>         object.setParam1(Enum1.VALUE1);
>         JexlContext context = new ObjectContext<>(jexl, object);
>         jexl.createExpression("param1").evaluate(context);
> //        jexl.createExpression("param0").evaluate(context);
>         jexl.createExpression("getParam0()").evaluate(context);
>     }
>     
>     public static class Parameters {
>         private String param0;
>         private Enum1 param1;
>         
>         public String getParam0() {
>             return param0;
>         }
>         public void setParam0(String param0) {
>             this.param0 = param0;
>         }
>         public Enum1 getParam1() {
>             return param1;
>         }
>         public void setParam1(Enum1 param1) {
>             this.param1 = param1;
>         }
>         
>     }
>     public enum Enum1 {
>         VALUE1
>     }
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to