Skip to main content

Module custom_rules

Module custom_rules 

Source

Structs§

CustomRule
A user-defined rule loaded from YAML. Fires when source, sink, and path predicates all match a propagation path produced by the engine.
MatchSpec
MetadataMatcher
Metadata matcher: map of field -> predicate, with an optional not sub-matcher (negation). The not: key is reserved and parsed specially — it cannot be used as a metadata field name.
MetadataOp
NodeMatcher
PathMatcher

Enums§

CustomRuleError
MetadataPredicate
Per-field metadata predicate. Bare string is equals (back-compat with v0.4.x). Operator object supports equals, not_equals, contains (substring match on string values), and in (any-of allowed values).
OneOrMany
A scalar-or-list helper. Lets YAML write node_type: secret (single value) or node_type: [secret, identity] (any-of). Single form preserved for backward compatibility with v0.4.x rule files.

Functions§

evaluate_custom_rules
Evaluate every (rule, path) pair. A finding is produced when the rule’s source, sink, and path predicates all match. Findings carry the rule id in the message so operators can trace back to the originating YAML.
load_rules_dir
Load all *.yml and *.yaml files from dir. Files are read in sorted order for deterministic output. Returns a list of all errors alongside successfully parsed rules — callers decide whether to fail fast or continue.
load_rules_dir_with_opts
Like load_rules_dir but lets the caller decide what to do with symlinks that escape the declared directory.
parse_rules_multi_doc
Parse a YAML string containing one or more CustomRule documents (separated by ---). Single-doc files behave identically to the legacy serde_yaml::from_str::<CustomRule> path. Empty/whitespace-only documents (e.g. a leading --- followed by a real doc) are skipped.
parse_rules_multi_doc_with_source
Parse one or more CustomRule documents from content and stamp every produced rule with source_file = source so downstream finding emission can attribute authority back to the originating YAML file. Used by load_rules_dir to thread file paths through into FindingSource::Custom.