Documentation
¶
Overview ¶
Package execution provides domain models for execution results.
Index ¶
- Constants
- type ControlResult
- type Evidence
- type EvidenceMeta
- type ExecutionResult
- func (r *ExecutionResult) AddControlResult(cr ControlResult)
- func (r *ExecutionResult) AddPartialResult(cr ControlResult)
- func (r *ExecutionResult) Finalize()
- func (r *ExecutionResult) GetControlResultByID(id string) *ControlResult
- func (r *ExecutionResult) GetControlStatus(id string) (values.Status, bool)
- func (r *ExecutionResult) GetID() values.ExecutionID
- func (r *ExecutionResult) GetVersion() int
- func (r *ExecutionResult) IncrementVersion()
- func (r *ExecutionResult) IsComplete(expectedControlCount int) bool
- type ExpectationResult
- type GreedyTruncator
- type ObservationResult
- type PluginError
- type ResultSummary
- type TruncationStrategy
Constants ¶
const DefaultMaxEvidenceSize = 1 * 1024 * 1024
DefaultMaxEvidenceSize is the default limit for evidence size (1MB).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControlResult ¶
type ControlResult struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Severity string `json:"severity,omitempty" yaml:"severity,omitempty"`
Status values.Status `json:"status" yaml:"status"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
SkipReason string `json:"skip_reason,omitempty" yaml:"skip_reason,omitempty"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
ObservationResults []ObservationResult `json:"observations" yaml:"observations"`
Index int `json:"index" yaml:"index"`
Duration time.Duration `json:"duration_ms" yaml:"duration_ms"`
}
ControlResult represents the result of executing a single control.
type Evidence ¶
type Evidence struct {
Timestamp time.Time
Error *PluginError
Data map[string]interface{}
Raw *string
Status bool
}
Evidence represents observation results (proof of compliance state). This is a core domain concept representing the evidence collected during a check.
type EvidenceMeta ¶
type EvidenceMeta struct {
Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
OriginalSize int `json:"original_size_bytes" yaml:"original_size_bytes"`
TruncatedAt int `json:"truncated_at_bytes" yaml:"truncated_at_bytes"`
Truncated bool `json:"truncated" yaml:"truncated"`
}
EvidenceMeta contains metadata about evidence truncation.
type ExecutionResult ¶
type ExecutionResult struct {
StartTime time.Time `json:"start_time" yaml:"start_time"`
EndTime time.Time `json:"end_time" yaml:"end_time"`
RegletVersion string `json:"reglet_version,omitempty" yaml:"reglet_version,omitempty"`
ProfileName string `json:"profile_name" yaml:"profile_name"`
ProfileVersion string `json:"profile_version" yaml:"profile_version"`
Controls []ControlResult `json:"controls" yaml:"controls"`
Summary ResultSummary `json:"summary" yaml:"summary"`
Version int `json:"version" yaml:"version"`
Duration time.Duration `json:"duration_ms" yaml:"duration_ms"`
ExecutionID values.ExecutionID `json:"execution_id" yaml:"execution_id"`
// contains filtered or unexported fields
}
ExecutionResult represents the complete result of executing a profile.
func NewExecutionResult ¶
func NewExecutionResult(profileName, profileVersion string) *ExecutionResult
NewExecutionResult creates a new execution result.
func NewExecutionResultWithID ¶
func NewExecutionResultWithID(id values.ExecutionID, profileName, profileVersion string) *ExecutionResult
NewExecutionResultWithID creates a new execution result with a specific ID.
func (*ExecutionResult) AddControlResult ¶
func (r *ExecutionResult) AddControlResult(cr ControlResult)
AddControlResult adds a control result to the execution result. Thread-safe for concurrent calls during parallel execution.
func (*ExecutionResult) AddPartialResult ¶
func (r *ExecutionResult) AddPartialResult(cr ControlResult)
AddPartialResult adds a control result from a partial execution (e.g. worker).
func (*ExecutionResult) Finalize ¶
func (r *ExecutionResult) Finalize()
Finalize completes the execution result and calculates the summary. Controls are sorted by their original definition order for deterministic output.
func (*ExecutionResult) GetControlResultByID ¶
func (r *ExecutionResult) GetControlResultByID(id string) *ControlResult
GetControlResultByID returns a pointer to the control result with the given ID, or nil if not found. Thread-safe.
func (*ExecutionResult) GetControlStatus ¶
func (r *ExecutionResult) GetControlStatus(id string) (values.Status, bool)
GetControlStatus returns the status of a control by ID. Returns the status and a boolean indicating if the control was found. Thread-safe.
func (*ExecutionResult) GetID ¶
func (r *ExecutionResult) GetID() values.ExecutionID
GetID returns the execution ID.
func (*ExecutionResult) GetVersion ¶
func (r *ExecutionResult) GetVersion() int
GetVersion returns the optimistic locking version.
func (*ExecutionResult) IncrementVersion ¶
func (r *ExecutionResult) IncrementVersion()
IncrementVersion increments the version counter.
func (*ExecutionResult) IsComplete ¶
func (r *ExecutionResult) IsComplete(expectedControlCount int) bool
IsComplete checks if the number of executed controls matches the expected count.
type ExpectationResult ¶
type ExpectationResult struct {
Expression string `json:"expression" yaml:"expression"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Passed bool `json:"passed" yaml:"passed"`
}
ExpectationResult represents the result of evaluating a single expectation expression. The Message field provides human-readable context about failures, constructed by the StatusAggregator which has full access to the evidence and expression evaluation context.
type GreedyTruncator ¶
type GreedyTruncator struct{}
GreedyTruncator implements a simple greedy truncation strategy. It truncates large string fields or replaces large complex objects until the size is reduced.
func (*GreedyTruncator) Truncate ¶
func (t *GreedyTruncator) Truncate(data map[string]interface{}, limit int) (map[string]interface{}, *EvidenceMeta, error)
Truncate returns a truncated copy of the evidence if it exceeds the limit.
type ObservationResult ¶
type ObservationResult struct {
RawError error `json:"-" yaml:"-"`
Config map[string]interface{} `json:"config" yaml:"config"`
Evidence *Evidence `json:"evidence,omitempty" yaml:"evidence,omitempty"`
EvidenceMeta *EvidenceMeta `json:"evidence_meta,omitempty" yaml:"evidence_meta,omitempty"`
Error *PluginError `json:"error,omitempty" yaml:"error,omitempty"`
Plugin string `json:"plugin" yaml:"plugin"`
Status values.Status `json:"status" yaml:"status"`
Expectations []ExpectationResult `json:"expectations,omitempty" yaml:"expectations,omitempty"`
Duration time.Duration `json:"duration_ms" yaml:"duration_ms"`
}
ObservationResult represents the result of executing a single observation.
type PluginError ¶
PluginError represents an error from plugin execution. This is a domain concept representing a failure in collecting evidence.
func (*PluginError) Error ¶
func (e *PluginError) Error() string
Error implements the error interface
type ResultSummary ¶
type ResultSummary struct {
TotalControls int `json:"total_controls" yaml:"total_controls"`
PassedControls int `json:"passed_controls" yaml:"passed_controls"`
FailedControls int `json:"failed_controls" yaml:"failed_controls"`
ErrorControls int `json:"error_controls" yaml:"error_controls"`
SkippedControls int `json:"skipped_controls" yaml:"skipped_controls"`
TotalObservations int `json:"total_observations" yaml:"total_observations"`
PassedObservations int `json:"passed_observations" yaml:"passed_observations"`
FailedObservations int `json:"failed_observations" yaml:"failed_observations"`
ErrorObservations int `json:"error_observations" yaml:"error_observations"`
}
ResultSummary provides aggregate statistics about the execution.
type TruncationStrategy ¶
type TruncationStrategy interface {
Truncate(data map[string]interface{}, limit int) (map[string]interface{}, *EvidenceMeta, error)
}
TruncationStrategy defines how evidence should be truncated when it exceeds limits.