You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The safety rules are different for user functions and builtin functions, but there's no clear reason for them to be different. In particular, user functions cannot use iteration variables in arguments, but builtin functions can.
Below we see that z[_] is allowed as the first argument to builtin function concat, but it is not allowed as the first argument to the user function f.
> x = {y | z = ["a", "b", "c"]; concat(z[_], ["123", "456"], y)}
>
> f (x) = x { true }
> x = {y | z = ["a", "b", "c"]; f(z[_], y)}
1 error occurred: 1:1: rego_unsafe_var_error: var _ is unsafe
The text was updated successfully, but these errors were encountered:
If a function input is unsafe, the output vars are added to the safe set regardless. This means the following query f(x, x) would be considered safe (and result in an error during evaluation.)
Previously, functions were implemented with a separate set of types that
had their own code paths in the compiler, eval, etc. These changes
refactor the function implementation so that functions are implemented
as rules with one or more arguments.
By representing functions as rules, we can avoid special casing required
to support functions, e.g., during parse and compile there are a number
of steps that required special casing for functions:
- Parser needed separate grammar definitions for functions (which
prevented them from being chained or using else)
- Compiler needed separate resolver and type checker implementations
which was a source of bugs.
In some cases, special casing is unavoidable for now (e.g., during eval)
however this could be improved in the future.
Fixesopen-policy-agent#471Fixesopen-policy-agent#467Fixesopen-policy-agent#463
The safety rules are different for user functions and builtin functions, but there's no clear reason for them to be different. In particular, user functions cannot use iteration variables in arguments, but builtin functions can.
Below we see that z[_] is allowed as the first argument to builtin function concat, but it is not allowed as the first argument to the user function f.
The text was updated successfully, but these errors were encountered: