-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kbs: switch to Regorus for resource policy #357
Conversation
Unfortunately when I rebase (and pick up az-snp-vtpm 0.5.2) I run into this dependency conflict. Not sure we can fix this ourselves? @mkulke @anakrish
|
Cargo.toml
Outdated
@@ -31,6 +31,8 @@ hex = "0.4.3" | |||
kbs-types = "0.5.3" | |||
log = "0.4.17" | |||
prost = "0.11.0" | |||
#regorus = "0.1.2" | |||
regorus = { git = "https://github.com/microsoft/regorus" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for the preference for github repo over crates.io?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. That's leftover from development when I was thinking about using the new eval_rule
thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eva;_rule
would be the way to go in future. It avoids having to parse a query, and also returns the value of a rule directly.
Cargo.toml
Outdated
@@ -31,6 +31,8 @@ hex = "0.4.3" | |||
kbs-types = "0.5.3" | |||
log = "0.4.17" | |||
prost = "0.11.0" | |||
#regorus = "0.1.2" | |||
regorus = { git = "https://github.com/microsoft/regorus" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could configure regorus to support only those builtins that will be used by the policies. The way it is used currently, we might not even need the arc
feature since neither the Engine instance nor the Value
instances are shared between threads.
regorus = { git = "https://github.com/microsoft/regorus" } | |
regorus = { git = "https://github.com/microsoft/regorus", default-features=false, features=["arc"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work. Thanks for the advice.
You could just not use the The following table lists various Rego builtins and which feature each one depends on. For OPA compatibility, all features are enabled by default. But most applications won't need or use all the OPA builtins. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR and good unit tests.
|[deny_all.rego](./deny_all.rego)|Deny all resources release| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we split docs and code, it would be better. But it looks good now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think we should refactor a few things in this repo including the docs.
use tokio::sync::Mutex; | ||
|
||
#[cfg(feature = "opa")] | ||
mod opa; | ||
|
||
const DEFAULT_POLICY_PATH: &str = "/opa/confidential-containers/kbs/policy.rego"; | ||
|
||
#[derive(Error, Debug, PartialEq)] | ||
pub enum ResourcePolicyError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw I like this definition of error types.
kbs/test/data/policy_4.rego
Outdated
@@ -0,0 +1,31 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should delete the empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GO OPA engine is very picky about the format of the policy and would often fail if there were any extra lines. This test is supposed to make sure Regorus is more resilient. I added a comment to the policy file because it does look odd.
1421883
to
a9b51a3
Compare
Hmm. Looks like there is some issue with building Regorus inside of our docker container
I don't see a similar issue building locally. I have also tried pinning to v0.1.0 and v0.1.1 and the upstream head. Any ideas @anakrish |
Hmm. I haven't seen such an issue before. The failing build command is trying to do this: let output = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap(); It is likely that
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. cc @jialez0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @fitzthum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some concerns about dropping error sources, but otherwise lg!
Switch from Go-based policy engine to rust-based Regorus Switch from Anyhow to thiserror for resource policy Add several unit tests and test policies Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
This does not touch the AS policy. I will do that later although the plan may change based on whether/how we use EAR tokens.