61 Commits

Author SHA1 Message Date
Charlie Egan 343ddf583f builtins: Add uri.parse and uri.is_valid built in functions (#8578)
Examples of things this is useful for:
- Implementing policy around AI coding tool calls (permitted domains
etc)
- Validating SPIFFE IDs

Fixes https://github.com/open-policy-agent/opa/issues/8263

---------

Signed-off-by: Charlie Egan <charlie_egan@apple.com>
2026-04-29 13:08:15 +00:00
Johan Fylling 9b330379f7 ast,format,planner: Add not block syntax (#8562)
Expanding the Rego syntax to support not-bodies (not blocks?): `not {...}`

For a not block to successfully evaluate, its body must not successfully evaluate. If evaluation causes iteration, all evaluation paths must fail.

Fixes: #8402

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-04-24 16:35:39 +00:00
Isaiah Vita 271c6cd99a Limit exponent size in parse_bytes/parse_units to prevent timeout bypass (#8524)
Timeouts passed via context are not honored because builtins that
parse exponents dont include context and will run with unrestricted
size on the exponents. Added an exponent limit checker based
on rough benchmakrking data of whats a reasonabile limit.

Fixes: #8326

Signed-off-by: Isaiah Vita <vita.isaiah@gmail.com>
2026-04-23 13:41:16 +00:00
davidmarne-wf 55a9eb6ffa fix: reachable_paths does not return all reachable paths (#8510)
* topdown: add failing tests for graph.reachable_paths with shared ancestors

Adds a regression test (shared_ancestor) reproducing the bug reported in
#5871: given a graph where node 4 has edges to both 3 and 2, and 3 also
has an edge to 2, graph.reachable_paths from 5 drops the path [5,4,2,1].

Also corrects the expected result for the existing cycle_1022_3 test, which
was asserting the buggy output ([one,five,six] truncated) rather than the
correct complete path [one,five,six,seven,eight,three].

Signed-off-by: David Marne <david.marne@workiva.com>

* topdown: fix graph.reachable_paths dropping paths with shared ancestors

graph.reachable_paths had two bugs that caused paths to be silently dropped
when a node is reachable via multiple routes (diamond-shaped graphs).

Bug 1: the `reached` set was mutated and shared across sibling recursive
calls. After branch A finished traversal and added nodes to `reached`,
branch B would see those nodes as already visited and terminate early,
emitting a truncated path instead of continuing.

Fix: copy `reached` once per pathBuilder invocation and pass the copy to
all recursive calls. Each branch now has its own ancestor-only visited set.

Bug 2: ast.NewArray stores the slice it receives directly (elems: a)
without copying. When sibling calls appended to a shared backing array,
the in-place write by one sibling corrupted the already-committed path
term of a previous sibling.

Fix: pass append([]*ast.Term(nil), path...) to each recursive call,
giving each branch its own independent backing array.

Signed-off-by: David Marne <david.marne@workiva.com>

---------

Signed-off-by: David Marne <david.marne@workiva.com>
2026-04-14 10:45:43 -05:00
Sebastian Spaink 1de861f2d6 Add support for days, weeks and years in parse_duration_ns (#8463)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-04-13 20:20:51 +00:00
Michael Munch 12b7290697 distributedtracing: export Prometheus metrics via OTLP (#8450)
* distributedtracing: export Prometheus metrics via OTLP

Add support for pushing OPA's existing Prometheus metrics to an
OpenTelemetry collector via OTLP, eliminating the need for a dedicated
scraper sidecar. Uses the OTel Prometheus bridge to read from OPA's
prometheus.Registry and export through an OTLP metric exporter (gRPC
or HTTP), reusing the same address and TLS configuration as traces.

New config fields: distributed_tracing.metrics (bool, default false)
and distributed_tracing.metrics_export_interval_ms (int, default 60000).

Fixes #7591

Signed-off-by: Michael Munch <mm.munk@gmail.com>

* metricsexport: decouple metrics export into top-level config section

Extract metrics export from distributed_tracing into its own
metrics_export config section with independent type (otlp/grpc,
otlp/http), address, and TLS settings. This allows exporting
Prometheus metrics via OTLP without enabling tracing, and to a
different endpoint than traces.

- Extract shared TLS helpers into internal/tlsutil
- Add MetricsExport field to top-level Config
- Create internal/metricsexport package with Init, config parsing
- Remove metrics fields from distributedtracing
- Update runtime to call metricsexport.Init separately
- Move e2e tests to v1/test/e2e/metricsexport
- Add Metrics Export section to configuration docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Michael Munch <mm.munk@gmail.com>

* ci: retrigger checks

Signed-off-by: Michael Munch <mm.munk@gmail.com>

* go.mod: upgrade dependencies downgraded during rebase

Modules like containerd, go-sqlbuilder, OpenTelemetry, and golang.org/x/*
were at older versions than main after a rebase. Upgrade them to match or
exceed main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Michael Munch <mm.munk@gmail.com>

* Update internal/distributedtracing/distributedtracing_test.go

Signed-off-by: Michael Munch <mm.munk@gmail.com>

---------

Signed-off-by: Michael Munch <mm.munk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 14:09:51 +00:00
Johan Fylling 670d2e2556 ast, topdown: Add not AST node type (#8427)
Disabled by default. To enable, `not` future keyword must be present in capabilities and imported into Rego module.

Implements: #8391

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-03-30 18:12:57 +02:00
Sebastian Spaink 573070615c Add public method to extend the compliance test cases with IR plans (#8313)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-02-12 15:51:34 +00:00
Stephan Renatus e426fd7c76 run: support --h2c with unix domain socket (UDS)
When `--h2c` is passed, HTTP2 will also be used on the unix domain socket.
Previously, it had no effect on UDS, only on TCP connections.

Fixes #8282.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-02-02 15:47:13 +01:00
Anders Eknert b624c08b49 Fix issue in array.flatten handling of single item arrays (#8273)
Fixes #8272

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2026-01-29 19:50:57 +00:00
Anders Eknert d0350b326e Add array.flatten built-in function (#8232)
Originally meant to be `array.concat_n`, but this name is better
as the behavior of this function differs from `array.concat` —
namely that `array.flatten` accepts any type of valued in the
input array. Only arrays are however flattened, and the rest
are appended directly to the flattened output.

Note that this function only flattens at the topmost level of
the input array — not recursively! A cursory look
at a few other languages suggest a single level is the common case.
But if others feel we should flstten more, I'm happy to make an update.

The C code for a Wasm implementstion here is cowboy coded, and
I did not manage to run the tests on my machine due to some
`docker` <-> `container` differences. I mostly just imitated
the existing code in the array category. I doubt it'll work
on the first try, but only CI can judge me.

Also:
- Remove `opa fmt` step from the Rego CI step, as this is done by
  Regal anyway a little later in the list of tasks.
- Replace some hard-coded `docker` names in the `Makefile` with `$(DOCKER)`
- Added name of built-in function missing to the unsupportedBuiltinErr
  error, as it has happened a few times now that I've used `:=` in a
  query, and had no clue what built-in it referred to.

Fixes #8226

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2026-01-27 21:46:11 +00:00
Colin J Lacy 207a294f5e strings.render_template: removes hard-coded missing key error (#8128)
Current implementation of render_template passes in an explicit
missingkey=error option when rendering a Golang template. That's
not the default behavior for Golang, so it's an unexpected result.

Fixes #7931.

Signed-off-by: Colin Lacy <colinjlacy@gmail.com>
2026-01-12 13:38:53 +01:00
Ville Vesilehto 0265c7cfd1 fix(topdown): correct operand in cheap range step (#8194)
Fix canGenerateCheapRangeStep to check operands[2] (step) instead of
operands[1] (y) when determining whether to use the fast path for
numbers.range_step.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2026-01-08 23:50:33 +01:00
Manuel Rüger 34bd4c12f1 chore: Switch to maintained yaml library
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2026-01-06 19:47:20 +01:00
Stephan Renatus 7df8ce10de cases: increase yaml test coverage for some regex and string builtins (#8152)
Relevant: #8151.

New tests: add some cases for these builtins:
* regex.match
* regex.replace
* strings.count
* regex.find_n
* regex.split

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-12-19 20:22:12 +01:00
Johan Fylling 8e410b830a String interpolation (#8109)
Adding string interpolation support to the Rego language.

An interpolated string is composed of a template-string that can contain zero or more template-expressions that interpolates values into the string generated at eval-time.

Requires the `template_strings` capability feature and `internal.template_string` built-in function.

Implements: #4733
2025-12-16 11:47:04 +01:00
Anders Eknert 51a50ca042 Concurrent Rego parsing in bundle loader (#8067)
Parsing is generally fast, so this mainly improves performance
of creating big bundles with many Rego files in them. For Regal's
embedded bundle, loading it from memory would previously take 16
ms on my laptop, and now it takes 9 ms. There are other things
in this process that could be concurrent too, like JSON unmarshalling
of multiple data files. But starting with parsing modules.

This PR adds `errgroup` as a direct dependency (previously indirect)
as it is a nicer way to work with wait groups, and one that can be
useful elsewhere in the codebase (like in the compiler).

Also, and as usual, went off on a bit of a tangent refactoring code
related to the bundle build process, and made sure to use some common
helpers in code where available.

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2025-11-21 08:42:43 +01:00
Anders Eknert e03ac2f200 Bump golangci-lint, more gocritic linters (#8052)
- Bump golangci-lint -> 2.6.2
- Fix all `deprecatedComment` "notices should be in a dedicated paragraph, separated from the rest" reports
- Enable `appendCombine` and fix all "appendCombine: can combine chain of X appends into one" notices
- Enable `preferFprint` and fix the few reported issues
- Fix various issues reported only once or twice, like `zeroByteRepeat`

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2025-11-17 11:08:39 +01:00
Johan Fylling 2691499f80 build(deps): github.com/vektah/gqlparser/v2 from 2.5.30 to 2.5.31
Fixing tests broken by new `ExpectedTypeHasDefault` field.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-11-10 10:06:21 +01:00
Stephan Renatus 55468b1022 topdown: fix split(..., "")
Fixes https://github.com/open-policy-agent/opa/issues/8018

goos: darwin
goarch: arm64
pkg: github.com/open-policy-agent/opa/v1/topdown
cpu: Apple M4 Max
                                        │ main.bench  │               pr.bench               │
                                        │   sec/op    │   sec/op     vs base                 │
Split-16                                  238.7n ± 1%   254.2n ± 1%  +6.47% (p=0.000 n=10)

                                        │  main.bench  │              pr.bench               │
                                        │     B/op     │    B/op     vs base                 │
Split-16                                  384.0 ± 0%     384.0 ± 0%       ~ (p=1.000 n=10) ¹
¹ all samples are equal

                                        │  main.bench  │              pr.bench               │
                                        │  allocs/op   │ allocs/op   vs base                 │
Split-16                                  14.00 ± 0%     14.00 ± 0%       ~ (p=1.000 n=10) ¹
¹ all samples are equal

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-11-05 09:54:53 +01:00
Dmitry Frenkel 6415ef17f3 Add test cases for consistent cache behavior
Using `rand.intn` test cases as template, we create similar tests
that verify consistent values returned by `uuid.rfc4122` and `time.now_ns`
builtins when invoked during the same evaluation/query.

These tests can also aid compliance regression testing for other OPA implementations,
such as Swift.

Signed-off-by: Dmitry Frenkel <d_frenkel@apple.com>
2025-11-04 07:21:12 +01:00
Stephan Renatus 8853b19a12 e2e/authz,topdown: fix benchmarks (#7980)
Before, we'd see these benchmarks die with

    benchmark.go:412: B.Loop called with timer stopped

Now, we can run them again:

```
% go test -bench=. -v -run=XXX ./v1/test/e2e/authz
{
  "level": "info",
  "msg": "Test server ready and listening on: http://127.0.0.1:64200",
  "time": "2025-10-15T11:44:06+02:00"
}
goos: darwin
goarch: arm64
pkg: github.com/open-policy-agent/opa/v1/test/e2e/authz
cpu: Apple M4 Max
BenchmarkRESTAuthzForbidAuthn
BenchmarkRESTAuthzForbidAuthn-16           22623             52375 ns/op
BenchmarkRESTAuthzForbidPath
BenchmarkRESTAuthzForbidPath-16            16729             71916 ns/op
BenchmarkRESTAuthzForbidMethod
BenchmarkRESTAuthzForbidMethod-16          16434             72963 ns/op
BenchmarkRESTAuthzAllow10Paths
BenchmarkRESTAuthzAllow10Paths-16          15883             74936 ns/op
BenchmarkRESTAuthzAllow100Paths
BenchmarkRESTAuthzAllow100Paths-16         10000            109283 ns/op
BenchmarkRESTAuthzAllow1000Paths
BenchmarkRESTAuthzAllow1000Paths-16         2731            462167 ns/op
PASS
ok      github.com/open-policy-agent/opa/v1/test/e2e/authz      13.349s
```

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-10-15 12:47:08 +02:00
Anders Eknert d3f34a3387 Modernize analyzer fixes (#7965)
Have done this some time in the past, but there was a few
new issues this would highlight now that we're on Go 1.24.

Mostly:
- Use `b.Loop()` in benchmarks
- Use `strings.SplitSeq` where possible
- Remove `omitempty` tag for types that can't be empty

Signed-off-by: Anders Eknert <anders@eknert.com>
2025-10-10 17:51:02 +02:00
Stephan Renatus 3279dd66aa test/e2e: move http.DefaultTransport fix to init() (#7955)
In its previous location, it was caught as a data race in tests.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-10-02 08:58:40 +02:00
Jacob Hochstetler 2cc948d872 TLM: Upgrade to v1 tablewriter (#7937)
- Updated test fixtures and various test fixes.

Signed-off-by: Jacob Hochstetler <jacob.hochstetler@gmail.com>
2025-10-01 10:44:42 +02:00
Anders Eknert e1e2bfb876 Some small improvements to inmem storage (#7944)
Mainly making transactions cheaper to create, and read transactions
much cheaper.

- Add exported RootPath shorthand var
- Don't return path on ParsePathEscaped failure
- Allocate nothing for read transactions, other than the transaction itself
- Lazy init of write update collections to avoid needless allocations
- Add benchmarks

**Before**
```
BenchmarkNewTransaction/Read-16                     26707234            44.78 ns/op      144 B/op          3 allocs/op
BenchmarkNewTransaction/Write-16                    20344212            59.44 ns/op      192 B/op          4 allocs/op
BenchmarkReadOne/Go_store_(roundtrip)-16            21963003            54.41 ns/op      144 B/op          3 allocs/op
BenchmarkReadOne/Go_store_(no_roundtrip)-16         22217593            54.18 ns/op      144 B/op          3 allocs/op
BenchmarkReadOne/AST_store_(roundtrip)-16           15626653            76.52 ns/op      160 B/op          4 allocs/op
BenchmarkReadOne/AST_store_(no_roundtrip)-16        15820837            76.15 ns/op      160 B/op          4 allocs/op
```

**After**
```
BenchmarkNewTransaction/Read-16                     68091271            17.37 ns/op       48 B/op          1 allocs/op
BenchmarkNewTransaction/Write-16                    24928028            47.68 ns/op      144 B/op          3 allocs/op
BenchmarkReadOne/Go_store_(roundtrip)-16            42967630            28.10 ns/op       48 B/op          1 allocs/op
BenchmarkReadOne/Go_store_(no_roundtrip)-16         43825009            27.63 ns/op       48 B/op          1 allocs/op
BenchmarkReadOne/AST_store_(roundtrip)-16           24885938            48.06 ns/op       64 B/op          2 allocs/op
BenchmarkReadOne/AST_store_(no_roundtrip)-16        25012396            47.96 ns/op       64 B/op          2 allocs/op
```

Signed-off-by: Anders Eknert <anders@eknert.com>
2025-09-30 00:00:39 +02:00
Charlie Egan f9801e478a topdown: Update step error message (#7882)
This makes the error more succinct.

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
Co-authored-by: Charlie Egan <charlieegan3@users.noreply.github.com>
2025-09-08 13:21:48 +00:00
Sebastian Spaink 8c0079f551 Bump golangci-lint to v2.4.0 (#7878)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2025-09-03 15:21:30 -05:00
Stephan Renatus 184d1b553f ci: port binary tests to testscript
The assertions are stricter now, e.g. we're also checking that nothing
is emitted to stderr.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-08-29 17:57:50 +02:00
Anders Eknert 9a766420c4 Avoid port exhaustion in concurrent tests (#7862)
Running `make test` on a new Macbook Pro could previously
fail with errors like "connect: can't assign requested address".
This can be alleviated by increasing the range of ports to open,
but setting a limit for idle connections in the tests seems like
the better solution.

Signed-off-by: Anders Eknert <anders@eknert.com>
2025-08-26 08:00:05 +02:00
Ville Vesilehto f77322b3fb build: bump Go version requirement to 1.24 (#7839)
Go 1.23 is no longer supported as per Go release policy.

Changes:

- Use Go v1.24.6 as the project SDK requirement
- Apply lint fixes for Go 1.24
- Fix "non-constant format string in call" issues as seen in CI.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-08-24 09:02:09 +02:00
Johan Fylling 5faa4e2e67 Adding EdDSA support for io.jwt built-ins (#7824)
Introducing the `io.jwt.verify_eddsa` built-in, and adding support to the following built-ins:

* `io.jwt.decode_verify`
* `io.jwt.encode_sign`
* `io.jwt.encode_sign_raw`

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-08-12 18:52:47 +02:00
Charlie Egan f746d8caa9 plugin/bundle: Correct bundle delay behavior (#7812)
* plugin/bundle: Correct bundle delay behavior

I ran into an issue when testing an earlier change:

https://github.com/open-policy-agent/opa/actions/runs/16646981900/job/47110035165

I found that this test generated around 100,000 lines of errors showing
the bundle downloader running.

This can be be tested using:

```
go test -v ./v1/plugins/bundle -count=1 2>&1 | grep -c "request failed"
```

This commit closes managers and plugins correctly.

Signed-off-by: Charlie Egan <charlie@styra.com>

* download: Update stop to be idempotent

I had some race detector issues with TestStartStopWithLongPollNotSupported
https://github.com/open-policy-agent/opa/actions/runs/16722869930/job/47334690407?pr=7812

I think this is a deadlock around multiple calls to Stop dead locking
updating the stopped var.

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-08-07 17:13:37 +00:00
lestrrat b08a1df858 Upgrade interned jwx (0.9.x) with github.com/lestrrat-go/jwx/v3 (#7733)
Fixes: #7638

Signed-off-by: Daisuke Maki <lestrrat+github@gmail.com>
2025-08-04 16:41:09 +02:00
Anders Eknert e61e638fe8 Benchmark fixes (#7765)
A number of benchmarks did not have a `for range b.N` (or equivalent) loop in
them, leading to nothing being measured. This PR fixes that, along with some
cleanups in benchmarks found along the way.

Also remove `b.StopTimer` where not absolutely necessary, as that is
[notoriously buggy](https://github.com/golang/go/issues/27217), and had some
benchmarks hang for a very long time.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-07-11 13:17:30 +02:00
Johan Fylling 817b6635a8 ast,format: Allowing keywords in Rego references (#7709)
Updating the parser and formatter to allow keywords in refs.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-06-25 15:19:21 +02:00
dependabot[bot] 053ae2460b build(deps): bump the go-opentelemetry-io group with 7 updates (#7651)
* build(deps): bump the go-opentelemetry-io group with 7 updates

Bumps the go-opentelemetry-io group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) | `0.60.0` | `0.61.0` |
| [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) | `1.35.0` | `1.36.0` |
| [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) | `1.35.0` | `1.36.0` |
| [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go) | `1.35.0` | `1.36.0` |
| [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp](https://github.com/open-telemetry/opentelemetry-go) | `1.35.0` | `1.36.0` |
| [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) | `1.35.0` | `1.36.0` |
| [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) | `1.35.0` | `1.36.0` |


Updates `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` from 0.60.0 to 0.61.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go-contrib/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go-contrib/compare/zpages/v0.60.0...zpages/v0.61.0)

Updates `go.opentelemetry.io/otel` from 1.35.0 to 1.36.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace` from 1.35.0 to 1.36.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` from 1.35.0 to 1.36.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` from 1.35.0 to 1.36.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

Updates `go.opentelemetry.io/otel/sdk` from 1.35.0 to 1.36.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

Updates `go.opentelemetry.io/otel/trace` from 1.35.0 to 1.36.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
  dependency-version: 0.61.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel
  dependency-version: 1.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-version: 1.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
  dependency-version: 1.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
  dependency-version: 1.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel/sdk
  dependency-version: 1.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel/trace
  dependency-version: 1.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fixing tests

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Johan Fylling <johan.dev@fylling.se>
2025-06-19 10:53:58 +02:00
robmyersrobmyers 70b98df0f2 build(deps): Bump gqlparser from v2.5.27 to v2.5.28 (#7700)
Additional test case for invalid graphql schemas. #7699

Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-06-18 13:38:14 +02:00
Anders Eknert 9d0557b7d3 Fix issue where path in walk would get mutated (#7657)
I'm still not sure where this mutation occurs, as the append operation
done in `walk` returns a copy and shouldn't mutate. But at least creating
a shallow copy rather than a slice fixes the issue, and is still quite
performant compared to the previous implementation that did a deep-copy
of the path in each iteration.

Fixes #7656

Signed-off-by: Anders Eknert <anders@styra.com>
2025-06-04 08:47:58 +02:00
robmyersrobmyers 912577c802 fix: Improve GraphQL error handling (#7622) (#7623)
prevent gqlparser errors without location information from crashing OPA

Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-05-27 11:14:53 -05:00
Anders Eknert def328edba perf: greatly improved walk performance (#7612)
While most uses of `walk` in Regal are able to leverage the optimized
"no path" version of the built-in, there are still many places where
we need both the path and the value. Optimizing this has been really
tricky (see comments in code), but last night I had an idea which proved
to have an incredible impact for the path-value form of `walk` (which
outside of Regal is the common one).

Instead of making a deep-copy of the path array in each iteration,
we now make a shallow copy. `.Copy`ing every item in the path was a
massive allocation source, and I don't think I've seen a single change
in OPA have this big impact before. **5 million allocations down**, or
almost 10% of all allocations performed in `regal lint bundle`.

**`regal lint bundle`, OPA main vs change**
```
966876500 ns/op	2960650884 B/op	56181759 allocs/op
934882916 ns/op	2807204756 B/op	51339375 allocs/op
```

Signed-off-by: Anders Eknert <anders@styra.com>
2025-05-21 13:36:23 +02:00
Anders Eknert 8ba08ac80c Apply modernize linter fixes (#7599)
Following up on #7566, and now applying the more exciting
modernizations. fmt.Appendf was new to me! But especially
the contains checks are so much better IMHO. I have reviewed
all changes myself and did a few manual changes where it
became obvious that things could be improved a little further.

(the modernize analyzer still has some issues running against
OPA, and I have manually worked around those for the time being)

Signed-off-by: Anders Eknert <anders@styra.com>
2025-05-20 23:12:13 +02:00
Stephan Renatus 0adc621b36 planner: deal with var-for-function replacement in indirect calls
This change still follows the approach thought up in #6996, but now does
it more consistently: the extra args accumulated through (multiple)
with-replacements using variables are now put into the funcstackj, and
consistently affect the planning of functions in "higher" gens.

Fixes #5311.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2025-05-16 19:41:47 +02:00
Anders Eknert e43ef0a979 Use any in place of interface{} (#7566)
Earlier this evening I tried to run the Go
[modernize](https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize)
analyzer on OPA. That didn't go as planned:

- https://github.com/golang/go/issues/73661
- https://github.com/golang/go/issues/73663

While we wait for that to be fixed, I figured an old-fashioned
search-and-replace across the repo may work for at least the
`interface{}` to `any` conversion. That should help make it easier
to see the other fixes as applied by the modernize tool once it has
had those issues resolved.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-05-12 13:57:48 +02:00
robmyersrobmyers 7dd0dceb6d refactor: Remove internal/gqlparser and use upstream instead. (#7538)
This updates gqlparser from version ~v2.5.1 and the June 2018 GraphQL spec to
v2.5.26 and the October 2021 GraphQL spec.

Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-05-05 11:11:27 -05:00
Johan Fylling ad2063247a Merge commit from fork
to disable code injection attacks, where Rego code can be injected into the constructed evaluation query.

See Security Advisory: https://github.com/open-policy-agent/opa/security/advisories/GHSA-6m8w-jc87-6cr7

Fixes: #GHSA-6m8w-jc87-6cr7
2025-05-01 16:26:52 +02:00
Anders Eknert bd5ceb5142 Enable unused-receiver linter (revive) (#7448)
Signed-off-by: Anders Eknert <anders@styra.com>
2025-03-14 11:41:25 +01:00
Stephan Renatus 7049966700 planner: address ref head issue, don't optimize if impossible (#7439)
When planning rules like these:

```
package authz

p.allow[action][resource] if { action := "list"; resource := "fruit" }

p.unrelated.eat.veggies if true

resp := p[input.rule][input.action][input.resource]
```

we ended up with a broken CallDynamic statement. Since the first ref
rule is planned as `g0.data.authz.p.allow` and builds an object return
value, and the second rule is planned as
`g0.data.authz.p.unrelated.eat.veggies` with a boolean return value, we cannot
dynamically dispatch their calls.

With this change, the previously existing "unbalanced ruletrie" check now
also hits before reaching the end of the ref. It'll catch this situation
and avoid optimizing the dispatch. We'll end up with a longer, less
efficient, but correct plan.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2025-03-12 19:18:21 +00:00
Stephan Renatus 63e7d35c4e planner: adjust check in ruletree scanning
The previous check there was running into false positives, as the added
test case showed. We should only count relevant ruletrie child nodes.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2025-03-10 16:09:06 +01:00
Johan Fylling a389d9a800 test: Fixing broken tests (#7387)
`TestControlPlaneSpans` could case a race condition, where the discovery plugin is manually triggered before/during server initialization, resulting in the manager config being changed while actively consumed.

Replacing `Runtime.serverInitialized` boolean field with more granular enum type state, to allow test-runtime to hold off on triggering plugins until runtime is actively waiting for plugin ready state.

Currently, manager config writes are guarded by an internal mutex, while config reads are largely unguarded. A broader fix here might be to deprecate the public `plugins.Manager.Context` field, replacing it with a getter that guards the config with an r/w-lock.

Also fixing:

* Possible race condition in telemetry reporter by using r/w-mutex guarded compiler getter instead of direct field access
* AWS signing tests where signing randomly failed because of too small mock random value used in test

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-02-25 22:15:54 +01:00