grippo 0.3.1

Grok, regex, CEL and scrubbing on typed primitives. Up to 9 times faster than the stock Rust regex.
Documentation
// Project:   grippo
// File:      src/shared_tests/windows_text.rs
// Purpose:   Windows text for tests: a CRLF event from the corpus and the lab VMs' samples
// Language:  Rust
//
// License:   Apache-2.0
// Copyright: (c) 2026 HYPERI PTY LIMITED

//! Real Windows text. [`event_4688`] is a committed corpus file. [`lab`] reads
//! the `windows-lab` corpus source, PowerShell and event log output from two
//! Windows images.

#![allow(dead_code, reason = "each area's test uses its own part of this")]

use std::path::PathBuf;

use super::corpus::{file_bytes, root};

/// A file written with CRLF, LF, a lone CR and CRLF again, as the lab VMs hold
/// it in `crlf_mixed.txt`.
pub const CRLF_MIXED: &[u8] = b"crlf one\r\nlf two\ncr three\rcrlf four\r\n";

/// The `windows-lab` corpus source, one folder per Windows image.
pub fn lab_root() -> PathBuf {
    root().join("windows-lab")
}

/// `file` from every lab image that holds it, with the image's name.
pub fn lab(file: &str) -> Vec<(String, Vec<u8>)> {
    let root = lab_root();
    let mut found: Vec<(String, Vec<u8>)> = std::fs::read_dir(&root)
        .unwrap_or_else(|e| panic!("{root:?}: {e}"))
        .flatten()
        .filter_map(|image| {
            let bytes = std::fs::read(image.path().join(file)).ok()?;
            Some((image.file_name().to_string_lossy().into_owned(), bytes))
        })
        .collect();
    found.sort();
    assert!(!found.is_empty(), "no windows-lab image holds {file}");
    found
}

/// Event 4688 as Windows renders it, with CRLF between lines, from the
/// `attack_data` corpus, and the same text with LF.
pub fn event_4688() -> (Vec<u8>, Vec<u8>) {
    let crlf = file_bytes(
        "attack-data",
        "datasets/attack_techniques/T1003.001/atomic_red_team/windows-security.log",
    );
    let lf = String::from_utf8(crlf.clone())
        .expect("the 4688 sample is ASCII")
        .replace("\r\n", "\n")
        .into_bytes();
    assert!(lf.len() < crlf.len(), "the corpus file lost its CRLF");
    (crlf, lf)
}