Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: Planner panic due to with keyword usage #2601

Closed
tsandall opened this issue Aug 3, 2020 · 0 comments · Fixed by #2642
Closed

panic: Planner panic due to with keyword usage #2601

tsandall opened this issue Aug 3, 2020 · 0 comments · Fixed by #2642
Assignees

Comments

@tsandall
Copy link
Member

tsandall commented Aug 3, 2020

The planner is panicking on certain policies containing with keywords. I don't have a minimal test case that reproduces the issue however running opa build -t wasm constraints.rego template.rego -e hooks/target/violation inside of https://github.com/tsandall/template-benchmark does the trick:

$ opa build -t wasm constraints.rego template.rego -e hooks/target/violation
panic: runtime error: slice bounds out of range [:-1]

goroutine 1 [running]:
github.com/open-policy-agent/opa/internal/planner.(*ruletrie).Pop(0xc0003195c0, 0xc00024e830, 0x2, 0x2)
        /home/torin/src/opa/internal/planner/rules.go:100 +0x1a4
github.com/open-policy-agent/opa/internal/planner.(*Planner).planWith.func1.1(0xc07540, 0xc000322f70)
        /home/torin/src/opa/internal/planner/planner.go:545 +0x98
github.com/open-policy-agent/opa/internal/planner.(*Planner).planExprTerm.func1(0xbcd100, 0xc000317300)
        /home/torin/src/opa/internal/planner/planner.go:623 +0x136
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefDataExtent(0xc000321d40, 0x0, 0xc00034a320, 0xc000335140, 0x203000, 0x203000)
        /home/torin/src/opa/internal/planner/planner.go:1625 +0x5cf
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefData(0xc000321d40, 0x0, 0xc00034a320, 0xc00023c4c0, 0x6, 0x8, 0x6, 0xc000335140, 0xc000322f40, 0x40904b)
        /home/torin/src/opa/internal/planner/planner.go:1355 +0xf0b
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefData.func3.1(0x5a, 0xc000317300, 0xc000322f40)
        /home/torin/src/opa/internal/planner/planner.go:1478 +0xd2
github.com/open-policy-agent/opa/internal/planner.(*Planner).planScan.func1(0xbcd100, 0x0)
        /home/torin/src/opa/internal/planner/planner.go:1664 +0x3e
github.com/open-policy-agent/opa/internal/planner.(*Planner).planUnifyLocal(0xc000321d40, 0x5a, 0xc00028ad20, 0xc00034a300, 0xc000322d10, 0x1)
        /home/torin/src/opa/internal/planner/planner.go:845 +0x482
github.com/open-policy-agent/opa/internal/planner.(*Planner).planScan(0xc000321d40, 0xc00028ad20, 0xc000333000, 0x8, 0x80)
        /home/torin/src/opa/internal/planner/planner.go:1662 +0x146
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefData.func3(0x100000000000004, 0x0)
        /home/torin/src/opa/internal/planner/planner.go:1460 +0xf1
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefRec(0xc000321d40, 0xc000171c58, 0x1, 0x1, 0x1, 0xc000332f40, 0x1, 0xc0001772c0)
        /home/torin/src/opa/internal/planner/planner.go:1316 +0x2c5
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefRec.func2(0xc260e0, 0xc0001772c0)
        /home/torin/src/opa/internal/planner/planner.go:1333 +0x5a
github.com/open-policy-agent/opa/internal/planner.(*Planner).planDot.func1(0xbcd100, 0xc00034a220)
        /home/torin/src/opa/internal/planner/planner.go:1644 +0xdb
...
@tsandall tsandall added this to TODO (Things That Should Be Done) in Open Policy Agent via automation Aug 3, 2020
@tsandall tsandall moved this from TODO (Things That Should Be Done) to Planned (Things We Are Going To Do) in Open Policy Agent Aug 3, 2020
@patrick-east patrick-east self-assigned this Aug 3, 2020
@patrick-east patrick-east moved this from Planned (Things We Are Going To Do) to In Progress in Open Policy Agent Aug 4, 2020
patrick-east added a commit to patrick-east/opa that referenced this issue Aug 20, 2020
There was an issue with iterating over virtual docs when planning
an expression that had `with` keywords. The iterator would potentially
be called multiple times, so the "with" values needed to be pushed
and popped accordingly. This essentially copies the pattern used in
the topdown eval flow.

Fixes: open-policy-agent#2601
Signed-off-by: Patrick East <east.patrick@gmail.com>
Open Policy Agent automation moved this from In Progress to Done Aug 24, 2020
tsandall pushed a commit that referenced this issue Aug 24, 2020
There was an issue with iterating over virtual docs when planning
an expression that had `with` keywords. The iterator would potentially
be called multiple times, so the "with" values needed to be pushed
and popped accordingly. This essentially copies the pattern used in
the topdown eval flow.

Fixes: #2601
Signed-off-by: Patrick East <east.patrick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants