Skip to content

Bound prefix and suffix cost estimates - #1531

Open
iholder101 wants to merge 2 commits into
cel-expr:masterfrom
iholder101:fix/1530-prefix-suffix-cost
Open

iholder101 wants to merge 2 commits into
cel-expr:masterfrom
iholder101:fix/1530-prefix-suffix-cost

Conversation

@iholder101

Copy link
Copy Markdown

Description
Use the shorter of the receiver and argument when estimating startsWith and endsWith. This prevents overestimating when the argument is longer than the receiver.

Adds regression tests for both functions and runtime tracking. Validated with go test ./common/cost.

Fixes #1530.

Verify static prefix and suffix estimates stay bounded by a short receiver.

Assisted-by: Codex <noreply@anthropic.com>
Signed-off-by: Itamar Holder <iholder@redhat.com>
Use the shorter operand in startsWith and endsWith estimates so an oversized argument cannot inflate static CEL cost checks.

Assisted-by: Codex <noreply@anthropic.com>
Signed-off-by: Itamar Holder <iholder@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cost estimate for startsWith/endsWith ignores the receiver's size, overestimating when the argument is larger

1 participant