reporter

package
v1.7.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ErrorLevel is for unexpected problems that require attention.
	ErrorLevel = iota
	// WarnLevel is for indicating potential issues or something that should be brought to the attention of users.
	WarnLevel
	// InfoLevel is for general information about what OSV-Scanner is doing during its runtime.
	InfoLevel
	// VerboseLevel is for providing even more information compared to InfoLevel about the inner workings of OSV-Scanner.
	VerboseLevel
)

Variables

This section is empty.

Functions

func Format added in v1.4.0

func Format() []string

func VerbosityLevels added in v1.6.0

func VerbosityLevels() []string

Types

type GHAnnotationsReporter added in v1.4.0

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

func NewGHAnnotationsReporter added in v1.4.0

func NewGHAnnotationsReporter(stdout io.Writer, stderr io.Writer, level VerbosityLevel) *GHAnnotationsReporter

func (*GHAnnotationsReporter) Errorf added in v1.6.0

func (r *GHAnnotationsReporter) Errorf(format string, a ...any)

func (*GHAnnotationsReporter) HasErrored added in v1.6.0

func (r *GHAnnotationsReporter) HasErrored() bool

func (*GHAnnotationsReporter) Infof added in v1.6.0

func (r *GHAnnotationsReporter) Infof(format string, a ...any)

func (*GHAnnotationsReporter) PrintResult added in v1.4.0

func (r *GHAnnotationsReporter) PrintResult(vulnResult *models.VulnerabilityResults) error

func (*GHAnnotationsReporter) Verbosef added in v1.6.0

func (r *GHAnnotationsReporter) Verbosef(format string, a ...any)

func (*GHAnnotationsReporter) Warnf added in v1.6.0

func (r *GHAnnotationsReporter) Warnf(format string, a ...any)

type JSONReporter

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

JSONReporter prints vulnerability results in JSON format to stdout. Runtime information will be written to stderr.

func NewJSONReporter

func NewJSONReporter(stdout io.Writer, stderr io.Writer, level VerbosityLevel) *JSONReporter

func (*JSONReporter) Errorf added in v1.6.0

func (r *JSONReporter) Errorf(format string, a ...any)

func (*JSONReporter) HasErrored added in v1.6.0

func (r *JSONReporter) HasErrored() bool

func (*JSONReporter) Infof added in v1.6.0

func (r *JSONReporter) Infof(format string, a ...any)

func (*JSONReporter) PrintResult

func (r *JSONReporter) PrintResult(vulnResult *models.VulnerabilityResults) error

func (*JSONReporter) Verbosef added in v1.6.0

func (r *JSONReporter) Verbosef(format string, a ...any)

func (*JSONReporter) Warnf added in v1.6.0

func (r *JSONReporter) Warnf(format string, a ...any)

type Reporter

type Reporter interface {
	// Errorf prints errors in an appropriate manner to ensure that results
	// are printed in a way that is semantically valid for the intended consumer,
	// and tracking that an error has been printed.
	//
	// Where the error is actually printed (if at all) is entirely up to the actual
	// reporter, though generally it will be to stderr.
	Errorf(format string, a ...any)
	// HasErrored returns true if there have been any calls to Errorf.
	//
	// This does not actually represent if the error was actually printed anywhere
	// since what happens to the error message is up to the actual reporter.
	HasErrored() bool
	// Warnf prints text indicating potential issues or something that should be brought to the attention of users.
	Warnf(format string, a ...any)
	// Infof prints text providing general information about what OSV-Scanner is doing during its runtime.
	Infof(format string, a ...any)
	// Verbosef prints text providing additional information about the inner workings of OSV-Scanner to the user.
	Verbosef(format string, a ...any)
	// PrintResult prints the models.VulnerabilityResults per the logic of the
	// actual reporter
	PrintResult(vulnResult *models.VulnerabilityResults) error
}

Reporter provides printing operations for vulnerability results and for runtime information (depending on the verbosity level given to the Reporter implementation).

When printing non-error-related runtime information, it is entirely up to the Reporter implementation as to where the text is actually printed (if at all); in most cases for "human format" reporters this will be stdout whereas for "machine format" reporters this will be stderr.

func New added in v1.4.0

func New(format string, stdout, stderr io.Writer, level VerbosityLevel, terminalWidth int) (Reporter, error)

New returns an implementation of the reporter interface depending on the format passed in set terminalWidth as 0 to indicate the output is not a terminal

type SARIFReporter added in v1.4.0

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

func NewSarifReporter added in v1.4.0

func NewSarifReporter(stdout io.Writer, stderr io.Writer, level VerbosityLevel) *SARIFReporter

func (*SARIFReporter) Errorf added in v1.6.0

func (r *SARIFReporter) Errorf(format string, a ...any)

func (*SARIFReporter) HasErrored added in v1.6.0

func (r *SARIFReporter) HasErrored() bool

func (*SARIFReporter) Infof added in v1.6.0

func (r *SARIFReporter) Infof(format string, a ...any)

func (*SARIFReporter) PrintResult added in v1.4.0

func (r *SARIFReporter) PrintResult(vulnResult *models.VulnerabilityResults) error

func (*SARIFReporter) Verbosef added in v1.6.0

func (r *SARIFReporter) Verbosef(format string, a ...any)

func (*SARIFReporter) Warnf added in v1.6.0

func (r *SARIFReporter) Warnf(format string, a ...any)

type TableReporter

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

func NewTableReporter

func NewTableReporter(stdout io.Writer, stderr io.Writer, level VerbosityLevel, markdown bool, terminalWidth int) *TableReporter

func (*TableReporter) Errorf added in v1.6.0

func (r *TableReporter) Errorf(format string, a ...any)

func (*TableReporter) HasErrored added in v1.6.0

func (r *TableReporter) HasErrored() bool

func (*TableReporter) Infof added in v1.6.0

func (r *TableReporter) Infof(format string, a ...any)

func (*TableReporter) PrintResult

func (r *TableReporter) PrintResult(vulnResult *models.VulnerabilityResults) error

func (*TableReporter) Verbosef added in v1.6.0

func (r *TableReporter) Verbosef(format string, a ...any)

func (*TableReporter) Warnf added in v1.6.0

func (r *TableReporter) Warnf(format string, a ...any)

type VerbosityLevel added in v1.6.0

type VerbosityLevel uint8

VerbosityLevel is used to determine what amount of information should be given in OSV-Scanner's runtime.

func ParseVerbosityLevel added in v1.6.0

func ParseVerbosityLevel(text string) (VerbosityLevel, error)

type VoidReporter

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

func (*VoidReporter) Errorf added in v1.6.0

func (r *VoidReporter) Errorf(msg string, a ...any)

func (*VoidReporter) HasErrored added in v1.6.0

func (r *VoidReporter) HasErrored() bool

func (*VoidReporter) Infof added in v1.6.0

func (r *VoidReporter) Infof(msg string, a ...any)

func (*VoidReporter) PrintResult

func (r *VoidReporter) PrintResult(vulnResult *models.VulnerabilityResults) error

func (*VoidReporter) Verbosef added in v1.6.0

func (r *VoidReporter) Verbosef(msg string, a ...any)

func (*VoidReporter) Warnf added in v1.6.0

func (r *VoidReporter) Warnf(msg string, a ...any)

Jump to

Keyboard shortcuts

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