Documentation ¶
Overview ¶
Package api contains constants and helpers for PodSecurity admission label keys and values
Index ¶
- Constants
- func CompareLevels(a, b Level) int
- type Attributes
- type AttributesRecord
- func (a *AttributesRecord) GetKind() schema.GroupVersionKind
- func (a *AttributesRecord) GetName() string
- func (a *AttributesRecord) GetNamespace() string
- func (a *AttributesRecord) GetObject() (runtime.Object, error)
- func (a *AttributesRecord) GetOldObject() (runtime.Object, error)
- func (a *AttributesRecord) GetOperation() admissionv1.Operation
- func (a *AttributesRecord) GetResource() schema.GroupVersionResource
- func (a *AttributesRecord) GetSubresource() string
- func (a *AttributesRecord) GetUserName() string
- type Level
- type LevelVersion
- type Policy
- type Version
Constants ¶
const ( EnforceLevelLabel = labelPrefix + "enforce" EnforceVersionLabel = labelPrefix + "enforce-version" AuditLevelLabel = labelPrefix + "audit" AuditVersionLabel = labelPrefix + "audit-version" WarnLevelLabel = labelPrefix + "warn" WarnVersionLabel = labelPrefix + "warn-version" ExemptionReasonAnnotationKey = "exempt" AuditViolationsAnnotationKey = "audit-violations" EnforcedPolicyAnnotationKey = "enforce-policy" )
const AuditAnnotationPrefix = labelPrefix
const VersionLatest = "latest"
Variables ¶
This section is empty.
Functions ¶
func CompareLevels ¶
CompareLevels returns an integer comparing two levels by strictness. The result will be 0 if a==b, -1 if a is less strict than b, and +1 if a is more strict than b.
Types ¶
type Attributes ¶ added in v0.23.0
type Attributes interface { // GetName is the name of the object associated with the request. GetName() string // GetNamespace is the namespace associated with the request (if any) GetNamespace() string // GetResource is the name of the resource being requested. This is not the kind. For example: pods GetResource() schema.GroupVersionResource // GetKind is the name of the kind being requested. For example: Pod GetKind() schema.GroupVersionKind // GetSubresource is the name of the subresource being requested. This is a different resource, scoped to the parent resource, but it may have a different kind. // For instance, /pods has the resource "pods" and the kind "Pod", while /pods/foo/status has the resource "pods", the sub resource "status", and the kind "Pod" // (because status operates on pods). The binding resource for a pod though may be /pods/foo/binding, which has resource "pods", subresource "binding", and kind "Binding". GetSubresource() string // GetOperation is the operation being performed GetOperation() admissionv1.Operation // GetObject returns the typed Object from incoming request. // For objects in the core API group, the result must use the v1 API. GetObject() (runtime.Object, error) // GetOldObject returns the typed existing object. Only populated for UPDATE requests. // For objects in the core API group, the result must use the v1 API. GetOldObject() (runtime.Object, error) // GetUserName is the requesting user's authenticated name. GetUserName() string }
Attributes exposes the admission request parameters consumed by the PodSecurity admission controller.
func RequestAttributes ¶ added in v0.23.0
func RequestAttributes(request *admissionv1.AdmissionRequest, decoder runtime.Decoder) Attributes
RequestAttributes adapts an admission.Request to the Attributes interface.
type AttributesRecord ¶ added in v0.23.0
type AttributesRecord struct { Name string Namespace string Kind schema.GroupVersionKind Resource schema.GroupVersionResource Subresource string Operation admissionv1.Operation Object runtime.Object OldObject runtime.Object Username string }
AttributesRecord is a simple struct implementing the Attributes interface.
func (*AttributesRecord) GetKind ¶ added in v0.23.0
func (a *AttributesRecord) GetKind() schema.GroupVersionKind
func (*AttributesRecord) GetName ¶ added in v0.23.0
func (a *AttributesRecord) GetName() string
func (*AttributesRecord) GetNamespace ¶ added in v0.23.0
func (a *AttributesRecord) GetNamespace() string
func (*AttributesRecord) GetObject ¶ added in v0.23.0
func (a *AttributesRecord) GetObject() (runtime.Object, error)
func (*AttributesRecord) GetOldObject ¶ added in v0.23.0
func (a *AttributesRecord) GetOldObject() (runtime.Object, error)
func (*AttributesRecord) GetOperation ¶ added in v0.23.0
func (a *AttributesRecord) GetOperation() admissionv1.Operation
func (*AttributesRecord) GetResource ¶ added in v0.23.0
func (a *AttributesRecord) GetResource() schema.GroupVersionResource
func (*AttributesRecord) GetSubresource ¶ added in v0.23.0
func (a *AttributesRecord) GetSubresource() string
func (*AttributesRecord) GetUserName ¶ added in v0.23.0
func (a *AttributesRecord) GetUserName() string
type Level ¶
type Level string
func ParseLevel ¶
ParseLevel returns the level that should be evaluated. level must be "privileged", "baseline", or "restricted". if level does not match one of those strings, "restricted" and an error is returned.
type LevelVersion ¶
func (*LevelVersion) Equivalent ¶ added in v0.25.0
func (lv *LevelVersion) Equivalent(other *LevelVersion) bool
Equivalent determines whether two LevelVersions are functionally equivalent. LevelVersions are considered equivalent if both are privileged, or both levels & versions are equal.
func (LevelVersion) String ¶
func (lv LevelVersion) String() string
type Policy ¶
type Policy struct { Enforce LevelVersion Audit LevelVersion Warn LevelVersion }
func PolicyToEvaluate ¶
PolicyToEvaluate resolves the PodSecurity namespace labels to the policy for that namespace, falling back to the provided defaults when a label is unspecified. A valid policy is always returned, even when an error is returned. If labels cannot be parsed correctly, the values of "restricted" and "latest" are used for level and version respectively.
func (*Policy) Equivalent ¶ added in v0.25.0
Equivalent determines whether two policies are functionally equivalent. Policies are considered equivalent if all 3 modes are considered equivalent.
func (*Policy) FullyPrivileged ¶ added in v0.25.0
FullyPrivileged returns true if all 3 policy modes are privileged.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
func GetAPIVersion ¶ added in v0.23.0
func GetAPIVersion() Version
GetAPIVersion get the version of apiServer and return the version major and minor
func LatestVersion ¶
func LatestVersion() Version
func MajorMinorVersion ¶
func ParseVersion ¶
ParseVersion returns the policy version that should be evaluated. version must be "latest" or "v1.x". If version does not match one of those patterns, the latest version and an error is returned.