Opa: wasm: Implement glob functions natively

Created on 3 Sep 2020  路  7Comments  路  Source: open-policy-agent/opa

The wasm library should implement the glob.match function natively as it's heavily used in API authorization use cases. This issue supersedes #1114.

wasm

Most helpful comment

Hi!

We have just started to implement OPA on our product and we planned to use WASM on the FrontEnd (the BackEnd is build in GO so no issue there hehe).

The policy that we use have glob.match because, as you mentioned heavily used in API authorization use cases.

I was wondering if there is any timeline approximated for this issue, to make a decision to wait for it or take a workaround for now waiting for it to be done.

I could potentially contribute to this issues if you give me some docs on how to do it, for what I've seen for the others you declare/test the function in C and then attach it to GO with the binders. The main issue is that I not really good with C but I can try if needed :).

All 7 comments

Hi!

We have just started to implement OPA on our product and we planned to use WASM on the FrontEnd (the BackEnd is build in GO so no issue there hehe).

The policy that we use have glob.match because, as you mentioned heavily used in API authorization use cases.

I was wondering if there is any timeline approximated for this issue, to make a decision to wait for it or take a workaround for now waiting for it to be done.

I could potentially contribute to this issues if you give me some docs on how to do it, for what I've seen for the others you declare/test the function in C and then attach it to GO with the binders. The main issue is that I not really good with C but I can try if needed :).

I'd like to get glob.match implemented natively in the next month or so. The implementation isn't too bad but it will require familiarity with C. It's probably not a great "getting started" issue.

Hi @tsandall I did a quick implementation https://github.com/xescugc/opa/tree/fg-glob (it's not ended as it does not fulfill all the API of the glob.match) to see if I'm on the good path or I'm going on a really wrong direction.

If it's a good direction I'll continue to actually do a final implementation (this was just more of a PoC hehe)

@xescugc very cool.

~My main concern w/ importing the fnmatch implementation is compatibility w/ the supported glob.match syntax. The implementation of glob.match is handled by https://github.com/gobwas/glob. Is fnmatch a superset of gobwas/glob? If so, that would be OK though it would be nice if they were identical. If fnmatch only supports a subset of the gobwas/glob syntax, how much work is it going to be to modify the fnmatch implementation? Sometimes it's just easier to start from scratch with these things.~

In the mean time, @koponen-styra has ported the gobwas/glob implementation to C++ here #2836. That PR will be landing shortly.

Ok perfect then I'll not continue with it and wait for #2836 to land :)

This has landed! 馃帄

Thx @tsandall I already tested it once it was merged to master with a new build and works like a charm :+1:

Was this page helpful?
0 / 5 - 0 ratings