Documentation
¶
Overview ¶
Package interfaces provides necessary interfaces and implementations for implementing engine plugins
Index ¶
- type Action
- type ActionCmd
- type ActionOpt
- type ActionType
- type ActionsParams
- type EvalParamsReadWriter
- type EvalParamsReader
- type EvalStatusParams
- func (e *EvalStatusParams) DecorateLogger(l zerolog.Logger) zerolog.Logger
- func (e *EvalStatusParams) GetActionsErr() evalerrors.ActionsError
- func (e *EvalStatusParams) GetActionsOnOff() map[ActionType]ActionOpt
- func (e *EvalStatusParams) GetEvalErr() error
- func (e *EvalStatusParams) GetEvalStatusFromDb() *db.ListRuleEvaluationsByProfileIdRow
- func (e *EvalStatusParams) GetIngestResult() *Result
- func (e *EvalStatusParams) GetProfile() *pb.Profile
- func (e *EvalStatusParams) GetRule() *pb.Profile_Rule
- func (e *EvalStatusParams) GetRuleTypeID() uuid.UUID
- func (e *EvalStatusParams) GetRuleTypeName() string
- func (e *EvalStatusParams) SetActionsErr(ctx context.Context, actionErr evalerrors.ActionsError)
- func (e *EvalStatusParams) SetActionsOnOff(actionsOnOff map[ActionType]ActionOpt)
- func (e *EvalStatusParams) SetEvalErr(err error)
- func (e *EvalStatusParams) SetIngestResult(res *Result)
- type Evaluator
- type Ingester
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface {
Class() ActionType
Type() string
GetOnOffState(*pb.Profile) ActionOpt
Do(ctx context.Context, cmd ActionCmd, setting ActionOpt, entity protoreflect.ProtoMessage,
params ActionsParams, metadata *json.RawMessage) (json.RawMessage, error)
}
Action is the interface for a rule type action
type ActionCmd ¶
type ActionCmd string
ActionCmd is the type that defines what effect an action should have
type ActionOpt ¶
type ActionOpt int
ActionOpt is the type that defines what action to take when remediating
const ( // ActionOptOn means perform the remediation ActionOptOn ActionOpt = iota // ActionOptOff means do not perform the remediation ActionOptOff // ActionOptDryRun means perform a dry run of the remediation ActionOptDryRun // ActionOptUnknown means the action is unknown. This is a sentinel value. ActionOptUnknown )
func ActionOptFromString ¶
ActionOptFromString returns the ActionOpt from a string representation
type ActionType ¶
type ActionType string
ActionType represents the type of action, i.e., remediate, alert, etc.
type ActionsParams ¶
type ActionsParams interface {
EvalParamsReader
GetActionsOnOff() map[ActionType]ActionOpt
GetActionsErr() evalerrors.ActionsError
GetEvalErr() error
GetEvalStatusFromDb() *db.ListRuleEvaluationsByProfileIdRow
GetRuleTypeName() string
GetProfile() *pb.Profile
GetRuleTypeID() uuid.UUID
}
ActionsParams is the interface used for processing a rule type action
type EvalParamsReadWriter ¶ added in v0.0.25
type EvalParamsReadWriter interface {
EvalParamsReader
SetIngestResult(*Result)
}
EvalParamsReadWriter is the interface used for a rule type engine, allows setting the ingestion result
type EvalParamsReader ¶ added in v0.0.25
type EvalParamsReader interface {
GetRule() *pb.Profile_Rule
GetIngestResult() *Result
}
EvalParamsReader is the interface used for a rule type evaluator
type EvalStatusParams ¶
type EvalStatusParams struct {
Result *Result
Profile *pb.Profile
Rule *pb.Profile_Rule
RuleTypeName string
ProfileID uuid.UUID
RepoID uuid.NullUUID
ArtifactID uuid.NullUUID
PullRequestID uuid.NullUUID
ProjectID uuid.UUID
ReleaseID uuid.UUID
PipelineRunID uuid.UUID
TaskRunID uuid.UUID
BuildID uuid.UUID
EntityType db.Entities
RuleTypeID uuid.UUID
EvalStatusFromDb *db.ListRuleEvaluationsByProfileIdRow
ExecutionID uuid.UUID
// contains filtered or unexported fields
}
EvalStatusParams is a helper struct to pass parameters to createOrUpdateEvalStatus to avoid confusion with the parameters' order. Since at the moment, all our entities are bound to a repo and most profiles are expecting a repo, the RepoID parameter is mandatory. For entities other than artifacts, the ArtifactID should be 0 that is translated to NULL in the database.
func (*EvalStatusParams) DecorateLogger ¶ added in v0.0.38
func (e *EvalStatusParams) DecorateLogger(l zerolog.Logger) zerolog.Logger
DecorateLogger decorates the logger with the necessary fields
func (*EvalStatusParams) GetActionsErr ¶
func (e *EvalStatusParams) GetActionsErr() evalerrors.ActionsError
GetActionsErr returns the actions' error
func (*EvalStatusParams) GetActionsOnOff ¶ added in v0.0.25
func (e *EvalStatusParams) GetActionsOnOff() map[ActionType]ActionOpt
GetActionsOnOff returns the actions' on/off state
func (*EvalStatusParams) GetEvalErr ¶
func (e *EvalStatusParams) GetEvalErr() error
GetEvalErr returns the evaluation error
func (*EvalStatusParams) GetEvalStatusFromDb ¶
func (e *EvalStatusParams) GetEvalStatusFromDb() *db.ListRuleEvaluationsByProfileIdRow
GetEvalStatusFromDb returns the evaluation status from the database
func (*EvalStatusParams) GetIngestResult ¶ added in v0.0.20
func (e *EvalStatusParams) GetIngestResult() *Result
GetIngestResult returns the result of the ingestion, if any
func (*EvalStatusParams) GetProfile ¶
func (e *EvalStatusParams) GetProfile() *pb.Profile
GetProfile returns the profile
func (*EvalStatusParams) GetRule ¶
func (e *EvalStatusParams) GetRule() *pb.Profile_Rule
GetRule returns the rule
func (*EvalStatusParams) GetRuleTypeID ¶ added in v0.0.55
func (e *EvalStatusParams) GetRuleTypeID() uuid.UUID
GetRuleTypeID returns the rule type ID
func (*EvalStatusParams) GetRuleTypeName ¶ added in v0.0.55
func (e *EvalStatusParams) GetRuleTypeName() string
GetRuleTypeName returns the rule type name
func (*EvalStatusParams) SetActionsErr ¶
func (e *EvalStatusParams) SetActionsErr(ctx context.Context, actionErr evalerrors.ActionsError)
SetActionsErr sets the actions' error
func (*EvalStatusParams) SetActionsOnOff ¶ added in v0.0.25
func (e *EvalStatusParams) SetActionsOnOff(actionsOnOff map[ActionType]ActionOpt)
SetActionsOnOff sets the actions' on/off state
func (*EvalStatusParams) SetEvalErr ¶
func (e *EvalStatusParams) SetEvalErr(err error)
SetEvalErr sets the evaluation error
func (*EvalStatusParams) SetIngestResult ¶ added in v0.0.20
func (e *EvalStatusParams) SetIngestResult(res *Result)
SetIngestResult sets the result of the ingestion for use later on in the actions
type Ingester ¶
type Ingester interface {
// Ingest does the actual data ingestion for a rule type
Ingest(ctx context.Context, ent protoreflect.ProtoMessage, params map[string]any) (*Result, error)
// GetType returns the type of the ingester
GetType() string
// GetConfig returns the config for the ingester
GetConfig() protoreflect.ProtoMessage
}
Ingester is the interface for a rule type ingester
type Result ¶
type Result struct {
// Object is the object that was ingested. Normally comes from an external
// system like an HTTP server.
Object any
// Fs is the filesystem that was created as a result of the ingestion. This
// is normally used by the evaluator to do rule evaluation. The filesystem
// may be a git repo, or a memory filesystem.
Fs billy.Filesystem
// Storer is the git storer that was created as a result of the ingestion.
// FIXME: It might be cleaner to either wrap both Fs and Storer in a struct
// or pass out the git.Repository structure instead of the storer.
Storer storage.Storer
}
Result is the result of an ingester