loader

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: 10 Imported by: 0

Documentation

Overview

Package loader reads Godzilla taint rules from YAML files (user-supplied or built-in) into rules.RuleSet values.

Fragments (`extend:`)

To avoid copy-pasting the same source/propagator lists into every rulepack, a `_`-prefixed YAML file (e.g. rulepacks/_go-common.yaml) is a FRAGMENT: a partial rule (a mapping of pattern-list fields such as sources/propagators/ request_object_sources), not a rulepack. A rule pulls a fragment in with a top-level `extend: $_go-common.yaml` (or a list, `extend: [$_a.yaml, $_b.yaml]`); the loader appends each fragment's list fields ahead of the rule's own (deduped) before the rule is validated or compiled. A rule keeps its own scalar fields (id/severity/cwe/message) and adds its own sinks and any extra sources/propagators. Builtin fragments are always available; a user rules directory may add its own (or override a builtin of the same name).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Builtin

func Builtin() (*rules.RuleSet, error)

Builtin loads Godzilla's embedded, shipped-in-the-binary rule set (the top-level rulepacks/*.yaml), expanding `$<fragment>` references against the embedded `_`-prefixed fragment files.

func LoadDefault

func LoadDefault(userPath string) (*rules.RuleSet, error)

LoadDefault returns Godzilla's built-in rules merged with the user-supplied rule file — or rulepack directory — at userPath, if any (userPath == "" means "no user rules"). User rules are appended after built-ins, so they take effect alongside (not instead of) the defaults.

func LoadDir

func LoadDir(dir string) (*rules.RuleSet, error)

LoadDir loads and merges every *.yaml/*.yml rulepack directly under dir (non-recursive). Files are read in the order returned by os.ReadDir, which is lexical. `_`-prefixed fragment files are consumed as fragments, not rules.

func LoadFile

func LoadFile(path string) (*rules.RuleSet, error)

LoadFile reads a single YAML rule file and unmarshals it into a RuleSet, expanding any `$<fragment>` references against the builtin fragments plus any fragment files sitting in the same directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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