finding

package
v5.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueProbesEqual

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

type AnonymousFinding struct {
	Probe string `json:"probe,omitempty"`
	Finding
}

AnonymousFinding is a finding without a corresponding 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
	// FileTypeBinaryVerified for verified binary files.
	FileTypeBinaryVerified
)

type Finding

type Finding struct {
	Location    *Location         `json:"location,omitempty"`
	Remediation *Remediation      `json:"remediation,omitempty"`
	Values      map[string]string `json:"values,omitempty"`
	Probe       string            `json:"probe"`
	Message     string            `json:"message"`
	Outcome     Outcome           `json:"outcome"`
	// contains filtered or unexported fields
}

Finding represents a finding.

func FromBytes

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 NewFalse

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

NewFalse create a false finding with the desired location.

func NewNotApplicable

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

NewNotApplicable create a finding with a NotApplicable outcome and the desired location.

func NewNotAvailable

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 NewNotSupported

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

NewNotSupported create a finding with a NotSupported outcome and the desired location.

func NewTrue

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

NewTrue create a true finding with the desired location.

func NewWith

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

NewWith create a finding with the desired location and outcome.

func (*Finding) Anonymize

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.

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.

func (*Finding) WithValue

func (f *Finding) WithValue(k, v string) *Finding

WithValue adds a value to f.Values. No copy is made.

func (*Finding) WithValues

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

WithValues sets the values to an existing finding. No copy is made.

type Location

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

Location represents the location of a finding.

type Outcome

type Outcome string

Outcome is the result of a finding.

const (
	// OutcomeFalse indicates the answer to the probe's question is "false" or "no".
	OutcomeFalse Outcome = "False"
	// OutcomeNotAvailable indicates an unavailable outcome,
	// typically because an API call did not return an answer.
	OutcomeNotAvailable Outcome = "NotAvailable"
	// OutcomeError indicates an errors while running.
	// The results could not be determined.
	OutcomeError Outcome = "Error"
	// OutcomeTrue indicates the answer to the probe's question is "true" or "yes".
	OutcomeTrue Outcome = "True"
	// OutcomeNotSupported indicates a non-supported outcome.
	OutcomeNotSupported Outcome = "NotSupported"
	// OutcomeNotApplicable indicates if a finding should not
	// be considered in evaluation.
	OutcomeNotApplicable Outcome = "NotApplicable"
)

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

func (*Outcome) UnmarshalYAML

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

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

type Remediation

type Remediation struct {
	// Patch for machines.
	Patch *string `json:"patch,omitempty"`
	// Text for humans.
	Text string `json:"text"`
	// Text in markdown format for humans.
	Markdown string `json:"markdown"`
	// Effort to remediate.
	Effort RemediationEffort `json:"effort"`
}

Remediation represents the remediation for a finding.

type RemediationEffort

type RemediationEffort int

RemediationEffort indicates the estimated effort necessary to remediate a finding.

const (
	// RemediationEffortNone indicates a no remediation effort.
	RemediationEffortNone RemediationEffort = iota
	// RemediationEffortLow indicates a low remediation effort.
	RemediationEffortLow
	// RemediationEffortMedium indicates a medium remediation effort.
	RemediationEffortMedium
	// RemediationEffortHigh indicates a high remediation effort.
	RemediationEffortHigh
)

func (*RemediationEffort) String

func (r *RemediationEffort) String() string

String stringifies the enum.

func (*RemediationEffort) UnmarshalYAML

func (r *RemediationEffort) UnmarshalYAML(n *yaml.Node) error

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

Jump to

Keyboard shortcuts

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