-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support Partial Evaluation in WASM #3407
Comments
@Rob4001 thanks for filing this. We can't promise that this will land anytime soon but perhaps we could start looking into it later this year. |
We would also benefit greatly from this! We use OPA partial evaluation to rewrite SQL queries to be secure before sending them to the database. As a single request to the backend is often 10+ SQL queries these network requests tend to add up. |
For my understanding about WASM and Partial Eval, today it is possible to do In Golang:
I assume this issue is about something else? What am I missing in this case? |
@simar7 this issue is about adding support for partial evaluation of wasm-compiled policies; the example you showed would partially evaluate the policy and then compile to wasm and execute it. The goal here would be to run partial evaluation against a wasm-compiled policy. |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
This issue opened 20 months. It is very important for our user case. Do you think we can proper priority this issue? |
It's not clear how wasm and partial eval would even play together. Have you explored other means? You can use the compile API in OPA running as a server from dotnet, or you could do regular partial eval and build a wasm bundle from that using OPA's CLI. |
We'd like to use WASM compiled (partial evaluation) OPA policy, so dotnet-opa-wasm (https://github.com/christophwille/dotnet-opa-wasm) can "compile"/"eval" and output with queries. We are going to base on output.queries to generate query filter condition.
|
This is how Wasm, "ordinary", and partial evaluation in the golang interpreter (topdown) work in OPA: flowchart LR
Rego-- parse -->AST
AST-- compile -->AST'
AST'-- plan --> IR
IR-- compile -->W(Wasm)
W-- wasm-run -->R(Result)
AST'-- eval -->R
AST'-- partial-eval -->PR(Partial Result)
PR-- eval -->R
So when you're working with a Wasm module, the information needed to do partial eval is already lost. It's a bit like wanting to work with the C code an executable was compiled into just using the executable. That said, you could, as mentioned above, go and compile the Partial Result into a Wasm module: flowchart LR
AST'-- partial-eval -->PR(Partial Result)
PR-- plan --> IR
IR-- compile -->W(Wasm)
W-- wasm-run -->R(Result)
|
@srenatus How I can compile the Partial Result into a Wasm module using existing "opa build -t wasm " ? I did not see opa build command has the options there. |
That's not available through the command line directly, but you could first build an optimized bundle, and then build a wasm bundle from that, I think. |
I assume we also need to add a change on [language]-opa-wasm (dotnet-opa-wasm in my case). Would you mind sharing with me how I can build an optimized bundle? It will be great if you can properly prioritize this issue so that a lot of us can benefit from that. |
Hearing that there are a lot of you that would benefit from this has me curious about who that group is? Could you elaborate some on where this is to be used? 🙂 |
Sorry, my previous message was very brief -- sent from a mobile. Let's unpack:
|
🗒️ #5548 |
Thank you so much, Stephan & Anders! test.rego is my test rego policy which contains partial evaluation.package test default doc_allow := false doc_allow := true {
|
@pzou19741 I've taken your problem into a new issue, as it's quite localized and a side-track for the discussion at hand here. Please bear with me, I'll reply over in #5556. |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
Expected Behavior
When using a WASM compiled OPA policy which is designed to operate with partial evaluation (e.g. Vet example here: https://blog.openpolicyagent.org/write-policy-in-opa-enforce-policy-in-sql-d9d24db93bf4) I would like to be able to partually evaluate the policy and get back a similar syntax as if I had called the OPA server Partial evaluation endpoint
Actual Behavior
WASM policy returns "[]"
Additional Info
I am trying to run a C# application which uses OPA policies to determine authorization on an action but would prefer to use a WASM compiled policy for the performance benifits. I would like to use the power of Linq to add the additional partial evaluation filters to the queries to my data store.
The text was updated successfully, but these errors were encountered: