rules

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package rules loads bumper's declarative rule set. Rules are authored in YAML with a CEL expression as the predicate; this package compiles each predicate once at load time so the engine can evaluate it against every change cheaply.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEnv

func NewEnv() (*cel.Env, error)

NewEnv builds the CEL environment exposing the variables a rule may read (before/after are dynamic; actions/type/address are strongly typed) plus bumper's custom function library.

Types

type Rule

type Rule struct {
	ID       string   `yaml:"id"`
	Severity string   `yaml:"severity"`
	Resource string   `yaml:"resource"` // resource-type filter, e.g. aws_security_group ("" = any)
	On       []string `yaml:"on"`       // change actions this rule applies to ("" = any)
	When     string   `yaml:"when"`     // CEL predicate, must evaluate to bool
	Title    string   `yaml:"title"`
	Fix      string   `yaml:"fix"`
	Refs     []string `yaml:"refs"`

	// Provenance — where this rule came from.
	Source   string `yaml:"source"`   // "custom" | "trivy"
	AVD      string `yaml:"avd"`      // original Trivy/AVD id, e.g. AVD-AWS-0180 ("" for custom)
	Provider string `yaml:"provider"` // "aws" | "gcp" | ... ("" = infer from resource prefix)
	// contains filtered or unexported fields
}

Rule is one declarative check. When (a CEL expression) is evaluated against a normalized resource change; if it returns true, the engine emits a finding.

func (*Rule) Program

func (r *Rule) Program() cel.Program

Program returns the compiled CEL program for this rule.

type Set

type Set struct {
	Rules []*Rule
	// contains filtered or unexported fields
}

Set is a loaded, compiled collection of rules with an id index for O(1) lookup (used by `explain` and findings provenance).

func Load

func Load(extraDir string) (*Set, error)

Load reads the embedded built-in rules plus any *.yaml rules under extraDir (may be ""), compiling every predicate.

func (*Set) ByID

func (s *Set) ByID(id string) (*Rule, bool)

ByID returns the rule with the given id, or (nil, false).

Jump to

Keyboard shortcuts

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