@@ -39,7 +39,7 @@ public enum ProtoUnsetFieldOptions {
3939 // Do not bind a field if it is unset. Repeated fields are bound as empty list.
4040 SKIP ,
4141 // Bind the (proto api) default value for a field.
42- BIND_DEFAULT ;
42+ BIND_DEFAULT
4343 }
4444
4545 public static final CelOptions DEFAULT = current ().build ();
@@ -121,6 +121,8 @@ public enum ProtoUnsetFieldOptions {
121121
122122 public abstract boolean enableComprehension ();
123123
124+ public abstract int maxRegexProgramSize ();
125+
124126 public abstract Builder toBuilder ();
125127
126128 public ImmutableSet <ExprFeatures > toExprFeatures () {
@@ -218,7 +220,8 @@ public static Builder newBuilder() {
218220 .enableStringConversion (true )
219221 .enableStringConcatenation (true )
220222 .enableListConcatenation (true )
221- .enableComprehension (true );
223+ .enableComprehension (true )
224+ .maxRegexProgramSize (-1 );
222225 }
223226
224227 /**
@@ -571,6 +574,19 @@ public abstract static class Builder {
571574 */
572575 public abstract Builder enableComprehension (boolean value );
573576
577+ /**
578+ * Set maximum program size for RE2J regex.
579+ *
580+ * <p>The program size is a very approximate measure of a regexp's "cost". Larger numbers are
581+ * more expensive than smaller numbers.
582+ *
583+ * <p>A negative {@code value} will disable the check.
584+ *
585+ * <p>There's no guarantee that RE2 program size has the exact same value across other CEL
586+ * implementations (C++ and Go).
587+ */
588+ public abstract Builder maxRegexProgramSize (int value );
589+
574590 public abstract CelOptions build ();
575591 }
576592}
0 commit comments