Ways to programmatically analyze rego files #694
Replies: 1 comment
-
Hey, some of what you are looking to do is almost the default behavior with Rego's json.match_schema function: https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonmatch_schema However, as you point out with the example this will not work for more complex files with more conditionals etc. I think it'd be best to have a series of rules that perform the check for which you also have an 'index' of their human/user facing description and if they're required. Generally, I'd look to avoid showing generated explanations of policies to users for security reasons anyway, but this is also something we don't really support in Rego/OPA today. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is my use case
Someone will create a rego policy. At runtime I need to read that policy and create a json of what is required to pass that policy.
For example consider this input
Now suppose someone wrote a rego file for this input that says name is mandatory and if age is below 21, SSN or license is mandatory.
I want a way to read that policy file and generate something like this
Is there a way to programmatically read a policy file and create a json like this, that indicates what input is required from the user before his application can be processed?
Beta Was this translation helpful? Give feedback.
All reactions