Documentation ¶
Index ¶
Constants ¶
const MaxScanAge = 5
MaxScanAge Max number of days a scan be in "creating checks state"
Variables ¶
var ErrNoDefaultQueueDefined = errors.New("At least a queue with the name 'default' must be defined")
ErrNoDefaultQueueDefined is returned when the initial default queues configuration does not contain a entry with the key "default".
Functions ¶
This section is empty.
Types ¶
type CheckNotifier ¶
CheckNotifier is used by the ChecksRunner to send notifications when a Check has ben created or sent to a queue.
type ChecksRunner ¶
type ChecksRunner struct {
// contains filtered or unexported fields
}
ChecksRunner allows to create the checks of a scan in a stateless way.
func NewJobsCreator ¶
func NewJobsCreator(store Store, sender JobSender, ctinformer ChecktypeInformer, checkListener CheckNotifier, l Logger) *ChecksRunner
NewJobsCreator creates and returns a new JobsCreator given its dependencies.
func (*ChecksRunner) CreateIncompleteScansChecks ¶
func (c *ChecksRunner) CreateIncompleteScansChecks() error
CreateIncompleteScansChecks queries the db for incomplete scans. For each of those scans either it creates the pending checks or it finishes the scan in case it's older than MaxScanAge.
func (*ChecksRunner) CreateScanChecks ¶
func (c *ChecksRunner) CreateScanChecks(id string) error
CreateScanChecks checks if a scan has still checks to be created and run, if it does, it locks the scan and creates the pending checks. The process of creating the checks of is done in a way that it can be stopped unexpectedly at any time and it will be automatically resumed using at least once semantincs.
type ChecksRunnerForTask ¶
type ChecksRunnerForTask interface {
CreateIncompleteScansChecks() error
}
type ChecksRunnerTask ¶
type ChecksRunnerTask struct {
ChecksRunnerForTask
}
ChecksRunnerTask implements a periodic check creator than can be run by the Scheduler.
func (*ChecksRunnerTask) Execute ¶
func (c *ChecksRunnerTask) Execute() error
func (*ChecksRunnerTask) Name ¶
func (c *ChecksRunnerTask) Name() string
func (*ChecksRunnerTask) Type ¶
func (c *ChecksRunnerTask) Type() string
type ChecktypeInformer ¶
type ChecktypeInformer interface { IndexChecktypes(ctx context.Context, path string, enabled *string, name *string) (*http.Response, error) DecodeChecktype(resp *http.Response) (*client.Checktype, error) }
ChecktypeInformer defines the services required by the JobCreator type to be able to query information about checktypes.
type ChecktypesByAssettypes ¶
ChecktypesByAssettypes is used as a lookup table to check if a checktype can be run against a concrete assettype.
type Job ¶
type Job struct { CheckID string `json:"check_id"` // Required ScanID string `json:"scan_id"` // Required ScanStartTime time.Time `json:"start_time"` // Required Image string `json:"image"` // Required Target string `json:"target"` // Required Timeout int `json:"timeout"` // Required AssetType string `json:"assettype"` // Optional Options string `json:"options"` // Optional RequiredVars []string `json:"required_vars"` // Optional Metadata map[string]string `json:"metadata"` // Optional }
Job stores the information necessary to create a new check job to be sent to an agent.
type JobsQueueSender ¶
type JobsQueueSender struct {
// contains filtered or unexported fields
}
JobsQueueSender allows to send jobs to the proper agent queue considering a map of default queues for checks.
func NewJobQueueSender ¶
func NewJobQueueSender(sender NamedQueuesSender, defaultCTQueues map[string]string) (*JobsQueueSender, error)
NewJobQueueSender creates a new JobQueueSender given the corresponder named queues message sender and the default queue names for checktypes.
type NamedQueuesSender ¶
NamedQueuesSender allows to send messages to a queue given its name.
type Store ¶
type Store interface { GetCreatingScans() ([]string, error) TryLockScan(id string) (*db.Lock, error) ReleaseScanLock(l *db.Lock) error GetScanByID(id uuid.UUID) (api.Scan, error) UpdateScan(id uuid.UUID, scan api.Scan, updateStates []string) (int64, error) InsertCheckIfNotExists(c api.Check) (string, error) }
Store defines the methods required by the check creator to query and update checks and scans.