koralium / OPADotNet

Apache License 2.0
10 stars 2 forks source link

Can I use this library to parse rego files without import / external libraries usage checks? #80

Open RonAmihai opened 1 year ago

RonAmihai commented 1 year ago

I need to parse a single rego file within a simple console application to iterate the rego script's rules. The file may use imports / external libraries.

I've tried to initiate an OpaClientEmbedded instance and load the rego file's content into it using the following code. But when I'm committing the policy - it throws an exception because of the unrecognized imports I'm using:

System.ArgumentException: Error in provided modules: 3 errors occurred:
policy-test:18: rego_type_error: undefined function data.generic.common.concat_path
policy-test:33: rego_type_error: undefined function data.generic.common.valid_key
policy-test:37: rego_type_error: undefined function data.generic.common.concat_path (Parameter 'modules')

Is there any way to configure the OPA compiler to ignore import / unrecognized function usage?

Ulimo commented 1 year ago

Hi, sorry for the late response.

The embedded client uses the rego sdk from OPA to parse and compile policies. So I am afraid there is no way that I know of right now.