1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! 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")?));
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// Tests assert on outcomes; a failed assertion should abort the test.
pub use ;
pub use ;
/// The mapping set for Sigma's Windows log sources shipped with this crate,
/// ready for [`MappingSet::from_yaml`].
pub const SIGMA_WINDOWS: &str = include_str!;
/// The mapping set for Sigma's AWS log sources shipped with this crate,
/// ready for [`MappingSet::from_yaml`].
pub const SIGMA_AWS: &str = include_str!;
/// The mapping set for Sigma's Okta log source shipped with this crate,
/// ready for [`MappingSet::from_yaml`].
pub const SIGMA_OKTA: &str = include_str!;
/// The mapping set for Sigma's Microsoft 365 log sources shipped with this
/// crate, ready for [`MappingSet::from_yaml`].
pub const SIGMA_M365: &str = include_str!;
/// The mapping set for Sigma's Zeek log sources shipped with this crate,
/// ready for [`MappingSet::from_yaml`].
pub const SIGMA_ZEEK: &str = include_str!;
pub use ;
pub use FieldPath;
pub use ;