Commit Graph

5599 Commits

Author SHA1 Message Date
Johan Fylling 8b0720247e Prepare v1.4.0 release (#7541)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
v1.4.0
2025-05-01 17:01:50 +02: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
Sebastian Spaink 24ff9cfb3a fix: return the raw strings when formatting (#7525)
prevent `\u0000` from being changed to `\x00` 

Signed-off-by: sspaink <sspaink@styra.com>
2025-04-25 12:04:16 -05:00
Sebastian Spaink 254f3bf0b9 fix(status plugin): make sure the latest status is read before manually triggering or returning a snapshot (#7533)
* when manually triggering, make sure the latest status event is registered. Only one status event should exist.
* read bundle status for snapshot as well
* revert back to buffering 1 status event

Signed-off-by: sspaink <sspaink@styra.com>
2025-04-25 18:04:18 +02:00
Sebastian Spaink 9b5f6010c0 docs: fix post merge badge (#7532)
Signed-off-by: sspaink <sspaink@styra.com>
2025-04-24 09:06:53 +01:00
Charlie Egan e490277477 docs: Point path versioned requests to new sites (#7531)
Following #7528, we also need to route any requests using the old
versioned paths to the correct location.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-23 14:54:07 +01:00
Sebastian Spaink d65888c14f plugins/status: FIFO buffer channel for status events to prevent slow status API blocking (#7522)
If a status API is slow to respond it can cause OPA to be blocked writing to an unbuffered channel. This fixes it by using a buffered channel that never blocks but drops the oldest status update if full.

Signed-off-by: Sebastian Spaink <3441183+sspaink@users.noreply.github.com>
2025-04-23 11:53:09 +02:00
Charlie Egan eb77d10971 docs: update edge links to use /docs/edge/ path (#7529)
No versioned archive deploy is available/maintained for this tag.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-22 15:40:43 +01:00
Charlie Egan f07d604b4f docs: Set versioned docs links to point to archive (#7528)
In the version dropdown, v1.2.0 used to point to:

https://www.openpolicyagent.org/docs/v1.2.0/

Now it'll point to the archived version for that release.

https://v1-2-0--opa-docs.netlify.app/

This is being done as part of https://github.com/open-policy-agent/opa/issues/7037

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-22 15:13:58 +01:00
Ali Jalal 828b8cb156 docs: improve request headers documentation in REST APIs (#7524)
Signed-off-by: ali-jalaal <4487124+ali-jalaal@users.noreply.github.com>
2025-04-21 10:26:56 -05:00
robmyersrobmyers 31c7d8b966 graphql: Cache GraphQL schema parse results (#7457)
This commit stores parsed GraphQL schemas to the cache, which improves
the performance of GraphQL operations that parse the schema more than once.

Queries are not cached.

Resolves: #5377

Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-04-17 17:59:08 +02:00
robmyersrobmyers 56c9aa5bbe gqlparser: Add JSON annotation in internal/gqlparser/ast to Position fields (#7509)
Annotate internal/gqlparser structs not to include Position when marshaled
to JSON.  This makes the JSON roundtrip succeed without allocating a ton of
memory for JSON fields that will be subsequently pruned.

Upstream PR: https://github.com/vektah/gqlparser/pull/364

$ time ./reproducer-pre-fix
Now passing 1262568 bytes to builtinGraphQLParseSchema() to reproduce the issue in ast.InterfaceToValue()
Alloc = 4159 MiB	TotalAlloc = 5625 MiB	Sys = 5584 MiB	NumGC = 18
Alloc = 8312 MiB	TotalAlloc = 11169 MiB	Sys = 11125 MiB	NumGC = 19
Alloc = 8312 MiB	TotalAlloc = 11169 MiB	Sys = 11125 MiB	NumGC = 19
Alloc = 16615 MiB	TotalAlloc = 22247 MiB	Sys = 22209 MiB	NumGC = 20
Alloc = 16615 MiB	TotalAlloc = 22247 MiB	Sys = 22209 MiB	NumGC = 20
Alloc = 16615 MiB	TotalAlloc = 22247 MiB	Sys = 22209 MiB	NumGC = 20
Alloc = 38765 MiB	TotalAlloc = 44397 MiB	Sys = 44377 MiB	NumGC = 20
Alloc = 33223 MiB	TotalAlloc = 44397 MiB	Sys = 44377 MiB	NumGC = 21

$ time ./reproducer-post-fix
Now passing 1262568 bytes to builtinGraphQLParseSchema() to reproduce the issue in ast.InterfaceToValue()

real	0m0.545s
user	0m0.201s
sys	0m0.028s

Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-04-16 17:57:31 +02:00
Lars Haugan 9ac87770fc docs: Update opa-docker-authz example to use ghcr and v0.10 release tag
Signed-off-by: Lars Haugan <lars.haugan@sparebank1.no>
2025-04-16 15:06:01 +02:00
Sebastian Spaink 0fb752607b fix: don't panic on format due to unexpected comments (#7458)
fix: don't panic on format due to unexpected comments

comments next to object elements is valid rego, instead of panicking
catch the error and write the rule as-is.

Signed-off-by: sspaink <sspaink@styra.com>
2025-04-15 08:55:47 -05:00
robmyersrobmyers a3be450eb9 doc: update builtin function examples for v1 (#7514) (#7515)
Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-04-14 09:09:48 -05:00
percyding-tavo cc0e87d23a Add tavo to ecosystem integration (#7511)
Signed-off-by: percyding <dwf838845792@gmail.com>
Co-authored-by: percyding <dwf838845792@gmail.com>
2025-04-14 10:22:31 +01:00
Finsen Varghese 2c123669d0 docs: fixed broken docs link (#7510)
Fixes: #7452

Signed-off-by: Finsen Varghese <3069588+fvarg00@users.noreply.github.com>
2025-04-11 16:46:00 +02:00
Sebastian Spaink f8c87c5af7 build(deps): bump github.com/hypermodeinc/badger from v4.6.0 to v4.7.0 (#7508)
Signed-off-by: sspaink <sspaink@styra.com>
2025-04-11 11:07:41 +02:00
Sebastian Spaink 8424eea2a3 fix: remove resource.syso after building windows binary (#7507)
Signed-off-by: sspaink <sspaink@styra.com>
2025-04-10 10:06:39 -05:00
Sebastian Spaink 804dcc1c98 feat: add version and icon to opa_windows_amd64.exe (#7501)
Signed-off-by: sspaink <sspaink@styra.com>
Co-authored-by: Philip Conrad <philip@chariot-chaser.net>
2025-04-10 07:41:59 -05:00
Charlie Egan f01cc53d9a ecosystem: Update traefik integration docs
Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-10 10:16:21 +00:00
Johan Fylling 6dbb4fab2b topdown: Handling default functions in Partial Eval (#7499)
Making Partial Eval (PE) respect default functions.

Before this fix, Rego functions with declared default values weren't respected by PE, and the default declaration was omitted from generated support modules.

Fixes: #7220

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-04-10 11:40:53 +02:00
Johan Fylling 5a62130b23 build: bump go to 1.23.8 (#7502)
CVE-2025-22871

https://pkg.go.dev/vuln/GO-2025-3563

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-04-09 14:26:54 +02:00
Charlie Egan 7378ec2c5f ecosystem: Add NACP integration
This is a nomad admission controller based on OPA.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-09 13:03:31 +02:00
Kapil Madan f2377ce961 Add Principled Evolution integration (#7495)
Add Principled Evolution integration

Signed-off-by: kapil.madan <kapil.madan@gmail.com>
2025-04-08 08:53:10 -05:00
ndouglas-cloudsmith 820bf4fc5c Cloudsmith adds support for OPA (#7498)
Add Cloudsmith to adopters file.

Signed-off-by: ndouglas-cloudsmith <ndouglas@cloudsmith.io>
2025-04-07 16:16:27 +02:00
Kapil Madan 1bbd38ab3e docs: Add link to inline schema annotations (#7496)
Signed-off-by: kapil.madan <kapil.madan@gmail.com>
2025-04-04 16:33:53 -05:00
Charlie Egan 8fe5571292 docs: Revert slack link change
This redirect has been reconfigured.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-03 16:05:11 +00:00
Johan Fylling 93c177449c ast: Adding rego_v1 feature to --v0-compatible capabilities (#7474)
to allow for using Rego v1 bundles in `opa build`/`check`/`eval`/`test`.

Before this change, a bundle with `1` as `rego_version`/`file_rego_versions` would be rejected when evaluated with the `--v0-compatible` flag with the error:

```
rego_parse_error: illegal capabilities: rego_v1 feature required for parsing v1 Rego
```

This is fixed by adding the `rego_v1` feature to the `v0` default capabilities applied when using the `--v0-compatible` flag. Note: this allows OPA to accept Rego `v1` modules inside bundles, but modules without a specified Rego version, such as freestanding non-bundle modules or modules inside bundles with no specified Rego version, are parsed as `v0`.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-04-03 11:30:53 +02:00
Stephan Renatus 13831ee5b3 topdown: fix wall clock time init for PartialRun()
Fixes #7490.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2025-04-03 11:21:21 +02:00
Charlie Egan 617e0966cd docs: Update community slack inviter link
Signed-off-by: Charlie Egan <charlie@styra.com>
2025-04-02 08:53:17 +00:00
dependabot[bot] 9c68b8f13c build(deps): bump the dependencies group with 4 updates (#7485)
Bumps the dependencies group with 4 updates: [github.com/spf13/viper](https://github.com/spf13/viper), [golang.org/x/net](https://github.com/golang/net), [google.golang.org/grpc](https://github.com/grpc/grpc-go) and [oras.land/oras-go/v2](https://github.com/oras-project/oras-go).


Updates `github.com/spf13/viper` from 1.18.2 to 1.20.1
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](https://github.com/spf13/viper/compare/v1.18.2...v1.20.1)

Updates `golang.org/x/net` from 0.37.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.37.0...v0.38.0)

Updates `google.golang.org/grpc` from 1.71.0 to 1.71.1
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.71.0...v1.71.1)

Updates `oras.land/oras-go/v2` from 2.3.1 to 2.5.0
- [Release notes](https://github.com/oras-project/oras-go/releases)
- [Commits](https://github.com/oras-project/oras-go/compare/v2.3.1...v2.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/viper
  dependency-version: 1.20.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: google.golang.org/grpc
  dependency-version: 1.71.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
- dependency-name: oras.land/oras-go/v2
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 20:19:23 +02:00
dependabot[bot] 23ce6710eb build(deps): bump the gha-dependencies group with 5 updates (#7486)
Bumps the gha-dependencies group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [github/codeql-action](https://github.com/github/codeql-action) | `3.28.10` | `3.28.13` |
| [8398a7/action-slack](https://github.com/8398a7/action-slack) | `3.16.2` | `3.18.0` |
| [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) | `0.29.0` | `0.30.0` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.6.1` | `4.6.2` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `4.1.9` | `4.2.1` |


Updates `github/codeql-action` from 3.28.10 to 3.28.13
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d...1b549b9259bda1cb5ddde3b41741a82a2d15a841)

Updates `8398a7/action-slack` from 3.16.2 to 3.18.0
- [Release notes](https://github.com/8398a7/action-slack/releases)
- [Commits](https://github.com/8398a7/action-slack/compare/28ba43ae48961b90635b50953d216767a6bea486...1750b5085f3ec60384090fb7c52965ef822e869e)

Updates `aquasecurity/trivy-action` from 0.29.0 to 0.30.0
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/18f2510ee396bbf400402947b394f2dd8c87dbb0...6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5)

Updates `actions/upload-artifact` from 4.6.1 to 4.6.2
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1...ea165f8d65b6e75b540449e92b4886f43607fa02)

Updates `actions/download-artifact` from 4.1.9 to 4.2.1
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/cc203385981b70ca67e1cc392babf9cc229d5806...95815c38cf2ff2164869cbab79da8d1f422bc89e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.13
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: gha-dependencies
- dependency-name: 8398a7/action-slack
  dependency-version: 3.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gha-dependencies
- dependency-name: aquasecurity/trivy-action
  dependency-version: 0.30.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gha-dependencies
- dependency-name: actions/upload-artifact
  dependency-version: 4.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: gha-dependencies
- dependency-name: actions/download-artifact
  dependency-version: 4.2.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gha-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 20:05:58 +02:00
Johan Fylling 353c06e13c deps: Grouping deps for dependabot (#7484)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-04-01 19:43:55 +02:00
dependabot[bot] 1f32af131d build(deps): bump actions/setup-go from 5.3.0 to 5.4.0 (#7475)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.3.0 to 5.4.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/f111f3307d8850f501ac008e886eec1fd1932a34...0aaccfd150d50ccaeb58ebd88d36e91967a5f35b)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 17:49:03 +02:00
Anders Eknert f922d78277 perf: zero alloc lower/upper unless changed (#7472)
Similar to how some other built-in functions have been optimized previously,
the `lower` and `upper` functions now return the operand as-is when the string
wasn't modified by the operation. The impact of this check is negligible when
the string is modified, and as the benchmarks demonstrate, quite an improvement
for the cases where it isn't. For those, we no longer need to allocate at all.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-03-31 18:18:59 +02:00
Charlie Egan aa2a16f139 docs: Add manual trigger to integration docs (#7473)
Following: https://github.com/orgs/open-policy-agent/discussions/685

This comes up often enough that it should be documented.

Based on the handy example in: https://github.com/open-policy-agent/opa/issues/3828#issuecomment-1013211919

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-03-31 12:07:32 +01:00
Johan Fylling c34a941204 docs: Update helm-kubernetes-quickstart bundle (#7469)
The previous update of this bundle was a corrupted tarball that OPA was unable to read.

```bash
$ opa eval -b helm-kubernetes-quickstart 'data'
  {
    "errors": [
      {
        "message": "loading error: bundle helm-kubernetes-quickstart: bundle load failed on manifest decode: invalid character '\\x00' looking for beginning of value"
      }
    ]
  }
```

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-03-27 21:38:02 +01:00
Johan Fylling 598d05804b Prepare v1.4.0 development (#7468)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-03-27 17:04:26 +01:00
Johan Fylling 89f4835395 Prepare v1.3.0 release (#7467)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
v1.3.0
2025-03-27 15:19:05 +01:00
Joost Holslag ee38d8345f docs/envoy-tutorial-standalone: simplify 'kind' usage instruction (#7465)
For me installing docker (desktop on Mac) wasn't enough to use kind. I had to install kind. This is compatible with the kind installation instruction which specifies to install kind after installing docker.
Additionally just installing docker isn't enough. It needs to be running. The docker info is a bit confusion in this regard, because if it's installed but not running, it will show output compatible with the example in the tutorial. 
Since this tutorial isn't (much) about docker, and the kind installation instructions I'd suggest to strike the rest of the text and just refer to the kind usage/installation instruction, which was already there.

Signed-off-by: Joost Holslag <joostholslag@users.noreply.github.com>
2025-03-27 12:27:53 +01:00
Joost Holslag 3d3b45f752 Delete reference to license key in envoy-tutorial-standalone-envoy.md (#7466)
Apparently setting a license key is not (longer?) needed. The tutorial doesn't mention it in the rest of the text as the deleted line promises. I couldn't find a hidden statement about a license key in the config files. Not does the page on installing opa using docker mention a license key. https://www.openpolicyagent.org/docs/latest/deployments/

Signed-off-by: Joost Holslag <joostholslag@users.noreply.github.com>
2025-03-27 11:16:46 +00:00
Joost Holslag 004af4c644 docs/envoy-tutorial-standalone: fix typo (#7464)
Signed-off-by: Joost Holslag <joostholslag@users.noreply.github.com>
2025-03-27 09:34:24 +01:00
Sebastian Spaink cd66fa36e2 feat: new event-based decisions log buffer implementation (#7446)
This new event-based buffer provides a performance improvement over
the existing buffer by reducing locks and allowing concurrent writes and uploads.
The buffer size is managed by number of individual events opposed to total bytes.

Signed-off-by: sspaink <sspaink@styra.com>
2025-03-26 16:35:45 -05:00
Shiqi Yang c8febc8625 feat: add more distributed tracing options (#7421)
Resolves: #7412

Signed-off-by: Shiqi Yang <syang482@bloomberg.net>
2025-03-24 19:29:00 +01:00
Anders Eknert b3b87ffd83 fmt: allow one liner rule grouping (#7453)
While the double newline added by the formatter after each rule makes sense
for most rules, short one-liner rules should be groupable. This PR changes
the behavior of the formatter, so that if the user does:

```rego
x := 1
y := 2
```

That is no longer formatted into:

```rego
x := 1

y := 2
```

If the user **wants** double newlines between one-liner rules, the formatter
respects those when present.

Note that the `default` rules are excepted even when a one-liner, as presenting
these separately helps understanding the policy.

Fixes #6760

Do note that the issued mentioned doing this only for incremental rules, i.e.
to group only rules of the same name. I changed my mind on that though, as grouping
"constants" should be possible too.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-03-19 14:35:58 +01:00
dependabot[bot] 92ae9a014f build(deps): bump github.com/containerd/containerd from 1.7.26 to 1.7.27 (#7451)
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.26 to 1.7.27.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.26...v1.7.27)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-18 09:56:14 +01:00
Charlie Egan f3de1006f9 docs: Update slack inviter link (#7450)
slack.openpolicyagent.org redirected to communityinviter. This service
is now migrated to inviter.co and should be used instead. I have not yet
updated the redirect, but when this has been done, we can revert the
change to refer to slack.openpolicyagent.org.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-03-17 18:15:56 +00: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