scanner

package
v0.0.0-...-66c98c8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRegistration

func AddRegistration(ctx context.Context, r *Registration) (int64, error)

AddRegistration adds a new registration

func DeleteRegistration

func DeleteRegistration(ctx context.Context, UUID string) error

DeleteRegistration deletes the registration with the specified UUID

func GetTotalOfRegistrations

func GetTotalOfRegistrations(ctx context.Context, query *q.Query) (int64, error)

GetTotalOfRegistrations returns the total count of scanner registrations according to the query.

func SetDefaultRegistration

func SetDefaultRegistration(ctx context.Context, UUID string) error

SetDefaultRegistration sets the specified registration as default one

func UpdateRegistration

func UpdateRegistration(ctx context.Context, r *Registration, cols ...string) error

UpdateRegistration update the specified registration

Types

type Registration

type Registration struct {
	// Basic information
	// int64 ID is kept for being aligned with previous DB schema
	ID          int64  `orm:"pk;auto;column(id)" json:"-"`
	UUID        string `orm:"unique;column(uuid)" json:"uuid"`
	Name        string `orm:"unique;column(name);size(128)" json:"name"`
	Description string `orm:"column(description);null;size(1024)" json:"description"`
	URL         string `orm:"column(url);unique;size(512)" json:"url"`
	Disabled    bool   `orm:"column(disabled);default(true)" json:"disabled"`
	IsDefault   bool   `orm:"column(is_default);default(false)" json:"is_default"`
	Health      string `orm:"-" json:"health,omitempty"`

	// Authentication settings
	// "","Basic", "Bearer" and api key header "X-ScannerAdapter-API-Key" can be supported
	Auth             string `orm:"column(auth);size(16)" json:"auth"`
	AccessCredential string `orm:"column(access_cred);null;size(512)" json:"access_credential,omitempty"`

	// Http connection settings
	SkipCertVerify bool `orm:"column(skip_cert_verify);default(false)" json:"skip_certVerify"`

	// Indicate whether use internal registry addr for the scanner to pull content
	UseInternalAddr bool `orm:"column(use_internal_addr);default(false)" json:"use_internal_addr"`

	// Indicate if the registration is immutable which is not allowed to remove
	Immutable bool `orm:"column(immutable);default(false)" json:"-"`

	// Optional properties for describing the adapter
	Adapter string `orm:"-" json:"adapter,omitempty"`
	Vendor  string `orm:"-" json:"vendor,omitempty"`
	Version string `orm:"-" json:"version,omitempty"`

	Metadata *v1.ScannerAdapterMetadata `orm:"-" json:"-"`

	// Timestamps
	CreateTime   time.Time              `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
	UpdateTime   time.Time              `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
	Capabilities map[string]interface{} `orm:"-" json:"capabilities,omitempty"`
}

Registration represents a named configuration for invoking a scanner via its adapter. UUID will be used to track the scanner.Endpoint as unique ID

func GetDefaultRegistration

func GetDefaultRegistration(ctx context.Context) (*Registration, error)

GetDefaultRegistration gets the default registration

func GetRegistration

func GetRegistration(ctx context.Context, UUID string) (*Registration, error)

GetRegistration gets the specified registration

func ListRegistrations

func ListRegistrations(ctx context.Context, query *q.Query) ([]*Registration, error)

ListRegistrations lists all the existing registrations

func (*Registration) Client

func (r *Registration) Client(pool v1.ClientPool) (v1.Client, error)

Client returns client of registration

func (*Registration) FromJSON

func (r *Registration) FromJSON(jsonData string) error

FromJSON parses registration from json data

func (*Registration) GetCapability

func (r *Registration) GetCapability(mimeType string) *v1.ScannerCapability

GetCapability returns capability for the mime type

func (*Registration) GetProducesMimeTypes

func (r *Registration) GetProducesMimeTypes(mimeType string, scanType string) []string

GetProducesMimeTypes returns produces mime types for the artifact

func (*Registration) GetRegistryAuthorizationType

func (r *Registration) GetRegistryAuthorizationType() string

GetRegistryAuthorizationType returns the registry authorization type of the scanner

func (*Registration) HasCapability

func (r *Registration) HasCapability(manifestMimeType string) bool

HasCapability returns true when mime type of the artifact support by the scanner

func (*Registration) TableName

func (r *Registration) TableName() string

TableName for Endpoint

func (*Registration) ToJSON

func (r *Registration) ToJSON() (string, error)

ToJSON marshals registration to JSON data

func (*Registration) Validate

func (r *Registration) Validate(checkUUID bool) error

Validate registration

Jump to

Keyboard shortcuts

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