chore: replace lazy_static with std::sync::LazyLock (#8815)

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
This commit is contained in:
Rodolfo Olivieri
2026-05-11 19:47:31 -03:00
committed by GitHub
parent 831a7f27d3
commit 826a437d08
4 changed files with 12 additions and 17 deletions
+9 -11
View File
@@ -1,6 +1,6 @@
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::HashMap;
use std::sync::LazyLock;
/// Security threat patterns for command injection detection
/// These patterns detect dangerous shell commands and injection attempts
@@ -315,17 +315,15 @@ pub const THREAT_PATTERNS: &[ThreatPattern] = &[
},
];
lazy_static! {
static ref COMPILED_PATTERNS: HashMap<&'static str, Regex> = {
let mut patterns = HashMap::new();
for threat in THREAT_PATTERNS {
if let Ok(regex) = Regex::new(&format!("(?i){}", threat.pattern)) {
patterns.insert(threat.name, regex);
}
static COMPILED_PATTERNS: LazyLock<HashMap<&'static str, Regex>> = LazyLock::new(|| {
let mut patterns = HashMap::new();
for threat in THREAT_PATTERNS {
if let Ok(regex) = Regex::new(&format!("(?i){}", threat.pattern)) {
patterns.insert(threat.name, regex);
}
patterns
};
}
}
patterns
});
/// Pattern matcher for detecting security threats
pub struct PatternMatcher {