OPA v1.19.0 #761
johanfylling
announced in
Announcements
OPA v1.19.0
#761
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 new features and bug fixes. Notably:
:=)strings.split_nbuilt-in functionFix SQL injection vector in Compile API: Quote SQL filter field identifiers (#8945)
The field names in the SQL emitted by the Compile API come from partially evaluated refs, so a
policy that selects a dynamic key — such as
input.fruits[input.column]— puts caller-controlledtext in an identifier position. That text was emitted verbatim, which turns
into
and an application appending the filter to its query returns rows the policy denies.
Field segments that are not bare identifiers are now quoted at the UCAST-to-SQL boundary, with any
embedded quote character escaped. Ordinary column names stay unquoted, so existing filters keep
their current shape and remain case-insensitive on Postgres.
Authored by @thevilledev
Behavior change: stricter safety for assignment (
:=) (#3546)The assignment operator (
:=) is documented as "syntactic sugar for=, local variable creation,and additional compiler checks," and the safety checker reflects that: after
rewriting,
:=is treated identically to=(unification), so an assignment'sright-hand side can be made safe by unifying "backwards" through the left-hand
side. This means policies like
x := y; x = 7compile (bindingyto7)even though
yis never assigned, andx := y; obj[x]can silently degrade anexpected constant-time lookup into full iteration.
This change makes the right-hand-side of
:=be treated as a read thatmust be made safe by other expressions, and can no longer be satisfied through
the left-hand-side. Affected policies that previously compiled now fail with a
rego_unsafe_var_error. Reference iteration on the right-hand-side (e.g.some k; v := obj[k]) is unaffected.Note: this is a deliberate semantic change, not a fix to match documented
behavior — the intended semantics of
:=in this case were never specified.Authored by @sspaink, reported by @tsandall
WebAssembly runtime: wasmtime-go replaced with wazero (#7557)
OPA's WebAssembly runtime — used by the
wasmevaluation target and the WASM SDK — now runs onthe pure-Go wazero runtime instead of
bytecodealliance/wasmtime-go. Thisremoves the cgo dependency from this path, so
wasm-enabled builds no longer need a C toolchain.Compiled policy modules are now cached process-wide, so repeated VM creation for the same policy
skips recompilation. On an Apple M4 Max this makes wasm cold start (compile + instantiate + first
eval) about 73% faster, and warm evaluation about 29% faster with ~28% fewer allocations.
Authored by @srenatus, reported by @sspaink
Configuration validation moved to Rego, with warnings on unknown options (#8891)
Top-level configuration validation and default injection (
default_decision,default_authorization_decision,labels) is now expressed as an embedded Rego policy rather thanhand-written Go, as is the validation of
server.metricsandmetrics_export.The user-visible effect is that unrecognized configuration options are reported instead of being
silently ignored. A typo such as
decision_loginstead ofdecision_logsnow logs a warning atstartup:
{"level":"warning","msg":"unknown configuration option \"decision_log\" encountered"}These are warnings, not errors: OPA starts as before, and sections that are intentionally
user-extensible are left alone, so extra keys there do not warn. Embedders reading configuration
through
config.ParseConfigcan find the same messages onConfig.Warnings.Authored by @sspaink
Add
strings.split_nbuilt-in function (#8344)Policies often need only the first or last few parts of a split string, but the existing
splitbuilt-in always returns every part, so the count has to be worked around with wildcards or a slice.
strings.split_ntakes the firstnsplit parts from the front or the back of the string,depending on whether
nis positive or negative:If
abs(n)is larger than the number of parts, all parts are returned. Annof0returns anempty array.
Authored by @wonju-dev, reported by @anderseknert
Improved REPL line editing, with history file migration (#962)
Pasting a tab-indented snippet into the REPL triggered tab-completion on the pasted tab, corrupting
the input (e.g. injecting a completion candidate mid-line and producing a spurious parse error).
Fixing that requires bracketed paste, where the terminal wraps pasted text in markers so the line
reader inserts it literally instead of treating an embedded tab as a completion request. The
previous reader,
peterh/liner, has no bracketed-paste support and is unmaintained (last release2021), so it has been replaced with
reeflective/readline.The new reader persists history as JSON lines instead of one command per line. Existing history
files (
~/.opa_historyby default, or the path given to--history) are detected and migrated inplace the first time the REPL loads them, so history written by earlier versions of OPA is kept.
OPA's own multi-line buffering is unchanged, and
readline's native multi-line editing is leftdisabled to avoid changing REPL behavior.
Authored by @sspaink, reported by @aeneasr
Runtime, SDK, Tooling
--formatflag for proto/JSON plan bundles toopa build(#8825) authored by @sspainkReadHeaderTimeoutto32son all HTTP servers (#8877) authored by @RinZ27RoundTripperperDecision(#8884) authored by @paulo-raca--var-valuescmd output (#7830) authored by @sspaink, reported by @charlieegan3Compiler, Topdown and Rego
future.keywords.notimport in Rego v0 (#8953) authored by @johanfyllingx in [...](#8918) reported and authored by @srenatusTermValueEqualperformance regression (#8863) authored by @mchittenCogeneratedExprsreturn deterministic order (#8895) authored by @sspainkobject.*builtins (#8692) reported and authored by @anderseknert"a", "a" in {"a"}not returningtrue(#8747) authored by @anderseknertformat_intprecision loss for integers larger than 64 bits (#8857) authored by @SynvoyaSliceStack/GroupStack, unify refStack/functionMocksStack/saveStack (#8886) authored by @srenatusruletrie.Children()call inDepth()(#8886) authored by @srenatusfunctionMocksStackon genericGroupStack[T](#8886) authored by @srenatusDocs, Website, Ecosystem
in, bare refs; modernize rego (#8822) authored by @srenatus, reported by @tsandallMiscellaneous
test.WithTempFS(#8908) authored by @anderseknertAddressing GHSA-fxhp-mv3v-67qp
Release notes and downloads can be found here.
All reactions