Commit Graph

4827 Commits

Author SHA1 Message Date
dependabot[bot] 89e02ef8ad build(deps): bump oras.land/oras-go/v2 from 2.3.0 to 2.3.1 (#6337)
Bumps [oras.land/oras-go/v2](https://github.com/oras-project/oras-go) from 2.3.0 to 2.3.1.
- [Release notes](https://github.com/oras-project/oras-go/releases)
- [Commits](https://github.com/oras-project/oras-go/compare/v2.3.0...v2.3.1)

---
updated-dependencies:
- dependency-name: oras.land/oras-go/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-24 21:00:46 +02:00
dependabot[bot] 1246ad2261 build(deps): bump github.com/fsnotify/fsnotify from 1.6.0 to 1.7.0
Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fsnotify/fsnotify/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsnotify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-24 10:28:39 -07:00
Stephan Renatus 544fd0329d ast+rego: disable compiler stages for IR-based eval paths (#6335)
Only topdown can make sense of rules and comprehension indices, so Wasm and any
eval plugins should instruct the compiler to avoid that work.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2023-10-24 17:52:07 +02:00
Johan Fylling c76d5d6330 ast: future.compat import (#6285)
Adding `future.compat` import for enforcing strict-mode checks and additional `1.0` behavior for the module.

Fixes: #6247
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-10-20 13:32:40 +02:00
Anders Eknert a0ed11bbf2 SDK: Fix typo in test package error message (#6331)
Signed-off-by: Anders Eknert <anders@styra.com>
2023-10-20 08:51:19 +02:00
Ashutosh Narkar da306b68fd build: Migrate to GitHub CLI tool (#6329)
The `hub` tool is deprecated in favor of the GitHub CLI and
is removed from GitHub's action runner images.

Fixes: #6326

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-19 10:23:54 +02:00
dependabot[bot] 8a96296ba1 build(deps): bump google.golang.org/grpc from 1.58.3 to 1.59.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.3 to 1.59.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.3...v1.59.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 10:58:47 -07:00
dependabot[bot] 71f5afc0f7 build(deps-dev): bump @babel/traverse (#6322)
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.14.5 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-18 17:49:30 +01:00
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
Johan Fylling 94a0b946eb Integrate v0.57.1 patch release (#6327)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-10-18 15:51:09 +02:00
Ashutosh Narkar 9a1a42758d deps: Bump OpenTelemetry-Go Contrib 0.45.0
This version includes security fixes which addresses
vulnerability CVE-2023-45142.More details can be
found at
https://github.com/open-telemetry/opentelemetry-go-contrib/security/advisories/GHSA-rcjv-mgp8-qvmr.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-17 12:25:48 -07:00
Anders Eknert 0cad9f9758 fmt: don't add virtual = true value unless provided (#6323)
This is especially nice for functions doing pattern matching on
equality in its arguments.

Previously, we'd rewrite:

```rego
f(1)
```

into

```rego
f(1) = true
```

Now, we'll leave the shorter form alone, while still respecting
explicit assignment, using either `=` or `:=`.

Signed-off-by: Anders Eknert <anders@eknert.com>
2023-10-17 11:17:53 +02:00
Asad Khan 98031ac004 adding comments on test bahaviour
Signed-off-by: Asad Khan <asadullah.khan@deliveryhero.com>
2023-10-16 13:59:09 -07:00
Asad Khan 86721eaef9 fix for plugin state reconciliation
Signed-off-by: Asad Khan <asadullah.khan@deliveryhero.com>
2023-10-16 13:59:09 -07:00
Asad Khan 29d24a495a adding a failing test for plugin.Reconfigure with bundle download Not Modified
Signed-off-by: Asad Khan <asadullah.khan@deliveryhero.com>
2023-10-16 13:59:09 -07:00
Johan Fylling 83c6744872 Adding regression test for edge case where partial rule hides recursion cycle (#6318)
In OPA versions older than 0.56.0, a recursion cycle could be hidden to the compiler if partial-object rules were "properly" organized. Adding regression test to cover this case.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-10-16 13:44:02 +02:00
Ashutosh Narkar 7637f609f7 golang: Update golang to 1.21.3
This version includes security fixes which addresses
vulnerability GO-2023-2102.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-12 10:35:01 -07:00
Anders Eknert 6c3f363de3 Don't use rounding for coverage calculation (#6308)
Perhaps it looks prettier, but this is only reported in
JSON output, so I don't think we should decide on what
precision to use there.

On coverage < threshold error, we still print using 2
decimals, which is Pretty (tm).

Fixes #6307

Signed-off-by: Anders Eknert <anders@eknert.com>
2023-10-12 06:49:09 +02:00
dependabot[bot] 9dac709a6a build(deps): bump google.golang.org/grpc from 1.58.2 to 1.58.3
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.2 to 1.58.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.2...v1.58.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-11 09:27:55 -07:00
Ashutosh Narkar 8115976890 server: Remove partial query parameter (#6300)
The partial query parameter has been marked as deprecated since
v0.23.0. It's also removed from the docs since that time.

Fixes: #2266

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-11 10:09:24 +02:00
Sidharthan Chandrasekaran Kamaraj f66ed81232 deps(build): bump go.opentelemetry.io libs (#6293)
To fix #6292 issue which leads to inconsistent dependencies when used wit otel library.

Fixes #6292.

Signed-off-by: Sidharthan Kamaraj <csidharthank@gmail.com>
Signed-off-by: Sidharthan Chandrasekaran Kamaraj <csidharthank@gmail.com>
2023-10-11 09:50:13 +02: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
dependabot[bot] c51be3e71e build(deps): bump github.com/google/go-cmp from 0.5.9 to 0.6.0
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.9 to 0.6.0.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.9...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-10 11:59:43 -07:00
dependabot[bot] 7fc8ea9a10 build(deps): bump golang.org/x/net from 0.16.0 to 0.17.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-10 11:44:29 -07:00
dependabot[bot] 689021a36e build(deps): bump github.com/containerd/containerd from 1.7.6 to 1.7.7
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.6 to 1.7.7.
- [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.6...v1.7.7)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-10 10:34:03 -07:00
dependabot[bot] 2347a7e81b build(deps-dev): bump postcss in /docs/website/scripts/live-blocks (#6279)
Bumps [postcss](https://github.com/postcss/postcss) from 8.3.2 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.3.2...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-09 17:29:56 +01: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
dependabot[bot] c78178e47c build(deps): bump golang.org/x/net from 0.15.0 to 0.16.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.16.0.
- [Commits](https://github.com/golang/net/compare/v0.15.0...v0.16.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-06 08:43:30 -07:00
Ashutosh Narkar 0d675ca7ed internal/pathwatcher: Fix how paths to watch are determined
Currently if a fsnotify watcher is specified for a particular
directory, we incorrectly also add it's parent directory to
be monitored. This happens because the function that determines
which paths are to be watched calls `filepath.Dir` on each of them
to get their directory. This is the right thing to do for files
as their parent directory gets watched, but when done on a directory
especially for the top-level directory adds an incorrect directory
to be watched. This changes attempts to fix that.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-06 08:26:47 -07:00
Johan Fylling e01c2b23aa Silencing expected error output in tests (#6276)
to reduce risk of chasing down red herrings when troubleshooting a failing build.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-10-05 18:14:36 +02: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
Charlie Egan a7fa31d56e [docs] Fix unversioned built-in docs issue (#6274)
Fixes https://github.com/open-policy-agent/opa/issues/6269

This fixes the issue by using the builtin_metadata.json file from each
version, the assumption that docs content that depends on the data
doesn't exist before this file was introduced.

I have removed the 'available' check since we haven't consistently
updated the file in the past, e.g.

* https://github.com/open-policy-agent/opa/blob/v0.41.0/builtin_metadata.json#L12710
* https://github.com/open-policy-agent/opa/blob/v0.57.0/builtin_metadata.json#L563

These examples show that sometimes the current version is included,
other times the file is updated after the release.

Video showing the correct content being displayed for various versions:

https://github.com/open-policy-agent/opa/assets/1774239/abf1af7d-9c59-4223-a019-c73d7550b322

To locally test this:

```
git clean -dfx
cd docs
make generate hugo-production-build
hugo server --source website --contentDir generated --ignoreCache --minify
```

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-10-05 09:28:40 +01:00
Johan Fylling fb16650d23 Adding lines not covered to test coverage threshold error message (#6272)
Printing lines not covered when test coverage threshold isn't met for `opa test --threshold`, and `--verbose` flag is enabled.

Fixes: #2562
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-10-04 15:08:14 +02:00
Ashutosh Narkar 59bc95c308 topdown: Add upper/lower bound for small ints to avoid overflow
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-03 16:53:07 -07:00
Anders Eknert 7fa6165c27 Walk: skip path creation in wildcard assignment (#6267)
We do a lot of `walk`-ing in [Regal](https://docs.styra.com/regal).
So much that it's by far the single most expensive operation. That means
any optimization of the `walk` built-in function will be a win for us.

Seeing as we rarely make use of the `path` component when `walk`-ing
through AST inputs, I was curious to see if there was any optimization
we could take when the path is a wildcard assignment, and as such clearly
marked as unimportant. Turns out there is. Since the return value is
provided in the operators list, we can check the value provided for the
`path` part of the assigned array, and if it's a wildcard (`_`) skip
path construction entirely. Example:

```rego
walk(input, [_, value])
```

This greatly simplifies the walk, and the performance gains are
substantial. Traversing a ~7MB AST:

**main**
```shell
$ opa bench -d p.rego -i objects.json data.p.w
+-------------------------------------------+---------------+
| samples                                   |             6 |
| ns/op                                     |     168806625 |
| B/op                                      |     197364318 |
| allocs/op                                 |       3855327 |
| histogram_timer_rego_query_eval_ns_75%    |     169968114 |
| histogram_timer_rego_query_eval_ns_90%    |     170513459 |
| histogram_timer_rego_query_eval_ns_95%    |     170513459 |
| histogram_timer_rego_query_eval_ns_99%    |     170513459 |
| histogram_timer_rego_query_eval_ns_99.9%  |     170513459 |
| histogram_timer_rego_query_eval_ns_99.99% |     170513459 |
| histogram_timer_rego_query_eval_ns_count  |          6.00 |
| histogram_timer_rego_query_eval_ns_max    |     170513459 |
| histogram_timer_rego_query_eval_ns_mean   |     168789611 |
| histogram_timer_rego_query_eval_ns_median |     168924020 |
| histogram_timer_rego_query_eval_ns_min    |     166685000 |
| histogram_timer_rego_query_eval_ns_stddev |       1239390 |
+-------------------------------------------+---------------+
```

**no-path-walk**
```shell
$ opa bench -d p.rego -i objects.json data.p.w
+-------------------------------------------+--------------+
| samples                                   |           21 |
| ns/op                                     |     50629984 |
| B/op                                      |     38018790 |
| allocs/op                                 |      1025211 |
| histogram_timer_rego_query_eval_ns_75%    |     51239562 |
| histogram_timer_rego_query_eval_ns_90%    |     51540933 |
| histogram_timer_rego_query_eval_ns_95%    |     51674420 |
| histogram_timer_rego_query_eval_ns_99%    |     51688208 |
| histogram_timer_rego_query_eval_ns_99.9%  |     51688208 |
| histogram_timer_rego_query_eval_ns_99.99% |     51688208 |
| histogram_timer_rego_query_eval_ns_count  |         21.0 |
| histogram_timer_rego_query_eval_ns_max    |     51688208 |
| histogram_timer_rego_query_eval_ns_mean   |     50611103 |
| histogram_timer_rego_query_eval_ns_median |     50871459 |
| histogram_timer_rego_query_eval_ns_min    |     49518833 |
| histogram_timer_rego_query_eval_ns_stddev |       748688 |
+-------------------------------------------+--------------+
```

The real-world impact is not as dramatic, since we aren't *just*
walking, but normally need to actually **do** something with the
values returned, but consistently shaving off about 13% eval time
when linting one of the largest policy libraries isn't bad at all:

**Regal main**
```shell
go run main.go lint ~/tmp/kics/assets  162.16s user 6.04s system 593% cpu 28.362 total
```

**Regal walk-no-path**
```shell
go run main.go lint ~/tmp/kics/assets  145.51s user 5.01s system 597% cpu 25.176 total
```

Signed-off-by: Anders Eknert <anders@eknert.com>
2023-10-03 13:12:29 +02:00
Ashutosh Narkar c867758864 topdown: Improve arith operations by caching small numbers
Currently for arithmetic operations like addition, subtraction etc.
the operands are first converted to the big float type before operating on
them. This conversion can be avoided for small numbers w/o impacting
the accuracy of the result. This change attemtps to avoid the conversion
for small numbers by caching them and thereby helping to speedup some operations.

Fixes: #6021

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-02 11:21:56 -07: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 d9a5cf7b07 Prepare v0.58.0 development
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-09-28 08:43:42 -07:00
Johan Fylling c2f42aa94a Prepare v0.57.0 release (#6256)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
v0.57.0
2023-09-28 14:31:12 +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
Ashutosh Narkar 974586e0a5 server: Add test case for bundle update - query API handler scenario
This test case exercises the scenario when a bundle is being written
to the store (ie. active write transaction) and the OPA server handling
a policy eval request at the same time. The former should not block
the later.

Fixes: #4792

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-09-27 08:25:47 -07:00
Johan Fylling c5314e357d Removing EXPERIMENTAL_GENERAL_RULE_REFS feature flag (#6252)
Fixes: #6245

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-09-27 14:41:39 +02:00
Johan Fylling c9d1a8db1f planner: Adding support for general ref rule heads (#6235)
Fixes: #5995

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-09-27 14:06:19 +02:00
Matthew A Johnson 391cb0c309 Add rego-cpp to OPA Ecosystem
Signed-off-by: Matthew A Johnson <matjoh@microsoft.com>
2023-09-26 16:32:02 -07:00
Charlie Egan 83a295f35e [docs] Use links on support page (#6249)
* [docs] Use links on support page

Previously JS was used to trigger navigation. Since the cursor hadn't
been updated, it wasn't clear that the boxes were clickable.

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

* Remove on-click event

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

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-09-26 16:55:19 +01:00
Ashutosh Narkar 919b290ef7 plugins: Surface AWS authentication error details
OPA supports multiple AWS authentication methods. Currently
on an unsuccessful authentication, OPA logs the error at the debug
level. It would be helpful especially in a prod env to surface these
errors via the Status API to assist with debugging issues. This change
attempts to achieve that.

Fixes: #6232

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-09-25 10:54:55 -07:00
Johan Fylling 276702fbaa Updating all vars in rule ref
Fixing issue where strict-mode would only see the last var in a rule head's ref as used,
if that var is assigned in the rule body but only used in the ref.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-09-25 09:59:19 -07:00
Stephan Renatus b07e60a9f8 nightly: skip Fri/Sat night (#6242)
It's unlikely that anyone is looking at the results when there's a
fresh run's results (of Sunday) awaiting you on Monday.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2023-09-23 21:29:49 +02:00
dependabot[bot] 0c3dae33b9 build(deps): bump google.golang.org/grpc from 1.58.1 to 1.58.2
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.1 to 1.58.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.1...v1.58.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-22 09:16:09 -07:00