audit

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	RawLogsEventsTopic EventTopic    = "dp-raw-logs-events"
	VersionV1          EventVersion  = "1.0"
	OriginCore         EventOrigin   = "core"
	OriginCluster      EventOrigin   = "cluster"
	AuditCategory      EventCategory = "AUDIT"
)

Audit events constants

View Source
const (
	DATABASE      string = "database"
	ELASTICSEARCH string = "elasticsearch"
)
View Source
const (
	SYSTEM      string = "system"
	KUBECTL_CMD string = "kubectl_cmd"
	KUBECTL_API string = "kubectl_api"
)

Variables

This section is empty.

Functions

func CreateEvent

func CreateEvent(al *zap.Logger, event *Event, opts ...CreateEventOption) error

CreateEvent creates an event

func CreateV1Event

func CreateV1Event(al *zap.Logger, sd *commonv3.SessionData, detail *EventDetail, eventType string, project string) error

func GetAuditLogger

func GetAuditLogger(opts *AuditOptions) *zap.Logger

func WriteEvent

func WriteEvent(event *Event, al *zap.Logger)

Types

type AuditOptions

type AuditOptions struct {
	LogPath    string
	MaxSizeMB  int
	MaxBackups int
	MaxAgeDays int
}

options holds audit options

type CreateEventOption

type CreateEventOption func(opts *createEventOptions)

CreateEventOption is the functional arg for creating audit event

func WithAccountID

func WithAccountID(accountID string) CreateEventOption

WithAccountID sets account id for audit event

func WithCategory

func WithCategory(category EventCategory) CreateEventOption

WithCategory sets category for audit event

func WithContext

func WithContext(ctx context.Context) CreateEventOption

WithContext sets context for audit event

func WithGroups

func WithGroups(groups []string) CreateEventOption

WithGroups sets groups for audit event

func WithOrigin

func WithOrigin(origin EventOrigin) CreateEventOption

WithOrigin sets origin for audit event

func WithProject

func WithProject(project string) CreateEventOption

WithProject sets project id for audit event

func WithTopic

func WithTopic(topic EventTopic) CreateEventOption

WithTopic sets topic for audit event

func WithUsername

func WithUsername(username string) CreateEventOption

WithUsername sets username for audit event

func WithVersion

func WithVersion(version EventVersion) CreateEventOption

WithVersion sets version for audit event

type Event

type Event struct {
	Version   EventVersion  `json:"version"`
	Category  EventCategory `json:"category"`
	Origin    EventOrigin   `json:"origin"`
	Portal    string        `json:"portal"`
	Type      string        `json:"type"`
	Project   string        `json:"project"`
	Actor     *EventActor   `json:"actor"`
	Client    *EventClient  `json:"client"`
	Detail    *EventDetail  `json:"detail"`
	Timestamp string        `json:"timestamp"`
}

Event is struct to hold event data

func GetEvent

func GetEvent(r *http.Request, sd *commonv3.SessionData, detail *EventDetail, eventType string, project string) *Event

type EventActor

type EventActor struct {
	Type string `json:"type"`
	// Add org and partner id once we have multi-org support
	// PartnerID      string            `json:"partner_id"`
	// OrganizationID string            `json:"organization_id"`
	Account EventActorAccount `json:"account"`
	Groups  []string          `json:"groups"`
}

EventActor Event's initiator

func GetActorFromSessionData

func GetActorFromSessionData(sd *commonv3.SessionData) *EventActor

type EventActorAccount

type EventActorAccount struct {
	Username string `json:"username"`
}

EventActorAccount Event's initiator account

type EventCategory

type EventCategory string

EventCategory is the category of the event

type EventClient

type EventClient struct {
	Type      string `json:"type"`
	IP        string `json:"ip"`
	UserAgent string `json:"user_agent"`
	Host      string `json:"host"`
}

EventClient Event's client

func GetClientFromRequest

func GetClientFromRequest(r *http.Request) *EventClient

func GetClientFromSessionData

func GetClientFromSessionData(sd *commonv3.SessionData) *EventClient

type EventDetail

type EventDetail struct {
	Message string            `json:"message"`
	Meta    map[string]string `json:"meta"`
}

EventDetail Event's detail

type EventOrigin

type EventOrigin string

EventOrigin is the origin of the event

type EventTopic

type EventTopic string

EventTopic is the topic to which event has to be published

type EventVersion

type EventVersion string

EventVersion is the version of event

Jump to

Keyboard shortcuts

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