136 Commits

Author SHA1 Message Date
Anders Eknert 0d9b9afa7d docs: Improve to_number built-in description (#8984)
The "strcov.Atoi" mention was both odd and incorrect. Hopefully a little
better now. Also a few other minor things.

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2026-08-10 16:15:50 +02:00
Johan Fylling 1e32c796e8 Prepare v1.19.0 release (#8955)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
Co-authored-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-07-30 14:38:54 -05:00
WonjuLee 95090fa4eb Add strings.split_n built-in function (#8915)
### Why the changes in this PR are needed?

Policies often need only the first or last few parts of a split string,
but `split()` always returns every part. The common workarounds add
noise:

```rego
[name, email, _, _] := split(user, ";")
[name, email] := array.slice(split(user, ";"), 0, 2)
```
### What are the changes in this PR?

Adds `strings.split_n(x, delimiter, n)`:
- Positive n: returns the first n parts from the left
- Negative n: returns the last abs(n) parts from the right
- n=0: returns an empty array
- If abs(n) exceeds the number of parts, all parts are returned

### Notes to assist PR review:

Semantics follow the design agreed on in the review of #8361.

### Further comments:

Fixes #8344

This change was developed with AI assistance.

Signed-off-by: wonju lee <wonju@kia.com>
Co-authored-by: wonju lee <wonju@kia.com>
2026-07-28 08:39:21 -05:00
Anders Eknert 193172daf1 Use more precise return types for object.* builtins
A bit surprising how not a single test seems to fail from this change 😅
I've added one to at least verify that the type checker does a little
better now than before. External tools like Regal can do even better :)

Fixes #8692

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2026-07-03 14:02:17 +02:00
Stephan Renatus defec76824 Integrate Patch v1.18.2 (#8852)
Signed-off-by: Anders Eknert <anders.eknert@apple.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Co-authored-by: Anders Eknert <anders.eknert@apple.com>
2026-07-03 09:20:49 +02:00
Stephan Renatus acc8bf9f88 Release v1.18.1
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-06-29 14:43:28 +02:00
Sebastian Spaink cc2c5c60a4 Prepare v1.18 release (#8820)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-06-25 12:10:29 -05:00
Sebastian Spaink 93d6984466 Integrate 1.17.1 patch release (#8798)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-06-18 07:37:36 +02:00
Johan Fylling 64a3625d33 Release v1.17.0 (#8710)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-05-28 16:48:35 +02:00
Sebastian Spaink 5e04b0f93b Enable pattern validation in json.verify_schema and json.match_schema (#8686)
resolve: https://github.com/open-policy-agent/opa/issues/6089

As a side effect of #4429 `json.match_schema` and `json.verify_schema`
have been silently ignoring the "pattern" keyword.

Updated the internal/gojsonschema project to have pattern validation be
optional to keep it disabled for type checking but enabled for the
builtins. Patterns that RE2 can't compile will fail.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-05-21 18:36:14 +02:00
Johan Fylling e80a469ecd Integrate 1.16.2 patch release
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-05-13 10:46:11 +02:00
Johan Fylling 9bfc806ec2 Integrate 1.16.1 patch release
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-05-04 11:23:20 +02:00
Johan Fylling f3adf61f72 Release v1.16.0 (#8581)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-04-30 16:29:23 +02:00
Charlie Egan 343ddf583f builtins: Add uri.parse and uri.is_valid built in functions (#8578)
Examples of things this is useful for:
- Implementing policy around AI coding tool calls (permitted domains
etc)
- Validating SPIFFE IDs

Fixes https://github.com/open-policy-agent/opa/issues/8263

---------

Signed-off-by: Charlie Egan <charlie_egan@apple.com>
2026-04-29 13:08:15 +00:00
Sebastian Spaink 1de861f2d6 Add support for days, weeks and years in parse_duration_ns (#8463)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-04-13 20:20:51 +00:00
Sebastian Spaink fa913dd5d3 Integrate 1.15.1 patch release (#8462)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-03-31 10:05:45 -05:00
Sebastian Spaink f9e7302d69 Prepare v1.15.0 release (#8446)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-03-26 16:11:06 -05:00
Stephan Renatus 777af8b069 Integrate patch release 1.14.1
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-03-09 10:40:10 +01:00
Johan Fylling acf81e85d6 Release v1.14.0 (#8379) 2026-02-26 16:21:02 +01:00
Stephan Renatus 5e989f85aa Integrate release 1.13.2
For GO-2026-4337, see https://github.com/open-policy-agent/opa/releases/tag/v1.13.2

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-02-18 10:36:30 +01:00
Sebastian Spaink 1c78f93507 Integrate patch and notes for v1.13.1 (#8275)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2026-01-30 09:14:54 -06:00
Anders Eknert 881d1f279a docs: fix json.patch target description (#8271)
This built-in can patch any composite type, which the documentation
for the first argument didn't mention.

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2026-01-29 21:18:58 +01:00
Johan Fylling a232916c93 Prepare v1.13.0 release (#8268)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2026-01-29 18:00:38 +01:00
Anders Eknert d0350b326e Add array.flatten built-in function (#8232)
Originally meant to be `array.concat_n`, but this name is better
as the behavior of this function differs from `array.concat` —
namely that `array.flatten` accepts any type of valued in the
input array. Only arrays are however flattened, and the rest
are appended directly to the flattened output.

Note that this function only flattens at the topmost level of
the input array — not recursively! A cursory look
at a few other languages suggest a single level is the common case.
But if others feel we should flstten more, I'm happy to make an update.

The C code for a Wasm implementstion here is cowboy coded, and
I did not manage to run the tests on my machine due to some
`docker` <-> `container` differences. I mostly just imitated
the existing code in the array category. I doubt it'll work
on the first try, but only CI can judge me.

Also:
- Remove `opa fmt` step from the Rego CI step, as this is done by
  Regal anyway a little later in the list of tasks.
- Replace some hard-coded `docker` names in the `Makefile` with `$(DOCKER)`
- Added name of built-in function missing to the unsupportedBuiltinErr
  error, as it has happened a few times now that I've used `:=` in a
  query, and had no clue what built-in it referred to.

Fixes #8226

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2026-01-27 21:46:11 +00:00
Sebastian Spaink 4afcfb992b Integrate patch and notes v1.12.3 (#8218)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
Co-authored-by: Johan Fylling <johan.dev@fylling.se>
2026-01-15 11:33:47 +01:00
Stephan Renatus b6af19fcf1 Integrate patch and notes v1.12.1
Extra integration tests will follow.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-12-19 08:21:37 +01:00
Johan Fylling d61ac383f8 Prepare v1.12.0 release (#8144)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-12-18 13:44:46 +01:00
Stephan Renatus c9656457b3 CHANGELOG+metadata: Integrate v1.11.1
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2025-12-16 22:24:53 +01:00
Johan Fylling 8e410b830a String interpolation (#8109)
Adding string interpolation support to the Rego language.

An interpolated string is composed of a template-string that can contain zero or more template-expressions that interpolates values into the string generated at eval-time.

Requires the `template_strings` capability feature and `internal.template_string` built-in function.

Implements: #4733
2025-12-16 11:47:04 +01:00
Johan Fylling 45cbfa1d83 Prepare v1.11.0 release (#8076)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-11-26 14:01:54 +01:00
Johan Fylling e6865c4c9f Prepare v1.10.0 release (#8002)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-10-31 14:15:30 +01:00
Johan Fylling c49e670294 Prepare v1.9.0 release (#7940)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-09-26 10:53:51 +02:00
Johan Fylling 78328267fb Prepare v1.8.0 release (#7866)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-08-28 16:49:47 +02:00
Charlie Egan 636b83a3d3 ast/builtins: Remove space from count desc (#7836)
https://github.com/StyraInc/regal/pull/1654#discussion_r2272530343

Signed-off-by: Charlie Egan <charlie@styra.com>
2025-08-13 15:53:26 +00:00
Johan Fylling 5faa4e2e67 Adding EdDSA support for io.jwt built-ins (#7824)
Introducing the `io.jwt.verify_eddsa` built-in, and adding support to the following built-ins:

* `io.jwt.decode_verify`
* `io.jwt.encode_sign`
* `io.jwt.encode_sign_raw`

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-08-12 18:52:47 +02:00
Johan Fylling 45b6eb6639 Prepare v1.7.0 release (#7809)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-07-31 15:09:28 +02:00
Johan Fylling 710b5a6278 Prepare v1.6.0 release (#7732)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-06-30 10:57:36 +02:00
Johan Fylling 046dca2f6e Integrating patch release v1.5.1 (#7659)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-06-04 12:05:50 +02:00
Johan Fylling b7d0a13145 Prepare v1.5.0 release (#7642)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-05-29 16:21:03 +02:00
Sebastian Spaink 03da822be9 Patch release v1.4.2 (#7546)
Signed-off-by: sspaink <sspaink@styra.com>
2025-05-02 13:30:51 -05:00
Johan Fylling 8b0720247e Prepare v1.4.0 release (#7541)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-05-01 17:01:50 +02:00
Johan Fylling 89f4835395 Prepare v1.3.0 release (#7467)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-03-27 15:19:05 +01:00
Johan Fylling d537788722 Release v1.2.0 (#7403)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-02-28 15:17:35 +01: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
Johan Fylling de28510b97 Prepare v1.1.0 release
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-01-27 16:44:49 +01:00
Ashutosh Narkar d5cbd16545 Integrate patch release v1.0.1
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2025-01-22 10:06:15 +01:00
Johan Fylling 563321d26b Rego v1 capabilities and keywords update (#7216)
* Separating v0- and v1 keywords
* Adding `rego_v1` capability feature

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-17 11:50:11 +01:00
Anders Eknert a60ef72799 Even less allocs (#7190)
**main**
```
BenchmarkLintAllEnabled-10    1	2640715625 ns/op	6385110200 B/op	116296633 allocs/op
```

**pr**
```
BenchmarkLintAllEnabled-10    1	2597179708 ns/op	6183614112 B/op	108421141 allocs/op
```

(I renamed the benchmark, but this is the same as "regal linting itself"
used in the past)

Another 8 million allocations cut off from `regal lint bundle`,
and a whopping 10% improvements to wall clock time!

The most significant improvement is the Equal implementation for
refs, since that is called all over the place. But there are many
other fixes here, and they all contribute something substantial
(and fixes that only have had marginal impact have been left out).

Signed-off-by: Anders Eknert <anders@styra.com>
2024-11-24 11:24:29 +01:00
berdanA 26e2db328d topdown: improve scientific notation parsing in extractNumAndUnit
- Updated extractNumAndUnit to recognize and correctly parse scientific notation, including cases with 'e' or 'E' followed by an exponent (e.g., "1e10", "3.2E4").
- Ensures that 'e' or 'E' is treated as part of the number if followed by digits, enhancing compatibility with scientific notation inputs.
- Scientific notation with units now also parses correctly (e.g., "1e10GB" extracts "1e10" as the number and "GB" as the unit).
- Maintains behavior for cases without units, allowing either the number or unit portion to be empty, while improving overall string parsing logic.
- Added tests for scientific notation parsing in `units.parse_bytes`, including both SI and binary units (e.g., KB, MiB, GiB, KiB).
- Included cases for uppercase, lowercase, and mixed case formats with scientific notation.
- Added validation for numbers without units defaulting to bytes.

Fixes #7142

Signed-off-by: bakar <berdan.akar@rise-world.com>
2024-11-08 12:48:02 -08:00
Anders Eknert 60ea2e7429 Add description to all built-in function args and return values (#7153)
Fixes #7151

Signed-off-by: Anders Eknert <anders@styra.com>
2024-11-04 14:00:23 +01:00