You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CEL supports <string>.matches(<string>) to apply an RE2 regular expression to strings. We expose this functionality in the custom/predefined constraints, as well as the underlying implementations of strings.pattern and bytes.pattern standard constraints.
Since the matches function only targets a string receiver, bytes.pattern first converts the value to a string before applying the regex. This only works if the bytes are a valid UTF8 string, failing with a runtime error within the CEL expression if it's not. This prevents the use of arbitrary byte sequences with the with regex.
To combat this, matches should be overloaded to support <bytes>.matches(<string>) which applies the regular expression without casting the receiver.
Problem it solves or use case:
Proper application of regular expressions against non-UTF8 bytes fields.
Proposed implementation or solution:
Add an overload to the custom CEL functions protovalidate requires of <bytes>.matches(<string>). This change can/should be upstreamed to the CEL project as well.
The text was updated successfully, but these errors were encountered:
Feature description:
CEL supports
<string>.matches(<string>)
to apply an RE2 regular expression to strings. We expose this functionality in the custom/predefined constraints, as well as the underlying implementations ofstrings.pattern
andbytes.pattern
standard constraints.Since the
matches
function only targets a string receiver,bytes.pattern
first converts the value to a string before applying the regex. This only works if the bytes are a valid UTF8 string, failing with a runtime error within the CEL expression if it's not. This prevents the use of arbitrary byte sequences with the with regex.To combat this,
matches
should be overloaded to support<bytes>.matches(<string>)
which applies the regular expression without casting the receiver.Problem it solves or use case:
Proper application of regular expressions against non-UTF8 bytes fields.
Proposed implementation or solution:
Add an overload to the custom CEL functions protovalidate requires of
<bytes>.matches(<string>)
. This change can/should be upstreamed to the CEL project as well.The text was updated successfully, but these errors were encountered: