From e7ca96d67650f0d8059983ff63c6ea31b562b481 Mon Sep 17 00:00:00 2001 From: memesaregood Date: Thu, 15 Jun 2023 17:01:34 +0300 Subject: Allowed primitive Java types in JEXL Engine --- src/main/java/org/traccar/handler/ComputedAttributesHandler.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java index d384bbffc..24d853bbe 100644 --- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java +++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java @@ -65,6 +65,14 @@ public class ComputedAttributesHandler extends BaseDataHandler { JexlSandbox sandbox = new JexlSandbox(false); sandbox.allow("com.safe.Functions"); sandbox.allow(Math.class.getName()); + sandbox.allow(Double.class.getName()); + sandbox.allow(Float.class.getName()); + sandbox.allow(Integer.class.getName()); + sandbox.allow(Long.class.getName()); + sandbox.allow(Short.class.getName()); + sandbox.allow(Character.class.getName()); + sandbox.allow(Boolean.class.getName()); + sandbox.allow(String.class.getName()); features = new JexlFeatures() .localVar(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOCAL_VARIABLES)) .loops(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOOPS)) -- cgit v1.2.3 From 57414098b8295e91d9c2436cf4be18c0ef430fd3 Mon Sep 17 00:00:00 2001 From: memesaregood Date: Thu, 15 Jun 2023 17:55:28 +0300 Subject: Use a lambda expression to allow the primitive types --- .../java/org/traccar/handler/ComputedAttributesHandler.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java index 24d853bbe..29d9bcdcb 100644 --- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java +++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.List; import io.netty.channel.ChannelHandler; import org.apache.commons.jexl3.JexlFeatures; @@ -65,14 +66,10 @@ public class ComputedAttributesHandler extends BaseDataHandler { JexlSandbox sandbox = new JexlSandbox(false); sandbox.allow("com.safe.Functions"); sandbox.allow(Math.class.getName()); - sandbox.allow(Double.class.getName()); - sandbox.allow(Float.class.getName()); - sandbox.allow(Integer.class.getName()); - sandbox.allow(Long.class.getName()); - sandbox.allow(Short.class.getName()); - sandbox.allow(Character.class.getName()); - sandbox.allow(Boolean.class.getName()); - sandbox.allow(String.class.getName()); + List.of(Double.class, Float.class, Integer.class, + Long.class, Short.class, Character.class, + Boolean.class, String.class, Byte.class) + .forEach((type) -> sandbox.allow(type.getName())); features = new JexlFeatures() .localVar(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOCAL_VARIABLES)) .loops(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOOPS)) -- cgit v1.2.3 From 2275e7d4e739eab9e24eab66d068cf0afafc5bb8 Mon Sep 17 00:00:00 2001 From: memesaregood1 <63505425+memesaregood1@users.noreply.github.com> Date: Thu, 15 Jun 2023 21:09:50 +0300 Subject: Update src/main/java/org/traccar/handler/ComputedAttributesHandler.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/handler/ComputedAttributesHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java index 29d9bcdcb..8ad4e41e4 100644 --- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java +++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java @@ -66,9 +66,9 @@ public class ComputedAttributesHandler extends BaseDataHandler { JexlSandbox sandbox = new JexlSandbox(false); sandbox.allow("com.safe.Functions"); sandbox.allow(Math.class.getName()); - List.of(Double.class, Float.class, Integer.class, - Long.class, Short.class, Character.class, - Boolean.class, String.class, Byte.class) + List.of( + Double.class, Float.class, Integer.class, Long.class, Short.class, + Character.class, Boolean.class, String.class, Byte.class) .forEach((type) -> sandbox.allow(type.getName())); features = new JexlFeatures() .localVar(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOCAL_VARIABLES)) -- cgit v1.2.3