Skip to content
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

invalid Roles are outputted #24

Closed
vrabbi opened this issue Feb 8, 2023 · 4 comments
Closed

invalid Roles are outputted #24

vrabbi opened this issue Feb 8, 2023 · 4 comments

Comments

@vrabbi
Copy link

vrabbi commented Feb 8, 2023

the tool is great but has a bug. it outputs roles and clusterroles with resourceNames even when it includes the create verb which is not possible in K8s.
is this something that can be fixed in the project?
currently i am manually removing the resource names field from those places but it would be much better if the tool did this itself

@liggitt
Copy link
Owner

liggitt commented Feb 8, 2023

Thanks for reporting the issue... it's very strange, since I've seen generation of create roles work properly, emitting without resourceNames populated (see the example in the demo at https://www.youtube.com/watch?v=n2cD20moYe8&t=137s at 2:17)

At first I thought it might be differences in audit configurations sometimes emitting the resource name in audit events for create requests, but in that same demo, you can see create requests audit events containing object names (e.g. at https://www.youtube.com/watch?v=n2cD20moYe8&t=5s at 0:05), so in that configuration, audit events contained names of objects being created, and a create permission was added to the role without populating the name.

I'll take a look to see if I can figure out why this was sometimes producing correct create roles, and make the output work consistently.

@vrabbi
Copy link
Author

vrabbi commented Feb 8, 2023

would it help if i sent you the audit log?

@liggitt
Copy link
Owner

liggitt commented Feb 8, 2023

sure, testdata is always welcome, though the transformation from audit events to authorizer attributes clearly just copies in the objectRef name:

if event.ObjectRef != nil {
attrs.ResourceRequest = true
attrs.Namespace = event.ObjectRef.Namespace
attrs.Name = event.ObjectRef.Name
attrs.Resource = event.ObjectRef.Resource
attrs.Subresource = event.ObjectRef.Subresource
attrs.APIGroup = event.ObjectRef.APIGroup
attrs.APIVersion = event.ObjectRef.APIVersion
}

so if the audit log has an objectRef with a name attribute populated, that will drive a simulated authorization check that doesn't match the authorization check that would have been done in reality

@liggitt liggitt closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants