-
Notifications
You must be signed in to change notification settings - Fork 238
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
Expand run-as-non-root
template to verify runAsGroup
field is nonzero.
#804
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #804 +/- ##
==========================================
- Coverage 62.36% 62.34% -0.02%
==========================================
Files 197 197
Lines 4854 4871 +17
==========================================
+ Hits 3027 3037 +10
- Misses 1439 1447 +8
+ Partials 388 387 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
could you add unit tests for new code?
if runAsUser != nil && *runAsUser > 0 { | ||
runAsGroup := effectiveRunAsGroup(podSpec.SecurityContext, container.SecurityContext) | ||
// runAsUser and runAsGroup explicitly set to non-root. All good. | ||
if (runAsUser != nil && *runAsUser > 0) && (runAsGroup != nil && *runAsGroup > 0) { |
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.
How about extracting a function to check for non zero int pointer?
func isNonZero(number *int64) bool {
return number != nil && *number > 0
}
Closes #748
This PR introduces changes which expand the
run-as-non-root
template/check to verifyrunAsGroup
field is set to a non-zero value.The
runAsGroup
field specifies the group ID under which the container’s process should run.If left unspecified, the GID defaults to 0.
Snippet of build in action where
pod.yaml
for first execution initially didn't setrunAsGroup
, second execution set the field to 0, and finally set to a non-zero value: