Skip to main content

Crate goliath_rule

Crate goliath_rule 

Source
Expand description

Detection rules resolved to OCSF paths.

A rule language such as Sigma names fields the way a log source names them. Goliath evaluates OCSF events, so every rule is resolved once, at load time, into a form that refers only to OCSF paths. The streaming match engine and the ClickHouse backend both consume that form and never the original, which is what keeps them from disagreeing about what a rule means. The decision is docs/adr/0012-sigma-field-mapping.md.

This crate holds the pieces every execution path shares: paths into an event, the case folding that defines case insensitive comparison, and the field mappings that translate a rule language’s field names into paths.

§Example

use goliath_rule::{FieldPath, MappingSet, sigma};

let rule = goliath_sigma::parse_rule(
    r"
title: Notepad opens a script
logsource: { category: process_creation, product: windows }
detection:
  selection:
    Image|endswith: '\notepad.exe'
    CommandLine|contains: '.ps1'
  condition: selection
",
)?;
let mappings = MappingSet::from_yaml(goliath_rule::SIGMA_WINDOWS)?;
let resolved = sigma::resolve(&rule, &mappings)?;

// Sigma's `Image` became OCSF paths, and the log source became a class.
let text = serde_json::to_string(&resolved)?;
assert!(text.contains("process.file.path"));
assert!(resolved.class.contains_key(&FieldPath::parse("class_uid")?));

Re-exports§

pub use error::MappingError;
pub use error::NetworkError;
pub use error::PathError;
pub use error::ResolveError;
pub use fold::fold;
pub use fold::fold_into;
pub use mapping::ClassValue;
pub use mapping::LogSourceSelector;
pub use mapping::MappingSet;
pub use mapping::SourceMapping;
pub use path::FieldPath;
pub use resolved::Comparison;
pub use resolved::Expr;
pub use resolved::MappingVersion;
pub use resolved::Network;
pub use resolved::Number;
pub use resolved::Predicate;
pub use resolved::ResolvedRule;
pub use resolved::StringTest;
pub use resolved::Test;

Modules§

error
Error types.
fold
Case folding for case insensitive comparison.
mapping
Field mappings: from a rule language’s field names to OCSF paths.
path
Dotted paths into an OCSF event.
resolved
The resolved form of a rule.
sigma
Resolving Sigma rules into the resolved form.

Constants§

SIGMA_AWS
The mapping set for Sigma’s AWS log sources shipped with this crate, ready for MappingSet::from_yaml.
SIGMA_M365
The mapping set for Sigma’s Microsoft 365 log sources shipped with this crate, ready for MappingSet::from_yaml.
SIGMA_OKTA
The mapping set for Sigma’s Okta log source shipped with this crate, ready for MappingSet::from_yaml.
SIGMA_WINDOWS
The mapping set for Sigma’s Windows log sources shipped with this crate, ready for MappingSet::from_yaml.
SIGMA_ZEEK
The mapping set for Sigma’s Zeek log sources shipped with this crate, ready for MappingSet::from_yaml.