actionlog

package
v0.0.0-...-2873e01 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestOrigin_APP_Init      = "app/init"
	RequestOrigin_APP_Upgrade   = "app/upgrade"
	RequestOrigin_APP_Activate  = "app/activate"
	RequestOrigin_APP_Provision = "app/provision"
	RequestOrigin_APP_Run       = "app/run"
	RequestOrigin_API_REST      = "api/rest"
	RequestOrigin_API_GRPC      = "api/grpc"
	RequestOrigin_Auth          = "auth"
	RequestOrigin_Automation    = "automation"
)

Variables

This section is empty.

Functions

func MakeDebugPolicy

func MakeDebugPolicy() policyMatcher

func MakeDisabledPolicy

func MakeDisabledPolicy() policyMatcher

func MakeProductionPolicy

func MakeProductionPolicy() policyMatcher

func NewPolicyAll

func NewPolicyAll(mm ...policyMatcher) policyMatcher

NewPolicyAll returns policy where all sub-policies should match

func NewPolicyAny

func NewPolicyAny(mm ...policyMatcher) policyMatcher

NewPolicyAny returns policy where at least one of the sub-policies should match

func NewPolicyMatchAction

func NewPolicyMatchAction(aa ...string) policyMatcher

NewPolicyMatchAction matches action

func NewPolicyMatchRequestOrigin

func NewPolicyMatchRequestOrigin(rr ...string) policyMatcher

NewPolicyMatchRequestOrigin matches resources

func NewPolicyMatchResource

func NewPolicyMatchResource(rr ...string) policyMatcher

NewPolicyMatchResource matches resources

func NewPolicyMatchSeverity

func NewPolicyMatchSeverity(ss ...Severity) policyMatcher

NewPolicyMatchSeverity matches severity

func NewPolicyNegate

func NewPolicyNegate(m policyMatcher) policyMatcher

NewPolicyNegate negates passed policy

func NewPolicyNone

func NewPolicyNone() policyMatcher

NewPolicyNone ignores all action logs

func NewService

func NewService(s actionlogStore, logger, tee *zap.Logger, policy policyMatcher) (svc *service)

NewService initializes action log service

func RequestOriginFromContext

func RequestOriginFromContext(ctx context.Context) string

RequestOriginFromContext returns remote IP address from context

func RequestOriginToContext

func RequestOriginToContext(ctx context.Context, origin string) context.Context

RequestOriginToContext stores request origin to context

Types

type Action

type Action struct {
	ID uint64 `json:"actionID,string"`

	// Timestamp of the raised event
	Timestamp time.Time `json:"timestamp"`

	// Origin of the action (rest-api, cli, grpc, system)
	RequestOrigin string `json:"requestOrigin"`

	// Request ID
	RequestID string `json:"requestID"`

	// This can contain a series of IP addresses (when proxied)
	// https://en.wikipedia.org/wiki/X-Forwarded-For#Format
	ActorIPAddr string `json:"actorIPAddr"`

	// ID of the user (if not anonymous)
	ActorID uint64 `json:"actorID,string"`

	// Resource
	Resource string `json:"resource"`

	// Type of action
	Action string `json:"action"`

	// Error, if any
	Error string `json:"error"`

	// Action severity
	Severity Severity `json:"severity"`

	// Description of the event
	Description string `json:"description"`

	// Meta data, resource specific values
	Meta Meta `json:"meta"`
}

Standardized data structure for audit log events

func (*Action) ToAction

func (a *Action) ToAction() *Action

type ActionSet

type ActionSet []*Action

ActionSet slice of Action

This type is auto-generated.

func (ActionSet) Filter

func (set ActionSet) Filter(f func(*Action) (bool, error)) (out ActionSet, err error)

Filter iterates through every slice item, calls f(Action) (bool, err) and return filtered slice

This function is auto-generated.

func (ActionSet) FindByID

func (set ActionSet) FindByID(ID uint64) *Action

FindByID finds items from slice by its ID property

This function is auto-generated.

func (ActionSet) IDs

func (set ActionSet) IDs() (IDs []uint64)

IDs returns a slice of uint64s from all items in the set

This function is auto-generated.

func (ActionSet) Walk

func (set ActionSet) Walk(w func(*Action) error) (err error)

Walk iterates through every slice item and calls w(Action) err

This function is auto-generated.

type Filter

type Filter struct {
	FromTimestamp *time.Time `json:"from"`
	ToTimestamp   *time.Time `json:"to"`

	BeforeActionID uint64 `json:"beforeActionID"`

	ActorID  []string `json:"actorID"`
	Origin   string   `json:"origin"`
	Resource string   `json:"resource"`
	Action   string   `json:"action"`
	Limit    uint     `json:"limit"`

	// Standard helpers for sorting
	filter.Sorting
}

type Meta

type Meta map[string]interface{}

Any additional data that can be packed with the raised audit event

func (*Meta) Scan

func (m *Meta) Scan(src any) error

func (Meta) Set

func (m Meta) Set(key string, in interface{}, omitempty bool)

Set value as key to meta, or skip it if value is empty (and omitempty is set)

func (Meta) Value

func (m Meta) Value() (driver.Value, error)

type Recorder

type Recorder interface {
	Record(context.Context, *Action)
	Find(context.Context, Filter) (ActionSet, Filter, error)
}

type Severity

type Severity uint8

Severity determinants event severity level

const (
	Emergency Severity = iota
	Alert
	Critical
	Error
	Warning
	Notice
	Info
	Debug

	ActionResourceType = "corteza::generic:action"
)

Severity constants

not using log/syslog LOG_* constants as they are only available outside windows env.

func NewSeverity

func NewSeverity(s string) Severity

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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