Repository navigation
Evaluate pod security in one place - #31
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pod security predicates were written three times with three different precedence rules. The admission non-root check let a pod-level
runAsNonRoot: truepass a container that setfalse, workloadsec readrunAsNonRoot: falseas root, a container'sUnconfinedseccomp profile under a podRuntimeDefaultread as confined, and the admission baseline counted unknown containers as non-root while the check flagged them.This adds
internal/podsec, the one place a pod security predicate is written, with Kubernetes precedence (container when set, else pod, else the documented default). Workloadsec, the security scanner, the admission checks, and the admission baseline all call it, and the old helpers are gone.Behavior changes:
runAsNonRoot: falsealone is unknown, not root. A container under a podrunAsUser: 0is root even withrunAsNonRoot: true. Privileged containers and addedSYS_ADMINorALLallow privilege escalation. A namespace withenforce: privilegedcounts as unenforced. Ephemeral containers are left out of the counts that feed the admission baseline.New workload security fields:
baseline_containers,run_as_non_root_containers, andrun_as_unknown_containers(replacesunknown_root_containers). The baseline non-root, privilege escalation, and read-only fractions now usebaseline_containersas the denominator, so scans stored before this change contribute nothing to them.Tests: an 81-case pod-by-container root status matrix, seccomp and escalation matrices, and precedence cases in workloadsec and admission. The local gate (lint, race, cmd x10, browser, kind integration) is green.
Also locks the shared root command in
TestScanFlagsDefined, which read its flags unlocked and racedTestBadFlagErrorShapeunder-count=10.