service

package
v1.1.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ScanStatusRunning status when a Scan is created.
	ScanStatusRunning = "RUNNING"

	// ScanStatusFinished status when a Scan has all the checks in a terminal status.
	ScanStatusFinished = "FINISHED"
)

Variables

View Source
var ErrAtLeastOneTargetAndChecktype = fmt.Errorf("AtLeastOneTargetAndChecktype")

ErrAtLeastOneTargetAndChecktype must have al least one checktype and one target.

View Source
var ErrNotDefinedCheckState = ers.New("CheckStateNotDefined")

ErrNotDefinedCheckState a check update with an unkown state has been received.

View Source
var ErrNotImplemented = ers.New("NotImplemented")

ErrNotImplemented ...

View Source
var ErrNotTargetGroupsDefined = fmt.Errorf("a scan must have a least one target_group defined")

ErrNotTargetGroupsDefined a scan must have at least one targetgroup defined.

Functions

func ErrAbortFailed

func ErrAbortFailed(statusCode int) error

ErrAbortFailed creates a new ErrorAbortFailed with the given status code returned by vulcan-core.

func ErrNotFound

func ErrNotFound(err error) error

ErrNotFound returns a pretty error

func ErrUpdateFailed

func ErrUpdateFailed(err error) error

ErrUpdateFailed returns a pretty error

func ErrValidationError

func ErrValidationError(err error) error

ErrValidationError returns a pretty error

Types

type ChecksCreator

type ChecksCreator interface {
	CreateScanChecks(id string) error
}

ChecksCreator abstracts the actual implementation for the checks creation process.

type ChecktypesByAssettypes

type ChecktypesByAssettypes map[string]map[string]struct{}

ChecktypesByAssettypes is used as a lookup table to check if a checktype can be run against a concrete assettype.

type ChecktypesInformer

type ChecktypesInformer interface {
	GetAssettypes() (*client.AssettypeCollection, error)
}

ChecktypesInformer represents an informer for the mapping between checktypes and supported asset types.

type HealthcheckService

type HealthcheckService struct {
	DB persistenceHealthChecker
}

HealthcheckService provides functionality to check the health of the service.

func (HealthcheckService) Healthcheck

func (s HealthcheckService) Healthcheck(ctx context.Context) error

Healthcheck checks the health of the service.

type ScansService

type ScansService struct {
	// contains filtered or unexported fields
}

ScansService implements the functionality needed to create and query scans.

func New

func New(logger log.Logger, db persistence.ScansStore, client ChecktypesInformer,
	metricsClient metrics.Client, ccreator ChecksCreator, scansNotifier notify.Notifier,
	checksNotifier notify.Notifier, streamClient stream.Client) ScansService

New Creates and returns ScansService with all the dependencies wired in.

func (ScansService) AbortScan

func (s ScansService) AbortScan(ctx context.Context, scanID string) error

AbortScan is called in order to signal the vulcan core to try to abort and on going scan.

func (ScansService) CreateScan

func (s ScansService) CreateScan(ctx context.Context, scan *api.Scan) (uuid.UUID, error)

func (ScansService) GetCheck

func (s ScansService) GetCheck(ctx context.Context, checkID string) (api.Check, error)

GetCheck returns the check for the given check ID.

func (ScansService) GetScan

func (s ScansService) GetScan(ctx context.Context, scanID string) (api.Scan, error)

GetScan returns the scan corresponding with a given id.

func (ScansService) GetScanChecks

func (s ScansService) GetScanChecks(ctx context.Context, scanID, status string) ([]api.Check, error)

GetScanChecks returns the checks for the scan with the given id.

func (ScansService) GetScanStats

func (s ScansService) GetScanStats(ctx context.Context, scanID string) ([]api.CheckStats, error)

GetScanStats returns the check stats for the given scan ID.

func (ScansService) ListScans

func (s ScansService) ListScans(ctx context.Context, extID string, offset, limit uint32) ([]api.Scan, error)

ListScans returns the list of scans.

func (ScansService) ProcessScanCheckNotification

func (s ScansService) ProcessScanCheckNotification(ctx context.Context, msg []byte) error

ProcessScanCheckNotification process and update the checks. The func will return nil if the event must be marked as consumed by the caller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL