tasks

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package tasks contains all implementations of tasks; these are instantiated and run from the main package

Index

Constants

View Source
const (
	// BugsEndpoint is the endpoint for the rest-backend API to fetch bugs
	BugsEndpoint = "/bugs"
)
View Source
const GUIPort string = "3001"

GUIPort is the port (on localhost) on which the Statement creation wizart will be exposed

Variables

This section is empty.

Functions

func IsVulnerabilityExportExcluded

func IsVulnerabilityExportExcluded(excluded []string, vulnID string) bool

IsVulnerabilityExportExcluded checks if a vulnerability id should be excluded from the export

func JoinNotes

func JoinNotes(s model.Statement) string

JoinNotes collects the text from all notes and concatenates it

func LinksAsCSV

func LinksAsCSV(s model.Statement) string

LinksAsCSV prints all links as csv

Types

type BaseTask

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

BaseTask defines the basis for all task implementations

func (*BaseTask) Verbose

func (t *BaseTask) Verbose(v bool)

Verbose makes the task verbose

type CreateTask

type CreateTask struct {
	BaseTask
	// contains filtered or unexported fields
}

CreateTask is the task that performs merging of statements, reconciling any conflicts using a set of pre-defined policies.

func NewCreateTask

func NewCreateTask() *CreateTask

NewCreateTask constructs a new MergeTask

func (*CreateTask) Execute

func (t *CreateTask) Execute() (success bool)

Execute performs the actual task and returns true on success

func (*CreateTask) WithGUI

func (t *CreateTask) WithGUI(enableGUI bool) *CreateTask

WithGUI enables a graphical UI to create the new statement

func (*CreateTask) WithVulnerabilityID added in v0.6.3

func (t *CreateTask) WithVulnerabilityID(id string) *CreateTask

WithVulnerabilityID sets the ID of the vulnerability we're creating a statement for

type ExportTask

type ExportTask struct {
	BaseTask
	// contains filtered or unexported fields
}

ExportTask is the task that generates a script to import statements into 3rd-party systems

func NewExportTask

func NewExportTask() *ExportTask

NewExportTask constructs a new ExportTask

func (*ExportTask) Execute

func (t *ExportTask) Execute() (success bool)

Execute performs the actual merge task and returns true on success The task supports both exporting sets of statements and individual statements. To export sets of statements, the source must be a directory containing either statements or subdirectories that contain, each, a statement. A source can also be an individual statement file. If no source is specified, the task aborts. If a default directory must be considered, it must be set in the calling command.

func (*ExportTask) WithDenylist

func (t *ExportTask) WithDenylist(bl []string) *ExportTask

WithDenylist sets the identifiers of vulnerabilities to exclude from the export

func (*ExportTask) WithExportScripts

func (t *ExportTask) WithExportScripts(scripts []conf.ExportScript) *ExportTask

WithExportScripts passes the export script templates to the task

func (*ExportTask) WithOutputFile

func (t *ExportTask) WithOutputFile(filename string) *ExportTask

WithOutputFile sets the name of the file that the export will produce

func (*ExportTask) WithSource

func (t *ExportTask) WithSource(s string) *ExportTask

WithSource sets the source to export from

func (*ExportTask) WithTarget

func (t *ExportTask) WithTarget(target string) *ExportTask

WithTarget sets the target type

type ImportTask

type ImportTask struct {
	BaseTask
	// contains filtered or unexported fields
}

ImportTask is the task that performs exporting of vulnerability information from a Steady backend or database, and produces a text-based (YAML) representation, useful for further processing (e.g., manual inspection, uploading to a repository, analysis, etc.)

func NewImportTask

func NewImportTask() *ImportTask

NewImportTask constructs a new ImportTask

func (*ImportTask) Execute

func (t *ImportTask) Execute() (success bool)

Execute performs the actual task and returns true on success

func (*ImportTask) WithBackend

func (t *ImportTask) WithBackend(backend string) *ImportTask

WithBackend sets the URL of the backend from which data will be imported

func (*ImportTask) WithConcurrency

func (t *ImportTask) WithConcurrency(c int) *ImportTask

WithConcurrency sets the number of concurrent importers

func (*ImportTask) WithLimit

func (t *ImportTask) WithLimit(l int) *ImportTask

WithLimit sets the maximum number of statements that will be imported

func (*ImportTask) WithOutputPath

func (t *ImportTask) WithOutputPath(p string) *ImportTask

WithOutputPath sets the path to which the imported data will be saved

type Importer

type Importer struct {
	Backend           string `yaml:"backend"`
	Bugs              []*model.Bug
	Statements        map[string]model.Statement
	SkippedStatements []model.Statement
	Client            *http.Client
	Filter            map[string][]*regexp.Regexp
	ProgressBar       *progressbar.ProgressBar
	Verbose           bool
}

Importer is used to download and convert bugs to statements. Each exporter instance gets a slice of bugs to fetch. Multiple importers can be used ad once, as part of a pool of importers (ImporterPool).

func (*Importer) Run

func (f *Importer) Run() error

Run fetches specific information from a slice of bugs and converts it to statements

type ImporterPool

type ImporterPool []Importer

ImporterPool is a pool of importers

func NewImporterPool

func NewImporterPool(backend string, concurrent int, limit int, filter map[string][]*regexp.Regexp, verbose bool) (*ImporterPool, error)

NewImporterPool instantiates a pool of Exporters, each taking care of fetching vulnerability data for a subset of the overall set of vulnerabilities stored in the Steady backend.

func (ImporterPool) Run

func (p ImporterPool) Run() map[string]model.Statement

Run launches a series of go routines that each try to fetch specific information from the slice of bug found in the local instance of the postgresql database and converts it to statements

type MergeTask

type MergeTask struct {
	BaseTask
	// contains filtered or unexported fields
}

MergeTask is the task that performs merging of statements, reconciling any conflicts using a set of pre-defined policies.

func NewMergeTask

func NewMergeTask() (mergeTask *MergeTask)

NewMergeTask constructs a new MergeTask

func (*MergeTask) Execute

func (t *MergeTask) Execute() (success bool)

Execute performs the actual merge task and returns true on success

func (*MergeTask) WithPolicy

func (t *MergeTask) WithPolicy(p conf.Policy) *MergeTask

WithPolicy sets the policy to be used to merge sources

func (*MergeTask) WithSources

func (t *MergeTask) WithSources(sources []conf.Source) *MergeTask

WithSources sets the sources to be merged

type PullTask

type PullTask struct {
	BaseTask
	// contains filtered or unexported fields
}

PullTask is the task that performs merging of statements, reconciling any conflicts using a set of pre-defined policies.

func NewPullTask

func NewPullTask() *PullTask

NewPullTask constructs a new MergeTask

func (*PullTask) Execute

func (t *PullTask) Execute() (success bool)

Execute performs the actual task and returns true on success

func (*PullTask) WithSources

func (t *PullTask) WithSources(sources []conf.Source) *PullTask

WithSources sets the sources to be merged

type SetupTask

type SetupTask struct {
	BaseTask
	// contains filtered or unexported fields
}

SetupTask is the task that performs merging of statements, reconciling any conflicts using a set of pre-defined policies.

func NewSetupTask

func NewSetupTask() *SetupTask

NewSetupTask constructs a new MergeTask

func (*SetupTask) Execute

func (t *SetupTask) Execute() (success bool)

Execute performs the actual task and returns true on success

func (*SetupTask) WithForce added in v0.6.1

func (t *SetupTask) WithForce(f bool) *SetupTask

WithForce sets the flag that controls whether the setup should be done even if a configuration file is already existing (in which case, it will be overwritten)

func (*SetupTask) WithInteractiveMode

func (t *SetupTask) WithInteractiveMode(im bool) *SetupTask

WithInteractiveMode enables interactive mode

type SteadyAffectedLib

type SteadyAffectedLib struct {
	LibraryID   SteadyLibID `json:"libraryId"`
	Affected    bool        `json:"affected"`
	Explanation string      `json:"explanation"`
	Source      string      `json:"source"`
}

SteadyAffectedLib represents an affected artifact as represented in the output of the Steady API /backend/bugs/CVE-2019-0232/affectedLibIds?onlyWellKnown=true

type SteadyLibID

type SteadyLibID struct {
	ArtifactID string `json:"artifact"`
	GroupID    string `json:"group"`
	Version    string `json:"version"`
}

SteadyLibID represents a GAV in the output of the Steady API

type Task

type Task interface {
	Execute() (success bool)
	// contains filtered or unexported methods
}

The Task interface defines the behaviour that all tasks must implement

Jump to

Keyboard shortcuts

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