fixed the rules engine not being pulled from the application state after refactor earlier

This commit is contained in:
2025-08-22 10:52:35 -05:00
parent 469334d137
commit dbd7cb31c7
2 changed files with 8 additions and 24 deletions

View File

@@ -48,19 +48,8 @@ class Browser:
lazily-loaded singleton factory `get_browser()`. lazily-loaded singleton factory `get_browser()`.
""" """
def __init__(self, storage_dir: Optional[Path] = None) -> None: def __init__(self) -> None:
"""
Args:
storage_dir: Base directory for run artifacts. Defaults to settings.sandbox.storage
(typically /data) if not provided.
"""
if storage_dir is None:
try:
# Prefer your settings models configured storage path
storage_dir = Path(settings.sandbox.storage)
except Exception:
storage_dir = Path("/data") storage_dir = Path("/data")
self.storage_dir: Path = storage_dir self.storage_dir: Path = storage_dir
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
@@ -69,15 +58,13 @@ class Browser:
@staticmethod @staticmethod
def _get_rule_engine(): def _get_rule_engine():
""" """
Retrieve the rules engine instance from the Flask application config. Retrieve the rules engine instance from the application state.
Returns: Returns:
RuleEngine or None: The engine if available, or None if not configured. RuleEngine or None: The engine if available, or None if not configured.
""" """
try: from app.state import get_rules_engine
return current_app.config.get("RULE_ENGINE") return get_rules_engine()
except Exception:
return None
@staticmethod @staticmethod
def _summarize_results(results: List[Dict[str, Any]]) -> Dict[str, int]: def _summarize_results(results: List[Dict[str, Any]]) -> Dict[str, int]:
@@ -537,14 +524,11 @@ except Exception:
@singleton_loader @singleton_loader
def get_browser(storage_dir: Optional[Path] = None) -> Browser: def get_browser() -> Browser:
""" """
Lazily construct and cache a singleton Browser instance. Lazily construct and cache a singleton Browser instance.
Args:
storage_dir: Optional override for artifact base directory.
Returns: Returns:
Browser: The singleton instance. Browser: The singleton instance.
""" """
return Browser(storage_dir=storage_dir) return Browser()

View File

@@ -1,9 +1,9 @@
# SneakyScope — Roadmap (Updated 8-21-25) # SneakyScope — Roadmap (Updated 8-21-25)
## Priority 1 Core Analysis / Stability ## Priority 1 Core Analysis / Stability
* why are the rules not finding anything now?
* if cloudflare, we notate and badge it, along with a blurp that explains how cloudflare is both used for good and evil. * if cloudflare, we notate and badge it, along with a blurp that explains how cloudflare is both used for good and evil.
* need a generalized "total score" for the site. something that is a quick 0/10 (guessing on the number), so new analyst don't have to think on the details. * need a generalized "total score" for the site. something that is a quick 0/10 (guessing on the number), so new analyst don't have to think on the details.
* make a "dectorators" file to unify imports
## Priority 2 UI / UX ## Priority 2 UI / UX
* Rules Lab (WYSIWYG tester): paste a rule, validate/compile, run against sample text; lightweight nav entry. * Rules Lab (WYSIWYG tester): paste a rule, validate/compile, run against sample text; lightweight nav entry.