Commit Graph

10 Commits

Author SHA1 Message Date
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
Johan Fylling 5464b005e8 Bumping golangci-lint to v1.59.1 (#6817)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-06-19 15:13:43 +02:00
Anders Eknert 50d4e31d6b chore: Use t.Setenv in tests (#5321)
And enable the `tenv` linter for the future.

Also, bump version of golangci-lint and fix some new
warnings that came from that.

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-10-27 17:44:56 +02:00
Anders Eknert a49e17eabd JSON schema: skip pattern attribute compilation (#4429)
We don't use the regex "pattern" attribute for type checking,
but this still caused problems parsing schemas where the pattern
specified contained things that the Go regex dialect did not
support, such as negative lookahead. Solved for now by simply
removing the regex compilation of pattern properties.

Fixes #4426

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-03-11 11:31:48 +01:00
Julia Friedman 13832fd96b ast: support for allOf in JSON schema type checker (#3724)
Currently OPA's schema checker does not support allOf. This commit parses allOf by merging all the subschemas into a single schema before converting to a Rego type. I also included a short explanation in schemas.md.

Fixes: open-policy-agent#3592

Signed-off-by: Julia Friedman <juliafriedman@ibm.com>
2021-08-12 11:10:54 +02:00
Jing Chen ab3152f855 ast: support anyOf in JSON schema type checker (#3689)
Currently OPA’s schema checker does not support features like
anyOf and allOf. This commit parses anyOf using types.Any because
anyOf can be implemented by an Or type. I also included a
short explanation in schemas.md.

Related to: #3592

Signed-off-by: Jing Chen <jing.10500@gmail.com>
2021-07-30 09:16:59 +02:00
Torin Sandall 7c9402cd5f ast: Treat array.items as dynamic element type (#3477)
This commit fixes the conversion to treat array.items schema as the
dynamic element type in arrays as opposed to the static element
type. If array.items is defined as an object then it applies to ALL
elements in the array. On the other hand, if array.items is defined as
an array then it applies pairwise to the elements in the array.

In order to fix this, we have to expose a new field from the schema library.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-05-21 13:38:02 +02:00
Will Beason 3be1d08b87 Change check-lint to use golangci-lint (#3465)
golint is deprecated. The author of the code no longer supports the
codebase. golangci-lint is faster than golint, and is in use by other
opa repositories (e.g. Gatekeeper).

This commit changes tools.go to reference golangci (so it ends up in
vendor) and modifies check-lint to use golangci instead.

Breaking API Changes:

- plugins/rest/rest.go: Fix typo "AllowInsureTLS" -> "AllowInsecureTLS"
- storage/errors.go: Removed unused IndexingNotSupportedErr

Signed-off-by: Will Beason <willbeason@google.com>
2021-05-19 07:52:02 +02:00
Will Beason 37bb22c2e0 Remove isKind() and existsMapKey() from gojsonschema (#3470)
These were written before type checking and map handling in Go was
standardized. This PR updates the copied library to use more modern
conventions.

Signed-off-by: Will Beason <willbeason@google.com>
2021-05-18 18:11:10 +02:00
Ansu Varghese cc1cecf567 opa eval: support rego validation using input JSON schema (#3060)
New support to input a JSON schema file via "opa eval --schema" that
helps improve static type checking and returns precise error reports as
you develop Rego code.

Also, uses modified version of https://github.com/xeipuuv/gojsonschema
from internal/ to help set Rego types, using gojsonschema's Compiler
results. See README docs for more details on the feature.

Co-authored-by: Mandana Vaziri <mvaziri@us.ibm.com>
Co-authored-by: Ansu Varghese <avarghese@us.ibm.com>
Signed-off-by: Ansu Varghese <avarghese@us.ibm.com>
2021-01-27 13:32:59 +01:00