report

package
v0.0.0-...-a548ab7 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Mgr is the global report manager
	Mgr = NewManager()
)

SupportedGenerators declares mappings between mime type and summary generator func.

SupportedMergers declares mappings between mime type and report merger func.

SupportedMimes indicates what mime types are supported to render at UI end.

SupportedSummaryMergers declares mappings between mime type and summary merger func.

Functions

func GenerateNativeSummary

func GenerateNativeSummary(r *scan.Report, _ ...Option) (interface{}, error)

GenerateNativeSummary generates the report summary for the native report.

func GenerateSummary

func GenerateSummary(r *scan.Report, options ...Option) (interface{}, error)

GenerateSummary is a helper function to generate report summary based on the given report.

func Merge

func Merge(mimeType string, r1, r2 interface{}) (interface{}, error)

Merge merge report r1 and r2

func MergeNativeReport

func MergeNativeReport(r1, r2 interface{}) (interface{}, error)

MergeNativeReport merge report r1 and r2

func MergeNativeSummary

func MergeNativeSummary(s1, s2 interface{}) (interface{}, error)

MergeNativeSummary merge vuln.NativeReportSummary together

func MergeSummary

func MergeSummary(mimeType string, s1, s2 interface{}) (interface{}, error)

MergeSummary merge summary s1 and s2

func ResolveData

func ResolveData(mime string, jsonData []byte, options ...Option) (interface{}, error)

ResolveData is a helper func to parse the JSON data with the given mime type.

Types

type Manager

type Manager interface {
	// Create a new report record.
	//
	//  Arguments:
	//    ctx context.Context : the context for this method
	//    r *scan.Report : report model to be created
	//
	//  Returns:
	//    string : uuid of the new report
	//    error  : non nil error if any errors occurred
	//
	Create(ctx context.Context, r *scan.Report) (string, error)

	// Delete delete report by uuid
	//
	//  Arguments:
	//    ctx context.Context : the context for this method
	//    uuid string : uuid of the report to delete
	//
	//  Returns:
	//    error  : non nil error if any errors occurred
	//
	Delete(ctx context.Context, uuid string) error

	// Update the report data (with JSON format) of the given report.
	//
	//  Arguments:
	//    ctx context.Context : the context for this method
	//    uuid string    : uuid to identify the report
	//    report string  : report JSON data
	//
	//  Returns:
	//    error  : non nil error if any errors occurred
	//
	UpdateReportData(ctx context.Context, uuid string, report string) error

	// Get the reports for the given digest by other properties.
	//
	//  Arguments:
	//    ctx context.Context : the context for this method
	//    digest string           : digest of the artifact
	//    registrationUUID string : [optional] the report generated by which registration.
	//                              If it is empty, reports by all the registrations are retrieved.
	//    mimeTypes []string      : [optional] mime types of the reports requiring
	//                              If empty array is specified, reports with all the supported mimes are retrieved.
	//
	//  Returns:
	//    []*scan.Report : report list
	//    error          : non nil error if any errors occurred
	GetBy(ctx context.Context, digest string, registrationUUID string, mimeTypes []string) ([]*scan.Report, error)

	// Delete the reports related with the specified digests (one or more...)
	//
	//  Arguments:
	//    ctx context.Context : the context for this method
	//    digests ...string : specify one or more digests whose reports will be deleted
	//
	//  Returns:
	//    error        : non nil error if any errors occurred
	DeleteByDigests(ctx context.Context, digests ...string) error

	// List reports according to the query
	//
	//  Arguments:
	//    ctx context.Context : the context for this method
	//    query *q.Query : the query to list the reports
	//
	//  Returns:
	//    []*scan.Report : report list
	//    error        : non nil error if any errors occurred
	List(ctx context.Context, query *q.Query) ([]*scan.Report, error)

	// Update update report information
	Update(ctx context.Context, r *scan.Report, cols ...string) error
	// DeleteByExtraAttr delete scan_report by sbom_digest
	DeleteByExtraAttr(ctx context.Context, mimeType, attrName, attrValue string) error
}

Manager is used to manage the scan reports.

func NewManager

func NewManager() Manager

NewManager news basic manager.

type Merger

type Merger func(r1, r2 interface{}) (interface{}, error)

Merger is a helper function to merge report together

type Option

type Option func(options *Options)

Option for getting the report w/ summary with func template way.

func WithArtifactDigest

func WithArtifactDigest(artifactDigest string) Option

WithArtifactDigest is an option of setting artifact digest

type Options

type Options struct {
	// If it is set, the returned report will contains artifact digest for the vulnerabilities
	ArtifactDigest string
}

Options provides options for getting the report w/ summary.

type Reports

type Reports []*scan.Report

Reports slice of scan.Reports pointer

func (Reports) ResolveData

func (l Reports) ResolveData(mimeType string) (interface{}, error)

ResolveData resolve the data from the reports and merge them together

type SummaryGenerator

type SummaryGenerator func(r *scan.Report, options ...Option) (interface{}, error)

SummaryGenerator is a func template which used to generated report summary for relevant mime type.

type SummaryMerger

type SummaryMerger func(s1, s2 interface{}) (interface{}, error)

SummaryMerger is a helper function to merge summary together

Jump to

Keyboard shortcuts

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