pub mod classify;
pub mod decode;
pub mod detect;
pub mod entropy;
pub mod fuzzy;
pub mod lowercase;
pub mod patterns;
pub mod scoring;
pub use classify::{
has_lowercase, has_uppercase, is_all_alphanumeric, is_all_base64_chars, is_all_hex,
is_uuid_format,
};
pub use decode::{entropy_with_decode, speculative_decode, DecodeResult, EncodingType};
pub use detect::{cpu_features, CpuFeatures, SimdLevel};
pub use fuzzy::{is_fuzzy_auth_like, is_fuzzy_sensitive, FuzzyMatcher};
pub use entropy::{byte_histogram, calculate_entropy, calculate_entropy_str};
pub use scoring::{quick_score, weighted_sum, FeatureIndex, FeatureVector};
pub use lowercase::{
to_ascii_lowercase, to_ascii_lowercase_inplace, to_ascii_uppercase,
to_ascii_uppercase_inplace,
};
pub use patterns::PatternMatcher;
#[inline]
pub fn init() -> CpuFeatures {
CpuFeatures::detect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_module_exports() {
let _ = init();
let _ = cpu_features();
assert!(is_all_hex("0123456789abcdef"));
assert!(is_uuid_format("550e8400-e29b-41d4-a716-446655440000"));
assert!(is_all_base64_chars("SGVsbG8="));
assert!(is_all_alphanumeric("Hello123"));
assert!(has_uppercase("Hello"));
assert!(has_lowercase("Hello"));
let lower = to_ascii_lowercase("HELLO");
assert_eq!(lower, "hello");
let upper = to_ascii_uppercase("hello");
assert_eq!(upper, "HELLO");
let entropy = calculate_entropy_str("test");
assert!(entropy > 0.0);
let hist = byte_histogram(b"test");
assert_eq!(hist[b't' as usize], 2);
let matcher = PatternMatcher::from_static(&["foo", "bar"]);
assert!(matcher.is_match("foobar"));
}
#[test]
fn test_prebuilt_matchers() {
assert!(patterns::prebuilt::logging_functions().is_match("println"));
assert!(patterns::prebuilt::auth_like().is_match("password"));
assert!(patterns::prebuilt::command_like().is_match("command"));
assert!(patterns::prebuilt::input_like().is_match("request"));
assert!(patterns::prebuilt::placeholders().is_match("changeme"));
}
}