Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateExecutionResultFile(result *ExecutionResult, outputDir string) error
- type Check
- type Configuration
- type ExecuteRequest
- type ExecutionResult
- type Executor
- type Manager
- type ManagerImpl
- type Meta
- type Policies
- type Policy
- type Provider
- type QueryResult
- type QueryType
- type Update
- type UpdateCallback
- type View
Constants ¶
View Source
const (
CloudQueryOrg = "cloudquery-policies"
)
Variables ¶
View Source
var ErrPolicyOrQueryNotFound = errors.New("selected policy/query not found")
Functions ¶
func GenerateExecutionResultFile ¶ added in v0.16.0
func GenerateExecutionResultFile(result *ExecutionResult, outputDir string) error
Types ¶
type Configuration ¶ added in v0.16.0
type Configuration struct {
Providers []*Provider `hcl:"provider,block"`
}
type ExecuteRequest ¶
type ExecuteRequest struct {
// Policy is the policy that should be executed.
Policy *Policy
// StopOnFailure if true policy execution will stop on first failure
StopOnFailure bool
// ProviderVersions describes current versions of providers in use.
ProviderVersions map[string]*version.Version
// UpdateCallback is the console ui update callback
UpdateCallback UpdateCallback
}
ExecuteRequest is a request that triggers policy execution.
type ExecutionResult ¶
type ExecutionResult struct {
// PolicyName is the running policy name
PolicyName string
// ExecutionTime is when the policy has been started
ExecutionTime time.Time
// True if all policies have passed
Passed bool
// List of all query result sets
Results []*QueryResult
// Error is the reason the execution failed
Error string
// List of loaded Policies
LoadedPolicies Policies
}
ExecutionResult contains all policy execution results.
type Executor ¶
type Executor struct {
PolicyPath []string
// contains filtered or unexported fields
}
Executor implements the execution framework.
func NewExecutor ¶
func NewExecutor(conn execution.QueryExecer, log hclog.Logger, progressUpdate UpdateCallback) *Executor
NewExecutor creates a new executor.
func (*Executor) Execute ¶ added in v0.19.0
func (e *Executor) Execute(ctx context.Context, req *ExecuteRequest, policy *Policy) (*ExecutionResult, error)
Execute executes given policy and the related sub queries/views.
type Manager ¶
type Manager interface {
// Run the given policy.
Run(ctx context.Context, request *ExecuteRequest) (*ExecutionResult, error)
// Load the policy
Load(ctx context.Context, policy *Policy) (*Policy, error)
}
Manager is the interface that describes the interaction with the policy hub. Implemented by ManagerImpl.
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl is the manager implementation struct.
func NewManager ¶
func NewManager(policyDir string, pool execution.QueryExecer, logger hclog.Logger) *ManagerImpl
NewManager returns a new manager instance.
func (*ManagerImpl) Run ¶ added in v0.16.0
func (m *ManagerImpl) Run(ctx context.Context, request *ExecuteRequest) (*ExecutionResult, error)
type Meta ¶ added in v0.19.0
type Policy ¶
type Policy struct {
// Name of the policy
Name string `hcl:"name,label"`
// Short human-readable title about the policy
Title string `hcl:"title,optional"`
// Full documentation about the policy, this will be shown in the hub
Doc string `hcl:"doc,optional"`
Config *Configuration `hcl:"configuration,block"`
Policies Policies `hcl:"policy,block"`
Checks []*Check `hcl:"check,block"`
Views []*View `hcl:"view,block"`
// Link to policy in filesystem/hub/git etc' to use, if source flag is set, all other attributes aren't allowed.
Source string `hcl:"source,optional"`
// contains filtered or unexported fields
}
func DecodePolicy ¶ added in v0.19.0
func DecodePolicyBlock ¶ added in v0.19.0
func DecodePolicyBlock(b *hcl.Block, ctx *hcl.EvalContext) (*Policy, hcl.Diagnostics)
func DetectPolicy ¶ added in v0.19.0
func (Policy) TotalQueries ¶ added in v0.19.0
type QueryResult ¶
type QueryResult struct {
Name string `json:"name"`
Description string `json:"description"`
Columns []string `json:"result_headers"`
Data [][]interface{} `json:"result_rows"`
Type QueryType `json:"type"`
Passed bool `json:"check_passed"`
}
QueryResult contains the result information from an executed query.
type Update ¶ added in v0.16.0
type Update struct {
// PolicyID is the name of the policy that is being updated.
PolicyName string
// Version is the policy version.
Version string
// Source policy was fetched from
Source string
// FinishedQueries is the number queries that have finished evaluating
FinishedQueries int
// QueriesCount is the amount of queries collected so far
QueriesCount int
// Error if any returned by the provider
Error string
}
type UpdateCallback ¶ added in v0.16.0
type UpdateCallback func(update Update)
Click to show internal directories.
Click to hide internal directories.