integration

package
v0.3.336 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const AgentStoppingTimeout = sandboxpolicy.AgentStoppingTimeout

AgentStoppingTimeout bounds how long Close waits for its best-effort AgentStopping status writes.

Variables

View Source
var ErrInputsChanged = errors.New("sandbox inputs changed during synchronization")

Functions

func SnapshotBindings

func SnapshotBindings(ctx context.Context, client kubernetes.Interface, collection *containercollection.ContainerCollection, nodeName string) ([]sandboxpolicy.Binding, error)

SnapshotBindings joins runtime identities to authoritative Kubernetes metadata. The caller must subscribe before snapshotting and reconcile subsequent churn; ContainerRange is not an atomic barrier across independent runtime/API watches. The backend must still verify live PID/cgroup ownership immediately before bind.

func SnapshotBindingsFromContainers

func SnapshotBindingsFromContainers(ctx context.Context, client kubernetes.Interface, containers []*containercollection.Container, nodeName string) ([]sandboxpolicy.Binding, error)

SnapshotBindingsFromContainers accepts the current (not cached/deleted) runtime collection. Any incomplete or contradictory live Kubernetes identity rejects the entire snapshot, so the caller can retain last-good rather than interpret discovery lag as authorization to withdraw enforcement.

func SnapshotSelectedBindings

func SnapshotSelectedBindings(ctx context.Context, client kubernetes.Interface, collection *containercollection.ContainerCollection, nodeName string, selector func(sandboxpolicy.Binding) bool) ([]sandboxpolicy.Binding, error)

SnapshotSelectedBindings requires runtime identities only for authoritatively selected Kubernetes workloads. It does not inherit observer namespace/agent exemptions: an explicitly selected but observer-ignored container still fails if discovery cannot provide its exact identity.

func SnapshotSelectedBindingsFromContainers

func SnapshotSelectedBindingsFromContainers(ctx context.Context, client kubernetes.Interface, containers []*containercollection.Container, nodeName string, selector func(sandboxpolicy.Binding) bool) ([]sandboxpolicy.Binding, error)

SnapshotSelectedBindingsFromContainers is the selected-only snapshot variant for explicit runtime collections. Unmatched entries authorize no binding and may be ignored. Missing or contradictory selected identities reject the whole snapshot, never silently reducing protection. A selected live container that is not yet correlated returns the correlated bindings together with a *sandboxpolicy.BindingPendingError: the caller binds those and reports pending.

func VerifyCompiledInImages

func VerifyCompiledInImages(ctx context.Context, store oras.ReadOnlyTarget) error

VerifyCompiledInImages checks every compiled-in product image in store (the agent's tracers.tar) with the agent's own start check, for the kernel entry's architecture: its name resolves to an index with exactly one manifest for that architecture, whose digest is the compiled-in one, and every blob that manifest references is present and digest-verified. `make check-product-images` runs it on the built archive, so an agent image cannot ship with a missing or different product image. Every entry is checked and every failure reported.

Types

type ProfileResolver

type ProfileResolver struct {
	// contains filtered or unexported fields
}

func (*ProfileResolver) ResolveExecs

func (r *ProfileResolver) ResolveExecs(ctx context.Context, namespace, name, container string) ([]api.ExecRule, error)

ResolveExecs imports only complete, unambiguous literal-path exec allowlists. Exact/anchored argv (including ArgsRequired's explicit-empty semantics), dynamic path tokens, and environment constraints cannot be faithfully represented by SandboxPolicy's prefix/contains vocabulary: refuse, never widen silently. The service must Reconcile on source changes (periodic refresh is sufficient).

type Service

type Service struct {
	Controller *sandboxpolicy.Controller
	// contains filtered or unexported fields
}

func NewService

func NewService(ctx context.Context, options ServiceOptions) (*Service, error)

NewService prepares the public watcher/exporter/native runtime bridge. It does not authorize any cgroup or start enforcement until Start is called.

func (*Service) AddHandler

func (s *Service) AddHandler(_ context.Context, obj runtime.Object)

func (*Service) Close

func (s *Service) Close(ctx context.Context) error

Close withdraws exact owned bindings before releasing their runtime. It waits for the reconciliation loop before cleanup so no concurrent pass can reinstall. Before withdrawing, it reports Ready False (AgentStopping) for every exec policy, best-effort within AgentStoppingTimeout; no status is written after. Only after withdrawal does it stop the verdict exporter, which delivers the verdicts still queued (including those reported during withdrawal) for at most VerdictDrainTimeout within ctx; what is still queued then is counted as dropped. If Close returns early (ctx ends while waiting for the loop, or backend.Close fails), the exporter keeps delivering until a later Close.

func (*Service) ContainerCallback

func (s *Service) ContainerCallback(containercollection.PubSubEvent)

ContainerCallback is deliberately nonblocking: event delivery must never hold discovery locks while a gadget is loading or Kubernetes is unavailable.

func (*Service) DeleteHandler

func (s *Service) DeleteHandler(_ context.Context, obj runtime.Object)

func (*Service) ExporterStats

func (s *Service) ExporterStats() sandboxpolicy.ExporterStats

ExporterStats exposes telemetry loss separately from enforcement readiness.

func (*Service) KernelEventStats

func (s *Service) KernelEventStats(ctx context.Context) (igbackend.KernelEventStats, error)

KernelEventStats exposes lifetime kernel verdict-ring statistics separately from ExporterStats. Unavailable counts/errors mean totals are incomplete; these evaluator counters do not cover early native-owner exec refusals.

func (*Service) ModifyHandler

func (s *Service) ModifyHandler(_ context.Context, obj runtime.Object)

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start is called after container discovery is running and before the generic dynamic watcher starts. Relisting repairs watch disconnections and re-resolves source profiles/selector labels. Failed snapshots never become an empty list.

func (*Service) WatchResources

func (s *Service) WatchResources() []watcher.WatchResource

Watch events are hints only. Generic watcher queues may deliver old updates after a relist/deletion; applying their payload could resurrect removed policy. Refresh always reads authoritative configuration and cannot revive queued UIDs.

type ServiceOptions

type ServiceOptions struct {
	Kubernetes                                        kubernetes.Interface
	Dynamic                                           dynamic.Interface
	Containers                                        *containercollection.ContainerCollection
	Tracers                                           *tracercollection.TracerCollection
	NodeName, AgentNamespace, ImageName, ImageArchive string
	ContainerdSocket, ControlRoot                     string
	MaxOwners                                         uint64
	Engine                                            config.SandboxPolicyEngineConfig
	Sources                                           sandboxpolicy.SourceResolver
	Receivers                                         *maps.SafeMap[utils.EventType, mapset.Set[containerwatcher.GenericEventReceiver]]
	Enricher                                          containerwatcher.TaskBasedEnricher
	OnError                                           func(error)
	// OnWarning receives start-time configuration notices that change no
	// enforcement (deprecated or ignored keys); nil drops them.
	OnWarning func(error)
	// Metrics receives the verdict telemetry counters (nil: not exported).
	Metrics metricsmanager.MetricsManager
}

ServiceOptions deliberately has no inferred host/runtime-helper exemptions. Callers must explicitly enable this service and ship the matching mutator image.

Jump to

Keyboard shortcuts

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