auditutil

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package auditutil contains shared Kubernetes audit-event parsing helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObjectRefGVR

ObjectRefGVR returns the GVR described by ref when resource and version are usable.

func ObjectRefGroupVersion

func ObjectRefGroupVersion(ref *auditv1.ObjectReference) (string, string)

ObjectRefGroupVersion returns the API group and version described by ref.

func SplitAPIVersion

func SplitAPIVersion(apiVersion string) (string, string)

SplitAPIVersion splits Kubernetes apiVersion into group and version.

func VerbToOperation

func VerbToOperation(verb string) (configv1alpha3.OperationType, bool)

VerbToOperation maps mutating Kubernetes audit verbs to watch operations.

Types

type AuditObjectIdentity

type AuditObjectIdentity struct {
	Namespace string
	Name      string
	UID       types.UID
}

AuditObjectIdentity is the (namespace, name, uid) of the object referenced by an audit event, after backfilling missing fields from the request or response body. Any field may be empty when the audit event does not carry it.

func IdentityFromAuditEvent

func IdentityFromAuditEvent(event auditv1.Event, op configv1alpha3.OperationType) AuditObjectIdentity

IdentityFromAuditEvent resolves the object identity of an audit event.

It starts from event.ObjectRef — the URL-level reference Kubernetes attached to the event — and backfills missing namespace/name/uid fields from the audit body that carries the authoritative object for op:

  • for non-delete operations the preferred body is ResponseObject, with RequestObject as fallback;
  • for delete operations the preferred body is RequestObject, with ResponseObject as fallback.

This handles `metadata.generateName` creates, where the server allocates the final name and writes it into responseObject.metadata.name while the objectRef points at the collection URL with an empty name.

A malformed body is ignored: the helper never panics and never overwrites a value that was already present on objectRef.

Jump to

Keyboard shortcuts

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