Documentation ¶
Index ¶
- Variables
- func ContextWithLogger(ctx context.Context, logger Logger) context.Context
- func NewDefaultPanicHandler() (*defaultPanicHandler, error)
- func NewNoopLogger() *noopLogger
- 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 StoreConfig
- type StoreType
- type Storer
- type Target
- type Updater
- type Validator
- type Writer
Constants ¶
This section is empty.
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 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 []*finding.VulnerabilityFinding) ([]*finding.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 []*finding.VulnerabilityFinding) ([]*finding.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) ([]*finding.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 []*finding.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 StoreConfig StoreConfig }
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(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 StoreConfig ¶
StoreConfig contains store configuration.
type StoreType ¶
type StoreType string
StoreType represents a store type ENUM(sqlite, postgresql, findings-client)
const ( // StoreTypeSqlite is a StoreType of type sqlite. StoreTypeSqlite StoreType = "sqlite" // StoreTypePostgresql is a StoreType of type postgresql. StoreTypePostgresql StoreType = "postgresql" // StoreTypeFindingsClient is a StoreType of type findings-client. StoreTypeFindingsClient StoreType = "findings-client" )
func ParseStoreType ¶
ParseStoreType attempts to convert a string to a StoreType.
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 []*finding.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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
internal
|
|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
local/sqlite/sqlc/migrations
empty file used to track migrations
|
empty file used to track migrations |