agent

package
v3.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuditResultStatusViolating = "Violation"
	AuditResultStatusCompliant = "Compliance"
	AuditResultStatusIgnored   = "Ignored"
)
View Source
const AuthorizationTimeoutDuration = 2 * time.Hour

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	AccountID uuid.UUID
	ClusterID uuid.UUID
	AgentID   uuid.UUID

	EntitiesSource EntitiesSource
	Gateway        Gateway
	Auditor        Auditor
	// contains filtered or unexported fields
}

func New

func New(entitiesSource EntitiesSource, gateway Gateway, logLevelHandler ChangeLogLevelHandler, auditor Auditor) *Agent

func (*Agent) Exit

func (a *Agent) Exit(exitCode int)

func (*Agent) Start

func (a *Agent) Start() error

func (*Agent) Stop

func (a *Agent) Stop() error

type AuditCommandHandler added in v3.4.0

type AuditCommandHandler func() error

type AuditResult added in v3.3.1

type AuditResult struct {
	TemplateID   *string
	ConstraintID *string
	CategoryID   *string
	Severity     *string
	Controls     []string
	Standards    []string

	Description string
	HowToSolve  string

	Status AuditResultStatus
	Msg    *string

	EntityName    *string
	EntityKind    *string
	NamespaceName *string
	ParentName    *string
	ParentKind    *string
	EntitySpec    map[string]interface{}
	Trigger       string
}

func (*AuditResult) ToPacket added in v3.6.1

func (r *AuditResult) ToPacket() *proto.PacketAuditResultItem

type AuditResultHandler added in v3.3.1

type AuditResultHandler func(auditResult []*AuditResult) error

type AuditResultStatus added in v3.4.0

type AuditResultStatus string

type Auditor added in v3.3.1

type Auditor interface {
	Start(ctx context.Context) error
	Stop() error

	HandleConstraints(constraint []*Constraint) map[string]error
	HandleAuditCommand() error
	SetAuditResultHandler(handler AuditResultHandler)
}

type ChangeLogLevelHandler

type ChangeLogLevelHandler func(level *LogLevel) error

type Constraint added in v3.3.1

type Constraint struct {
	Id         string
	TemplateId string
	AccountId  string
	ClusterId  string

	Name         string
	TemplateName string
	Parameters   map[string]interface{}
	Match        Match
	Code         string
	Description  string
	HowToSolve   string

	UpdatedAt  time.Time
	CategoryId string
	Severity   string
	Controls   []string
	Standards  []string
	DeletedAt  *string
}

type ConstraintsHandler added in v3.3.1

type ConstraintsHandler func(constraints []*Constraint) map[string]error

type Delta

type Delta struct {
	Kind      EntityDeltaKind
	Gvrk      GroupVersionResourceKind
	Data      unstructured.Unstructured
	Parent    *ParentController
	Timestamp time.Time
}

type DeltasHandler

type DeltasHandler func(deltas []*Delta) error

type EntitiesResync

type EntitiesResync struct {
	Timestamp time.Time `json:"timestamp"`

	// map of entities kind and entities definitions
	Snapshot map[string]EntitiesResyncItem `json:"snapshot"`
}

type EntitiesResyncHandler

type EntitiesResyncHandler func(resync *EntitiesResync) error

type EntitiesResyncItem

type EntitiesResyncItem struct {
	Gvrk GroupVersionResourceKind     `json:"gvrk"`
	Data []*unstructured.Unstructured `json:"data"`
}

type EntitiesSource

type EntitiesSource interface {
	Start(ctx context.Context) error
	Stop() error

	SetDeltasHandler(handler DeltasHandler)
	SetEntitiesResyncHandler(handler EntitiesResyncHandler)
}

type EntityDeltaKind

type EntityDeltaKind string
const (
	EntityDeltaKindUpsert EntityDeltaKind = "UPSERT"
	EntityDeltaKindDelete EntityDeltaKind = "DELETE"
)

type Gateway

type Gateway interface {
	Start(ctx context.Context) error
	WaitAuthorization(timeout time.Duration) error

	SendEntitiesDeltas(deltas []*Delta) error
	SendEntitiesResync(resync *EntitiesResync) error
	SendAuditResults(auditResult []*AuditResult) error

	SetRestartHandler(handler RestartHandler)
	SetChangeLogLevelHandler(handler ChangeLogLevelHandler)
	SetConstraintsHandler(handler ConstraintsHandler)
	SetAuditCommandHandler(handler AuditCommandHandler)
}

type GroupVersionResourceKind

type GroupVersionResourceKind struct {
	schema.GroupVersionResource
	Kind string
}

type LogLevel

type LogLevel struct {
	Level string
}

type Match added in v3.3.1

type Match struct {
	Namespaces []string
	Kinds      []string
	Labels     []map[string]string
}

type ParentController

type ParentController struct {
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	APIVersion string `json:"api_version"`
	IsWatched  bool   `json:"is_watched"`

	Parent *ParentController `json:"parent"`
}

type RestartHandler

type RestartHandler func() error

Jump to

Keyboard shortcuts

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