rules

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear removes all registered rules (used in tests or reload).

func Register

func Register(r *Rule) error

Register registers a rule into the global registry.

Types

type Rule

type Rule struct {
	ID          string    // Unique rule ID (e.g., "sql-injection")
	Title       string    // Human-readable title
	Category    string    // Category (e.g., "security", "style", "performance")
	Severity    string    // Severity level (e.g., "HIGH", "LOW")
	Description string    // Detailed description
	Suggestion  string    // Suggested fix
	References  []string  // External documentation links
	Engine      RuleFunc  // Optional Go-based rule implementation
	YAML        *YAMLRule // Optional YAML-based definition
	Enabled     bool      // If the rule is enabled
}

Rule represents metadata and behavior for a registered rule.

func All

func All() []*Rule

All returns all registered rules.

func EnabledRules

func EnabledRules() []*Rule

EnabledRules returns only rules that are marked as enabled.

func Get

func Get(id string) (*Rule, bool)

Get returns a rule by its ID.

type RuleFunc

type RuleFunc func(ctx *analyzer.AnalyzerContext) ([]result.Issue, error)

RuleFunc defines the function signature for Go-based rules.

type YAMLRule

type YAMLRule struct {
	Pattern string            `yaml:"pattern"`
	Filters map[string]string `yaml:"filters,omitempty"`
}

YAMLRule represents a YAML-based rule definition.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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