Typed input and data #40
-
One of the biggest challanges we face maintaining hundreds of policies and running them with conftest is the unstructured nature of input and data. We end up spending a lot of time correcting typos or recreating the right inputs for each test. Since we run conftest on a fixed set of inputs, with the same data (used as context) every time, it would be much easier if those were structured. That would completly eliminate simple mistakes and also guarantee that policies will actually apply to real data. Structured input and data would enable auto-complete and error-detection as we write policies, dramatically increaing our productivity with Rego. Anybody else facing a similar issue? Are there any alternative solutions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Have you checked out the type checking capabilities via JSON schemas added recently to OPA? It sounds a lot like what you are asking for :) I don't know whether conftest presently supports this though, but if not we should raise the issue there. Also see the blog posts on the topic on the OPA blog: |
Beta Was this translation helpful? Give feedback.
-
Hi @anderseknert and @mbrg , jumping in on the thread. I think @mbrg suggestion is great, and I think that even a "strict mode" would do the trick (like JavaScript has) where accessing undefined properties etc. will cause an error that can be used to differ between "rule didn't find issues and returned False/Undefined" and "rule had syntax error". Such a strict mode will require ways to check if properties exist to keep support for dynamically structure objects so they can be explored safely. |
Beta Was this translation helpful? Give feedback.
Have you checked out the type checking capabilities via JSON schemas added recently to OPA? It sounds a lot like what you are asking for :) I don't know whether conftest presently supports this though, but if not we should raise the issue there.
Also see the blog posts on the topic on the OPA blog:
@jpreese @jalseth, thoughts?