Commit Graph

842 Commits

Author SHA1 Message Date
Charlie Egan d10827c8fa docs: Return cli docs gen command (#7597)
This is used in post-merge. I have yet to fix the generation of this md
file and so I am just returning this command for now to fix post merge
until this is done.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-05-19 13:36:41 +00:00
Charlie Egan d6b5659856 docs: Switch to new OPA website (#7592)
Some things added on this branch:
- icons and client logos at known paths
- some spam redirects
- some redirects for docs/latest/foo /docs/foo
- redirects for the two ‘moved’ pages (k8s and envoy intros)

I am going to be monitoring the traffic this week on Netlify to make
sure we have a good coverage with redirects where needed.
We also now prompt users to file issues directly from the 404 pages
which should help flag things we miss too.
2025-05-19 10:42:17 +00:00
Johan Fylling d81dd759eb topdown: Improved default rule value inlining (#7578)
Not generating support rules for cases where the default rule value is `false` and the rule is simply referenced; making the default value inconsequential.

Adding tests for asserting the trivial case, with only default rules, is already supported.

Fixes: #1418
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-05-19 12:00:19 +02:00
cli-docs-updater c50c7eedcc docs: Update generated CLI docs 2025-05-15 13:36:32 +00: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
efi shtain 13f212ba53 add support for aws sso credentials provider (#7527)
Signed-off-by: Efi Shtain <efi@autokitteh.com>
2025-05-09 11:27:17 -05:00
Sebastian Spaink c99bf28eec runtime: don't override user set commit and timestamp (#7549)
Signed-off-by: sspaink <sspaink@styra.com>
2025-05-05 12:03:44 -05: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
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
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
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
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
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
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
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
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
Charlie Egan f6c20b0a46 docs: Add some notes about AI assisted patches (#7436)
Namely, as it relates to the DCO and licensing requirements.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-03-11 17:17:01 +00:00
Charlie Egan b574c3eb01 Reapply "docs: Update terraform examples" (#7428) (#7429)
This reverts commit 93321b220e.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-03-11 16:59:01 +00:00
Mikhail Sedov fcf2182538 docs: add query_parameters_to_set
Signed-off-by: Mikhail Sedov <sedov.mikhail@gmail.com>
2025-03-07 11:45:44 -08:00
Charlie Egan 93321b220e Revert "docs: Update terraform examples" (#7428)
This reverts commit d506db305c.

This was committed to main in error and should be merged via PR instead.

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-03-06 16:57:16 +00:00
Charlie Egan d506db305c docs: Update terraform examples
- removed live output at it appeared to cause confusion here: https://github.com/open-policy-agent/opa/issues/7388
- Updated outputs to be raw examples as you see from exec commands
- Updated rego code examples too

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-03-06 17:29:09 +01:00
Charlie Egan 85eaacd059 docs: Add note about v1.0 addr behaviour (#7398)
Fixes https://github.com/open-policy-agent/opa/issues/7360

Also https://github.com/orgs/open-policy-agent/discussions/662#discussioncomment-12338962t

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-02-27 14:34:28 +00:00
Johan Fylling a6fcabbba6 cmd+tester: Parameterized tests (#7366)
Adding the ability to parameterize Rego `test_*` rules, effectively declaring multiple "test cases" within the rule, which is then individually reported (grouped under their parent rule) when running `opa test`.

Fixes: #2176

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-02-17 22:08:27 +01:00
Anders Eknert bfd09256b2 Add make test-short task (#7364)
By tagging the worst offenders, we can make use of `go test -short` to
avoid them for a quicker dev-test cycle. Compare:

```
make test       200.69s user 209.81s system 170% cpu 4:01.20 total
```
```
make test-short  70.32s user  29.17s system 350% cpu 28.367 total
```

From 4 minutes down to under 30 seconds. The short tests can either
be run with `go test -short ./...` or `make test-short`.

We'll still run the full test suite in CI, naturally.

Also:
- Remove section on benchmarking that linked to a no longer used resource.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-02-14 14:27:47 +01:00
cli-docs-updater eeb5de8916 docs: Update generated CLI docs 2025-02-10 12:15:41 +00:00
cli-docs-updater a44bda98b2 docs: Update generated CLI docs 2025-02-06 09:39:25 +00:00
Brian Cullen 08f98e9527 Add Additional Resource Attributes for OpenTelemetry
Adds the "deployment.environment" resource attribute to those that can
be configured for OpenTelemetry. This was done as some collectors,
including Datadog, require this value to properly classify traces.

Note: the "deployment.environment" attribute is being deprecated in
future versions of the OTel schemas and this may need to be
updated when that library is upgraded.

Fixes #7322

Signed-off-by: Brian Cullen <brianc@kahoot.com>
2025-02-04 11:35:29 -08:00
Johan Fylling 6483e7a6a9 docs: Updating --v1-compatible mentions outside the v1 upgrade guide and v0 compatibility docs (#7337)
to describe `--v0-compatible` behaviour instead.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-02-04 11:36:36 +01:00
Jonathan De La Cruz b7397bb0c6 links fixed
Signed-off-by: Jonathan De La Cruz <jonathan.delacruz@encora.com>
2025-01-28 12:49:57 -08:00
cli-docs-updater 2d47dd885a docs: Update generated CLI docs 2025-01-27 12:12:18 +00:00
Stephan Renatus 4b8a1382d0 topdown+rego+server: allow opt-in for evaluating non-det builtins in PE (#7313)
* topdown+rego: allow opt-in for evaluating non-det builtins in PE

Some use cases of PE, notably generating queries that are to be translated
into filters of some sort (think SQL), require the evaluation of non-deterministic
builtins. This is because the result of the builtin informs what queries are
returned.

Imagine that the user associated with a request is known at PE-time, but we need
extra information from an HTTP API to determine the filters that should be applied.

Previously, that was just impossible to do. Now, we can opt-in to evaluate non-det
builtins during PE from the Rego API.

Note that it would probably make sense to include this in the inlining controls, as
sent to the Compile API. (Considered out of scope for this PR.)

Also note that this will take highest precedence over the `ast.IgnoreDuringPartialEval`
map and the "Nondeterministic" value of the registered builtin. If the new option is
provided, both of these are ignored.

Signed-off-by: Stephan Renatus <stephan@styra.com>

* server+rego: expose nondeterministicBuiltins via inlining controls

With `foo.rego` as

```rego
package ex

include if input.fruits.name == object.get(http.send(input.req).body, input.path, "unknown")
```

the following queries show the difference:

```interactive
$ curl -v http://127.0.0.1:8181/v1/compile \
  -d '{"input": {"req": {"url": "https://httpbin.org/json", "method":"GET"}, "path": ["slideshow", "title"]}, "query": "data.ex.include", "unknowns": ["input.fruits"]}'
{
  "result": {
    "queries": [
      [
        {
          "index": 0,
          "terms": [
            {
              "type": "ref",
              "value": [
                {
                  "type": "var",
                  "value": "http"
                },
                {
                  "type": "string",
                  "value": "send"
                }
              ]
            },
            {
              "type": "object",
              "value": [
                [
                  {
                    "type": "string",
                    "value": "method"
                  },
                  {
                    "type": "string",
                    "value": "GET"
                  }
                ],
                [
                  {
                    "type": "string",
                    "value": "url"
                  },
                  {
                    "type": "string",
                    "value": "https://httpbin.org/json"
                  }
                ]
              ]
            },
            {
              "type": "var",
              "value": "__local0__1"
            }
          ]
        },
        {
          "index": 1,
          "terms": [
            {
              "type": "ref",
              "value": [
                {
                  "type": "var",
                  "value": "eq"
                }
              ]
            },
            {
              "type": "ref",
              "value": [
                {
                  "type": "var",
                  "value": "input"
                },
                {
                  "type": "string",
                  "value": "fruits"
                },
                {
                  "type": "string",
                  "value": "name"
                }
              ]
            },
            {
              "type": "call",
              "value": [
                {
                  "type": "ref",
                  "value": [
                    {
                      "type": "var",
                      "value": "object"
                    },
                    {
                      "type": "string",
                      "value": "get"
                    }
                  ]
                },
                {
                  "type": "ref",
                  "value": [
                    {
                      "type": "var",
                      "value": "__local0__1"
                    },
                    {
                      "type": "string",
                      "value": "body"
                    }
                  ]
                },
                {
                  "type": "array",
                  "value": [
                    {
                      "type": "string",
                      "value": "slideshow"
                    },
                    {
                      "type": "string",
                      "value": "title"
                    }
                  ]
                },
                {
                  "type": "string",
                  "value": "unknown"
                }
              ]
            }
          ]
        }
      ]
    ]
  }
}
```
Here, the builtin call to http.send is preserved.

If we also pass `nondeterminsticBuiltins: true` to the options, we get this:
```interactive
$ curl http://127.0.0.1:8181/v1/compile \
  -d '{"input": {"req": {"url": "https://httpbin.org/json", "method":"GET"}, "path": ["slideshow", "title"]}, "query": "data.ex.include", "unknowns": ["input.fruits"], "options": {"nondeterministicBuiltins": true}}'
{
  "result": {
    "queries": [
      [
        {
          "index": 0,
          "terms": [
            {
              "type": "ref",
              "value": [
                {
                  "type": "var",
                  "value": "eq"
                }
              ]
            },
            {
              "type": "ref",
              "value": [
                {
                  "type": "var",
                  "value": "input"
                },
                {
                  "type": "string",
                  "value": "fruits"
                },
                {
                  "type": "string",
                  "value": "name"
                }
              ]
            },
            {
              "type": "string",
              "value": "Sample Slide Show"
            }
          ]
        }
      ]
    ]
  }
}
```
Here, all args to http.send have been known at PE time and the call was fully
evaluated.

Signed-off-by: Stephan Renatus <stephan@styra.com>

* cmd/eval: expose --nondeterminstic-builtins for new PE control

```interactive
$ echo '{"req": {"url": "https://httpbin.org/json", "method":"GET"}, "path": ["slideshow", "title"]}'| ./opa_darwin_amd64 eval -fpretty -p -I -d foo.rego -u input.fruits data.ex.include
+---------+-------------------------------------------------------------------------------------+
| Query 1 | http.send({"method": "GET", "url": "https://httpbin.org/json"}, __local0__1)        |
|         | input.fruits.name = object.get(__local0__1.body, ["slideshow", "title"], "unknown") |
+---------+-------------------------------------------------------------------------------------+
$ echo '{"req": {"url": "https://httpbin.org/json", "method":"GET"}, "path": ["slideshow", "title"]}'| ./opa_darwin_amd64 eval -fpretty -p -I -d foo.rego -u input.fruits data.ex.include --nondeterminstic-builtins
+---------+-----------------------------------------+
| Query 1 | input.fruits.name = "Sample Slide Show" |
+---------+-----------------------------------------+
```

Signed-off-by: Stephan Renatus <stephan@styra.com>

---------

Signed-off-by: Stephan Renatus <stephan@styra.com>
2025-01-27 13:10:37 +01:00
Johan Fylling 6e83f2ac53 topdown: jwt cache (#7274)
Adding cache to `io.jwt` token verification built-ins

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-01-24 23:03:26 +01:00
cli-docs-updater 8d8907a75f docs: Update generated CLI docs 2025-01-21 10:50:38 +00:00
Zan Liffick 43be454bc5 Docs: Update docker compose file in HTTP API tutorial and use addr for binding (#7267)
Fixes #7264

Signed-off-by: Zan Liffick <aliffick@tenable.com>
2025-01-15 15:35:34 +01:00
Kamil Turek be037b09c8 docs: formatting and wording fixes
Signed-off-by: Kamil Turek <kamil.turek@hotmail.com>
2025-01-14 14:05:17 -08:00
cli-docs-updater 682fbc1d58 docs: Update generated CLI docs 2025-01-14 16:25:07 +00:00
Charlie Egan d1db42d028 plugins/logs: Add support for masking with array keys (#7246)
Fixes https://github.com/open-policy-agent/opa/issues/6883

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-01-07 19:05:37 +01:00
Anthony Regeda 3568eab2f4 docs: update output document of Envoy plugin. (#7241)
A new attribute `query_parameters_to_remove` has been added.

Ref https://github.com/open-policy-agent/opa-envoy-plugin/pull/621

Signed-off-by: Anthony Regeda <regedaster@gmail.com>
2025-01-03 17:06:30 +00:00
Leonardo Vicentini 444dbcf894 docs: fix typo in k8s primer (#7242)
Signed-off-by: vicentinileonardo <vicentini.leonardo99@gmail.com>
2025-01-03 17:51:27 +01:00
Ashutosh Narkar 9a7d920494 Update docs and server binding addr per OPA v1.0 specs (#7140)
This changes updates the docs and all the policy examples in them to
be OPA v1.0-compliant. It also binds the OPA server to `localhost`
interface by default per OPA v1.0 specs.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Co-authored-by: Charlie Egan <charlie@styra.com>
2024-12-19 12:25:47 +01:00
cli-docs-updater 67cfa13648 docs: Update generated CLI docs 2024-12-17 16:14:21 +00:00
cli-docs-updater ba028b59b4 docs: Update generated CLI docs 2024-12-17 10:51:49 +00:00
Johan Fylling a179a24c48 v1 API
All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.

Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.

Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:27:34 +01:00
cli-docs-updater 6367acf616 docs: Update generated CLI docs 2024-11-30 14:55:42 +00:00