santh-sigma 0.1.4

Sigma rule compiler for security research
Documentation
//! Performance tests for the sigma compiler
//!
//! Each test has a time bound that must not be exceeded.

use sigma::SigmaCompiler;
use std::time::Instant;

/// 16. Sigma compilation of 50 rules in < 200ms
#[test]
fn sigma_compilation_50_rules_in_200ms() {
    let rules: Vec<String> = (0..50)
        .map(|i| {
            format!(
                r#"
title: Sigma Test Rule {}
logsource:
  product: windows
  category: process_creation
detection:
  selection:
    CommandLine|contains:
      - "powershell.exe"
      - "cmd.exe"
      - "wscript.exe"
    ParentImage|endswith:
      - "\\winword.exe"
      - "\\excel.exe"
      - "\\outlook.exe"
  condition: selection
level: high
"#,
                i
            )
        })
        .collect();

    let start = Instant::now();
    for rule in &rules {
        let _template = SigmaCompiler::compile_str(rule).unwrap();
    }
    let elapsed = start.elapsed();

    assert!(
        elapsed.as_millis() < 200,
        "Compiling 50 Sigma rules took {:?}, expected < 200ms",
        elapsed
    );
}