Documentation
¶
Index ¶
- Constants
- func EnsureDefaultScanner(ctx context.Context, scannerName string) (err error)
- func EnsureScanners(ctx context.Context, wantedScanners []scanner.Registration) (err error)
- func ExtractScanReq(params job.Parameters) (*v1.ScanRequest, error)
- func GenAccessoryArt(sq v1sq.ScanRequest, accData []byte, accAnnotations map[string]string, ...) (string, error)
- func RegisterScanHanlder(requestType string, handler Handler)
- func RemoteOptions() []remote.Option
- func RemoveImmutableScanners(ctx context.Context, names []string) error
- type CheckInReport
- type Handler
- type Job
- type ReportHandler
Constants ¶
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 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.
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) ShouldRetry ¶
func (j *Job) ShouldRetry() bool
ShouldRetry indicates if the job should be retried
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