Expand description
Named rulesets: curated, overlaid rule collections resolved in memory.
A ruleset is declared under rulesets: in rsigma.yaml and names its
sources, include and exclude selectors, dependency policy, overlays, and
pipelines. resolve_ruleset validates the spec, loads every source with
per-document provenance, and returns a SigmaCollection ready for
evaluation or emission.
use rsigma_parser::ruleset::{resolve_ruleset, ResolveOptions, RulesetSpec};
let dir = tempfile::tempdir().unwrap();
std::fs::write(
dir.path().join("rule.yml"),
"title: Whoami\nlogsource:\n product: windows\ndetection:\n selection:\n CommandLine|contains: whoami\n condition: selection\n",
)
.unwrap();
let spec: RulesetSpec = yaml_serde::from_str(&format!(
"sources:\n - {}\n",
dir.path().display()
))
.unwrap();
let resolved = resolve_ruleset("local", &spec, &ResolveOptions::default()).unwrap();
assert_eq!(resolved.collection.rules.len(), 1);Structs§
- Applied
Overlay - An overlay that was applied to a kept document.
- Candidate
- A rule document together with where it came from.
- FsOverlay
Loader - Reads overlay files and directories from disk, recording what it read.
- Inline
Only Overlay Loader - A loader that accepts only inline overlays, for fuzzing and benchmarks.
- Loaded
Sources - Everything read from a spec’s sources.
- Logsource
Selector - A logsource selector with exact, case-insensitive values.
- Overlay
Entry - One overlay entry: either inline patches for an id, or a file or directory of overlay files.
- Overlay
Patch - Metadata keys an overlay may set or append.
- Resolve
Options - Options that constrain a resolution.
- Resolved
Ruleset - A resolved ruleset: the kept collection plus per-document decisions.
- Rule
Entry - Why one candidate is in or out of the resolved collection.
- Rule
Origin - Where a candidate came from.
- Rule
Selector - A metadata selector. Every key that is set must match; values within a key are alternatives.
- Ruleset
Spec - A named rule set: sources, selectors, dependency policy, overlays, and pipelines.
- Source
File - A file read while resolving a ruleset, with the bytes used to hash it.
Enums§
- Candidate
Doc - A parsed document from a ruleset source.
- Decision
- Why a candidate was kept or dropped.
- Dependency
Policy - Policy for unresolved correlation references.
- Document
Kind - The kind of a Sigma document.
- Overlay
Origin - Where an applied overlay came from.
- Ruleset
Error - A failure while resolving a ruleset. Every variant maps to a configuration error (exit 3) at the CLI, except source parse errors, which follow each command’s existing policy.
- Stale
Overlay Policy - Policy for overlays that match no kept rule.
Traits§
- Overlay
Loader - Expands
fileanddiroverlay entries. Inline entries are handled by the resolver and are never passed to a loader.
Functions§
- load_
sources - Load every source declared by
specin declaration order, parsing each file separately so every document keeps its origin. - resolve_
loaded - Resolve already-loaded sources into a collection, applying metadata
overlays through
loader. The spec is validated first, as inresolve_ruleset. - resolve_
ruleset - Resolve a ruleset from its spec, loading sources from disk.
- validate_
ruleset_ name - Ruleset names become metric labels, file names, and CLI arguments.
- validate_
spec - Static validation of a ruleset spec: names, unknown keys, empty selectors, enum values, globs, and overlay entry shapes.