Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithLogger(ctx context.Context, logger Logger) context.Context
- func NewDefaultPanicHandler() (*defaultPanicHandler, error)
- func NewNoopLogger() *noopLogger
- func ParsestoreType(name string) (storeType, error)
- func RunEnricher(ctx context.Context, enricher Enricher, opts ...RunnerOption) error
- func RunFilter(ctx context.Context, filter Filter, opts ...RunnerOption) error
- func RunReporter(ctx context.Context, reporter Reporter, opts ...RunnerOption) error
- func RunScanner(ctx context.Context, scanner Scanner, opts ...RunnerOption) error
- func RunTarget(ctx context.Context, target Target, opts ...RunnerOption) error
- type Closer
- type Enricher
- type ErrInvalidRunnerConfig
- type ErrRunnerOption
- type Filter
- type Logger
- type PanicHandler
- type Reader
- type Reporter
- type RunnerConfig
- type RunnerConfigLogging
- type RunnerConfigLoggingLevel
- type RunnerConfigOption
- type RunnerOption
- type Scanner
- type Storer
- type Target
- type Updater
- type Validator
- type Writer
Constants ¶
const (
// StoreTypeLocal is a storeType of type local.
StoreTypeLocal storeType = "local"
)
Variables ¶
var ErrInvalidRunnerConfigLoggingLevel = errors.New("not a valid RunnerConfigLoggingLevel")
var ErrInvalidstoreType = errors.New("not a valid storeType")
Functions ¶
func ContextWithLogger ¶
ContextWithLogger returns a context with a logger in its values for reusability.
func NewDefaultPanicHandler ¶
func NewDefaultPanicHandler() (*defaultPanicHandler, error)
NewDefaultPanicHandler returns a new default panic handler.
func NewNoopLogger ¶
func NewNoopLogger() *noopLogger
NewNoopLogger can be used to get a NOOP Logger.
func ParsestoreType ¶
ParsestoreType attempts to convert a string to a storeType.
func RunEnricher ¶
func RunEnricher(ctx context.Context, enricher Enricher, opts ...RunnerOption) error
RunEnricher runs an enricher after initialising the run context.
func RunFilter ¶
func RunFilter(ctx context.Context, filter Filter, opts ...RunnerOption) error
RunFilter runs a filter after initialising the run context.
func RunReporter ¶
func RunReporter(ctx context.Context, reporter Reporter, opts ...RunnerOption) error
RunReporter runs a reporter after initialising the run context.
func RunScanner ¶
func RunScanner(ctx context.Context, scanner Scanner, opts ...RunnerOption) error
RunScanner runs a scanner after initialising the run context.
Types ¶
type Closer ¶
type Closer interface {
// Close can be implemented to gracefully close component dependencies.
Close(context.Context) error
}
Closer allows to define behaviours to close component dependencies gracefully.
type Enricher ¶
type Enricher interface {
// Annotate enriches vulnerability findings by some criteria.
Annotate(ctx context.Context, findings []*ocsf.VulnerabilityFinding) ([]*ocsf.VulnerabilityFinding, error)
}
Enricher allows enriching vulnerability findings by some criteria.
type ErrInvalidRunnerConfig ¶
ErrInvalidRunnerConfig is returned when a configuration is invalid.
func (ErrInvalidRunnerConfig) Error ¶
func (er ErrInvalidRunnerConfig) Error() string
type ErrRunnerOption ¶
ErrRunnerOption is returned when a supplied RunnerOption is not valid.
func (ErrRunnerOption) Error ¶
func (er ErrRunnerOption) Error() string
type Filter ¶
type Filter interface {
// Filter returns filtered findings from the supplied ones applying some criteria.
// It returns false if no findings have been filtered out.
Filter(ctx context.Context, findings []*ocsf.VulnerabilityFinding) ([]*ocsf.VulnerabilityFinding, bool, error)
}
Filter allows filtering out vulnerability findings by some criteria.
type Logger ¶
type Logger interface {
Debug(msg string, keyvals ...any)
Info(msg string, keyvals ...any)
Warn(msg string, keyvals ...any)
Error(msg string, keyvals ...any)
With(args ...any) Logger
}
Logger exposes an slog.Logger compatible logger contract.
func LoggerFromContext ¶
LoggerFromContext extracts a structured logger from the context for reusability.
type PanicHandler ¶
type PanicHandler interface {
// HandlePanic handles a panic and returns an optional error with a signal on whether it should be
// fatal or not.
HandlePanic(ctx context.Context, err any) (error, bool)
}
PanicHandler defines a generic contract for handling panics following the recover semantics.
type Reader ¶
type Reader interface {
// Read reads vulnerability findings from a storage.
Read(ctx context.Context, instanceID uuid.UUID) ([]*ocsf.VulnerabilityFinding, error)
}
Reader allows reading vulnerability findings from a storage.
type Reporter ¶
type Reporter interface {
// Report reports vulnerability findings on a specified destination.
// i.e. raises them as tickets on your favourite ticketing system.
Report(ctx context.Context, findings []*ocsf.VulnerabilityFinding) error
}
Reporter advertises behaviours for reporting vulnerability findings.
type RunnerConfig ¶
type RunnerConfig struct {
SDKVersion string
ComponentName string
InstanceID uuid.UUID
Logging RunnerConfigLogging
PanicHandler PanicHandler
// contains filtered or unexported fields
}
RunnerConfig is used for centralised runner configuration to be shared between components. This should be extended with all related things with reliability and observability.
type RunnerConfigLogging ¶
type RunnerConfigLogging struct {
Level RunnerConfigLoggingLevel
Logger Logger
}
RunnerConfigLogging contains the configuration related with the runner logger.
type RunnerConfigLoggingLevel ¶
type RunnerConfigLoggingLevel string
RunnerConfigLoggingLevel is used to represent log levels. ENUM(debug, info, error, warn)
const ( // RunnerConfigLoggingLevelDebug is a RunnerConfigLoggingLevel of type debug. RunnerConfigLoggingLevelDebug RunnerConfigLoggingLevel = "debug" // RunnerConfigLoggingLevelInfo is a RunnerConfigLoggingLevel of type info. RunnerConfigLoggingLevelInfo RunnerConfigLoggingLevel = "info" // RunnerConfigLoggingLevelError is a RunnerConfigLoggingLevel of type error. RunnerConfigLoggingLevelError RunnerConfigLoggingLevel = "error" // RunnerConfigLoggingLevelWarn is a RunnerConfigLoggingLevel of type warn. RunnerConfigLoggingLevelWarn RunnerConfigLoggingLevel = "warn" )
func ParseRunnerConfigLoggingLevel ¶
func ParseRunnerConfigLoggingLevel(name string) (RunnerConfigLoggingLevel, error)
ParseRunnerConfigLoggingLevel attempts to convert a string to a RunnerConfigLoggingLevel.
func (RunnerConfigLoggingLevel) IsValid ¶
func (x RunnerConfigLoggingLevel) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (RunnerConfigLoggingLevel) String ¶
func (x RunnerConfigLoggingLevel) String() string
String implements the Stringer interface.
type RunnerConfigOption ¶
type RunnerConfigOption func(*RunnerConfig) error
RunnerConfigOption can be used to override runner configuration defaults. For example overriding the default logger.
type RunnerOption ¶
type RunnerOption func(r *runner) error
RunnerOption is used to customise the runner if the provided defaults are not enough.
func RunnerWithComponentName ¶
func RunnerWithComponentName(name string) RunnerOption
RunnerWithComponentName allows customising the component name.
func RunnerWithInstanceID ¶
func RunnerWithInstanceID(id uuid.UUID) RunnerOption
RunnerWithInstanceID allows customising the instance id.
func RunnerWithLogger ¶
func RunnerWithLogger(logger Logger) RunnerOption
RunnerWithLogger allows customising the runner logger.
func RunnerWithStorer ¶
func RunnerWithStorer(stType string, store Storer) RunnerOption
RunnerWithStorer can be used to customise the underlying storage.
type Scanner ¶
type Scanner interface {
// Transform transforms the raw scan data into vulnerability finding format.
Transform(ctx context.Context) ([]*ocsf.VulnerabilityFinding, error)
}
Scanner reads a scan's result and produces vulnerability findings.
type Target ¶
type Target interface {
// Prepare prepares the target to be scanned.
Prepare(ctx context.Context) error
}
Target prepares the workflow environment.
type Updater ¶
type Updater interface {
// Update updates existing vulnerability findings.
Update(ctx context.Context, instanceID uuid.UUID, findings []*ocsf.VulnerabilityFinding) error
}
Updater allows updating vulnerability findings in an underlying storage.
type Validator ¶
type Validator interface {
// Validate validates the supplied vulnerability finding and returns an error if invalid.
Validate(finding *ocsf.VulnerabilityFinding) error
}
Validator allows validating vulnerability findings by a specified criteria.