Skip to content

v1.23.0

Latest

Choose a tag to compare

@github-actions github-actions released this 26 Nov 18:16
· 1 commit to main since this release
Immutable release. Only release title and notes can be modified.
7c0ba9d

This release contains a mix of new features, performance improvements and bug fixes. Notably:

  • Enforcement of bundle structure: now rooted at their .manifest file
  • Lucene (Solr) target for the Compile API
  • Hardening of the MySQL Compile API target: use of startswith, endswith and contains built-in functions is rejected
  • Improvements to the rule indexer
  • A new json.pointer_escape built-in function

Note

Help us improve OPA, and fill out the 2026 OPA Community Survey!

Bundles are rooted at their .manifest file (#9459)

Breaking change: OPA now treats the directory containing a bundle's .manifest file as the bundle root, as the
bundle documentation describes.
Previously, the root depended on the path a bundle was loaded from, which made bundle contents, data placement,
and signatures depend on how a path was typed.

  • Bundle directories (opa build -b, opa run -b, opa eval -b, opa sign --bundle, ...) are rooted at
    the directory containing .manifest, even when it is nested below the provided path. Files above it are not
    part of the bundle. opa build and opa sign warn about policy and data files they leave out, but other
    commands do not, so keep other .manifest files (e.g., test fixtures) out of directories loaded as bundles.
  • Bundle tarballs loaded from disk must have .manifest at the root of the archive. opa build always writes
    it there.
  • Signatures: file names in .signatures.json are relative to the bundle root, with / separators on every
    platform. Bundles signed by opa sign <dir> or opa build -b <dir> with older OPA versions must be re-signed,
    and --exclude-files-verify patterns may need updating.
  • opa build with multiple bundles places each bundle's files under the path it was given with -b, with a
    new .manifest at the root. Leading .. segments are replaced with the name of the directory they refer to.
    Merging fails when two bundles would be placed under the same path. opa sign with multiple bundle paths
    names files under each bundle's path, like opa build does when merging. A merged opa build output has its
    own new .manifest, so signatures from multiple separate source bundles cannot be used to verify a merged build.
  • opa build -t plan and -t wasm replace any plan, or wasm resolvers that were carried in from the input bundles.
  • .manifest, .signatures.json, and patch.json must be at the bundle root, and only files named exactly
    .manifest are treated as manifests.

For example, consider this tarball, built without opa build:

$ tar tzf bundle.tar.gz
bundle/.manifest
bundle/data.json
bundle/authz.rego

Previously, opa run -b bundle.tar.gz loaded it with bundle/data.json placed under data.bundle. It is now
rejected because .manifest is not at the root of the archive. Running opa build -b bundle/ on the extracted
directory produces a bundle rooted at bundle/, with data.json placed at the root of data.

To avoid breaking existing deployments, bundles that the bundle plugin downloads over HTTP or from an OCI registry
(and their persisted copies) are still loaded as before, and OPA logs a warning each time a bundle with a misplaced .manifest, .signatures.json,
or patch.json is loaded. These bundles will fail to load in a future OPA release. Rebuild them with
opa build to place the manifest at the root.

Go API: the bundle.Reader expects bundle-relative descriptor paths, so directory loaders configured with the
SlashRooted or Passthrough path formats now have their manifests rejected. When Reader.WithBaseDir is used,
module paths include the manifest's directory, which directory loaders report through a RootOffset() string
method. Custom loaders that wrap a directory loader should forward RootOffset.

Authored by @philipaconrad

Lucene (Solr) target for the Compile API (#9376)

The Compile API can now translate a policy into a Lucene query for Solr's fq or q, with
Accept: application/vnd.opa.lucene.solr+json. The one unknown is the document searched:

# METADATA
# scope: package
# compile:
#   unknowns: [input.doc]
package filters

include if {
    input.doc.owner == input.user
    input.doc.level >= 3
    not input.doc.status == "draft"
}

For the user alice, this compiles to (owner:"alice" AND level:[3 TO *] AND NOT status:"draft").
Multi-valued fields are compared by their elements, as in "a" in input.doc.tags; schemas
annotations declare which fields are, and
solr_schema.rego generates them from
Solr's Schema API. The target can't be combined with others in a multitarget request.

See Lucene filters.

Authored by @srenatus

Compile API: no startswith, endswith or contains for MySQL (#9624)

Breaking change: the MySQL target rejects startswith, endswith and contains, as the SQLite target
already did. They were translated to LIKE, which is case- and accent-insensitive in MySQL's default
collations, so startswith(input.fruits.name, "APP") also matched apple. Policies using them now fail
to compile for application/vnd.opa.sql.mysql+json, and for multitarget requests that include mysql.

Reported by @kianwang0610, authored by @srenatus

Generated bundles

A bundle whose policies are generated, for example from a policy database, can say so in its manifest:

{
  "revision": "...",
  "roots": ["authz"],
  "generated": true
}

OPA then parses its policies without source locations. In a benchmark of 20000 generated rules, that cut
the memory the compiled policies hold by 40%. Annotations are kept. See the
manifest documentation.

Authored by @srenatus

Rule indexing covers more ways of saying "any of these"

The rule index now narrows down rules written with:

  • a local iterating a literal set, array or object, in any indexable statement:
    some g in {"devs", "ops"}; data.groups[g].members[input.subject];
  • collection lookups in the operands of and and or:
    {data.groups.devs.members[input.subject]} or {data.groups.ops.members[input.subject]};
  • a collection lookup keyed by any element of a collection: data.groups.devs.members[input.subjects[_]].

Looking up a key in a collection in base data also no longer converts the store's data on every query:
in benchmarks of 500 rules gated by group membership, that takes 40-55% off evaluation and partial
evaluation where every candidate is evaluated.

See Use indexed statements.

  • ast: Index a collection lookup keyed by an element of a collection (#9461) authored by @srenatus
  • ast: Index collection lookups in and/or operands (#9461) authored by @srenatus
  • ast: Index expressions over a local iterating a literal (#9461) authored by @srenatus
  • ast: Keep a rule indexed as "anything" for in with a var member (#9506) authored by @srenatus, reported by @kholia
  • rego: Compare indexed and unindexed evaluation for every index condition (#9525) authored by @srenatus
  • topdown: Ask the index candidates whether a rule depends on unknowns (#9570) authored by @srenatus
  • topdown: Report key conflicts in indexed object comprehensions (#9613) authored by @srenatus

New json.pointer_escape built-in function (#9591)

Escapes a string so it can be used as one reference token of a JSON Pointer, as defined in RFC 6901.
The characters ~ and / are replaced with ~0 and ~1.
For example: json.pointer_escape(\"a/b~c\") results in \"a~1b~0c\".

Authored by @charlieegan3

Runtime, SDK, Tooling

  • cmd(fmt): Honor --drop-v0-imports when formatting stdin (#9619) authored by @FayezBast
  • cmd/inspect: Show labels metadata with -a (#9504) authored by @srenatus, reported by @humbertoc-silva
  • cmd: Add --v2-compatible flag (#9251) authored by @sspaink, reported by @johanfylling
  • cmd: Replace --v2-compatible with --compatible= (#9496) authored by @sspaink
  • compile: Compile without indices where nothing evaluates (#9605) authored by @srenatus
  • compile: Release the checking compiler after a rego build (#9604) authored by @srenatus
  • format: Preserve nested comparison grouping (#9407) authored by @rudraa2005, reported by @alecthomas
  • plugins/bundle: Activate generated bundles incrementally (#9359) authored by @srenatus
  • plugins/logs: Copy JSON-shaped values natively for console logs (#9576) authored by @sspaink
  • plugins/logs: Split oversized chunks without decoding them (#9577) authored by @sspaink
  • plugins: Close the Wasm resolvers a bundle update replaces (#9513) authored by @jbpros
  • rego: Close the Wasm engine after Rego.Eval (#9513) authored by @jbpros
  • rego: Close the Wasm resolvers a prepared query loaded (#9513) authored by @jbpros
  • rego: Drop the test that Close does nothing on the default target (#9513) authored by @jbpros
  • rego: Exclude wasm compile time from context timeout test (#9455) authored by @sspaink
  • rego: Test a Wasm resolver result not named "result" (#9541) authored by @jbpros
  • repl: Allow implicit function bodies (#9539) authored by @devjoshi2005, reported by @anderseknert
  • server: Fix oversized request body status in v2-compatible mode (#9497) authored by @darshpatel1052
  • storage/inmem: Speed up NonEmpty conflict checks (#9545) reported and authored by @believetech-orw
  • tester: Add --strict-builtin-errors to opa test (#6816) authored by @oleksii-udovychenko, reported by @selaux
  • tester: Close the Wasm engine after each test (#9513) authored by @jbpros
  • tester: Close the Wasm engine of a benchmark (#9513) authored by @jbpros
  • tester: Do not wait forever to evaluate a closed engine (#9513) authored by @jbpros
  • wasm: Return an error when the result has no "result" key (#9541) authored by @jbpros
  • wasm: Replace non-object values when upserting for with (#6304) authored by @sspaink, reported by @srenatus

Compiler, Topdown and Rego

Docs, Website, Ecosystem

Miscellaneous

  • types: Decode set types without an element type (#9544) authored by @srenatus
  • types: Decode type JSON in linear time (#9473) authored by @srenatus
  • util/test: don't panic in MakeTempFS when creating files fails (#9578) authored by @sspaink
  • Dependency updates; notably:
    • build(go): Bump to 1.27.4 (#9543) authored by @srenatus
    • build(deps): Bump github.com/agnivade/levenshtein from 1.2.1 to 1.2.2
    • build(deps): Bump github.com/foxcpp/go-mockdns from 1.2.0 to 1.3.0
    • build(deps): Bump github.com/gobwas/glob from 1.0.0 to 1.1.0
    • build(deps): Bump github.com/huandu/go-sqlbuilder from 1.43.0 to 1.44.1
    • build(deps): Bump github.com/klauspost/compress from 1.20.0 to 1.20.4
    • build(deps): Bump github.com/lestrrat-go/jwx/v3 from 3.3.0 to 3.4.0
    • build(deps): Bump github.com/prometheus/client_golang from 1.24.1 to 1.25.0
    • build(deps): Bump github.com/sergi/go-diff from 1.4.0 to 1.4.5
    • build(deps): Bump github.com/spf13/pflag from 1.0.10 to 1.1.0
    • build(deps): Bump github.com/vektah/gqlparser/v2 from 2.5.58 to 2.5.64
    • build(deps): bump go.opentelemetry.io deps from 1.46.0/0.71.0 to 1.47.0/0.72.0
    • build(deps): Bump go.opentelemetry.io/proto/otlp from 1.11.0 to 1.11.1
    • build(deps): Bump go.yaml.in/yaml/v3 from 3.0.5 to 3.0.6
    • build(deps): Bump golang.org/x/sync from 0.23.0 to 0.25.0
    • build(deps): Bump golang.org/x/term from 0.46.0 to 0.48.0
    • build(deps): Bump golang.org/x/text from 0.42.0 to 0.44.0
    • build(deps): Bump golang.org/x/net from v0.60.0 to v0.62.0 (#9555) authored by @anderseknert
    • build(deps): Bump google.golang.org/grpc from 1.84.0 to 1.85.0
    • build(deps): Bump gopkg.in/ini.v1 from 1.67.3 to 1.68.0
    • build(deps): Bump oras.land/oras-go/v2 from 2.6.2 to 2.7.0