Skip to content
Back to skills

Opa Knowledge Patch

ASecurity

Open Policy Agent (OPA)

  • 25 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 5, 2026
developmentgosqlexpresstestingdebuggingapisecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill opa-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Opa Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Opa Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-opa-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-opa-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: opa-knowledge-patch
description: Open Policy Agent (OPA)
version: "1.23.0"
license: MIT
metadata:
  author: Nevaberry
---


# Open Policy Agent compatibility guidance

Load this skill when migrating Rego, building or signing bundles, using partial
evaluation or data filters, embedding OPA in Go, or changing server configuration.
It also covers testing, formatting, built-ins, authentication, logs, and tracing.
Use the topic references for complete guidance, examples, and version attribution.

## Reference index

| Reference | Topics |
| --- | --- |
| [Rego language and built-ins](references/rego-language-and-builtins.md) | Rule heads, language opt-ins, type checking, precision, strings, collections, JWT, URI, YAML, schemas |
| [Bundles, partial evaluation, and Wasm](references/bundles-partial-evaluation-and-wasm.md) | Compatibility manifests, roots, signatures, optimization, plans, Wasm, residual policies, SQL and Solr filters |
| [CLI, testing, and formatting](references/cli-testing-and-formatting.md) | Migration, compatibility flags, tests, coverage, formatting, inspection, debugging, automation |
| [Go SDK, AST, and extensibility](references/go-sdk-ast-and-extensibility.md) | Transports, caches, AST, compiler stages, oracle, runtime extensions, bundle readers, query cleanup |
| [Plugins, authentication, and observability](references/plugins-auth-and-observability.md) | Decision logs, masking, buffering, metrics, tracing, REST authentication, TLS, discovery, lifecycle |
| [Server runtime and security](references/server-runtime-and-security.md) | Authorization, API metadata, HTTP, configuration, resource limits, source builds, security rebuilds |

## Breaking changes and deprecations

### Preserve rule shapes during migration

Use the OPA 1.0 formatter to migrate legacy syntax, then validate both Rego versions
with strict checking. The formatter's `--write` flag updates files in place.

```sh
opa fmt --write --v0-v1 ./policy
opa check --v0-v1 --strict ./policy
```

A legacy `p.a { true }` adds a set member: use `p contains "a" if { true }`.
Changing it to `p.a if { true }` produces an object field instead.
The deeper `q.a.b { true }` already produces a nested object; its bare form
`q.a.b` needs an explicit assignment to preserve the `true` value.

OPA 1.0 rejects shadowing imports and reserves `input` and `data` against rule
declarations and variable assignments. Before migrating to Rego v1, replace
`any`, `all`, `re_match`, `net.cidr_overlap`, `set_diff`, `cast_array`, `cast_set`,
`cast_string`, `cast_boolean`, `cast_null`, and `cast_object`.

### Keep bundle syntax compatible with consumers

Consumers use the manifest's `rego_version` ahead of runtime compatibility mode.
Upgrade producers first and use `--v0-compatible` while v0.x consumers remain.
Use the same flag on v1.0 consumers loading unversioned bundles with legacy Rego.

```sh
opa build --v0-compatible ./policy
```

On v0.x releases that write versioned manifests, `opa build --v1-compatible`
builds Rego v1 policies and records `rego_version: 1`.
When v0.x consumers support `rego.v1` and select syntax through module imports,
add `import rego.v1` to each migrated module.

### Update bundle roots and signatures

OPA 1.23.0 roots a local bundle directory at its exact `.manifest`, even below the
supplied path. Files above that directory are excluded; `opa build` and `opa sign`
warn. For local tarballs, put `.manifest`, `.signatures.json`, and `patch.json`
at the archive root. The bundle plugin still loads HTTP and OCI bundles and their
persisted copies with misplaced descriptors, warning at each load.
Rebuild affected bundles with `opa build -b ./bundle`, using the extracted manifest
directory, before a future release rejects them.

OPA 1.23.0 signs bundle-root-relative paths with `/` separators. Re-sign directory
bundles signed with older `opa sign` or `opa build -b`, and update
`--exclude-files-verify` patterns. Sign merged builds separately to cover the new
root manifest. OPA 1.22.0 requires the exact basename `.signatures.json` at any
directory depth and rejects multiple such files; re-sign affected bundles so
ordinary files ending in `signatures.json` are covered too.

In OPA 1.21.3, a bundle or discovery `signing` block requires snapshot signatures.
`signing.keyid` selects the verification key; top-level `keys` alone causes a
startup warning. With verification enabled, delta bundles are rejected by default.
To accept unsigned deltas, set `bundles.<name>.signing.allow_unsigned_delta_bundles`
or `discovery.signing.allow_unsigned_delta_bundles` to `true`.
Snapshot bundles still require signatures.

### Recheck type-sensitive policies and data

- The right side of `:=` must be safe independently of its left side. Bind inputs
  in another expression, or use `some k` followed by `v := obj[k]`.
- OPA 1.22.0 rejects a `some … in` binding if its introduced variable appears in
  the collection expression. Use a separate collection reference.
- OPA 1.21.0 rejects iteration on literal empty collections. OPA 1.22.2 accepts
  `some x in []` and lookups such as `m[_]` for `m := {}`; non-constant iteration
  yields no bindings, while `[][0]` still raises `rego_type_error`.
- OPA 1.21.0 checks `in` operands against collection types. Comparing `{}` or `[]`
  to a statically nonempty value is a type error; use `count(x) == 0` for emptiness.
  Set comparisons such as `{"foo"} == set()` still compile.
- OPA 1.21.0 loads bare `y`, `n`, `yes`, `no`, `on`, and `off` as YAML strings in
  `--data`, bundles, server configuration, and `yaml.unmarshal`.
  Use `true` and `false` for booleans.
- Partial set and partial object rules sharing a name are rejected. OPA 1.23.0
  allows different rule kinds under a shared prefix when reference heads are disjoint.

### Check filters, integrations, and artifacts

Upgrade Compile API SQL emitters to OPA 1.19.0 or later for the SQL injection fix.
OPA 1.23.0 rejects `startswith`, `endswith`, and `contains` for MySQL filters,
including multitarget requests containing `mysql`: their former `LIKE` translation
uses case- and accent-insensitive matching under default MySQL collations.

OPA caches the result of `HTTPAuthPlugin.NewClient()` once per REST client
instance. Move per-request authentication and side effects to `Prepare()`.
Go integrations using `gorilla/mux` directly with
OPA's router need to adapt to `net/http.ServeMux`.
OPA 1.22.0 deprecates the `_static` binaries.

## Language features and built-ins

OPA 1.22.0's `import rego.v2` enables `and`, `or`, and improved `not` semantics
together, implies `rego.v1` in a v0 module, and requires `rego_v2_import`.
Set the bundle manifest's `rego_version` to `2`, or select versions per module
with `file_rego_versions`. Go callers can select `ast.RegoV2`.
The `rego_v2` capability also implies `template_strings`
and `keywords_in_refs`.

```rego
package example

import rego.v2

allow if input.user.admin or not (input.user.suspended or input.user.locked)
```

With `import future.keywords.not`, argument evaluation occurs inside negation,
so `not` succeeds when a nested expression is undefined.
Template strings use `$"...{expression}..."`; undefined expressions insert
`<undefined>` and evaluation continues.

| Built-in | Behavior |
| --- | --- |
| `array.flatten` | Combines nested arrays; OPA 1.13.1 fixes single-item arrays |
| `strings.split_n(s, delimiter, n)` | Positive counts select first fields; negative counts select last fields in original order; zero returns an empty array; oversized counts return all fields |
| `uri.parse` / `uri.is_valid` | Parses RFC 3986 components, omitting empty ones; tests whether a URI can be parsed |
| `json.match_schema` | Accepts array documents; supports `pattern` validation |
| `json.pointer_escape` | Escapes one JSON Pointer token: `"a/b~c"` becomes `"a~1b~0c"` |

## Partial evaluation and data filtering

The Go Rego API and Compile API can opt in to nondeterministic built-ins during
partial evaluation; `http.send` can then run when its arguments are known.
OPA 1.21.0 treats `json.verify_schema` and `json.match_schema` as nondeterministic.
Opt in if those calls should run during partial evaluation.

OPA 1.22.0 unrolls `every` over known collections when its body contains unknowns,
with a 32-element limit across nested `every` expressions. The Compile API can
translate the resulting conjunction of one condition per element for filtering.

POST to `/v1/compile/<path>` with the SQL media type in `Accept` for SQL filters.
OPA 1.23.0's `application/vnd.opa.lucene.solr+json` produces a query for Solr's
`fq` or `q`. Use the searched document as the single unknown and request this
target on its own. Declare multivalued fields with `schemas` annotations and
match their elements with expressions such as `"a" in input.doc.tags`.

## Tests, formatting, and inspection

`opa test` runs in parallel by default with one worker per available CPU core.
Named parameterized tests report each case and fail the rule if any case fails.

```sh
opa test . --parallel=1
opa test --fail-on-empty -r 'test_allow' ./policy
opa test --strict-builtin-errors ./policy
```

These commands select sequential execution, fail when no tests run, and surface
built-in evaluation errors respectively. `opa test --coverage` reports source
ranges and tracks inline rule heads and conjunction expressions; refresh coverage
baselines and check report consumers. `opa inspect -a ./bundle` includes labels.
`opa fmt --drop-v0-imports < policy.rego` applies import removal to stdin.

## Decision logs, metrics, and server operations

Set `decision_logs.reporting.buffer_type` to `event` to reduce lock contention
under heavy load; this relaxes the default buffer's memory-footprint guarantees.
Set `decision_logs.reporting.trigger` to `immediate` to upload when the configured
chunk size is reached; the configured delay still bounds a partially filled chunk's wait.

Decision-log masking paths support zero-based array indexes. Mask and drop policy
events include `trace_id`, `span_id`, and `request_context`; OPA 1.22.0 adds
`metrics` and `error`, array-rooted `input` and `result` masking, and SDK masking
of the nondeterministic built-in cache.
Decision logs merge labels for each successfully evaluated rule and deduplicate
identical maps; annotation precedence is
`subpackages` < `package` < `document` < `rule`.

Set `distributed_tracing.type` to `http` for HTTP collectors and use
`distributed_tracing.exclude_paths` to omit selected paths. OPA supports OTLP
metrics exports with custom request headers and resource attributes.
Set `--log-level-request=debug` to hide HTTP request/response entries at the
general `info` level. OPA restarts its serving routine when reloading a changed
configuration file to apply the updated configuration.

## Go integration and Wasm lifecycle

Use `EvalHTTPRoundTrip` for an evaluation or `WithHTTPRoundTrip` for a query.
Their callback receives OPA's configured transport and returns the
`http.RoundTripper` used by `http.send`. The SDK also supports a transport per
`Decision`. `WithStageAfterID` takes an `ast.StageID`; update callers holding
stage names in string variables.

The `wasm` target and Wasm SDK use pure-Go `wazero`, removing their cgo build
dependency. Linear memory is on the Go heap and appears in heap profiles.
In OPA 1.23.0, `Rego.Eval` closes its Wasm engine after evaluation, and closing
a prepared query closes the Wasm resolvers it loaded.

Files in this skill

  • SKILL.md7.8 KB
  • coverage.json1.7 KB
  • references/bundles-partial-evaluation-and-wasm.md5.3 KB
  • references/cli-testing-and-formatting.md5.1 KB
  • references/go-sdk-ast-and-extensibility.md5 KB
  • references/plugins-auth-and-observability.md5.8 KB
  • references/rego-language-and-builtins.md5.6 KB
  • references/server-runtime-and-security.md4.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.