Name | lakera-regorus JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Python bindings for Regorus - a fast, lightweight Rego interpreter written in Rust |
upload_time | 2024-04-05 10:13:17 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
interpreter
opa
policy-as-code
rego
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# regorus
**Regorus** is
- *Rego*-*Rus(t)* - A fast, light-weight [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/)
interpreter written in Rust.
- *Rigorous* - A rigorous enforcer of well-defined Rego semantics.
Regorus can be used in Python via `regorus` package. (It is not yet available in PyPI, but can be manually built.)
See [Repository](https://github.com/microsoft/regorus).
To build this binding, see [building](https://github.com/microsoft/regorus/bindings/python/building.md)
## Usage
```Python
import regorus
# Create engine
engine = regorus.Engine()
# Load policies
engine.add_policy_from_file('../../tests/aci/framework.rego')
engine.add_policy_from_file('../../tests/aci/api.rego')
engine.add_policy_from_file('../../tests/aci/policy.rego')
# Add policy data
data = {
"metadata": {
"devices": {
"/run/layers/p0-layer0": "1b80f120dbd88e4355d6241b519c3e25290215c469516b49dece9cf07175a766",
"/run/layers/p0-layer1": "e769d7487cc314d3ee748a4440805317c19262c7acd2fdbdb0d47d2e4613a15c",
"/run/layers/p0-layer2": "eb36921e1f82af46dfe248ef8f1b3afb6a5230a64181d960d10237a08cd73c79",
"/run/layers/p0-layer3": "41d64cdeb347bf236b4c13b7403b633ff11f1cf94dbc7cf881a44d6da88c5156",
"/run/layers/p0-layer4": "4dedae42847c704da891a28c25d32201a1ae440bce2aecccfa8e6f03b97a6a6c",
"/run/layers/p0-layer5": "fe84c9d5bfddd07a2624d00333cf13c1a9c941f3a261f13ead44fc6a93bc0e7a"
}
}
}
engine.add_data(data)
# Set input
input = {
"containerID": "container0",
"layerPaths": [
"/run/layers/p0-layer0",
"/run/layers/p0-layer1",
"/run/layers/p0-layer2",
"/run/layers/p0-layer3",
"/run/layers/p0-layer4",
"/run/layers/p0-layer5"
],
"target": "/run/gcs/c/container0/rootfs"
}
engine.set_input(input)
# Eval query
results = engine.eval_query('data.framework.mount_overlay=x')
# Print results
print(results['result'][0])
# Eval query as json
results_json = engine.eval_query_as_json('data.framework.mount_overlay=x')
print(results_json)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "lakera-regorus",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "interpreter, opa, policy-as-code, rego",
"author": null,
"author_email": null,
"download_url": null,
"platform": null,
"description": "# regorus\n\n**Regorus** is\n\n - *Rego*-*Rus(t)* - A fast, light-weight [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/)\n interpreter written in Rust.\n - *Rigorous* - A rigorous enforcer of well-defined Rego semantics.\n\nRegorus can be used in Python via `regorus` package. (It is not yet available in PyPI, but can be manually built.)\n\nSee [Repository](https://github.com/microsoft/regorus).\n\nTo build this binding, see [building](https://github.com/microsoft/regorus/bindings/python/building.md)\n\n## Usage\n```Python\nimport regorus\n\n# Create engine\nengine = regorus.Engine()\n\n# Load policies\nengine.add_policy_from_file('../../tests/aci/framework.rego')\nengine.add_policy_from_file('../../tests/aci/api.rego')\nengine.add_policy_from_file('../../tests/aci/policy.rego')\n\n# Add policy data\ndata = {\n \"metadata\": {\n \"devices\": {\n \"/run/layers/p0-layer0\": \"1b80f120dbd88e4355d6241b519c3e25290215c469516b49dece9cf07175a766\",\n \"/run/layers/p0-layer1\": \"e769d7487cc314d3ee748a4440805317c19262c7acd2fdbdb0d47d2e4613a15c\",\n \"/run/layers/p0-layer2\": \"eb36921e1f82af46dfe248ef8f1b3afb6a5230a64181d960d10237a08cd73c79\",\n \"/run/layers/p0-layer3\": \"41d64cdeb347bf236b4c13b7403b633ff11f1cf94dbc7cf881a44d6da88c5156\",\n \"/run/layers/p0-layer4\": \"4dedae42847c704da891a28c25d32201a1ae440bce2aecccfa8e6f03b97a6a6c\",\n \"/run/layers/p0-layer5\": \"fe84c9d5bfddd07a2624d00333cf13c1a9c941f3a261f13ead44fc6a93bc0e7a\"\n }\n }\n}\nengine.add_data(data)\n\n# Set input\ninput = {\n \"containerID\": \"container0\",\n \"layerPaths\": [\n \"/run/layers/p0-layer0\",\n \"/run/layers/p0-layer1\",\n \"/run/layers/p0-layer2\",\n \"/run/layers/p0-layer3\",\n \"/run/layers/p0-layer4\",\n \"/run/layers/p0-layer5\"\n ],\n \"target\": \"/run/gcs/c/container0/rootfs\"\n}\nengine.set_input(input)\n\n# Eval query\nresults = engine.eval_query('data.framework.mount_overlay=x')\n\n# Print results\nprint(results['result'][0])\n\n# Eval query as json\nresults_json = engine.eval_query_as_json('data.framework.mount_overlay=x')\nprint(results_json)\n```\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Python bindings for Regorus - a fast, lightweight Rego interpreter written in Rust",
"version": "0.1.0",
"project_urls": {
"Source Code": "https://github.com/microsoft/regorus/bindings/python"
},
"split_keywords": [
"interpreter",
" opa",
" policy-as-code",
" rego"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "311a5b8f0d42b78db6bcd7ca93c852e0b956916ad433e2affd515b70f38da0a9",
"md5": "ee3c62697d1c52f7758c198ca0390c5e",
"sha256": "15d58bdc5aaee2bb39cfea34ef16b742ad1164927c4b6f8654e454e6ec1a0083"
},
"downloads": -1,
"filename": "lakera_regorus-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "ee3c62697d1c52f7758c198ca0390c5e",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 2694150,
"upload_time": "2024-04-05T10:13:17",
"upload_time_iso_8601": "2024-04-05T10:13:17.033099Z",
"url": "https://files.pythonhosted.org/packages/31/1a/5b8f0d42b78db6bcd7ca93c852e0b956916ad433e2affd515b70f38da0a9/lakera_regorus-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 10:13:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "microsoft",
"github_project": "regorus",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "lakera-regorus"
}