pluginkit

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Overview

errors.go contains error definitions to streamline testing and log management

Index

Constants

This section is empty.

Variables

View Source
var (
	CORRUPTION_FOUND = func(mod string) error {
		return errMod("target state may be corrupted! Halting to prevent futher damage. See logs for more information", mod)
	}
	NO_EVALUATION_SUITES = func(mod string) error {
		return errMod("no control evaluations provided by the plugin", mod)
	}
	EVAL_NAME_MISSING = func(mod string) error {
		return errMod("evaluationSuite name must not be empty", mod)
	}
	CONFIG_NOT_INITIALIZED = func(mod string) error {
		return errMod("configuration not initialized", mod)
	}
	NO_ASSESSMENT_STEPS_PROVIDED = func(mod string) error {
		return errMod("assessment steps not provided", mod)
	}
	NO_ASSESSMENT_REQS_PROVIDED = func(mod string) error {
		return errMod("assessment requirements not provided", mod)
	}
	EVAL_SUITE_CRASHED = func(mod string) error {
		return errMod("evaluation suite crashed", mod)
	}
)

Errors with no parameters

View Source
var (
	EVALUATION_ORCHESTRATOR_NAMES_NOT_SET = func(serviceName, pluginName string, mod string) error {
		return errMod(fmt.Errorf("expected service and plugin names to be set. ServiceName='%s' PluginName='%s'", serviceName, pluginName), mod)
	}
	WRITE_FAILED = func(name, err string, mod string) error {
		return errMod(fmt.Errorf("failed to write results for evaluation suite. name: %s, error: %s", name, err), mod)
	}
	BAD_LOADER = func(pluginName string, err error, mod string) error {
		return errMod(fmt.Errorf("failed to load payload for %s: %s", pluginName, err), mod)
	}
	BAD_CATALOG = func(pluginName string, errMsg string, mod string) error {
		return errMod(fmt.Errorf("malformed data in catalog for %s: %s", pluginName, errMsg), mod)
	}
	BAD_EVAL_LOG = func(err error, mod string) error {
		return errMod(fmt.Errorf("failed to setup evaluation log: %w", err), mod)
	}
	BAD_ASSESSMENT_REQS = func(err error, mod string) error {
		return errMod(fmt.Errorf("failed to load assessment requirements from catalog: %w", err), mod)
	}
	BAD_CONFIG = func(err error, mod string) error {
		return errMod(fmt.Errorf("failed to setup config: %w", err), mod)
	}
)

Errors with parameters required

Functions

This section is empty.

Types

type ApplyFunc added in v1.7.0

type ApplyFunc func(interface{}) (interface{}, error)

Prepared function to apply the change

type Change

type Change struct {
	// TargetName is the name or ID of the resource or configuration that is to be changed
	TargetName string `yaml:"target-name"`
	// Description is a human-readable description of the change
	Description string `yaml:"description"`

	// TargetObject is an optional representation of the object that is being changed
	TargetObject interface{} `yaml:"target-object,omitempty"`
	// Applied is true if the change was successfully applied at least once
	Applied bool `yaml:"applied,omitempty"`
	// Reverted is true if the change was successfully reverted and not applied again
	Reverted bool `yaml:"reverted,omitempty"`
	// Error is used if any error occurred during the change
	Error error `yaml:"error,omitempty"`
	// CorruptedState is true if something went wrong during apply or revert, indicating that the system may be in a bad state
	CorruptedState bool `yaml:"bad-state,omitempty"`
	// contains filtered or unexported fields
}

Change is a struct that contains the data and functions associated with a single change to a target resource.

func (*Change) AddFunctions added in v1.7.0

func (c *Change) AddFunctions(applyFunc ApplyFunc, revertFunc RevertFunc)

type ChangeManager added in v1.7.0

type ChangeManager struct {
	// Changes is a map of change names to Change objects, so that multiple changes can be tracked and reused.
	Changes map[string]*Change `yaml:"changes"`
	// Allowed must be set to true before any change can be applied.
	Allowed bool `yaml:"allowed,omitempty"`
	// CorruptedState is true if any change has failed to apply or revert, indicating that the system may be in a bad state.
	CorruptedState bool `yaml:"bad-state,omitempty"`
}

func (*ChangeManager) AddChange added in v1.7.0

func (cm *ChangeManager) AddChange(changeName string, change Change)

func (*ChangeManager) Allow added in v1.7.0

func (cm *ChangeManager) Allow()

Allow marks the change as allowed to be applied.

func (*ChangeManager) Apply added in v1.7.0

func (cm *ChangeManager) Apply(changeName string, targetName string, changeInput any) (success bool, target any)

Apply the prepared function for the change. It will not apply the change if it is not allowed, or if it has already been applied and not reverted.

func (*ChangeManager) Revert added in v1.7.0

func (cm *ChangeManager) Revert(changeName string)

func (*ChangeManager) RevertAll added in v1.7.0

func (cm *ChangeManager) RevertAll()

type DataLoader added in v1.0.1

type DataLoader func(*config.Config) (any, error)

type EvaluationOrchestrator added in v1.3.0

type EvaluationOrchestrator struct {
	ServiceName       string             `yaml:"service-name"`
	PluginName        string             `yaml:"plugin-name"`
	PluginUri         string             `yaml:"plugin-uri"`
	PluginVersion     string             `yaml:"plugin-version"`
	Payload           any                `yaml:"payload,omitempty"`
	Evaluation_Suites []*EvaluationSuite `yaml:"evaluation-suites"` // EvaluationSuite is a map of evaluations to their catalog names
	// contains filtered or unexported fields
}

The evaluation orchestrator gets the plugin in position to execute the specified evaluation suites

func (*EvaluationOrchestrator) AddEvaluationSuite added in v1.3.0

func (v *EvaluationOrchestrator) AddEvaluationSuite(catalogId string, loader DataLoader, steps map[string][]layer4.AssessmentStep) error

func (*EvaluationOrchestrator) AddLoader added in v1.10.0

func (v *EvaluationOrchestrator) AddLoader(loader DataLoader)

func (*EvaluationOrchestrator) AddReferenceCatalogs added in v1.10.0

func (v *EvaluationOrchestrator) AddReferenceCatalogs(dataDir string, files embed.FS) error

func (*EvaluationOrchestrator) AddRequiredVars added in v1.7.0

func (v *EvaluationOrchestrator) AddRequiredVars(vars []string)

func (*EvaluationOrchestrator) Mobilize added in v1.3.0

func (v *EvaluationOrchestrator) Mobilize() error

func (*EvaluationOrchestrator) WriteResults added in v1.3.0

func (v *EvaluationOrchestrator) WriteResults() error

type EvaluationSuite added in v1.0.0

type EvaluationSuite struct {
	Name   string        // Name is the name of the suite
	Result layer4.Result // Result is Passed if all evaluations in the suite passed

	CatalogId string `yaml:"catalog-id"` // CatalogId associates this suite with a catalog
	StartTime string `yaml:"start-time"` // StartTime is the time the plugin started
	EndTime   string `yaml:"end-time"`   // EndTime is the time the plugin ended

	CorruptedState bool `yaml:"corrupted-state"` // CorruptedState is true if any testSet failed to revert at the end of the evaluation

	EvaluationLog layer4.EvaluationLog `yaml:"control-evaluations"` // EvaluationLog is a slice of evaluations to be executed
	// contains filtered or unexported fields
}

EvaluationSuite is a struct that contains the results of all EvaluationLog executions Exported fields will be used in the final YAML or JSON output documents

func (*EvaluationSuite) AddChangeManager added in v1.7.0

func (e *EvaluationSuite) AddChangeManager(cm *ChangeManager)

AddChangeManager sets up the change manager for the evaluation suite

func (*EvaluationSuite) Evaluate added in v1.0.0

func (e *EvaluationSuite) Evaluate(serviceName string) error

Execute is used to execute a list of EvaluationLog provided by a Plugin and customized by user config Name is an arbitrary string that will be used to identify the EvaluationSuite

func (*EvaluationSuite) GetAssessmentRequirements added in v1.7.0

func (e *EvaluationSuite) GetAssessmentRequirements() (map[string]*layer2.AssessmentRequirement, error)

type RevertFunc added in v1.7.0

type RevertFunc func(interface{}) error

Prepared function to revert the change after it has been applied

type TestSet

type TestSet func() (result layer4.ControlEvaluation)

Jump to

Keyboard shortcuts

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