From 4309bdb7df84d3c5b9fda96dc228fd5896d29762 Mon Sep 17 00:00:00 2001 From: j-sandy <30489233+j-sandy@users.noreply.github.com> Date: Wed, 26 Jun 2024 19:55:08 +0530 Subject: [PATCH] feat(SpEL): implement to configure the limit of characters for SpEL expressions Spring Expression Lanuage (SpEL) has a default limit of 10,000 characters. Springframework provides the feature to configure the limit. This feature allows to configure the limit of characters for SpEL expressions. Approach: In order to use an expression with characters more than the given default limit, require to follow either of the below approaches: 1. For Springframework >=5.3.28 and <6.1.3, by setting `maximumExpressionLength` field while instantiating the custom `SpelParserConfiguration` class. https://github.com/spring-projects/spring-framework/issues/30380 https://github.com/spring-projects/spring-framework/issues/30446 2. For Springframework >=6.1.3, by setting a JVM system property or Spring property named `spring.context.expression.maxLength` to the maximum expression length needed by your application. https://github.com/spring-projects/spring-framework/issues/31952 https://github.com/spring-projects/spring-framework/commit/785598629abda944343a02307ad82a79bb31b589 Spinnaker supports spring boot 2.7.18, that brings springframework 5.3.31 [https://docs.spring.io/spring-boot/docs/2.7.18/reference/html/dependency-versions.html#appendix.dependency-versions.propertie9]. So first approach need to be implemented along with spinnaker enhancement to expose the `maximumExpressionLength` field. --- .../kork/expressions/config/ExpressionProperties.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kork-expressions/src/main/java/com/netflix/spinnaker/kork/expressions/config/ExpressionProperties.java b/kork-expressions/src/main/java/com/netflix/spinnaker/kork/expressions/config/ExpressionProperties.java index 77100734f..0db8ba7fb 100644 --- a/kork-expressions/src/main/java/com/netflix/spinnaker/kork/expressions/config/ExpressionProperties.java +++ b/kork-expressions/src/main/java/com/netflix/spinnaker/kork/expressions/config/ExpressionProperties.java @@ -18,6 +18,7 @@ import lombok.Data; import lombok.experimental.Accessors; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; @Data @@ -26,6 +27,9 @@ public class ExpressionProperties { private final FeatureFlag doNotEvalSpel = new FeatureFlag().setEnabled(true); + @Value("${expression.max-expression-length:-1}") + private int maxExpressionLength; + @Data @Accessors(chain = true) public static class FeatureFlag {