finding

package
v4.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueProbesEqual added in v4.12.0

func UniqueProbesEqual(findings []Finding, probes []string) bool

UniqueProbesEqual checks the probe names present in a list of findings and compare them against an expected list.

Types

type AnonymousFinding added in v4.11.0

type AnonymousFinding struct {
	Finding
	// Remove the probe ID from
	// the structure until the probes are GA.
	Probe string `json:"probe,omitempty"`
}

AnonymousFinding is a finding without a corerpsonding probe ID.

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 {
	Probe       string             `json:"probe"`
	Outcome     Outcome            `json:"outcome"`
	Message     string             `json:"message"`
	Location    *Location          `json:"location,omitempty"`
	Remediation *probe.Remediation `json:"remediation,omitempty"`
}

Finding represents a finding. nolint: govet

func FromBytes added in v4.11.0

func FromBytes(content []byte, probeID string) (*Finding, error)

FromBytes creates a finding for a probe given its config file's content.

func New

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

New creates a new finding.

func NewNegative added in v4.11.0

func NewNegative(efs embed.FS, probeID, text string, loc *Location,
) (*Finding, error)

NewWith create a negative finding with the desired location.

func NewNotAvailable added in v4.11.0

func NewNotAvailable(efs embed.FS, probeID, text string, loc *Location,
) (*Finding, error)

NewNotAvailable create a finding with a NotAvailable outcome and the desired location.

func NewPositive added in v4.11.0

func NewPositive(efs embed.FS, probeID, text string, loc *Location,
) (*Finding, error)

NewPositive create a positive finding with the desired location.

func NewWith added in v4.11.0

func NewWith(efs embed.FS, probeID, text string, loc *Location,
	o Outcome,
) (*Finding, error)

NewWith create a finding with the desried location and outcome.

func (*Finding) Anonymize added in v4.11.0

func (f *Finding) Anonymize() *AnonymousFinding

Anonymize removes the probe ID and outcome from the finding. It is a temporary solution to integrate the code in the details without exposing too much information.

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"`
	Path      string   `json:"path"`
	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 (
	// NOTE: The additional '_' are intended for future use.
	// This allows adding outcomes without breaking the values
	// of existing outcomes.
	// OutcomeNegative indicates a negative outcome.
	OutcomeNegative Outcome = iota

	// OutcomeNotAvailable indicates an unavailable outcome,
	// typically because an API call did not return an answer.
	OutcomeNotAvailable

	// OutcomeError indicates an errors while running.
	// The results could not be determined.
	OutcomeError

	// OutcomePositive indicates a positive outcome.
	OutcomePositive

	// OutcomeNotSupported indicates a non-supported outcome.
	OutcomeNotSupported
)

TODO(#2928): re-visit the finding definitions.

func (*Outcome) UnmarshalYAML added in v4.11.0

func (o *Outcome) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML is a custom unmarshalling function to transform the string into an enum.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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