InitContainers are not checked for hostPort ranges

PodSecurityPolicy must verify that host port ranges are guarded on init
containers.
This commit is contained in:
Clayton Coleman
2016-07-20 22:20:42 -04:00
parent d0ddefffd9
commit affd79fdc0
2 changed files with 11 additions and 2 deletions

View File

@@ -250,6 +250,12 @@ func (s *simpleProvider) ValidateContainerSecurityContext(pod *api.Pod, containe
allErrs = append(allErrs, s.hasInvalidHostPort(&c, idxPath)...)
}
containersPath = fldPath.Child("initContainers")
for idx, c := range pod.Spec.InitContainers {
idxPath := containersPath.Index(idx)
allErrs = append(allErrs, s.hasInvalidHostPort(&c, idxPath)...)
}
if !s.psp.Spec.HostPID && pod.Spec.SecurityContext.HostPID {
allErrs = append(allErrs, field.Invalid(fldPath.Child("hostPID"), pod.Spec.SecurityContext.HostPID, "Host PID is not allowed to be used"))
}