-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Partial Evaluation produce duplicate rules
- OPA version: tried 0.38.1 & 0.37.2
- Example query:
- Example JSON Request (to compile endpoint): https://gist.github.com/t83714/0b6249a33ab9f5ecf45269df38818213
- Example Policy: https://github.com/magda-io/magda/blob/next/magda-opa/policies/entrypoint/allow.rego
- Example output that OPA returned: https://gist.github.com/t83714/e13dfada9e20ca2550707b06ce227408
- For server and CLI, the flags/configuration that you provided to OPA:
"run", "--server", "/policies" - For server, any relevant log messages from OPA: N/A
- For Go and Wasm, the arguments you invoked OPA with: N/A
General Summary
The partial evaluation result might include many duplicate / identical rules sometimes.
The sample response provided above includes 432 rules. Many of those are duplicated / identical rules. e.g. like (I converted AST into a more readable format):
{
input.object.record.dcat-dataset-strings
input.object.record.publishing.state
NOT input.object.record.publishing.state = "draft"
input.object.record.dataset-draft
NOT input.object.record.dcat-dataset-strings
input.object.record.publishing.state
input.object.record.publishing.state = "published"
NOT input.object.record.access-control.orgUnitId
}
or
{
input.object.record.dcat-dataset-strings
input.object.record.publishing.state
NOT (input.object.record.publishing.state = "draft")
input.object.record.dataset-draft
NOT input.object.record.publishing.state = "published"
input.object.record.publishing.state
input.object.record.publishing.state = "published"
"c59aa487-32fc-4d00-b16c-e070f2c88943" = input.object.record.access-control.orgUnitId
}
Those above are example rules that are duplicated more than once.
Steps To Reproduce
- Download the example policy files and Run
opa run -s [folder of policy files] - Send sample JSON request to compile endpoint
Expected behaviour
The partial evaluation result should not contain duplicate rules. But right now you can locate duplicate rules in the partial evaluation result.