Documentation
¶
Overview ¶
errors.go contains error definitions to streamline testing and log management
Index ¶
- Variables
- type ApplyFunc
- type Change
- type ChangeManager
- func (cm *ChangeManager) AddChange(changeName string, change Change)
- func (cm *ChangeManager) Allow()
- func (cm *ChangeManager) Apply(changeName string, targetName string, changeInput any) (success bool, target any)
- func (cm *ChangeManager) Revert(changeName string)
- func (cm *ChangeManager) RevertAll()
- type DataLoader
- type EvaluationOrchestrator
- type EvaluationSuite
- type PayloadTypeExample
- type RevertFunc
- type TestSet
Constants ¶
This section is empty.
Variables ¶
var ( CORRUPTION_FOUND = func() error { return errors.New("target state may be corrupted! Halting to prevent futher damage. See logs for more information") } NO_EVALUATION_SUITES = func() error { return errors.New("no control evaluations provided by the plugin") } EVAL_NAME_MISSING = func() error { return errors.New("evaluationSuite name must not be empty") } CONFIG_NOT_INITIALIZED = func() error { return errors.New("configuration not initialized") } NO_ASSESSMENT_STEPS_PROVIDED = func() error { return errors.New("assessment steps not provided") } NO_ASSESSMENT_REQS_PROVIDED = func() error { return errors.New("assessment requirements not provided") } )
Errors with no parameters
var ( EVALUATION_ORCHESTRATOR_NAMES_NOT_SET = func(serviceName, pluginName string) error { return fmt.Errorf("expected service and plugin names to be set. ServiceName='%s' PluginName='%s'", serviceName, pluginName) } WRITE_FAILED = func(name, err string) error { return fmt.Errorf("failed to write results for evaluation suite. name: %s, error: %s", name, err) } BAD_LOADER = func(pluginName string, err error) error { return fmt.Errorf("failed to load payload for %s: %s", pluginName, err) } BAD_CATALOG = func(pluginName string, errMsg string) error { return fmt.Errorf("malformed data in catalog for %s: %s", pluginName, errMsg) } NO_EVAL_LOG = func(err error) error { return fmt.Errorf("failed to setup evaluation log: %w", err) } BAD_ASSESSMENT_REQS = func(err error) error { return fmt.Errorf("failed to load assessment requirements from catalog: %w", err) } )
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 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 interface{}
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(loader DataLoader, steps map[string][]layer4.AssessmentStep, catalog *layer2.Catalog)
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 PayloadTypeExample ¶ added in v1.0.0
type PayloadTypeExample struct {
CustomPayloadField bool
}
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)