audit

package
v3.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package audit defines supported contrib audit-event contracts for services.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEvent reports that an audit event is missing required fields.
	ErrInvalidEvent = errors.New("invalid audit event")
	// ErrUnsafeMetadata reports that audit metadata appears to contain a secret.
	ErrUnsafeMetadata = errors.New("unsafe audit metadata")
)

Functions

func CloneMetadata

func CloneMetadata(metadata map[string]string) map[string]string

CloneMetadata returns a defensive copy of metadata.

func ValidateEvent

func ValidateEvent(event Event) error

ValidateEvent verifies required fields and metadata safety.

func ValidateMetadata

func ValidateMetadata(metadata map[string]string) error

ValidateMetadata rejects metadata keys that commonly carry raw secrets.

Types

type Actor

type Actor struct {
	Type string
	ID   string
}

Actor identifies the principal responsible for an action.

type Event

type Event struct {
	ID         string
	TenantID   string
	Actor      Actor
	Action     string
	Resource   Resource
	Result     Result
	RequestID  string
	Metadata   map[string]string
	OccurredAt time.Time
}

Event records a security-relevant action for tenant-scoped services.

type Recorder

type Recorder interface {
	Record(ctx context.Context, event Event) error
}

Recorder stores audit events.

type Resource

type Resource struct {
	Type string
	ID   string
}

Resource identifies the object affected by an action.

type Result

type Result string

Result describes the outcome recorded by an audit event.

const (
	// ResultSuccess records an allowed action that completed successfully.
	ResultSuccess Result = "success"
	// ResultDenied records an authorization or policy denial.
	ResultDenied Result = "denied"
	// ResultFailure records an attempted action that failed.
	ResultFailure Result = "failure"
)

Directories

Path Synopsis
Package audittest contains reusable audit recorder contract tests.
Package audittest contains reusable audit recorder contract tests.

Jump to

Keyboard shortcuts

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