opa icon indicating copy to clipboard operation
opa copied to clipboard

Enforce some of the compiler Strict Mode constraints and checks

Open ashutosh-narkar opened this issue 2 years ago • 2 comments

The Rego compiler enforces the following rules when strict mode is enabled:

  1. Duplicate imports
  2. Unused local assignments
  3. Unused imports
  4. input and data reserved keywords
  5. Use of deprecated built-ins

OPA could enforce some of these checks by default such as 1,4 and 5. If deprecated builtins are removed, then 5 will have been taken care of. We can still have opt-in for 2 and 3.

ashutosh-narkar avatar Oct 04 '23 04:10 ashutosh-narkar

I am new to using the OPA rule engine and have a question regarding the use of the "re_match" function, which I believe is a deprecated built-in function. Is their any possibility to utilize this function in strict mode? if yes can you please share some example maybe.

RohitashavSoni avatar Jul 16 '24 05:07 RohitashavSoni

That function has been replaced by regex.match. Just change the name to use that instead. See https://blog.openpolicyagent.org/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368 for more details.

anderseknert avatar Jul 16 '24 06:07 anderseknert

This was implemented as a feature of the rego.v1 import, and later made the default behavior when introducing the v1 API.

johanfylling avatar Feb 03 '25 20:02 johanfylling