v1alpha1

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package v1alpha1 contains API Schema definitions for the runtime.nirmata.io API group. +kubebuilder:object:generate=true +groupName=runtime.nirmata.io +versionName=v1alpha1

Index

Constants

View Source
const (
	// ConditionApplied reports that a node's daemon has the policy loaded,
	// with the reason naming the mode it is running in.
	ConditionApplied = "Applied"
	ReasonEnforcing  = "Enforcing"
	ReasonMonitoring = "Monitoring"
	// ReasonNoMode reports a policy that sets no spec.mode, so no manager
	// attached anything for it.
	ReasonNoMode = "NoMode"
	// ReasonCompileFailed reports a policy whose spec the compiler rejected,
	// so nothing at all was programmed for it.
	ReasonCompileFailed = "CompileFailed"

	ConditionTargetsValid     = "TargetsValid"
	ReasonUnsupportedTargets  = "UnsupportedTargets"
	ReasonAllTargetsSupported = "AllTargetsSupported"
	ReasonNoTargets           = "NoTargets"
	// ReasonUnresolvedServices reports cluster DNS values whose Service or
	// endpoint is absent from cache, so no address could be programmed.
	ReasonUnresolvedServices = "UnresolvedServices"

	// Exec and open get a condition each because conditions are keyed by type
	// and last-write-wins: one shared type would report whichever behavior was
	// recorded last.
	ConditionExecRulesValid = "ExecRulesValid"
	ConditionOpenRulesValid = "OpenRulesValid"
	ReasonUnsupportedPaths  = "UnsupportedPaths"
	ReasonAllPathsSupported = "AllPathsSupported"
	ReasonNoPaths           = "NoPaths"

	ConditionObservationAvailable = "ObservationAvailable"
	ReasonObservationUnavailable  = "ObservationUnavailable"
	ReasonObservationAvailable    = "ObservationAvailable"

	// ConditionEnforcementAvailable reports a kernel map the runtime could not
	// program, so the policy's workloads run unenforced.
	ConditionEnforcementAvailable = "EnforcementAvailable"
	ReasonEnforcementUnavailable  = "EnforcementUnavailable"
	ReasonEnforcementAvailable    = "EnforcementAvailable"

	// ConditionPodsMatched reports whether any node currently has a pod
	// selected by the policy's podSelector/namespaceSelector, so a selector
	// that matches nothing does not read the same as a working policy.
	ConditionPodsMatched = "PodsMatched"
	ReasonNoMatchingPods = "NoMatchingPods"
	ReasonPodsMatched    = "PodsMatched"
)

Condition types and reasons the daemons write onto a RuntimePolicy's status.

Variables

View Source
var (
	GroupVersion       = schema.GroupVersion{Group: "runtime.nirmata.io", Version: "v1alpha1"}
	SchemeGroupVersion = GroupVersion

	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
	AddToScheme   = SchemeBuilder.AddToScheme
)

Functions

func Resource

func Resource(resource string) schema.GroupResource

Types

type Behavior

type Behavior struct {
	// Allow specifies allowed entries for this behavior type.
	// +optional
	Allow *BehaviorRule `json:"allow,omitempty"`

	// Deny specifies denied entries for this behavior type.
	// +optional
	Deny *BehaviorRule `json:"deny,omitempty"`
}

Behavior defines the allowed and denied entries of a given type.

func (*Behavior) DeepCopy

func (in *Behavior) DeepCopy() *Behavior

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Behavior.

func (*Behavior) DeepCopyInto

func (in *Behavior) DeepCopyInto(out *Behavior)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type BehaviorRule

type BehaviorRule struct {
	// Values is a list of allowed or denied items (IPs, commands, files, etc.).
	// +optional
	Values []string `json:"values,omitempty"`

	// Expression is a CEL expression that evaluates to a list of items.
	// +optional
	Expression string `json:"expression,omitempty"`
}

BehaviorRule defines allow/deny rules with values and/or expressions.

func (*BehaviorRule) DeepCopy

func (in *BehaviorRule) DeepCopy() *BehaviorRule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BehaviorRule.

func (*BehaviorRule) DeepCopyInto

func (in *BehaviorRule) DeepCopyInto(out *BehaviorRule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MonitorFilter

type MonitorFilter struct {
	// Expressions each state a condition a finding must satisfy to be reported.
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:validation:MaxItems=64
	Expressions []MonitorFilterExpression `json:"expressions"`
}

MonitorFilter selects which findings are reported. Expressions are ANDed and evaluated in order, short-circuiting on the first false. Each must evaluate to bool over the event variable.

func (*MonitorFilter) DeepCopy

func (in *MonitorFilter) DeepCopy() *MonitorFilter

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitorFilter.

func (*MonitorFilter) DeepCopyInto

func (in *MonitorFilter) DeepCopyInto(out *MonitorFilter)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MonitorFilterExpression

type MonitorFilterExpression struct {
	// Name identifies this expression in compile errors, status conditions and
	// the eval-error metric. It is never emitted to a Report.
	// +kubebuilder:validation:MinLength=1
	Name string `json:"name"`

	// Expression is a CEL expression over the event variable that must evaluate
	// to bool. event.kind selects the arm that is populated: event.open.path,
	// event.exec.filename and .argv, event.net.destIP and .domain,
	// event.dns.qname, event.protocol.protocol and .alpn. Every event also
	// carries time, comm, pid, count, kernelDenied, wouldDeny, and pod.
	// +kubebuilder:validation:MinLength=1
	Expression string `json:"expression"`
}

MonitorFilterExpression is one named condition on a candidate finding.

func (*MonitorFilterExpression) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitorFilterExpression.

func (*MonitorFilterExpression) DeepCopyInto

func (in *MonitorFilterExpression) DeepCopyInto(out *MonitorFilterExpression)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type NodePolicyStatus

type NodePolicyStatus struct {
	NodeName string `json:"nodeName"`

	// +optional
	LastEvaluatedTime *metav1.Time `json:"lastEvaluatedTime,omitempty"`

	// EnforcementAvailable reports whether the kernel programs and maps
	// enforcing this policy are attached and programmed on this node.
	// +optional
	EnforcementAvailable *bool `json:"enforcementAvailable,omitempty"`

	// ObservationAvailable reports whether observation for this policy is
	// attached on this node.
	// +optional
	ObservationAvailable *bool `json:"observationAvailable,omitempty"`

	// PodsMatched reports whether any pod on this node currently matches the
	// policy's podSelector/namespaceSelector.
	// +optional
	PodsMatched *bool `json:"podsMatched,omitempty"`

	// Message explains a false EnforcementAvailable or ObservationAvailable.
	// +optional
	Message string `json:"message,omitempty"`
}

NodePolicyStatus is one node's shard of a RuntimePolicy's status, written only by that node's daemon. The cluster-scoped Applied, EnforcementAvailable, ObservationAvailable and PodsMatched conditions are derived from the shards.

func (*NodePolicyStatus) DeepCopy

func (in *NodePolicyStatus) DeepCopy() *NodePolicyStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePolicyStatus.

func (*NodePolicyStatus) DeepCopyInto

func (in *NodePolicyStatus) DeepCopyInto(out *NodePolicyStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PolicyBehavior

type PolicyBehavior struct {
	// Network defines network behavior rules.
	// +optional
	Network *Behavior `json:"network,omitempty"`

	// Exec defines command execution behavior rules.
	// +optional
	Exec *Behavior `json:"exec,omitempty"`

	// Open defines file open behavior rules.
	// +optional
	Open *Behavior `json:"open,omitempty"`

	// Protocol defines application protocol behavior rules, evaluated
	// against the first data segment of a connection.
	// +optional
	Protocol *Behavior `json:"protocol,omitempty"`

	// DNS declares the DNS names a selected workload is expected to resolve.
	// It is observation only: it reports, it never blocks, so a policy carrying
	// a dns behavior must use mode monitor and is rejected in mode enforce.
	//
	// Allow is the expected set. Deny names specific unwanted names, and the
	// "*" sentinel in deny means "report every name", which is how an operator
	// discovers what a workload resolves before writing an allow list.
	// +optional
	DNS *Behavior `json:"dns,omitempty"`
}

PolicyBehavior defines allow/deny rules for a specific behavior type. +kubebuilder:validation:XValidation:rule="(has(self.network) ? 1 : 0) + (has(self.exec) ? 1 : 0) + (has(self.open) ? 1 : 0) + (has(self.protocol) ? 1 : 0) + (has(self.dns) ? 1 : 0) == 1",message="exactly one of network, exec, open, protocol, or dns must be specified"

func (*PolicyBehavior) DeepCopy

func (in *PolicyBehavior) DeepCopy() *PolicyBehavior

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyBehavior.

func (*PolicyBehavior) DeepCopyInto

func (in *PolicyBehavior) DeepCopyInto(out *PolicyBehavior)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RuntimePolicy

type RuntimePolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   RuntimePolicySpec   `json:"spec,omitempty"`
	Status RuntimePolicyStatus `json:"status,omitempty"`
}

func (*RuntimePolicy) DeepCopy

func (in *RuntimePolicy) DeepCopy() *RuntimePolicy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimePolicy.

func (*RuntimePolicy) DeepCopyInto

func (in *RuntimePolicy) DeepCopyInto(out *RuntimePolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*RuntimePolicy) DeepCopyObject

func (in *RuntimePolicy) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type RuntimePolicyList

type RuntimePolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RuntimePolicy `json:"items"`
}

func (*RuntimePolicyList) DeepCopy

func (in *RuntimePolicyList) DeepCopy() *RuntimePolicyList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimePolicyList.

func (*RuntimePolicyList) DeepCopyInto

func (in *RuntimePolicyList) DeepCopyInto(out *RuntimePolicyList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*RuntimePolicyList) DeepCopyObject

func (in *RuntimePolicyList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type RuntimePolicyMode

type RuntimePolicyMode string

RuntimePolicyMode represents the operational mode for policy enforcement. +kubebuilder:validation:Enum=monitor;enforce

const (
	PolicyModeMonitor RuntimePolicyMode = "monitor"
	PolicyModeEnforce RuntimePolicyMode = "enforce"
)

type RuntimePolicySpec

type RuntimePolicySpec struct {
	// PodSelector identifies the pods this policy applies to. An empty selector
	// and an omitted field both match every pod on the node.
	// +optional
	PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"`

	// NamespaceSelector narrows PodSelector to pods whose namespace carries
	// these labels. An empty selector and an omitted field both match every
	// namespace.
	//
	// Target namespaces by name through kubernetes.io/metadata.name, which the
	// API server sets on every namespace.
	// +optional
	NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`

	// EvaluationInterval specifies how frequently the policy is re-evaluated.
	// +optional
	EvaluationInterval *metav1.Duration `json:"evaluationInterval,omitempty"`

	// Variables defines custom variables that can be used in behavior expressions.
	// +optional
	Variables []admissionregistrationv1.Variable `json:"variables,omitempty"`

	// Behaviors defines the allowed and denied runtime behaviors.
	//
	// The bound is what keeps the per-item XValidation rule inside the CEL cost
	// budget: an unbounded list makes the API server multiply that rule's cost by
	// the largest number of items a request could carry, and the estimate then
	// exceeds the budget and the CRD is refused at apply time.
	// +optional
	// +kubebuilder:validation:MaxItems=64
	Behaviors []PolicyBehavior `json:"behaviors,omitempty"`

	// Mode defines the operational mode of the policy.
	// +optional
	// +kubebuilder:default=monitor
	Mode *RuntimePolicyMode `json:"mode,omitempty"`

	// MonitorFilter narrows which findings a monitor-mode policy reports. It
	// selects what is observed into a finding, never what the kernel blocks.
	// +optional
	MonitorFilter *MonitorFilter `json:"monitorFilter,omitempty"`
}

RuntimePolicySpec defines a runtime policy for enforcing or monitoring behaviors.

The dns rule is enforced here rather than only at compile time so the API server refuses the object outright: a policy that was accepted and then reported an unapplied condition is a policy an author has to go looking for.

+kubebuilder:validation:XValidation:rule="!(has(self.mode) && self.mode == 'enforce' && has(self.behaviors) && self.behaviors.exists(b, has(b.dns)))",message="a dns behavior reports the names a workload resolves, it does not block them: set spec.mode to \"monitor\", or express the destinations you want blocked as a network behavior, which enforces domain values" +kubebuilder:validation:XValidation:rule="!(has(self.mode) && self.mode == 'enforce' && has(self.monitorFilter))",message="a monitorFilter narrows what a monitor-mode policy reports; an enforce-mode policy reports only operations the kernel actually denied, and those are never suppressed" +kubebuilder:validation:XValidation:rule="!(has(self.mode) && self.mode == 'enforce') || has(self.podSelector) || has(self.namespaceSelector)",message="an enforce-mode policy must state the pods it applies to: set spec.podSelector or spec.namespaceSelector, or set spec.podSelector to {} to enforce on every pod on the node"

func (*RuntimePolicySpec) DeepCopy

func (in *RuntimePolicySpec) DeepCopy() *RuntimePolicySpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimePolicySpec.

func (*RuntimePolicySpec) DeepCopyInto

func (in *RuntimePolicySpec) DeepCopyInto(out *RuntimePolicySpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RuntimePolicyStatus

type RuntimePolicyStatus struct {
	// LastEvaluatedTime is the last time the policy was evaluated.
	// +optional
	LastEvaluatedTime *metav1.Time `json:"lastEvaluatedTime,omitempty"`

	// Nodes holds one per-node shard, each written only by that node's daemon.
	// +optional
	// +listType=map
	// +listMapKey=nodeName
	Nodes []NodePolicyStatus `json:"nodes,omitempty"`

	// +optional
	Conditions []metav1.Condition `json:"conditions,omitempty"`
}

RuntimePolicyStatus reflects the observed state of the policy.

func (*RuntimePolicyStatus) DeepCopy

func (in *RuntimePolicyStatus) DeepCopy() *RuntimePolicyStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimePolicyStatus.

func (*RuntimePolicyStatus) DeepCopyInto

func (in *RuntimePolicyStatus) DeepCopyInto(out *RuntimePolicyStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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