Skip to main content

Module ruleset

Module ruleset 

Source
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§

AppliedOverlay
An overlay that was applied to a kept document.
Candidate
A rule document together with where it came from.
FsOverlayLoader
Reads overlay files and directories from disk, recording what it read.
InlineOnlyOverlayLoader
A loader that accepts only inline overlays, for fuzzing and benchmarks.
LoadedSources
Everything read from a spec’s sources.
LogsourceSelector
A logsource selector with exact, case-insensitive values.
OverlayEntry
One overlay entry: either inline patches for an id, or a file or directory of overlay files.
OverlayPatch
Metadata keys an overlay may set or append.
ResolveOptions
Options that constrain a resolution.
ResolvedRuleset
A resolved ruleset: the kept collection plus per-document decisions.
RuleEntry
Why one candidate is in or out of the resolved collection.
RuleOrigin
Where a candidate came from.
RuleSelector
A metadata selector. Every key that is set must match; values within a key are alternatives.
RulesetSpec
A named rule set: sources, selectors, dependency policy, overlays, and pipelines.
SourceFile
A file read while resolving a ruleset, with the bytes used to hash it.

Enums§

CandidateDoc
A parsed document from a ruleset source.
Decision
Why a candidate was kept or dropped.
DependencyPolicy
Policy for unresolved correlation references.
DocumentKind
The kind of a Sigma document.
OverlayOrigin
Where an applied overlay came from.
RulesetError
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.
StaleOverlayPolicy
Policy for overlays that match no kept rule.

Traits§

OverlayLoader
Expands file and dir overlay entries. Inline entries are handled by the resolver and are never passed to a loader.

Functions§

load_sources
Load every source declared by spec in 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 in resolve_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.