Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<commons.validator.version>1.6</commons.validator.version>
<commons-io.version>2.16.1</commons-io.version>
<commons-csv.version>1.4</commons-csv.version>
<commons-jexl.version>3.0</commons-jexl.version>
<commons-jexl.version>3.3</commons-jexl.version>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Upgrading Apache Commons JEXL from 3.0 to 3.3 introduces a major breaking change regarding security permissions. Starting in JEXL 3.2, JEXL uses restricted permissions (JexlPermissions.RESTRICTED) by default if none are explicitly configured on the JexlBuilder. This will block access to many standard Java classes, packages, and methods in existing user expressions, leading to runtime JexlException failures. To prevent breaking existing pipelines and maintain backward compatibility, you must configure the JexlBuilder in EL.java (line 84) to use appropriate permissions, such as .permissions(org.apache.commons.jexl3.introspection.JexlPermissions.UNRESTRICTED) or define a safe, custom set of permissions.

<commons-lang.version>2.6</commons-lang.version>
<commons-lang3.version>3.5</commons-lang3.version>
<commons-math3.version>3.6.1</commons-math3.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.commons.jexl3.JexlException;
import org.apache.commons.jexl3.JexlInfo;
import org.apache.commons.jexl3.JexlScript;
import org.apache.commons.jexl3.introspection.JexlPermissions;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -87,6 +88,7 @@ public static EL compile(ELRegistration registration, String expression) throws
.cache(1024)
.strict(true)
.logger(new NullLogger())
.permissions(JexlPermissions.UNRESTRICTED)
.create();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import io.cdap.wrangler.expression.EL;
import org.apache.commons.jexl3.parser.ParserTokenManager;
import org.apache.commons.jexl3.parser.SimpleCharStream;

import java.io.ByteArrayInputStream;
import org.apache.commons.jexl3.parser.StringProvider;
import java.util.Map;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -57,7 +56,7 @@ public static EntityCountMetric getJexlCategoryMetric(String jexlScript) {

private static String parseJexlCategory(String script) {
ParserTokenManager manager = new ParserTokenManager(
new SimpleCharStream(new ByteArrayInputStream(script.getBytes())));
new SimpleCharStream(new StringProvider(script)));
return manager.getNextToken().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import io.cdap.wrangler.TestingRig;
import io.cdap.wrangler.api.RecipeException;
import io.cdap.wrangler.api.Row;
import io.cdap.wrangler.expression.EL;
import io.cdap.wrangler.expression.ELContext;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -30,17 +32,17 @@
*/
public class RowConditionFilterTest {

@Test(expected = RecipeException.class)
public void testRHSLHSTypeDisconnect() throws Exception {
@Test
public void testRHSLHSTypeCoercion() throws Exception {
String[] directives = new String[]{
"parse-as-csv body ,",
"drop body",
"set columns PassengerId,Survived,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked",
"filter-row-if-true Fare < 10" // RHS is double, but it's not converted. Check next test case.
"filter-row-if-true Fare < 10" // JEXL 3.3 supports coercion between string and numeric types directly
};

List<Row> rows = Arrays.asList(
new Row("body", "1,0,3,\"Braund, Mr. Owen Harris\",male,22,1,0,A/5 21171,7.25,,S"),
new Row("body", "1,0,3,\"Braund, Mr. Owen Harris\",male,22,1,0,A/5 21171,7,,S"),
new Row("body", "2,1,1,\"Cumings, Mrs. John Bradley (Florence Briggs Thayer)\",female," +
"38,1,0,PC 17599,71.2833,C85,C")
);
Expand Down
Loading