Regorus
Regorus is
- Rego-Rus(t) - A fast, light-weight Rego interpreter written in Rust.
- Rigorous - A rigorous enforcer of well-defined Rego semantics.
Regorus is available as a library that can be easily integrated into your Rust projects.
use Result;
use *;
use serde_json;
Regorus passes the OPA v0.60.0 test-suite barring a few builtins. See OPA Conformance below.
Getting Started
examples/regorus is an example program that shows how to integrate Regorus into your project and evaluate Rego policies.
To build and install it, do
Check that the regorus example program is working
)
First, let's evaluate a simple Rego expression 1*2+3
This produces the following output
Next, evaluate a sample policy and input (borrowed from Rego tutorial):
Finally, evaluate real-world policies used in Azure Container Instances (ACI)
ACI Policies
Regorus successfully passes the ACI policy test-suite. It is fast and can run each of the tests in a few milliseconds.
)
)
Run the ACI policies in the tests/aci directory, using data tests/aci/data.json and input tests/aci/input.json:
Verify that OPA produces the same output
Performance
To check how fast Regorus runs on your system, first install a tool like hyperfine.
Then benchmark evaluation of the ACI policies,
)
)
Compare it with OPA
)
)
OPA Conformance
Regorus has been verified to be compliant with OPA v0.60.0 using a test driver that loads and runs the OPA testsuite using Regorus, and verifies that expected outputs are produced.
The test driver can be invoked by running:
Currently, Regorus passes all the non-builtin specific tests. See passing tests suites.
The following test suites don't pass fully due to mising builtins:
cryptoparsersaprivatekeyscryptox509parseandverifycertificatescryptox509parsecertificaterequestcryptox509parsecertificatescryptox509parsekeypaircryptox509parsersaprivatekeyglobsmatchgraphqlinvalidkeyerrorjsonpatchjwtbuiltinsjwtdecodeverifyjwtencodesignjwtencodesignrawjwtverifyhs256jwtverifyhs384jwtverifyhs512jwtverifyrsanetcidrcontainsnetcidrcontainsmatchesnetcidrexpandnetcidrintersectsnetcidrisvalidnetcidrmergenetcidroverlapnetlookupipaddrproviders-awsregometadatachainregometadataruleregoparsemodulerendertemplatetime
They are captured in the following github issues.
Grammar
The grammar used by Regorus to parse Rego policies is described in grammar.md in both W3C EBNF and RailRoad Diagram formats.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.