mirror of
https://github.com/fabriziosalmi/patterns.git
synced 2025-12-17 17:55:48 +00:00
Merge pull request #9 from fabriziosalmi/codeflash/optimize-validate_regex-m6xkx22f
⚡️ Speed up function `validate_regex` by 9,172%
This commit is contained in:
commit
1a4a2d4e42
@ -4,6 +4,7 @@ import re
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Optional
|
||||
from functools import lru_cache
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
@ -46,6 +47,7 @@ def load_owasp_rules(file_path: Path) -> List[Dict]:
|
||||
logging.error(f"[!] Error loading OWASP rules: {e}")
|
||||
raise
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def validate_regex(pattern: str) -> bool:
|
||||
"""
|
||||
Validate regex pattern for HAProxy.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user