scan

package
v0.0.0-...-e8722c0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JobParamRegistration ...
	JobParamRegistration = "registration"
	// JobParameterRequest ...
	JobParameterRequest = "scanRequest"
	// JobParameterMimes ...
	JobParameterMimes = "mimeTypes"
	// JobParameterAuthType ...
	JobParameterAuthType = "authType"
	// JobParameterRobot ...
	JobParameterRobot = "robotAccount"
)

Variables

This section is empty.

Functions

func EnsureDefaultScanner

func EnsureDefaultScanner(ctx context.Context, scannerName string) (err error)

EnsureDefaultScanner ensures that the scanner with the specified URL is set as default in the system.

func EnsureScanners

func EnsureScanners(ctx context.Context, wantedScanners []scanner.Registration) (err error)

EnsureScanners ensures that the scanners with the specified endpoints URLs exist in the system.

func ExtractScanReq

func ExtractScanReq(params job.Parameters) (*v1.ScanRequest, error)

ExtractScanReq extracts the scan request from the job parameters.

func GenAccessoryArt

func GenAccessoryArt(sq v1sq.ScanRequest, accData []byte, accAnnotations map[string]string, mediaType string, robot *model.Robot) (string, error)

GenAccessoryArt composes the accessory oci object and push it back to harbor core as an accessory of the scanned artifact.

func RegisterScanHanlder

func RegisterScanHanlder(requestType string, handler Handler)

RegisterScanHanlder register scanner handler

func RemoteOptions

func RemoteOptions() []remote.Option

RemoteOptions ...

func RemoveImmutableScanners

func RemoveImmutableScanners(ctx context.Context, names []string) error

RemoveImmutableScanners removes immutable scanner Registrations with the specified endpoint URLs.

Types

type CheckInReport

type CheckInReport struct {
	Digest           string `json:"digest"`
	RegistrationUUID string `json:"registration_uuid"`
	MimeType         string `json:"mime_type"`
	RawReport        string `json:"raw_report"`
}

CheckInReport defines model for checking in the scan report with specified mime.

func (*CheckInReport) FromJSON

func (cir *CheckInReport) FromJSON(jsonData string) error

FromJSON parse json to CheckInReport

func (*CheckInReport) ToJSON

func (cir *CheckInReport) ToJSON() (string, error)

ToJSON marshal CheckInReport to JSON

type Handler

type Handler interface {
	// RequestProducesMineTypes returns the produces mime types
	RequestProducesMineTypes() []string
	// RequiredPermissions defines the permission used by the scan robot account
	RequiredPermissions() []*types.Policy
	// RequestParameters defines the parameters for scan request
	RequestParameters() map[string]interface{}
	// PostScan defines the operation after scan
	PostScan(ctx job.Context, sr *v1.ScanRequest, rp *scan.Report, rawReport string, startTime time.Time, robot *model.Robot) (string, error)
	ReportHandler
	// JobVendorType returns the job vendor type
	JobVendorType() string
}

Handler handler for scan job, it could be implement by different scan type, such as vulnerability, sbom

func GetScanHandler

func GetScanHandler(requestType string) Handler

GetScanHandler get the handler

type Job

type Job struct{}

Job for running scan in the job service with async way

func (*Job) MaxCurrency

func (j *Job) MaxCurrency() uint

MaxCurrency is implementation of same method in Interface.

func (*Job) MaxFails

func (j *Job) MaxFails() uint

MaxFails for defining the number of retries

func (*Job) Run

func (j *Job) Run(ctx job.Context, params job.Parameters) error

Run the job

func (*Job) ShouldRetry

func (j *Job) ShouldRetry() bool

ShouldRetry indicates if the job should be retried

func (*Job) Validate

func (j *Job) Validate(params job.Parameters) error

Validate the parameters of this job

type ReportHandler

type ReportHandler interface {
	// URLParameter defines the parameters for scan report
	URLParameter(sr *v1.ScanRequest) (string, error)
	// Update update the report data in the database by UUID
	Update(ctx context.Context, uuid string, report string) error
	// MakePlaceHolder make the report place holder, if exist, delete it and create a new one
	MakePlaceHolder(ctx context.Context, art *artifact.Artifact, r *scanner.Registration) (rps []*scan.Report, err error)
	// GetPlaceHolder get the the report place holder
	GetPlaceHolder(ctx context.Context, artRepo string, artDigest string, scannerUUID string, mimeType string) (rp *scan.Report, err error)
	// GetSummary get the summary of the report
	GetSummary(ctx context.Context, ar *artifact.Artifact, mimeTypes []string) (map[string]interface{}, error)
}

ReportHandler handler for scan report, it could be sbom report or vulnerability report

Directories

Path Synopsis
dao
rest
v1
dao

Jump to

Keyboard shortcuts

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