refactor: separate config service from jail config service
- Split config_service.py into config_service.py and jail_config_service.py - Update Docs/Tasks.md, Security.md, TROUBLESHOOTING.md
This commit is contained in:
@@ -98,17 +98,26 @@ async def _safe_get_typed[T](
|
||||
|
||||
|
||||
def _validate_regex(pattern: str) -> str | None:
|
||||
"""Try to compile *pattern* and return an error message if invalid.
|
||||
"""Validate *pattern* for syntax correctness and ReDoS vulnerabilities.
|
||||
|
||||
Args:
|
||||
pattern: A regex pattern string to validate.
|
||||
|
||||
Returns:
|
||||
``None`` if valid, or an error message string if the pattern is broken.
|
||||
``None`` if valid, or an error message string if the pattern is broken
|
||||
or detected as a ReDoS vulnerability.
|
||||
"""
|
||||
from app.utils.regex_validator import (
|
||||
ReDoSDetectedError,
|
||||
RegexTimeoutError,
|
||||
validate_regex_pattern,
|
||||
)
|
||||
|
||||
try:
|
||||
re.compile(pattern)
|
||||
validate_regex_pattern(pattern)
|
||||
return None
|
||||
except (ReDoSDetectedError, RegexTimeoutError) as exc:
|
||||
return str(exc)
|
||||
except re.error as exc:
|
||||
return str(exc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user