Documentation ¶
Index ¶
- Constants
- func IsValidControlStatus(status string) bool
- type ControlRun
- func (r *ControlRun) AsTreeNode() *steampipeconfig.SnapshotTreeNode
- func (r *ControlRun) Finished() bool
- func (*ControlRun) GetChildren() []ExecutionTreeNode
- func (r *ControlRun) GetControlId() string
- func (r *ControlRun) GetError() error
- func (r *ControlRun) GetName() string
- func (r *ControlRun) GetRunStatus() dashboardtypes.RunStatus
- func (r *ControlRun) GetStatusSummary() *controlstatus.StatusSummary
- func (*ControlRun) IsExecutionTreeNode()
- func (*ControlRun) IsSnapshotPanel()
- func (r *ControlRun) MatchTag(key string, value string) bool
- type ControlRunInstance
- type Dimension
- type DimensionColorGenerator
- type ExecutionTree
- func (e *ExecutionTree) AddControl(ctx context.Context, control *modconfig.Control, group *ResultGroup) error
- func (e *ExecutionTree) Execute(ctx context.Context) error
- func (e *ExecutionTree) GetAllTags() []string
- func (*ExecutionTree) IsExportSourceData()
- func (tree *ExecutionTree) PopulateControlRunInstances()
- func (e *ExecutionTree) ShouldIncludeControl(controlName string) bool
- type ExecutionTreeNode
- type GroupSummary
- type ResultGroup
- func (r *ResultGroup) AllTagKeys() []string
- func (r *ResultGroup) AsTreeNode() *steampipeconfig.SnapshotTreeNode
- func (r *ResultGroup) ControlRunCount() int
- func (r *ResultGroup) GetChildGroupByName(name string) *ResultGroup
- func (r *ResultGroup) GetChildren() []ExecutionTreeNode
- func (r *ResultGroup) GetControlRunByName(name string) *ControlRun
- func (r *ResultGroup) GetGroupByName(name string) *ResultGroup
- func (r *ResultGroup) GetName() string
- func (*ResultGroup) IsExecutionTreeNode()
- func (*ResultGroup) IsSnapshotPanel()
- type ResultRow
- type ResultRowInstance
- type ResultRows
Constants ¶
const RootResultGroupName = "root_result_group"
Variables ¶
This section is empty.
Functions ¶
func IsValidControlStatus ¶
Types ¶
type ControlRun ¶
type ControlRun struct { // properties from control ControlId string `json:"-"` FullName string `json:"name"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Documentation string `json:"documentation,omitempty"` Tags map[string]string `json:"tags,omitempty"` Display string `json:"display,omitempty"` Type string `json:"display_type,omitempty"` // this will be serialised under 'properties' Severity string `json:"-"` // "control" NodeType string `json:"panel_type"` // the control being run Control *modconfig.Control `json:"-"` // this is populated by retrieving Control properties with the snapshot tag Properties map[string]any `json:"properties,omitempty"` // control summary Summary *controlstatus.StatusSummary `json:"summary"` RunStatus dashboardtypes.RunStatus `json:"status"` // result rows Rows ResultRows `json:"-"` // the results in snapshot format Data *dashboardtypes.LeafData `json:"data"` // a list of distinct dimension keys from the results of this control DimensionKeys []string `json:"-"` // execution duration Duration time.Duration `json:"-"` // parent result group Parents []*ResultGroup `json:"-"` // execution tree Tree *ExecutionTree `json:"-"` // save run error as string for JSON export RunErrorString string `json:"error,omitempty"` // contains filtered or unexported fields }
ControlRun is a struct representing the execution of a control run. It 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, error)
func (*ControlRun) AsTreeNode ¶
func (r *ControlRun) AsTreeNode() *steampipeconfig.SnapshotTreeNode
AsTreeNode implements ExecutionTreeNode
func (*ControlRun) Finished ¶
func (r *ControlRun) Finished() bool
func (*ControlRun) GetChildren ¶
func (*ControlRun) GetChildren() []ExecutionTreeNode
GetChildren implements ExecutionTreeNode
func (*ControlRun) GetControlId ¶
func (r *ControlRun) GetControlId() string
GetControlId implements ControlRunStatusProvider
func (*ControlRun) GetError ¶
func (r *ControlRun) GetError() error
func (*ControlRun) GetName ¶
func (r *ControlRun) GetName() string
GetName implements ExecutionTreeNode
func (*ControlRun) GetRunStatus ¶
func (r *ControlRun) GetRunStatus() dashboardtypes.RunStatus
GetRunStatus implements ControlRunStatusProvider
func (*ControlRun) GetStatusSummary ¶
func (r *ControlRun) GetStatusSummary() *controlstatus.StatusSummary
GetStatusSummary implements ControlRunStatusProvider
func (*ControlRun) IsExecutionTreeNode ¶
func (*ControlRun) IsExecutionTreeNode()
IsExecutionTreeNode implements ExecutionTreeNode
func (*ControlRun) IsSnapshotPanel ¶
func (*ControlRun) IsSnapshotPanel()
IsSnapshotPanel implements SnapshotPanel
type ControlRunInstance ¶ added in v0.4.1
type ControlRunInstance struct { ControlRun Group *ResultGroup `json:"-"` Rows []*ResultRowInstance }
ControlRunInstance is used to store control runs for each parent (in case of multiple parents)
func NewControlRunInstance ¶ added in v0.4.1
func NewControlRunInstance(cr *ControlRun, parent *ResultGroup) ControlRunInstance
type Dimension ¶
type Dimension struct { Key string `json:"key"` Value string `json:"value"` SqlType string `json:"-"` }
Dimension is a struct representing an attribute returned by a control run. An attribute is stored as a dimension if it's not a standard attribute (reason, resource, status).
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
func (*DimensionColorGenerator) GetDimensionProperties ¶
func (g *DimensionColorGenerator) GetDimensionProperties() []string
type ExecutionTree ¶
type ExecutionTree struct { Root *ResultGroup `json:"root"` // map of all control runs, keyed by FULL name ControlRuns map[string]*ControlRun `json:"-"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` Progress *controlstatus.ControlProgress `json:"progress"` // map of dimension property name to property value to color map DimensionColorGenerator *DimensionColorGenerator `json:"-"` // the current session search path SearchPath []string `json:"-"` Workspace *workspace.Workspace `json:"-"` // ControlRunInstances is a list of control runs for each parent. ControlRunInstances []*ControlRunInstance `json:"-"` // contains filtered or unexported fields }
ExecutionTree is a structure representing the control execution hierarchy
func NewExecutionTree ¶
func NewExecutionTree(ctx context.Context, workspace *workspace.Workspace, client *db_client.DbClient, controlFilter workspace.ResourceFilter, targets ...modconfig.ModTreeItem) (*ExecutionTree, error)
func (*ExecutionTree) AddControl ¶
func (e *ExecutionTree) AddControl(ctx context.Context, control *modconfig.Control, group *ResultGroup) error
AddControl checks whether control should be included in the tree if so, creates a ControlRun, which is added to the parent group
func (*ExecutionTree) GetAllTags ¶
func (e *ExecutionTree) GetAllTags() []string
func (*ExecutionTree) IsExportSourceData ¶
func (*ExecutionTree) IsExportSourceData()
IsExportSourceData implements ExportSourceData
func (*ExecutionTree) PopulateControlRunInstances ¶ added in v0.4.1
func (tree *ExecutionTree) PopulateControlRunInstances()
PopulateControlRunInstances creates a list of ControlRunInstances, by expanding the list of control runs for each parent.
func (*ExecutionTree) ShouldIncludeControl ¶
func (e *ExecutionTree) ShouldIncludeControl(controlName string) bool
type ExecutionTreeNode ¶
type ExecutionTreeNode interface { IsExecutionTreeNode() GetChildren() []ExecutionTreeNode GetName() string AsTreeNode() *steampipeconfig.SnapshotTreeNode }
ExecutionTreeNode is implemented by all control execution tree nodes
type GroupSummary ¶
type GroupSummary struct { Status controlstatus.StatusSummary `json:"status"` Severity map[string]controlstatus.StatusSummary `json:"-"` }
func NewGroupSummary ¶
func NewGroupSummary() *GroupSummary
type ResultGroup ¶
type ResultGroup struct { GroupId string `json:"name" csv:"group_id"` Title string `json:"title,omitempty" csv:"title"` Description string `json:"description,omitempty" csv:"description"` Tags map[string]string `json:"tags,omitempty"` Documentation string `json:"documentation,omitempty"` Display string `json:"display,omitempty"` Type string `json:"type,omitempty"` // the overall summary of the group Summary *GroupSummary `json:"summary"` // child result groups Groups []*ResultGroup `json:"-"` // child control runs ControlRuns []*ControlRun `json:"-"` // list of children stored as controlexecute.ExecutionTreeNode Children []ExecutionTreeNode `json:"-"` Severity map[string]controlstatus.StatusSummary `json:"-"` // "benchmark" NodeType string `json:"panel_type"` // the control tree item associated with this group(i.e. a mod/benchmark) GroupItem modconfig.ModTreeItem `json:"-"` Parent *ResultGroup `json:"-"` Duration time.Duration `json:"-"` // a list of distinct dimension keys from descendant controls DimensionKeys []string `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(ctx context.Context, executionTree *ExecutionTree, treeItem modconfig.ModTreeItem, parent *ResultGroup) (*ResultGroup, error)
NewResultGroup creates a result group from a ModTreeItem
func NewRootResultGroup ¶
func NewRootResultGroup(ctx context.Context, executionTree *ExecutionTree, rootItem modconfig.ModTreeItem) (*ResultGroup, error)
NewRootResultGroup creates a ResultGroup to act as the root node of a control execution tree
func (*ResultGroup) AllTagKeys ¶
func (r *ResultGroup) AllTagKeys() []string
func (*ResultGroup) AsTreeNode ¶
func (r *ResultGroup) AsTreeNode() *steampipeconfig.SnapshotTreeNode
AsTreeNode implements ExecutionTreeNode
func (*ResultGroup) ControlRunCount ¶
func (r *ResultGroup) ControlRunCount() int
func (*ResultGroup) GetChildGroupByName ¶
func (r *ResultGroup) GetChildGroupByName(name string) *ResultGroup
GetChildGroupByName finds a nested child ResultGroup with a specific name
func (*ResultGroup) GetChildren ¶
func (r *ResultGroup) GetChildren() []ExecutionTreeNode
GetChildren implements ExecutionTreeNode
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 an immediate child ResultGroup with a specific name
func (*ResultGroup) GetName ¶
func (r *ResultGroup) GetName() string
GetName implements ExecutionTreeNode
func (*ResultGroup) IsExecutionTreeNode ¶
func (*ResultGroup) IsExecutionTreeNode()
IsExecutionTreeNode implements ExecutionTreeNode
func (*ResultGroup) IsSnapshotPanel ¶
func (*ResultGroup) IsSnapshotPanel()
IsSnapshotPanel implements SnapshotPanel
type ResultRow ¶
type ResultRow struct { // reason for the status Reason string `json:"reason" csv:"reason"` // resource name Resource string `json:"resource" csv:"resource"` // status of the row (ok, info, alarm, error, skip) Status string `json:"status" csv:"status"` // dimensions for this row Dimensions []Dimension `json:"dimensions"` // parent control run Run *ControlRun `json:"-"` // source control Control *modconfig.Control `json:"-" csv:"control_id:UnqualifiedName,control_title:Title,control_description:Description"` }
ResultRow is the result of a control execution for a single resource
func NewResultRow ¶
func NewResultRow(run *ControlRun, row *queryresult.RowResult, cols []*queryresult.ColumnDef) (*ResultRow, error)
func (*ResultRow) AddDimension ¶
func (r *ResultRow) AddDimension(c *queryresult.ColumnDef, val interface{})
AddDimension checks whether a column value is a scalar type, and if so adds it to the Dimensions map
func (*ResultRow) GetDimensionValue ¶
GetDimensionValue returns the value for a dimension key. Returns an empty string with 'false' if not found
type ResultRowInstance ¶ added in v0.4.1
type ResultRowInstance struct { ResultRow ControlRun *ControlRunInstance `json:"-"` }
ResultRowInstance is used in ControlRunInstance, to store the single ResultRow and the ControlRunInstance data
type ResultRows ¶
type ResultRows []*ResultRow
func (ResultRows) ToLeafData ¶
func (r ResultRows) ToLeafData(dimensionSchema map[string]*queryresult.ColumnDef) *dashboardtypes.LeafData
ToLeafData converts the result rows to snapshot data format