Commit Graph

4893 Commits

Author SHA1 Message Date
Johan Fylling 8497550f34 Adding --rego-v1 flag to check cmd (#6430)
When enabled, checked module(s) must be compliant with OPA 1.0 Rego.

Fixes: #6429
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-30 11:36:51 +01:00
cli-docs-updater 26a02e4e20 docs: Update generated CLI docs 2023-11-30 10:01:37 +00:00
Johan Fylling 187d688c58 cmd & format: Adding rego-v1 mode to opa fmt (#6413)
Fixes: #6297
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-30 11:00:01 +01:00
tjons 4f9058b746 update istio envoy tutorial to use AuthorizationPolicy
Signed-off-by: tjons <tyler.schade@solo.io>
2023-11-29 16:28:13 -08:00
Charlie Egan 7a32e8ffb3 topdown/crypto: Add URIStrings field to JSON certs
This is being added to make it easier to write policy on the contents of
certificate URI SANs. This is where information like SPIFFE IDs etc are
contained and it's helpful to Rego authors to have access to these
values without rebuilding the URI from the parsed data under URIs.

Fixes: #6416

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-11-29 12:24:16 -08:00
Cyril Dangerville 8194a22605 Fixed XACML Policy in documentation (Comparing to Other Systems) to be XACML 3.0 compliant (#6438)
* Fixed the XACML Policy to be XACML 3.0 compliant
* Modernized the OPA policy shown as comparison to the XACML policy
2023-11-29 19:16:02 +01:00
Colin J Lacy 0b9bbc5011 plugins/rest: masks X-AMZ-SECURITY-TOKEN header in decision logs (#6423)
Decision logs had previously been configured to hide the value of the
Authorization header, as that is considered sensitive information.
However, there are cases when additional headers are provided that
contain sensitive information, such as the X-AMZ-SECURITY-TOKEN header.
This PR creates an internal map of headers that should be masked, which
can be expanded if additional headers are required. It then loops over
the headers in a request, and performs a lookup on the internal map
to see if any of them match those that should be masked. If so, it
replaces their values with "REDACTED". An existing test was added to
check both the header keys that should be masked, as well as a key
that should not.

Additional work, out of scope for this PR, would be to open a config
setting that would allow users to pass in a list of headers that should
be masked.

Fixes: #5848

Signed-off-by: Colin Lacy <colinjlacy@gmail.com>
2023-11-29 17:26:25 +01:00
dependabot[bot] f66f7e0488 build(deps): bump golang.org/x/net from 0.18.0 to 0.19.0 (#6441)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.18.0 to 0.19.0.
- [Commits](https://github.com/golang/net/compare/v0.18.0...v0.19.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>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 09:36:36 +01:00
dependabot[bot] 2da6376048 build(deps): bump golang.org/x/time from 0.4.0 to 0.5.0
Bumps [golang.org/x/time](https://github.com/golang/time) from 0.4.0 to 0.5.0.
- [Commits](https://github.com/golang/time/compare/v0.4.0...v0.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-28 12:57:05 -08:00
Tyler Schade e40bfe0cf8 add options to the filter to only load rego files (#6437)
Signed-off-by: tjons <tyler.schade@solo.io>
2023-11-27 14:42:16 +01:00
Jamie Tanna 05d52d6647 Add dependency-management-data to the Ecosystem (#6436)
Signed-off-by: Jamie Tanna <jamie@jamietanna.co.uk>
2023-11-27 09:28:34 +00:00
Torin Sandall 3c6e079afd ast: change ident token string (#6435)
This commit changes the string representation of the ident token from
'ident' to 'identifier' as this shows up in error messages and should be
a bit friendlier for users.

Signed-off-by: Torin Sandall <torin@styra.com>
2023-11-25 10:49:31 +01:00
Torin Sandall 85886a5ce4 chore: Disable verbose output in wasm-sdk-e2e-test (#6434)
The output is extremely noisy and there does not seem to be a good
reason for it to be enabled all of the time.

Signed-off-by: Torin Sandall <torin@styra.com>
2023-11-25 08:11:37 +01:00
francoisauclair911 a8b57b0664 fix: Disk storage broken link
Signed-off-by: francoisauclair911 <francois.auclair.911@gmail.com>
2023-11-21 08:28:25 -08:00
Rohan Vasavada d46bc9d2be feat(builtins): add a new builtin function strings.render_template to render templated strings
This adds support for rendering of templated strings utilizing Golang's text/template library.
For a given templated string and key/value mapping of template var inputs, this builtin will
inject the values into the template where they are referenced by key.

Fixes #6371
Signed-off-by: Rohan Vasavada <rohanvasavada@gmail.com>
2023-11-17 08:53:28 -08:00
dependabot[bot] 31b1633efe build(deps): bump the go-opentelemetry-io group with 3 updates
Bumps the go-opentelemetry-io group with 3 updates: [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib), [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) and [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go).


Updates `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` from 0.46.0 to 0.46.1
- [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.46.0...zpages/v0.46.1)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace` from 1.20.0 to 1.21.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.20.0...v1.21.0)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` from 1.20.0 to 1.21.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.20.0...v1.21.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-opentelemetry-io
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  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-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-17 08:31:13 -08:00
robhafner 2ba393076d sdk_test: add environment variable tests (#6420)
Add two environment variable tests which illustrate how an environment variable can be used in OPA to verify a JWT.

Signed-off-by: Robert Hafner <robert.hafner@sas.com>
2023-11-17 15:46:39 +01:00
Johan Fylling ba021abad7 ast: Disallow root document shadowing in leading term of rule refs
when:
* strict-mode is enabled
* `rego.v1` is imported

Fixes: #6291
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-16 09:15:01 -08:00
dependabot[bot] 946d12b347 build(deps): bump github.com/containerd/containerd from 1.7.8 to 1.7.9
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.8 to 1.7.9.
- [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.8...v1.7.9)

---
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-11-16 09:05:50 -08:00
Stephan Renatus e71e5191b2 internal/planner: Insert general ref head objects starting from the leaves, not root. (#6401)
This way the object insert operations can return a new object instance.

Before, the object construction for a rule like

    p[a][b] := ...

would look like this:

    *ir.BlockStmt BlockStmt (1 blocks)
      *ir.Block Block (3 statements)
        *ir.BlockStmt BlockStmt (1 blocks)
          *ir.Block Block (2 statements)
            *ir.DotStmt &{Source:{Value:Local<2>} Key:{Value:Local<10>} Target:Local<14>}
            *ir.BreakStmt &{Index:1}
        *ir.MakeObjectStmt &{Target:Local<14>}
        *ir.ObjectInsertOnceStmt &{Key:{Value:Local<10>} Value:{Value:Local<14>} Object:Local<2>}
    *ir.ObjectInsertOnceStmt &{Key:{Value:Local<11>} Value:{Value:Local<13>} Object:Local<14>}

Now, it'll look like

    *ir.BlockStmt BlockStmt (1 blocks)
      *ir.Block Block (2 statements)
        *ir.BlockStmt BlockStmt (1 blocks)
          *ir.Block Block (2 statements)
            *ir.DotStmt &{Source:{Value:Local<2>} Key:{Value:Local<10>} Target:Local<14>}
            *ir.BreakStmt &{Index:1}
        *ir.MakeObjectStmt &{Target:Local<14>}
    *ir.ObjectInsertOnceStmt &{Key:{Value:Local<11>} Value:{Value:Local<13>} Object:Local<14>}
    *ir.ObjectInsertStmt &{Key:{Value:Local<10>} Value:{Value:Local<14>} Object:Local<2>}

so the object in Local<14> is built first, and the added to object Local<2>.

Signed-off-by: Stephan Renatus <stephan@styra.com>
Co-authored-by: Teemu Koponen <koponen@styra.com>
2023-11-15 15:23:48 +01:00
Charlie Egan 1fdd509ae2 Update spinnaker integration (#6414)
Signed-off-by: Charlie Egan <charlie@styra.com>
2023-11-15 12:53:51 +00:00
Johan Fylling bcf82eb405 ast: Adding capability feature for the rego.v1 import (#6375)
Resolves: #6366
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-15 12:16:19 +01:00
Johan Fylling 56f2350d0f ast: Adding rule_head_refs capabilities feature flag (#6346)
To signal/toggle support for general refs in rule heads.

Fixes: #6334
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-15 11:24:16 +01:00
Ashutosh Narkar 7933a40006 golang: Update golang to 1.21.4
This version includes security fixes which addresses
vulnerability GO-2023-2186 and GO-2023-2185.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-11-14 10:36:54 -08:00
dependabot[bot] da4cf3d9b7 build(deps): bump the go-opentelemetry-io group with 3 updates
Bumps the go-opentelemetry-io group with 3 updates: [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib), [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) and [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go).


Updates `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` from 0.45.0 to 0.46.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.45.0...zpages/v0.46.0)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace` from 1.19.0 to 1.20.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.19.0...v1.20.0)

Updates `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` from 1.19.0 to 1.20.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.19.0...v1.20.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
  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-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-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-opentelemetry-io
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-13 19:32:11 -08:00
Will Beason 8119dc097b Fix IDE warnings and remove usage of several deprecated fields. (#6397)
Signed-off-by: Will Beason <willbeason@gmail.com>
Co-authored-by: Johan Fylling <johan.dev@fylling.se>
2023-11-13 10:22:33 -06:00
Stephan Renatus 619957c030 deps: group otel deps (#6407)
Signed-off-by: Stephan Renatus <stephan@styra.com>
2023-11-13 16:25:58 +01:00
Anders Eknert 69a4f3d769 Add ExcludeLocationFile JSON marshalling option (#6398)
Repeating the name of the file in each location is often redundant,
and large AST trees carry thousands of these attributes. Providing
an option to have them removed at least for serialization (as anything
more would be a breaking change) seems like a good compromise.

For reference, see https://github.com/StyraInc/regal/issues/408

Signed-off-by: Anders Eknert <anders@styra.com>
2023-11-10 15:37:38 +01:00
Johan Fylling d38a4f1b07 Moving wasm test (#6399)
to not fail when running `make test`.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-10 14:11:28 +01:00
wasm-updater f6b54ccad9 wasm: Update generated binaries 2023-11-09 19:05:55 +00:00
Stephan Renatus fb00caa989 wasm: fix re2 bug
When feeding a `char *` into `re->Match()`, it was converted to a StringPiece,
taking its size as `strlen()`. For our (long) input, that wasn't resulting in
the correct size, and did then freak out the re2 match input validation if the
regular expression has an end anchor, but the endpos wasn't the same as its
length. Since the endpos was taken from `s->len`, and the "length" taken via
the mentioned StringPiece's strlen() call, they did indeed not match.

Worked around by feeding it a properly-constructed std::string instead. I'm a
C++ novice at best, but it does the trick, and I'm reasonable certain it's less
wrong than before.

Fixes #6376.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2023-11-09 11:04:20 -08:00
dependabot[bot] 14bf6fe638 build(deps): bump golang.org/x/net from 0.17.0 to 0.18.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.17.0 to 0.18.0.
- [Commits](https://github.com/golang/net/compare/v0.17.0...v0.18.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-11-09 10:33:43 -08:00
dependabot[bot] 30a244e580 build(deps): bump aquasecurity/trivy-action from 0.13.1 to 0.14.0
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.13.1 to 0.14.0.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/0.13.1...0.14.0)

---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-07 09:29:21 -08:00
Johan Fylling 7f17c36ece ast: Allowing packages to be declared within the dynamic extent of a rule (#6388)
Fixes: #6387

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-07 13:26:09 +01:00
Tyler Schade c12463c4c4 Add docs for dynamic_metadata feature in opa-envoy-plugin
Signed-off-by: tjons <tyler.schade@solo.io>
2023-11-06 15:40:45 -08:00
Charlie Egan f102042ea8 discovery: Make status updates non blocking (#6345)
Fixes #6343

A status endpoint that times out, will no longer delay boots.

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-11-06 16:19:09 -06:00
Stephan Renatus 2acef3bb79 planner: don't plan superfluous Equal/NotEqualStmts (#6386)
Basically lifting this compiler optiimization for the Wasm compiler into the planning stage: If we already know at plan time that a certain (in)equality check fails/succeeds, we don't need to do it. The less work, the better.

* planner: don't emit `NotEqualStmt{A: ..., B: false}` where superfluous
* planner: don't emit `EqualStmt{A: x, B: x}`
   for string and bool constants
* compiler/wasm: remove optimizations

Signed-off-by: Stephan Renatus <stephan@styra.com>
2023-11-06 22:21:32 +01:00
dependabot[bot] 11f2d7f2fb build(deps): bump github.com/gorilla/mux from 1.8.0 to 1.8.1
Bumps [github.com/gorilla/mux](https://github.com/gorilla/mux) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/gorilla/mux/releases)
- [Commits](https://github.com/gorilla/mux/compare/v1.8.0...v1.8.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-06 09:02:30 -08:00
Johan Fylling 17aafaa55b ast: Making rego.v1 import errors more specific
to whether they concern a rule or function.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-06 09:01:01 -08:00
dependabot[bot] f91665993b build(deps): bump github.com/spf13/cobra from 1.7.0 to 1.8.0
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.7.0...v1.8.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-06 08:31:42 -08:00
dependabot[bot] e37dc1ac4f build(deps): bump golang.org/x/time from 0.3.0 to 0.4.0
Bumps [golang.org/x/time](https://github.com/golang/time) from 0.3.0 to 0.4.0.
- [Commits](https://github.com/golang/time/compare/v0.3.0...v0.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-06 08:17:34 -08:00
Johan Fylling 89855df570 rego.v1: Improving support for rules with chained bodies (#6374)
Fixes: #6370
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-03 11:29:35 +01:00
Ashutosh Narkar eade10ae0e build: Remove rootless image variant
All published OPA images now run with a non-root uid/gid.
The uid:gid is set to 1000:1000 for all images. As a result
there is no longer a need for the --rootless image variant
hence it will not be published as part of future releases.
This change is in line with container security best practices.
OPA can still be run with root privileges by explicitly setting the user,
either with the --user argument for docker run, or by specifying
the securityContext in the Kubernetes Pod specification.

Fixes: #4295

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-11-02 08:55:09 -07:00
Johan Fylling 030923998d rego.v1: Fixing erroneous missing value assignment error (#6368)
for rules/functions that only has value assignment for `else` but not "primary" head, when `rego.v1` is imported.

Fixes: #6364

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-11-01 15:04:50 +01:00
Charlie Egan eaa1854e04 docs: add newstack blog to regal (#6372)
Signed-off-by: Charlie Egan <charlie@styra.com>
2023-11-01 09:35:16 +00:00
dependabot[bot] 53e011a820 build(deps): bump aquasecurity/trivy-action from 0.13.0 to 0.13.1
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.13.0 to 0.13.1.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/0.13.0...0.13.1)

---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-31 09:27:51 -07:00
Charlie Egan c0d9abac11 docs: Add legitify to ecosystem (#6369)
Signed-off-by: Charlie Egan <charlie@styra.com>
2023-10-31 14:11:38 +00:00
Anders Eknert 684c8ae2fb Update docs on rego.v1 / OPA 1.0 (#6365)
Unused local assignment and unused imports will remain strict mode
checks even in OPA 1.0.

Signed-off-by: Anders Eknert <anders@styra.com>
2023-10-31 10:38:19 +01:00
Charlie Egan 5ce5ab6f61 docs: add cheat sheet link
Adds a link to the Cheat Sheet project: https://docs.styra.com/opa/rego-cheat-sheet

Signed-off-by: Charlie Egan <charlie@styra.com>
2023-10-30 10:40:39 -07:00
Torin Sandall 8a8dd09f78 cmd: fix inspect to omit unnecessary whitespace
Signed-off-by: Torin Sandall <torin@styra.com>
2023-10-30 09:36:35 -07:00