config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config loads a per-project .godzilla.yaml so a repository can carry its scan policy in version control (CI-5): the gate threshold, path include/exclude filters (e.g. drop findings in test fixtures or generated code), and per-rule disable / severity overrides. CLI flags take precedence over file values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// FailOn is the gate threshold (info|low|medium|high|critical). A CLI
	// -fail-on overrides it.
	FailOn string `yaml:"fail-on"`
	// Exclude drops findings whose file matches any of these path globs. Include,
	// when non-empty, keeps only findings whose file matches one of them (applied
	// before Exclude). Globs use '*' (within a path segment), '**' (across
	// segments), and a bare name matches any path segment (so "testdata" matches
	// any testdata/ directory).
	Exclude []string `yaml:"exclude"`
	Include []string `yaml:"include"`
	Rules   Rules    `yaml:"rules"`
}

Config is the parsed .godzilla.yaml. Every field is optional.

func Load

func Load(root string) (*Config, string, error)

Load reads .godzilla.yaml (or .godzilla.yml) from root. When root is a file, its directory is used. It returns (nil, "", nil) when no config file exists — a missing config is not an error. The returned string is the path loaded.

func LoadFile

func LoadFile(path string) (*Config, error)

LoadFile parses a config file at an explicit path.

func (*Config) ApplyRules

func (c *Config) ApplyRules(rs *rules.RuleSet) *rules.RuleSet

ApplyRules returns a copy of rs with the config's disabled rules removed and severity overrides applied. It leaves rs untouched. Unknown rule IDs in the config are ignored (a rule may simply not be loaded).

func (*Config) FilterFindings

func (c *Config) FilterFindings(findings []analysis.Finding, root string) ([]analysis.Finding, int)

FilterFindings marks findings excluded by the path filters as Suppressed (retained and flagged, consistent with baseline/inline-ignore — auditable, not silently deleted). root is the scan root, used to relativize finding paths for matching. It returns the findings and the number newly excluded.

type Rules

type Rules struct {
	Disable           []string          `yaml:"disable"`            // rule IDs to drop entirely
	SeverityOverrides map[string]string `yaml:"severity-overrides"` // rule ID -> new severity
}

Rules holds per-rule policy.

Jump to

Keyboard shortcuts

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