Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Add CEL math extension #1569

Merged
merged 1 commit into from May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/modules/policies/pages/conditions.adoc
Expand Up @@ -337,6 +337,15 @@ NOTE: The IP address functions are Cerbos-specific extensions to CEL.
| size | Number of elements in a list or map | size(P.attr.teams) == 4 && size(P.attr.clients) == 2
|===

== Math

[caption=]
[%header,cols=".^1m,.^2,4m",grid=rows]
|===
| Function | Description | Example
| math.greatest | Get the greatest valued number present in the arguments | math.greatest([1, 3, 5]) == 5
| math.least | Get the least valued number present in the arguments | math.least([1, 3, 5]) == 1
|===

== Strings

Expand Down
2 changes: 2 additions & 0 deletions internal/conditions/cel.go
Expand Up @@ -139,6 +139,7 @@ func newCELQueryPlanEnvOptions() []cel.EnvOption {
),
ext.Strings(),
ext.Encoders(),
ext.Math(),
CerbosCELLib(),
}
}
Expand All @@ -150,6 +151,7 @@ func newCELEnvOptions() []cel.EnvOption {
cel.Declarations(StdEnvDecls...),
ext.Strings(),
ext.Encoders(),
ext.Math(),
CerbosCELLib(),
}
}