Documentation
¶
Overview ¶
Package rulefiles reads a project's own check rules, each one written in Datalog in a YAML file, and compiles them into a catalog source (agni issue 1713). A project lists the files under `rules:` in its project.yaml, and `agni check` runs them beside the built-in rules.
One file holds one rule. The match goal yields the subjects that fail, the optional domain goal yields every subject the rule examined, and the subjects in the domain and not in the match pass. So a rule with a domain states its considered set, as a built-in Datalog rule does. A rule without one reports failures only. docsite/content/build/check-rule.md#a-projects-own-rules is the authoring guide.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
Compile turns d into a check.Rule over reg. The catalog shows it under its source, as `<source>/<name>`. reg is the run's vocabulary, so the rule can call the project's library. A relation the vocabulary lacks, a subject the goal does not project or a domain that does not key like the match is an error naming the file.
Types ¶
type Def ¶
type Def struct {
// Name is the rule's name within the project. The catalog shows it as `<project>/<name>`.
Name string `yaml:"name"`
Severity string `yaml:"severity"` // error, warning or info; warning when empty
Summary string `yaml:"summary"`
Impact string `yaml:"impact,omitempty"`
Remedy string `yaml:"remedy,omitempty"`
// Kind is what the subject is: net, component or pin.
Kind string `yaml:"kind"`
// Match is a Datalog query whose rows are the failing subjects. Clauses written ahead of its goal
// are visible to Domain too.
Match string `yaml:"match"`
// Subject names the projected variable that binds the subject, and Pin the one that binds its pin
// on a pin-kind rule. Neither carries a leading "?".
Subject string `yaml:"subject"`
Pin string `yaml:"pin,omitempty"`
// Message is the finding's text, with {var} replaced by that variable's value in the row.
Message string `yaml:"message"`
// Domain is a Datalog query whose rows are every subject the rule examined. It must project
// Subject, and Pin when set. Empty means the rule reports failures only.
Domain string `yaml:"domain,omitempty"`
// Witness is a passing subject's statement, interpolated from its domain row. It is required
// with Domain.
Witness string `yaml:"witness,omitempty"`
// Context names further projected variables, each shown on the finding as a context entity.
Context []Context `yaml:"context,omitempty"`
// File is where the rule came from, for an error message. It is not read from the YAML.
File string `yaml:"-"`
}
Def is one rule as its file declares it, before compiling. It is a value, so a host can carry the rules it read to the place that knows the run's vocabulary.