-
Notifications
You must be signed in to change notification settings - Fork 1.2k
genpolicy: Enable AdditionalGids checks in rules.rego #11214
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
genpolicy: Enable AdditionalGids checks in rules.rego #11214
Conversation
11150ff
to
913ebe6
Compare
913ebe6
to
2b200c2
Compare
Policy enforcement for additionalGids, A list of groups applied to the first process run in each container. Manifests in OCI struct as additionalGids: Consists of container's GID, fsGroup, and supplementalGroups. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#PodSecurityContext-v1-core Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
With added support for parsing these fields in genpolicy, we can now enable policy verification of AdditionalGids. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
Introduce new test case to the security context bats file which verifies that policy works properly for a deployment yaml containing fsGroup and supplementalGroup configuration. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
Fix up genpolicy test inputs to include required additionalGids Include a test for the pod_container container in security_context tests as these containers follow slightly different paths in containerd. Introduce a test for fsGroup/supplementalGroups fields in the security context. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
2b200c2
to
090497f
Compare
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 @Camelron !
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!
As the genpolicy from_files call makes network requests to container registries, it has a chance to fail. Harden us against flakes due to network by introducing a 6x retry loop in genpolicy tests. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
66f17fc
to
7bba737
Compare
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.
Thanks for solving these issues @Camelron !
Handle PodSecurityContext.fsGroup|supplementalGroups
Policy enforcement for additionalGids, A list of groups applied to the first process run in each container. Manifests in OCI struct as additionalGids: Consists of container's GID, fsGroup, and supplementalGroups.
See: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#PodSecurityContext-v1-core
With added support for parsing these fields in genpolicy, we can now enable policy verification of AdditionalGids.