Help us shape the future of Go! Take the 2026 Go Developer Survey

podsec

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package podsec evaluates pod and container security settings with Kubernetes precedence, so every scanner and admission check that asks the same question gets the same answer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowsPrivilegeEscalation

func AllowsPrivilegeEscalation(c corev1.Container) bool

AllowsPrivilegeEscalation reports whether the container may gain privileges. An unset field is true, and privileged or an added CAP_SYS_ADMIN (or ALL) forces true whatever the field says.

func Containers

func Containers(pod *corev1.Pod, includeEphemeral bool) []corev1.Container

Containers returns the pod's init and regular containers, followed by its ephemeral containers converted to Container when includeEphemeral is true. It returns nil for a nil pod.

func DropsAllCapabilities

func DropsAllCapabilities(c corev1.Container) bool

DropsAllCapabilities reports whether the container drops ALL capabilities, matched without regard to case as container runtimes do. The field exists only on the container.

func ReadOnlyRootFS

func ReadOnlyRootFS(c corev1.Container) bool

ReadOnlyRootFS reports whether the container's root filesystem is read-only. The field exists only on the container and an unset field means writable.

func RunAsNonRoot

func RunAsNonRoot(pod *corev1.Pod, c corev1.Container) (bool, bool)

RunAsNonRoot returns the effective runAsNonRoot and whether either level sets it. The container value wins when set, else the pod value applies.

func RunAsUser

func RunAsUser(pod *corev1.Pod, c corev1.Container) (int64, bool)

RunAsUser returns the effective runAsUser and whether either level sets it. The container value wins when set, else the pod value applies.

func SeccompConfined

func SeccompConfined(pod *corev1.Pod, c corev1.Container) bool

SeccompConfined reports whether the container runs under a RuntimeDefault or Localhost seccomp profile. The container profile wins when set, Unconfined included, else the pod profile applies, and no profile at either level is not confined.

Types

type Status

type Status string

Status describes what a pod spec settles about the user a container runs as.

const (
	// Root means the effective runAsUser is 0.
	Root Status = "root"
	// NonRoot means the effective runAsUser is above 0, or it is unset and the effective
	// runAsNonRoot is true.
	NonRoot Status = "non-root"
	// Unknown means the spec does not settle the user, so only the image can.
	Unknown Status = "unknown"
)

Status values. Unknown counts as not non-root for every consumer.

func RootStatus

func RootStatus(pod *corev1.Pod, c corev1.Container) Status

RootStatus classifies the container's user from the effective runAsUser and runAsNonRoot. An effective runAsUser of 0 is Root even under runAsNonRoot true, since that container cannot run as anything else, and runAsNonRoot false alone is Unknown because false only skips the check.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL