Behaviour differing from OPA on cyclic references between multiple policies
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
The results from OPA and regorus differ for noncyclic rules across cyclicly referencing packages/files.
I get
opa eval --data test/registry.rego --data test/package_a.rego data
Allowed by stage 1: package_a
Allowed by stage 2: package_a
{
"result": [
{
"expressions": [
{
"value": {
"registry": {
"allow": true,
"allow_stage1": true,
"allow_stage2": true,
"packages": {
"package_a": {
"allow_stage1": true,
"allow_stage2": true
}
}
}
},
"text": "data",
"location": {
"row": 1,
"col": 1
}
}
]
}
]
}
with OPA 1.17.0 while regorus v0.9.1 with python using the Engine class returns:
/home/phi1010/.local/bin/uv run /home/phi1010/PycharmProjects/htmlplayground1/.venv/bin/python /home/phi1010/PycharmProjects/htmlplayground1/documentation/evaluate_policies_with_regorus.py
ic| engine: <builtins.Engine object at 0xb30ca00>
Traceback (most recent call last):
File "/home/phi1010/PycharmProjects/htmlplayground1/documentation/evaluate_policies_with_regorus.py", line 22, in <module>
run()
~~~^^
File "/home/phi1010/PycharmProjects/htmlplayground1/documentation/evaluate_policies_with_regorus.py", line 18, in run
ic(engine.eval_query("data"))
~~~~~~~~~~~~~~~~~^^^^^^^^
RuntimeError:
--> package_a.rego:6:1
|
6 | allow_stage2 if registry.allow_stage1
| ^
error: recursion detected when evaluating rule:
--> package_a.rego:6:1
|
6 | allow_stage2 if registry.allow_stage1
| ^
depends on:
--> registry.rego:5:1
|
5 | allow if allow_stage2
| ^
depends on:
--> registry.rego:12:1
|
12 | allow_stage2 if {
| ^
depends on:
--> package_a.rego:6:1
|
6 | allow_stage2 if registry.allow_stage1
| ^
depends on: cyclic evaluation
Process finished with exit code 1
The files look like this:
package_a.rego
package registry.packages.package_a
import data.registry
import rego.v1
allow_stage2 if registry.allow_stage1
allow_stage1 := true
registry.rego
package registry
import rego.v1
allow if allow_stage2
allow_stage1 if {
data.registry.packages[name].allow_stage1
print("Allowed by stage 1: ", name)
}
allow_stage2 if {
data.registry.packages[name].allow_stage2
print("Allowed by stage 2: ", name)
}
I can't try it out with v0.10.1 right now, as there are no python wheels available on pypi for that version.
- Dominant language
- Rust
- Stars
- 375
- Forks
- 81
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 78
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/regorus
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
RVM: errors and conflicts in rule bodies evaluate to undefined, even with strict builtin errorsMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
microsoft/regorus#932 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 32/100
Maintainers usually reply within 1 day
All issues in microsoft/regorus
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
speakeasy-api/speakeasy#2159 ·
Maintainers usually reply within 1 day
-
documentation target:powerpoint
Difficulty 1/5 Under an hour Newbie friendliness 76/100
tomast1337/PdfLapas#602 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day