Skip to content

Commit

Permalink
feat(SpEL): implement to configure the limit of characters for SpEL e…
Browse files Browse the repository at this point in the history
…xpressions

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.
spring-projects/spring-framework#30380
spring-projects/spring-framework#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.
spring-projects/spring-framework#31952
spring-projects/spring-framework@7855986
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.
  • Loading branch information
j-sandy committed Jul 1, 2024
1 parent 8180419 commit 8bcabe9
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;

/** Configuration properties for Spring Expression Language (SpEL) evaluation related features. */
@Data
@ConfigurationProperties(prefix = "expression")
public class ExpressionProperties {

/** Flag to determine if SpEL evaluation to be skipped. */
private final FeatureFlag doNotEvalSpel = new FeatureFlag().setEnabled(true);

/**
* To set the maximum limit of characters in expression for SpEL evaluation. Default value -1
* signifies to use default maximum limit of 10,000 characters provided by springframework.
*/
private int maxExpressionLength = -1;

@Data
@Accessors(chain = true)
public static class FeatureFlag {
Expand Down

0 comments on commit 8bcabe9

Please sign in to comment.