Commit Graph

702 Commits

Author SHA1 Message Date
cli-docs-updater 16e2ef4022 docs: Update generated CLI docs 2023-10-18 15:58:59 +00:00
Ashutosh Narkar f48a4563db Bind OPA server to localhost interface by default
Currently OPA binds to the 0.0.0.0 interface by default, which allows
the OPA server to be exposed to services running outside of the same machine.
Though not inherently insecure in a trusted environment, it's good practice
to bind OPA to the localhost interface by default if OPA is not intended
to be exposed to remote services.

This change also adds a new feature flag to `opa run` to allow users to enable
future OPA compatible behavior.

Fixes: #6286

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-18 08:56:03 -07:00
Ashutosh Narkar 57ebae867d Drop EXPERIMENTAL status of reported prom metrics (#6299)
Drop `EXPERIMENTAL` status of metrics reported via
Prometheus in Status API. OPA's maintained these for a while
now and there's no 3rd party dependency required to support these.

Fixes: #6298

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-11 06:39:50 +02:00
aarnautu 38c997eef4 This change adds support to configurable prometheus buckets
http_request_duration has fixed, hardcoded number of buckets with no possibility to tweak them
For cases when the most of the latencies are above 1ms, with only 4 available buckets there's no good insight on OPA's performance.

This implementation:
- adds the possibility for the buckets to be configurable in ```server.metrics.prom.http_request_duration_seconds.buckets``` key
- it's not a breaking change, if the buckets are not present in the configuration, the metric is configured with the existing values as a fallback

Signed-off-by: aarnautu <aarnautu@adobe.com>
2023-10-06 13:27:46 -07:00
Ggg6542 fd66f84bb3 Update policy-language.md (#6275)
more clear description of negation

Signed-off-by: Ggg6542 <465806+gusega@users.noreply.github.com>
2023-10-05 12:34:27 +02:00
Dennis Geurts b9f2e892e8 Update documentation on GCS bundles (#6264)
When an object in GCS contains special characters such as slashes (/) these
need to be url-encoded in the configuration. If not, the bundle will not be found.

e.g. `bundles/bundle.tar.gz` should be entered as `bundles%2fbundle.tar.gz`

This PR adds a small note to help the reader know about this.

Signed-off-by: Dennis Geurts <dennisg@dennisg.nl>
2023-10-01 19:38:10 +02:00
Johan Fylling c36a6051e8 docs: Documenting general refs in rule heads (#6244)
Fixes: #5996

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-09-28 10:14:15 +02:00
Charlie Egan 93d7d07ff1 [docs] Link to expressing or post (#6236)
This is a good learning material and linking here might help users self
service when faced with this.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-09-21 11:52:50 +01:00
cli-docs-updater bb62835460 docs: Update generated CLI docs 2023-09-11 22:36:13 +00:00
Ashutosh Narkar 0e69dbba20 Extend type checking for authz policies
The schema of the input document for the authorization
policy is known to OPA. This feature leverages that
to perform automatic type checking on the authorization policy.
The checks happen on policies provided to OPA on start-up and
also those provided via bundles. This check is enabled by default
and can be disabled using the `--skip-known-schema-check` flag
on `opa run`. This feature will help catch errors such as
typos, mismatch types etc. in these policies and provide precise
feedback to the policy author.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-09-11 15:34:10 -07:00
Johan Fylling 0431567c26 General refs in rule heads (#5913)
* Adding support for multiple variables at arbitrary locations in rule refs
* Updating type-checker to handle general ref heads

Fixes: #5993
Fixes: #5994

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-08-31 12:29:49 +02:00
Charlie Egan 9bf54788f5 [docs] Move OPA ecosystem pages to site top-level (#6198)
* We are having trouble managing the complexity of having ecosystem pages shown in the versioned area of the OPA docs site (see website: link ecosystem from edge #6170)
* We have invested in the OPA ecosystem data recently and it makes sense to make it more prominent.
* The data in the OPA Ecosystem is harder to use when nested in docs as some Hugo functions are unavailable to nested sections.

This PR implements a solution by:

* Pages that were under /docs/version/ecosystem, /docs/version/integrations etc have been moved to /ecosystem and /integrations.
* Redirects have been created for the old pages in the netlify config.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-08-31 09:36:51 +01:00
Anders Eknert 7c36762dd5 docs: make it clear dropped decisions aren't logged (#6180)
And modernize the Rego examples while at it.

Signed-off-by: Anders Eknert <anders@styra.com>
2023-08-25 18:50:33 +02:00
cli-docs-updater 5dc378269f docs: Update generated CLI docs 2023-08-21 09:32:20 +00:00
Ronnie-personal c3854aa6ae feat(cmd): Adding fail-non-empty flag (#6153)
Add fail-non-empty flag to opa exec

Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
2023-08-21 11:30:25 +02:00
Anders Eknert 644c7908d6 Update Regal link from GH -> docs.styra.com (#6169)
Signed-off-by: Anders Eknert <anders@styra.com>
2023-08-17 20:32:22 +02:00
Charlie Egan 1e4f120beb [docs] Update integrations, organisations and softwares to have pages (#6158)
This PR makes it possible to browse integrations, organizations and related softwares. Previously, these details were only available as modals on the ecosystem page.

There are also some changes to the policy enforcement on the docs content, the validation rules are much the same but have been updated to reflect that the content is stored in a new place. I have used some generated JSON in Hugo rather than using GitHub api requests to validate the files since it's A) faster, B) I think more simple, and C) easier to get Hugo to process the markdown frontmatter.

Much of the hackery in this PR (Hugo function partials to look up sets of files and get the data from them) is due to the fact that we can't use Hugo's native sections feature. All of our content is nested under docs, this means that all our pages are in the same section so custom lookups have been implemented as function partials instead to work around this.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-08-17 16:09:33 +01:00
Pushkar Mishra 8fb297c4d1 [docs] Added Missing Hints in policy-reference (#6139)
* [docs] Missing hint "future.keywords.if" for "Ordered (Else)"

Signed-off-by: pushkarm029 <pushkarmishra029@gmail.com>
2023-08-03 08:36:35 +02:00
Pushkar Mishra 01aaf64e0a [docs] Missing hint "future.keywords.if" for "Ordered (Else)"
Signed-off-by: pushkarm029 <pushkarmishra029@gmail.com>
2023-08-02 10:21:23 -07:00
guangwu 6abb668205 Fix typos (#6135)
Fix typos

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-08-02 10:05:57 +02:00
Mohammad Abdolirad 20db615bc0 Specify "path" for livenessProbe
Signed-off-by: Mohammad Abdolirad <m.abdolirad@gmail.com>
2023-07-31 09:31:41 -07:00
Ashutosh Narkar 67533c063e docs: Update def func ex to use wildcard
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-07-27 22:20:57 -07:00
Charlie Egan 49f580518a [docs] Brush up OPA profiling docs
I referenced the docs in
https://github.com/orgs/open-policy-agent/discussions/475 and figured
the formatting could be improved.

I also made some minor edits to the intro.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-07-24 11:08:12 -07:00
Ashutosh Narkar 768dcd9b4c docs: Add a note about default functions
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-07-21 00:50:03 -07:00
Charlie Egan e57b6c748c [docs] Correct envoy tutorial mistake (#6107)
This line appears to have been truncated.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-07-20 17:47:57 +01:00
Charlie Egan a996188936 Update the standalone envoy tutorial (#6105)
The tutorial now uses kind as well as updated versions for envoy.

I have made some adjustments to how the bundle is served and the test
commands run to exercise the policy too.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-07-20 09:53:33 +01:00
cli-docs-updater 57c4daa7fa docs: Update generated CLI docs 2023-07-19 08:10:54 +00:00
cli-docs-updater 1448abfbd7 docs: Update generated CLI docs 2023-07-19 07:41:40 +00:00
Prasanth Ullattil db2f8ae7bb Add AWS KMS support for OAuth2 Client Credentials JWT authentication
This implementaion adds new configuration properties to "oauth2"
aws_kms: AWS KMS key details
aws_signing: Infomation for signing AWS requestion, similar to s3_signing

References:
1) https://github.com/go-jose/go-jose/blob/v3/asymmetric.go#L501
2) https://github.com/codelittinc/gobitauth/blob/master/sign.go#L101

Signed-off-by: Prasanth Ullattil <prasanth.ullattil@dnb.no>
2023-07-03 11:01:15 -07:00
Charlie Egan f74a5f61d8 [docs/website] Link to OPA Ecosystem from docs (#6064)
* [docs/website] Link to OPA Ecosystem from docs

This PR makes the following changes to the website Ecosystem content and
linking:

* Creates and assigns categories to various projects where information
  is available.
* Displays top level categories on Ecosystem page
* Links to categories from various relevant locations within the docs.
* Embeds related Ecosystem projects at the ends of some docs pages where
  there are fewer than 6 and all have related content to the page in
  question.
* Implements Hugo partials and shortcodes to make this extensible in
  future.
* Updates to ecosystem projects to keep them current
* Adds various, previously unlisted, OPA ecosystem projects


Signed-off-by: Charlie Egan <charlie@styra.com>
2023-07-03 17:41:40 +01:00
Benjamin Nørgaard caa24f0c4e plugins/discovery: Fix discovery erasing persistence_directory config
Before this change, if a discovery bundle didn't contain configuration
for `persistence_directory`, this would be deleted from the manager's
configuration. When enabling persistence of the discovery bundle this
doesn't make much sense, as the first discovery bundle would erase the
persistence settings.

This change ensures that discovery never erases `persistence_directory`.

Signed-off-by: Benjamin Nørgaard <mail@blacksails.dev>
2023-06-28 16:35:16 -07:00
cli-docs-updater 191a653893 docs: Update generated CLI docs 2023-06-25 16:44:45 +00:00
Charlie Egan 54d041d6b1 Import time/tzdata (#6038)
Standard OPA images are based on cc-dynamic from Chainguard Images:

https://github.com/chainguard-images/images/blob/main/images/cc-dynamic/README.md

(now deprecated, see: https://github.com/open-policy-agent/opa/issues/6037)

This image doesn't include tzdata.

Our static images however are based on static.

https://github.com/chainguard-images/images/blob/main/images/static/README.md

This build includes tzdata:

https://github.com/chainguard-images/images/blob/main/images/static/configs/latest.apko.yaml#L8

How to see this:

```
$ docker run -it openpolicyagent/opa:0.53.1-static eval 'time.clock([time.now_ns(), "Asia/Shanghai"])'
{
  "result": [
    {
      "expressions": [
        {
          "value": [
            17,
            54,
            3
          ],
          "text": "time.clock([time.now_ns(), \"Asia/Shanghai\"])",
          "location": {
            "row": 1,
            "col": 1
          }
        }
      ]
    }
  ]
}

$ docker run -it openpolicyagent/opa:0.53.1 eval 'time.clock([time.now_ns(), "Asia/Shanghai"])'
{}
```

How to test this change:

```
make ci-build-linux ci-build-linux-static
make image-quick-amd64
docker run -it openpolicyagent/opa:0.54.0-dev eval 'time.clock([time.now_ns(), "Asia/Shanghai"])'
docker run -it openpolicyagent/opa:0.54.0-dev-static eval 'time.clock([time.now_ns(), "Asia/Shanghai"])'
```

You should see that both images provide the expected output. This shows
that `time/tzdata` is being used in the non-static image as expected.
These steps will not work as expected on main.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-06-22 15:23:05 +01:00
Charlie Egan 251c7fbc0d [website/docs] Refactor ecosystem page (#6029)
Signed-off-by: Charlie Egan <charlie@styra.com>
2023-06-20 11:50:27 +01:00
Tyler Schade 4f5882dd98 Allow time formatting constants in rego time.format and time.parse_ns (#6005)
Allow time formatting constants in `time.format` and `time.parse_ns`

Signed-off-by: Tyler Schade <tyler.schade@solo.io>
2023-06-13 14:51:15 +02:00
Johannes Alberti e43ad7f3e6 Update kubernetes-debugging.md (#5998)
annotation was changed in PR163 in kube-mgmt

Signed-off-by: Johannes Alberti <johannes.alberti@gmail.com>
2023-06-12 10:02:18 +01:00
cli-docs-updater e9190cabee docs: Update generated CLI docs 2023-06-07 00:01:40 +00:00
cli-docs-updater 119794ddce docs: Update generated CLI docs 2023-06-02 10:23:46 +00:00
Johan Fylling 77475dc2ab rest: Make Amazon AWS STS domain configurable for AWS rest plugin
Fixes: #5915

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-05-17 11:41:53 -07:00
cli-docs-updater 855c12dc19 docs: Update generated CLI docs 2023-05-16 18:45:43 +00:00
Ashutosh Narkar 4cfc77994d topdown: Add retry option for http.send
When http.send reaches out to the server if an
entry is not found in the cache or a stale entry
needs to revalidated, a network error while
calling the server will result in http.send recording
the error in the cache. It may sometimes be useful to
retry the request in case of intermittent failures etc.

This change adds a new option to the http.send input
object which allows policy authors to specify a retry count
for executing a HTTP request. Retries are performed with
an exponential backoff delay.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-05-05 13:21:16 -07:00
Javad f44aa7eb51 Add OPA environment information Gauge to Prometheus metrics
Closes issue #5852
Provides version of OPA in a Prometheus gauge for observability

Signed-off-by: Javad <j.moghisi@gmail.com>
2023-05-02 23:15:57 -07:00
cli-docs-updater a01a660706 docs: Update generated CLI docs 2023-05-02 16:09:37 +00:00
Chris Telfer d718975b5d Fix memory leaks in WASM when modifying data doc
This commit fixes several memory leaks in the WASM engine that occur
when a caller mixes incremental calls to opa_value_path_add() /
opa_value_path_remove() with actual policy evaluations.  The issue
occurs due to a combination of lack of deep free of internal data
structures and the fact that eval() and opa_eval() calls reset the heap
to free temporary memory that they previous allocated.

More details about the issues and their fix are described in detail at
https://github.com/open-policy-agent/opa/issues/5785.

The changes in this patch fall into 5 categories:

1. Adding support for both internal WASM functions and external WASM
   callers to perform a "deep" free of OPA values by freeing not only
   the immediate object memory but all the opa values it refers to.
   The opa_value_free() function now does this by default and is
   also an exported function.  The opa_value_free_shallow() is added
   for the few cases where shallow frees are required, primarily in
   eval()-invoked functions.
2. Enable stashing of free blocks prior to eval() and opa_eval() calls.
   Eval calls will always leak free blocks due to the way that
   opa_heap_ptr_get() works.  This patch adds three new exports allowing
   the user to save this memory from leaking.
   * opa_heap_blocks_stash() -- saves free heap blocks to shadow
     freelists.
   * opa_heap_blocks_restore() -- restores the allocated heap blocks from
     shadow freelists.
   * opa_heap_stash_clear() -- discard any saved heap blocks on the shadow
     freelists.  (this is used for resetting VM heap to an initial state)
3. Update the WASM calling conventions in the SDK.  This includes using
   the new APIs to avoid leaking memory when adding or removing data
   from the data doc.  It requires bumping the WASM ABI to 1.3
4. Adding unit tests for the WASM ABI 1.3 functions.
5. Adding documenttion for the WASM ABI 1.3 functions.

Fixes: #5785

Signed-off-by: Chris Telfer <chris.telfer@sophos.com>
2023-04-28 13:38:35 -07:00
Anders Eknert f2c84747aa docs: mention ID property of sdk.Options and its benefits (#5876)
Fixes #5875

Signed-off-by: Anders Eknert <anders@styra.com>
2023-04-27 10:14:25 +02:00
DerGut b626a2c93b Use existing auth plugins with OCIDownloader
This change addresses solutions 2) and 3) of the related issue #5553.
It mainly starts using the (now exposed) `Config.AuthPlugin()` function
of the `rest` package in the `download.OCIDownloader`. This allows it
to use any `HTTPAuthPlugin` that is defined in the `Config.Credentials`
section and makes it much more consistent with behavior of the
`download.Downloader` and potential other uses of the rest package.

Fixes #5553

Signed-off-by: DerGut <jannik.steinmann@gmx.de>
2023-04-25 17:15:46 -07:00
Roald Storm 85fbad5e4c docs: Add Nondeterministic field to func decl
Add missing nondeterministic argument to function in docs, see discussion here:
https://github.com/orgs/open-policy-agent/discussions/407

Signed-off-by: Roald Storm <RmStorm@users.noreply.github.com>
2023-04-25 09:44:34 -07:00
Charlie Egan 8e48167568 Clarify use cases for Compile API
This updates the text for the compile API description to include some
more details on how the Compile API can be used as well as a link to

https://blog.openpolicyagent.org/write-policy-in-opa-enforce-policy-in-sql-d9d24db93bf4

This is being done in order to help users understand if this endpoint is suitable for their use cases.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-04-24 11:33:22 -07:00
Ashutosh Narkar 7f2895ddc8 profiler: Add number of generated expr to profile o/p
The number of EVAL/REDO counts in the profile result
are sometimes difficult to understand. This is mainly due to the
fact that the compiler rewrites expressions and assigns the
same location to each generated expression and the profiler
keys the counters by the location. So users have no idea
that multiple expressions may be contributing to the profile
result for a given line in the policy.

This change attempts to provide more clarity to the profile
output by including the number of generated expressions for
each given expression thereby helping to better understand
the result and also how the evaluation works.

Fixes: #2552

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-04-18 23:54:19 -07:00
Magnus Jungsbluth 04351d288b Allow adding labels via discovery
Signed-off-by: Magnus Jungsbluth <magnus@jungsbluth.de>
2023-04-17 14:17:39 -07:00