finding

package
v4.10.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 4 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileType

type FileType int

FileType is the type of a file.

const (
	// FileTypeNone must be `0`.
	FileTypeNone FileType = iota
	// FileTypeSource is for source code files.
	FileTypeSource
	// FileTypeBinary is for binary files.
	FileTypeBinary
	// FileTypeText is for text files.
	FileTypeText
	// FileTypeURL for URLs.
	FileTypeURL
)

type Finding

type Finding struct {
	Rule        string            `json:"rule"`
	Outcome     Outcome           `json:"outcome"`
	Risk        rule.Risk         `json:"risk"`
	Message     string            `json:"message"`
	Location    *Location         `json:"location,omitempty"`
	Remediation *rule.Remediation `json:"remediation,omitempty"`
}

Finding represents a finding. nolint: govet

func New

func New(loc embed.FS, ruleID string) (*Finding, error)

New creates a new finding.

func (*Finding) WithLocation

func (f *Finding) WithLocation(loc *Location) *Finding

WithLocation adds a location to an existing finding. No copy is made.

func (*Finding) WithMessage

func (f *Finding) WithMessage(text string) *Finding

WithMessage adds a message to an existing finding. No copy is made.

func (*Finding) WithOutcome

func (f *Finding) WithOutcome(o Outcome) *Finding

WithOutcome adds an outcome to an existing finding. No copy is made. WARNING: this function should be called at most once for a finding.

func (*Finding) WithPatch

func (f *Finding) WithPatch(patch *string) *Finding

WithPatch adds a patch to an existing finding. No copy is made.

func (*Finding) WithRemediationMetadata

func (f *Finding) WithRemediationMetadata(values map[string]string) *Finding

WithRemediationMetadata adds remediation metadata to an existing finding. No copy is made.

type Location

type Location struct {
	Type      FileType `json:"type"`
	Value     string   `json:"value"`
	LineStart *uint    `json:"lineStart,omitempty"`
	LineEnd   *uint    `json:"lineEnd,omitempty"`
	Snippet   *string  `json:"snippet,omitempty"`
}

Location represents the location of a finding. nolint: govet

type Outcome

type Outcome int

Outcome is the result of a finding.

const (
	// OutcomeNegative indicates a negative outcome.
	OutcomeNegative Outcome = iota
	// OutcomePositive indicates a positive outcome.
	OutcomePositive
	// OutcomeNotApplicable indicates a non-applicable outcome.
	OutcomeNotApplicable
	// OutcomeNotSupported indicates a non-supported outcome.
	OutcomeNotSupported
)

func (*Outcome) WorseThan

func (o *Outcome) WorseThan(oo Outcome) bool

WorseThan compares outcomes.

Jump to

Keyboard shortcuts

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