OPA Release v0.45.0 #282
anderseknert
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This release contains a mix of bugfixes, optimizations, and new features.
Improved Decision Logging with
nd_builtin_cache
OPA has several non-deterministic built-ins, such as
rand.intn
andhttp.send
that can make debugging policies from decision log results a surprisingly tricky and involved process. To improve the situation around debugging policies that use those built-ins, OPA now provides an opt-in system for caching the inputs and outputs of these built-ins during policy evaluation, and can include this information in decision log entries.A new top-level config key is used to enable the non-deterministic builtin caching feature, as shown below:
This data is exposed to OPA's decision log masking system under the
/nd_builtin_cache
path, which allows masking or dropping sensitive values from decision logs selectively. This can be useful in situations where only some information about a non-deterministic built-in was needed, or the arguments to the built-in involved sensitive data.To prevent unexpected decision log size growth from non-deterministic built-ins like
http.send
, the new cache information is included in decision logs on a best-effort basis. If a decision log event exceeds thedecision_logs.reporting.upload_size_limit_bytes
limit for an OPA instance, OPA will reattempt uploading it, after dropping the non-deterministic builtin cache information from the event. This behavior will trigger a log error when it happens, and will increment thedecision_logs_nd_builtin_cache_dropped
metrics counter, so that it will be possible to debug cases where the cache information is unexpectedly missing from a decision log entry.Decision Logging Example
To observe the change in decision logging we can run OPA in server mode with
nd_builtin_cache
enabled:After sending it the query
x := rand.intn("a", 15)
we should see something like the following in the decision logs:The new information is included under the optional
nd_builtin_cache
JSON key, and shows what arguments were provided for each unique invocation ofrand.intn
, as well as what the output of that builtin call was (in this case,3
).If we send the query
x := rand.intn("a", 15); y := rand.intn("b", 150)"
we can see how unique input arguments get recorded in the cache:With this information, it's now easier to debug exactly why a particular rule is used or why a rule fails when non-deterministic builtins are used in a policy.
New Built-in Function:
regex.replace
This release introduces a new builtin for regex-based search/replace on strings:
regex.replace
.See the built-in functions docs for all the details
This implementation fixes #5162 and was authored by @boranx.
object.union_n
OptimizationThe
object.union_n
builtin allows easily merging together an array of Objects.Unfortunately, as noted in #4985 its implementation generated unnecessary intermediate copies from doing pairwise, recursive Object merges. These pairwise merges resulted in poor performance for large inputs; in many cases worse than writing the equivalent operation in pure Rego.
This release changes the
object.union_n
builtin's implementation to use a more efficient merge algorithm that respects the original implementation's sequential, left-to-right merging semantics. Theobject.union_n
builtin now provides a 2-3x improvement in speed and memory efficiency over the pure Rego equivalent.Tooling, SDK, and Runtime
internal/ir
package public asir
.Rego
SetAllowNet
. (#5187) authored and reported by @liamgwith
clauses. (#5148) authored and reported by @liu-duTopdown
object.union_n
to use in-place merge algorithm. (reported by @charlesdaniels)exp
andnbf
fields are numbers when present. (#5165) authored and reported by @charlieflowersInterQueryCache
only dropping one entry when over the size limit. (authored by @vinhph0906)json.filter
on empty JSON paths.intersection
builtin tests.Documentation
#development
to#contributors
. (authored by @charlieflowers)Website + Ecosystem
Miscellaneous
ci: Add
prealloc
linter check and linter fixes.ci: Add govulncheck to Nightly CI.
build/wasm: Use golang1.16
go:embed
mechanism.util/backoff: Seed from math/rand source.
version: Use
runtime/debug.BuildInfo
.Dependency bumps, notably:
👉 Release notes and downloads
Beta Was this translation helpful? Give feedback.
All reactions