Documentation
¶
Index ¶
- Constants
- func IsValidControlStatus(status string) bool
- type ControlProgressRenderer
- type ControlRun
- type ControlRunStatus
- type Dimension
- type DimensionColorGenerator
- type ExecutionTree
- type GroupSummary
- type ResultGroup
- func (r *ResultGroup) AddResult(run *ControlRun)
- func (r *ResultGroup) Execute(ctx context.Context, client *db.Client) int
- func (r *ResultGroup) GetControlRunByName(name string) *ControlRun
- func (r *ResultGroup) GetGroupByName(name string) *ResultGroup
- func (r *ResultGroup) PopulateGroupMap(groupMap map[string]*ResultGroup)
- type ResultRow
- type StatusSummary
Constants ¶
const ( ControlOk = "ok" ControlAlarm = "alarm" ControlSkip = "skip" ControlInfo = "info" ControlError = "error" )
const RootResultGroupName = "root_result_group"
Variables ¶
This section is empty.
Functions ¶
func IsValidControlStatus ¶
Types ¶
type ControlProgressRenderer ¶
type ControlProgressRenderer struct {
// contains filtered or unexported fields
}
func NewControlProgressRenderer ¶
func NewControlProgressRenderer(total int) *ControlProgressRenderer
func (*ControlProgressRenderer) Finish ¶
func (p *ControlProgressRenderer) Finish()
func (*ControlProgressRenderer) OnComplete ¶
func (p *ControlProgressRenderer) OnComplete()
func (*ControlProgressRenderer) OnControlStart ¶
func (p *ControlProgressRenderer) OnControlStart(control *modconfig.Control)
func (*ControlProgressRenderer) OnError ¶
func (p *ControlProgressRenderer) OnError()
func (*ControlProgressRenderer) Start ¶
func (p *ControlProgressRenderer) Start()
type ControlRun ¶
type ControlRun struct {
Error error `json:"-"`
// the parent control
Control *modconfig.Control `json:"-"`
Summary StatusSummary `json:"-"`
// the result
ControlId string `json:"control_id"`
Description string `json:"description"`
Severity string `json:"severity"`
Tags map[string]string `json:"tags"`
Title string `json:"title"`
Rows []*ResultRow `json:"results"`
// contains filtered or unexported fields
}
ControlRun is a struct representing a a control run - will contain one or more result items (i.e. for one or more resources)
func NewControlRun ¶
func NewControlRun(control *modconfig.Control, group *ResultGroup, executionTree *ExecutionTree) *ControlRun
func (*ControlRun) Finished ¶
func (r *ControlRun) Finished() bool
func (*ControlRun) GetRunStatus ¶
func (r *ControlRun) GetRunStatus() ControlRunStatus
func (*ControlRun) SetError ¶
func (r *ControlRun) SetError(err error)
type ControlRunStatus ¶
type ControlRunStatus uint32
const ( ControlRunReady ControlRunStatus = 1 << iota ControlRunStarted ControlRunComplete ControlRunError )
type DimensionColorGenerator ¶
type DimensionColorGenerator struct {
Map map[string]map[string]uint8
// contains filtered or unexported fields
}
func NewDimensionColorGenerator ¶
func NewDimensionColorGenerator(startingRow, startingColumn uint8) (*DimensionColorGenerator, error)
NewDimensionColorGenerator creates a new NewDimensionColorGenerator
type ExecutionTree ¶
type ExecutionTree struct {
Root *ResultGroup
// map of dimension property name to property value to color map
DimensionColorGenerator *DimensionColorGenerator
// contains filtered or unexported fields
}
ExecutionTree is a structure representing the control result hierarchy
func NewExecutionTree ¶
func NewExecutionTree(ctx context.Context, workspace *workspace.Workspace, client *db.Client, arg string) (*ExecutionTree, error)
NewExecutionTree creates a result group from a ControlTreeItem
func (*ExecutionTree) AddControl ¶
func (e *ExecutionTree) AddControl(control *modconfig.Control, group *ResultGroup)
AddControl checks whether control should be included in the tree if so, creates a ControlRun, which is added to the parent group
func (*ExecutionTree) ShouldIncludeControl ¶
func (e *ExecutionTree) ShouldIncludeControl(controlName string) bool
type GroupSummary ¶
type GroupSummary struct {
Status StatusSummary `json:"status"`
}
type ResultGroup ¶
type ResultGroup struct {
GroupId string `json:"group_id"`
Title string `json:"title"`
Description string `json:"description"`
Tags map[string]string `json:"tags"`
Summary GroupSummary `json:"summary"`
Groups []*ResultGroup `json:"groups"`
ControlRuns []*ControlRun `json:"controls"`
// the control tree item associated with this group(i.e. a mod/benchmark)
GroupItem modconfig.ControlTreeItem `json:"-"`
// contains filtered or unexported fields
}
ResultGroup is a struct representing a grouping of control results It may correspond to a Benchmark, or some other arbitrary grouping
func NewResultGroup ¶
func NewResultGroup(executionTree *ExecutionTree, treeItem modconfig.ControlTreeItem, parent *ResultGroup) *ResultGroup
NewResultGroup creates a result group from a ControlTreeItem
func NewRootResultGroup ¶
func NewRootResultGroup(executionTree *ExecutionTree, rootItems ...modconfig.ControlTreeItem) *ResultGroup
NewRootResultGroup creates a ResultGroup to act as the root node of a control execution tree
func (*ResultGroup) AddResult ¶
func (r *ResultGroup) AddResult(run *ControlRun)
AddResult adds a result to the list, updates the summary status (this also updates the status of our parent, all the way up the tree)
func (*ResultGroup) GetControlRunByName ¶
func (r *ResultGroup) GetControlRunByName(name string) *ControlRun
GetControlRunByName finds a child ControlRun with a specific control name
func (*ResultGroup) GetGroupByName ¶
func (r *ResultGroup) GetGroupByName(name string) *ResultGroup
GetGroupByName finds a child ResultGroup with a specific name
func (*ResultGroup) PopulateGroupMap ¶
func (r *ResultGroup) PopulateGroupMap(groupMap map[string]*ResultGroup)
PopulateGroupMap mutates the passed in a map to return all child result groups
type ResultRow ¶
type ResultRow struct {
Reason string `json:"reason"`
Resource string `json:"resource"`
Status string `json:"status"`
Dimensions []Dimension `json:"dimensions"`
Control *modconfig.Control `json:"-"`
}
ResultRow is the result of a control execution for a single resource
func NewResultRow ¶
func NewResultRow(control *modconfig.Control, row *queryresult.RowResult, colTypes []*sql.ColumnType) (*ResultRow, error)
func (*ResultRow) AddDimension ¶
func (r *ResultRow) AddDimension(c *sql.ColumnType, val interface{})
AddDimension checks whether a column value is a scalar type, and if so adds it to the Dimensions map
type StatusSummary ¶
type StatusSummary struct {
Alarm int `json:"alarm"`
Ok int `json:"ok"`
Info int `json:"info"`
Skip int `json:"skip"`
Error int `json:"error"`
}
StatusSummary is a struct containing the counts of each possible control status
func (*StatusSummary) FailedCount ¶
func (s *StatusSummary) FailedCount() int
func (*StatusSummary) TotalCount ¶
func (s *StatusSummary) TotalCount() int