kubewarden / kwctl

Go-to CLI tool for Kubewarden users
https://kubewarden.io
Apache License 2.0
73 stars 15 forks source link

Handle Rego policies #55

Closed flavio closed 3 years ago

flavio commented 3 years ago

Allow kwctl to interact with Rego policies that have been compiled to WebAssembly

Both OPA and Gatekeeper use Rego to express their policies. However the policies have to be written in different ways, because of how policy settings are handled by OPA and Gatekeeper.

OPA relies on the data dictionary to pass additional data to the policy, while Gatekeeper enriches the input dictionary. While it's easy to understand whether a Wasm policy has been generated by opa built -t wasm, there currently is no way to know if the a policy has been written for OPA or Gatekeeper.

To eliminate this ambiguity, we will rely on the user to kwctl annotate the Wasm policy to explain whether the policy was written for OPA or for Gatekeeper.

Aside from that, kwctl can easily identify Wasm modules that have been produced by opa (as opposed to say, a kubewarden policy). The identification can be done by looking at the following globals that are always defined inside of "rego-based" Wasm files: opa_wasm_abi_version, opa_wasm_abi_minor_version. These are documented here.

Admission criteria

Part of https://github.com/kubewarden/policy-evaluator/issues/14

flavio commented 3 years ago

This is done, we should create a new one to track Gatekeeper.