feat(validation): add pre-execution validation layer#764
feat(validation): add pre-execution validation layer#764nader-ziada wants to merge 2 commits intocontainers:mainfrom
Conversation
pkg/validation/rbac_validator.go
Outdated
There was a problem hiding this comment.
@Cali0707 just wondering (un releated) some sort of validation of "larger cluster" access would be nice for multi-cluster/acm use-case. I think we currently list all "managed clusters", w/o some sort of "validation"
There was a problem hiding this comment.
Note that we already have a canIUser method defined here:
kubernetes-mcp-server/pkg/kubernetes/resources.go
Lines 232 to 248 in dbc1bd0
There was a problem hiding this comment.
both methods are unexposed (private methods) and serve different purposes in different contexts
I prefer to have them in different packages with clear separation of concerns.
but let me know if you prefer to combine them somehow and I can do that
There was a problem hiding this comment.
Just noting in the context of the downstream issue that relates to this fix.
I'm not sure that if in that context, we might just want to put this in the AccessControlRoundTripper.
Here, we're already checking for denied resources in the configuration (for example)
There was a problem hiding this comment.
my understanding is that AccessControlRoundTripper checks configured denials (checks against a static deny list that the server operator configures. This is separate from Kubernetes RBAC) while the RBACValidator checks actual RBAC (what the cluster says about the current user's permissions)
Are you saying we don't need the RBACValidator since we will get the AccessControlRoundTripper check anyways? but the error message and logging would be different?
There was a problem hiding this comment.
No, I was saying that maybe (if we're just tackling the downstream issue -it's unclear to me the scope of it since it's not properly described-) we can just add RBAC validation to the roundrtipper (simple solution: KISS, YAGNI)
In any case, I'll review everything else in the issue.
What I'd also suggest is to make this opt-in for a couple of vesions at least upstream, since it might have side-effects we haven't accounted for.
manusa
left a comment
There was a problem hiding this comment.
Thx for putting this together.
I gave it an initial look and added a few comments.
f08a31e to
108f733
Compare
Add validation middleware that catches errors before they reach the Kubernetes API. Signed-off-by: Nader Ziada <nziada@redhat.com>
108f733 to
b07324e
Compare
|
made a refactor of how this works, sorry to the reviewers, to make work from the kubernetes pkg instead of the mcp pkg, now more dynamic and flexible. also disabled by default. |
manusa
left a comment
There was a problem hiding this comment.
I think that the decoupling from the mcp layer is going great, thx.
I added some more comments regarding the new approach.
pkg/config/validation_config.go
Outdated
There was a problem hiding this comment.
I don't recall we support config overrides through environment variables at the moment, we do support those through CLI flags.
Is there any reason why we need to be able to override this through an environment variable?
pkg/config/validation_config.go
Outdated
There was a problem hiding this comment.
Are we planning to add more config options to validation?
If so, I understand the nesting of the config into a different struct.
If not, why is the nesting needed?
There was a problem hiding this comment.
i originally had different flags for each validator, but decided its too much complexity, will remove struct
There was a problem hiding this comment.
This seems to be a substitute to the AccessControlRoundTripper, but the former is still retained (which is confusing).
I'm not sure if we prefer to make the composable and compose the when wiring together in kubernetes.go.
Or merging both into this one.
Whatever works better, but we should trim and clean up the redundant bits.
There was a problem hiding this comment.
merged the validation login into the AccessControlRoundTripper
Signed-off-by: Nader Ziada <nziada@redhat.com>
Add validation middleware that catches errors before they reach the Kubernetes API.
Changes:
Closes #775