Documentation
¶
Overview ¶
Package rule defines rule registration and evaluation infrastructure. input: domain statements and registered statement/global rule implementations output: deterministic finding collection for the audit engine pos: domain rule registry and execution coordination note: if this file changes, update this header and module README.md.
Package rule defines domain findings and rule-engine types. input: rule evaluation details, source-location metadata, and statement/global rule implementations output: normalized findings and registry-facing rule contracts pos: domain rule vocabulary and execution contracts shared across audit evaluation note: if this file changes, update this header and module README.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyRuleID indicates a rule was registered without an ID. ErrEmptyRuleID = errors.New("rule ID must not be empty") // ErrDuplicateRuleID indicates a rule ID was registered more than once. ErrDuplicateRuleID = errors.New("duplicate rule ID") // ErrRuleIDMismatch indicates a rule emitted a finding with a conflicting rule ID. ErrRuleIDMismatch = errors.New("finding rule ID does not match registered rule ID") )
Functions ¶
This section is empty.
Types ¶
type ExplanationMetadata ¶ added in v0.6.2
type ExplanationMetadata struct {
Status string `json:"status,omitempty"`
Note string `json:"note,omitempty"`
}
ExplanationMetadata describes how metadata availability affected a finding explanation.
type Finding ¶
type Finding struct {
RuleID string `json:"rule_id"`
Level Level `json:"level"`
Message string `json:"message"`
StatementIndex int `json:"statement_index,omitempty"`
StatementKind string `json:"statement_kind,omitempty"`
Location *Location `json:"location,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Explanation *FindingExplanation `json:"explanation,omitempty"`
}
Finding is the domain result produced by a rule.
type FindingExplanation ¶ added in v0.6.2
type FindingExplanation struct {
Summary string `json:"summary,omitempty"`
Why string `json:"why,omitempty"`
Risk string `json:"risk,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
Metadata *ExplanationMetadata `json:"metadata,omitempty"`
}
FindingExplanation captures additive explanation data for one finding.
type GlobalRule ¶
type GlobalRule interface {
ID() string
EvaluateAll(statements []spec.Statement) ([]Finding, error)
}
GlobalRule evaluates the full statement batch.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores rule registrations in deterministic order.
func (*Registry) EvaluateGlobal ¶
EvaluateGlobal applies global rules in registration order.
func (*Registry) EvaluateStatement ¶
EvaluateStatement applies all matching statement rules in registration order.
func (*Registry) RegisterGlobal ¶
func (r *Registry) RegisterGlobal(rule GlobalRule) error
RegisterGlobal appends a global rule to the registry.
func (*Registry) RegisterStatement ¶
func (r *Registry) RegisterStatement(rule StatementRule) error
RegisterStatement appends a statement rule to the registry.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package catalog defines explanation-oriented metadata for shipped audit rules.
|
Package catalog defines explanation-oriented metadata for shipped audit rules. |
|
Package ddl defines Tier-1 DDL rules.
|
Package ddl defines Tier-1 DDL rules. |
|
Package dml defines Tier-1 DML rules.
|
Package dml defines Tier-1 DML rules. |