scan

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 25 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DarkTheme  = "solarized-dark256"
	LightTheme = "github"
)

Variables

This section is empty.

Functions

func Highlight added in v0.60.0

func Highlight(filename, input, theme string) (string, bool)

Types

type CheckFunc

type CheckFunc func(s *state.State) (results Results)

type Code

type Code struct {
	Lines []Line
}

func (*Code) IsCauseMultiline

func (c *Code) IsCauseMultiline() bool

type CodeOption

type CodeOption func(*codeSettings)

func OptionCodeWithDarkTheme

func OptionCodeWithDarkTheme() CodeOption

func OptionCodeWithHighlighted

func OptionCodeWithHighlighted(include bool) CodeOption

func OptionCodeWithLightTheme

func OptionCodeWithLightTheme() CodeOption

func OptionCodeWithMaxLines

func OptionCodeWithMaxLines(lines int) CodeOption

func OptionCodeWithTheme

func OptionCodeWithTheme(theme string) CodeOption

func OptionCodeWithTruncation

func OptionCodeWithTruncation(truncate bool) CodeOption

type CustomChecks

type CustomChecks struct {
	Terraform *TerraformCustomCheck
}

type EngineMetadata

type EngineMetadata struct {
	GoodExamples        []string `json:"good_examples,omitempty"`
	BadExamples         []string `json:"bad_examples,omitempty"`
	RemediationMarkdown string   `json:"remediation_markdown,omitempty"`
	Links               []string `json:"links,omitempty"`
}

type FlatRange

type FlatRange struct {
	Filename  string `json:"filename"`
	StartLine int    `json:"start_line"`
	EndLine   int    `json:"end_line"`
}

type FlatResult

type FlatResult struct {
	Deprecated      bool               `json:"deprecated,omitempty"`
	RuleID          string             `json:"rule_id"`
	LongID          string             `json:"long_id"`
	RuleSummary     string             `json:"rule_description"`
	RuleProvider    providers.Provider `json:"rule_provider"`
	RuleService     string             `json:"rule_service"`
	Impact          string             `json:"impact"`
	Resolution      string             `json:"resolution"`
	Links           []string           `json:"links"`
	Description     string             `json:"description"`
	RangeAnnotation string             `json:"-"`
	Severity        severity.Severity  `json:"severity"`
	Status          Status             `json:"status"`
	Resource        string             `json:"resource"`
	Occurrences     []Occurrence       `json:"occurrences,omitempty"`
	Location        FlatRange          `json:"location"`
	RenderedCause   RenderedCause      `json:"rendered_cause"`
}

type Line

type Line struct {
	Number      int    `json:"Number"`
	Content     string `json:"Content"`
	IsCause     bool   `json:"IsCause"`
	Annotation  string `json:"Annotation"`
	Truncated   bool   `json:"Truncated"`
	Highlighted string `json:"Highlighted,omitempty"`
	FirstCause  bool   `json:"FirstCause"`
	LastCause   bool   `json:"LastCause"`
}

type MetadataProvider

type MetadataProvider interface {
	GetMetadata() iacTypes.Metadata
	GetRawValue() any
}

type Occurrence

type Occurrence struct {
	Resource  string `json:"resource"`
	Filename  string `json:"filename"`
	StartLine int    `json:"start_line"`
	EndLine   int    `json:"end_line"`
}

type RenderedCause added in v0.60.0

type RenderedCause struct {
	Raw string
}

type Result

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

func (*Result) AbsolutePath

func (r *Result) AbsolutePath(fsRoot string, metadata iacTypes.Metadata) string

func (Result) Annotation

func (r Result) Annotation() string

func (Result) Description

func (r Result) Description() string

func (*Result) Flatten

func (r *Result) Flatten() FlatResult

func (*Result) GetCode

func (r *Result) GetCode(opts ...CodeOption) (*Code, error)

func (Result) Metadata

func (r Result) Metadata() iacTypes.Metadata

func (*Result) Occurrences

func (r *Result) Occurrences() []Occurrence

func (*Result) OverrideAnnotation

func (r *Result) OverrideAnnotation(annotation string)

func (*Result) OverrideDescription

func (r *Result) OverrideDescription(description string)

func (*Result) OverrideMetadata

func (r *Result) OverrideMetadata(metadata iacTypes.Metadata)

func (*Result) OverrideSeverity

func (r *Result) OverrideSeverity(s severity.Severity)

func (*Result) OverrideStatus

func (r *Result) OverrideStatus(status Status)

func (Result) Range

func (r Result) Range() iacTypes.Range

func (Result) RegoNamespace

func (r Result) RegoNamespace() string

func (Result) RegoRule

func (r Result) RegoRule() string

func (*Result) RelativePathTo

func (r *Result) RelativePathTo(fsRoot, to string, metadata iacTypes.Metadata) string

func (Result) Rule

func (r Result) Rule() Rule

func (*Result) SetRule

func (r *Result) SetRule(ru Rule)

func (Result) Severity

func (r Result) Severity() severity.Severity

func (Result) Status

func (r Result) Status() Status

func (Result) Traces

func (r Result) Traces() []string

func (*Result) WithRenderedCause added in v0.60.0

func (r *Result) WithRenderedCause(cause RenderedCause)

type Results

type Results []Result

func (*Results) Add

func (r *Results) Add(description string, source any)

func (*Results) AddIgnored

func (r *Results) AddIgnored(source any, descriptions ...string)

func (*Results) AddPassed

func (r *Results) AddPassed(source any, descriptions ...string)

func (*Results) AddPassedRego

func (r *Results) AddPassedRego(namespace, rule string, traces []string, source any)

func (*Results) AddRego

func (r *Results) AddRego(description, namespace, rule string, traces []string, source MetadataProvider)

func (Results) Flatten

func (r Results) Flatten() []FlatResult

func (*Results) GetFailed

func (r *Results) GetFailed() Results

func (*Results) GetIgnored

func (r *Results) GetIgnored() Results

func (*Results) GetPassed

func (r *Results) GetPassed() Results

func (*Results) Ignore added in v0.51.0

func (r *Results) Ignore(ignoreRules ignore.Rules, ignores map[string]ignore.Ignorer)

func (*Results) SetRule

func (r *Results) SetRule(rule Rule)

func (*Results) SetSourceAndFilesystem

func (r *Results) SetSourceAndFilesystem(source string, f fs.FS, logicalSource bool)

type Rule

type Rule struct {
	Deprecated          bool                             `json:"deprecated"`
	AVDID               string                           `json:"avd_id"`
	Aliases             []string                         `json:"aliases"`
	ShortCode           string                           `json:"short_code"`
	Summary             string                           `json:"summary"`
	Explanation         string                           `json:"explanation"`
	Impact              string                           `json:"impact"`
	Resolution          string                           `json:"resolution"`
	Provider            providers.Provider               `json:"provider"`
	Service             string                           `json:"service"`
	Links               []string                         `json:"links"`
	Severity            severity.Severity                `json:"severity"`
	Terraform           *EngineMetadata                  `json:"terraform,omitempty"`
	CloudFormation      *EngineMetadata                  `json:"cloud_formation,omitempty"`
	Examples            string                           `json:"-"`
	CustomChecks        CustomChecks                     `json:"-"`
	RegoPackage         string                           `json:"-"`
	Frameworks          map[framework.Framework][]string `json:"frameworks"`
	Check               CheckFunc                        `json:"-"`
	MinimumTrivyVersion string                           `json:"minimum_trivy_version"`
}

func (Rule) HasID

func (r Rule) HasID(id string) bool

func (Rule) IsDeprecated added in v0.52.0

func (r Rule) IsDeprecated() bool

func (Rule) LongID

func (r Rule) LongID() string

func (Rule) ServiceDisplayName

func (r Rule) ServiceDisplayName() string

func (Rule) ShortCodeDisplayName

func (r Rule) ShortCodeDisplayName() string

type Status

type Status uint8
const (
	StatusFailed Status = iota
	StatusPassed
	StatusIgnored
)

type TerraformCustomCheck

type TerraformCustomCheck struct {
	RequiredTypes   []string
	RequiredLabels  []string
	RequiredSources []string
	Check           func(*terraform.Block, *terraform.Module) Results
}

Jump to

Keyboard shortcuts

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