-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
fix invalid match rules for advanced audit policy #59398
Conversation
if len(r.Users) > 0 && attrs.GetUser() != nil { | ||
if !hasString(r.Users, attrs.GetUser().GetName()) { | ||
if len(r.Users) > 0 { | ||
if attrs.GetUser() == nil || !hasString(r.Users, attrs.GetUser().GetName()) { |
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.
No need to call attrs.GetUser()
again and again.
Better assign to a variable?
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.
Done.
c0ab610
to
9a7acaa
Compare
When users or groups are set in a rule, this rule should not match attribute with unauthorized request where user and group are nil.
/lgtm |
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.
/test pull-kubernetes-bazel-test |
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.
One nit, otherwise LGTM
@@ -73,6 +73,16 @@ var ( | |||
ResourceRequest: true, | |||
Path: "/api/v1/namespaces/default/pods/busybox", | |||
}, | |||
"Unauthorized": &authorizer.AttributesRecord{ |
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.
unauthenticated
?
lgtm. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CaoShuFeng, dixudx, sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
When is the user - level: None
users: ["", "system:anonymous"] # Don't log unauthenticated requests |
@tallclair: It would seem to me that having the empty string match the nil user is a related feature which should exist in its own ticket. The issue here is that rules are matching events that they should not match, while your request is for an expansion in rule semantics. |
@smurfralf agreed, this just seemed like a good place to discuss whether we want that feature :) sorry for the confusion. |
When users or groups are set in a rule, this rule should not match
attribute with unauthorized request where user and group are nil.
Release note:
Fixes: #59331