report

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Fail  Status = "fail"
	Warn  Status = "warn"
	Error Status = "error"
	Pass  Status = "pass"
	Skip  Status = "skip"

	Low    Severity = "low"
	Medium Severity = "medium"
	High   Severity = "high"
)

Enums for predefined values from the PolicyReport spec

View Source
const (
	DefaultPriority = iota
	DebugPriority
	InfoPriority
	WarningPriority
	CriticalPriority
	ErrorPriority
)

Internal Priority definitions and weighting

Variables

This section is empty.

Functions

This section is empty.

Types

type PolicyReport

type PolicyReport struct {
	Name              string
	Namespace         string
	Results           map[string]Result
	Summary           Summary
	CreationTimestamp time.Time
}

PolicyReport from the PolicyReport spec wgpolicyk8s.io/v1alpha1.PolicyReport

func (PolicyReport) GetIdentifier

func (pr PolicyReport) GetIdentifier() string

GetIdentifier returns a global unique PolicyReport identifier

func (PolicyReport) GetNewResults

func (pr PolicyReport) GetNewResults(or PolicyReport) []Result

GetNewResults filters already existing Results from the old PolicyReport and returns only the diff with new Results

func (PolicyReport) GetType

func (pr PolicyReport) GetType() Type

GetType returns the Type of the Report

func (PolicyReport) HasResult

func (pr PolicyReport) HasResult(id string) bool

HasResult returns if the Report has an Rusult with the given ID

func (PolicyReport) ResultHash

func (pr PolicyReport) ResultHash() string

ResultHash generates a has of the current result set

type PolicyReportCallback

type PolicyReportCallback = func(watch.EventType, PolicyReport, PolicyReport)

PolicyReportCallback is called whenever a new PolicyReport comes in

type PolicyReportStore

type PolicyReportStore struct {
	// contains filtered or unexported fields
}

PolicyReportStore caches the latest version of an PolicyReport

func NewPolicyReportStore

func NewPolicyReportStore() *PolicyReportStore

NewPolicyReportStore construct a PolicyReportStore

func (*PolicyReportStore) Add

func (s *PolicyReportStore) Add(r PolicyReport)

Add a PolicyReport to the Store

func (*PolicyReportStore) Get

func (s *PolicyReportStore) Get(rType Type, id string) (PolicyReport, bool)

Get an PolicyReport by Type and ID

func (*PolicyReportStore) List

func (s *PolicyReportStore) List(rType Type) []PolicyReport

List all PolicyReports of the given Type

func (*PolicyReportStore) Remove

func (s *PolicyReportStore) Remove(rType Type, id string)

Remove a PolicyReport with the given Type and ID from the Store

type PolicyResultCallback

type PolicyResultCallback = func(Result, bool)

PolicyResultCallback is called whenever a new PolicyResult comes in

type PolicyResultClient

type PolicyResultClient interface {
	// RegisterCallback register Handlers called on each PolicyReport watch.Event
	RegisterCallback(PolicyReportCallback)
	// RegisterPolicyResultCallback register Handlers called on each PolicyReport watch.Event for each changed PolicyResult
	RegisterPolicyResultCallback(PolicyResultCallback)
	// RegisterPolicyResultWatcher register a handler for ClusterPolicyReports and PolicyReports who call the registered PolicyResultCallbacks
	RegisterPolicyResultWatcher(skipExisting bool)
	// StartWatching calls the WatchAPI, waiting for incoming PolicyReport watch.Events and call the registered Handlers
	StartWatching(ctx context.Context) error
	// GetFoundResources as Map of Names
	GetFoundResources() map[string]string
}

PolicyResultClient watches for PolicyReport Events and executes registered callback

type Priority

type Priority int

Priority Enum for internal Result weighting

func NewPriority

func NewPriority(p string) Priority

NewPriority creates a new Priority based an its string representation

func PriorityFromSeverity

func PriorityFromSeverity(s Severity) Priority

PriorityFromSeverity creates a Priority based on a Severity

func PriorityFromStatus

func PriorityFromStatus(s Status) Priority

PriorityFromStatus creates a Priority based on a Status

func (Priority) MarshalJSON

func (p Priority) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Priority) String

func (p Priority) String() string

String maps the internal weighting of Priorities to a String representation

type Resource

type Resource struct {
	APIVersion string
	Kind       string
	Name       string
	Namespace  string
	UID        string
}

Resource from the Kubernetes spec k8s.io/api/core/v1.ObjectReference

type Result

type Result struct {
	Message    string
	Policy     string
	Rule       string
	Priority   Priority
	Status     Status
	Severity   Severity `json:",omitempty"`
	Category   string   `json:",omitempty"`
	Source     string   `json:"source,omitempty"`
	Scored     bool
	Timestamp  time.Time
	Resource   Resource
	Properties map[string]string
}

Result from the PolicyReport spec wgpolicyk8s.io/v1alpha1.PolicyReportResult

func (Result) GetIdentifier

func (r Result) GetIdentifier() string

GetIdentifier returns a global unique Result identifier

func (Result) HasResource

func (r Result) HasResource() bool

HasResource checks if the result has an valid Resource

type Severity

type Severity = string

Severity Enum defined for PolicyReport

type Status

type Status = string

Status Enum defined for PolicyReport

type Summary

type Summary struct {
	Pass  int
	Skip  int
	Warn  int
	Error int
	Fail  int
}

Summary from the PolicyReport spec wgpolicyk8s.io/v1alpha1.PolicyReportSummary

type Type added in v1.10.0

type Type = string

Type Enum defined for PolicyReport

const (
	PolicyReportType        Type = "PolicyReport"
	ClusterPolicyReportType Type = "ClusterPolicyReport"
)

ReportType Enum

Jump to

Keyboard shortcuts

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