The recursive internet scanner for hackers. 🧡
Python asmattack-surface-managementautomationbugbountyclieasmhackingneo4josintosint-frameworkpentestingpythonreconrecursionscannersubdomain-enumerationsubdomain-scannersubdomainsthreat-intelligencethreatintel
fix: request sqlalchemy's asyncio extra in the SQL output modules (#3505)
Paul Mueller7aeee20235b8
diff --git a/bbot/modules/output/mysql.py b/bbot/modules/output/mysql.pyindex b09d101b4..ac929016a 100644--- a/bbot/modules/output/mysql.py+++ b/bbot/modules/output/mysql.py@@ -20,7 +20,7 @@ class MySQL(SQLTemplate):10, description="Number of times to retry connecting to the database (1 second between retries)")- deps_pip = ["sqlmodel", "aiomysql"]+ deps_pip = ["sqlmodel[asyncio]", "aiomysql"]protocol = "mysql+aiomysql"async def create_database(self):diff --git a/bbot/modules/output/postgres.py b/bbot/modules/output/postgres.pyindex a94ade61b..000e73845 100644--- a/bbot/modules/output/postgres.py+++ b/bbot/modules/output/postgres.py@@ -20,7 +20,7 @@ class Postgres(SQLTemplate):10, description="Number of times to retry connecting to the database (1 second between retries)")- deps_pip = ["sqlmodel", "asyncpg"]+ deps_pip = ["sqlmodel[asyncio]", "asyncpg"]protocol = "postgresql+asyncpg"async def create_database(self):diff --git a/bbot/modules/output/sqlite.py b/bbot/modules/output/sqlite.pyindex f48b80055..852426715 100644--- a/bbot/modules/output/sqlite.py+++ b/bbot/modules/output/sqlite.py@@ -18,7 +18,7 @@ class SQLite(SQLTemplate):10, description="Number of times to retry connecting to the database (1 second between retries)")- deps_pip = ["sqlmodel", "aiosqlite"]+ deps_pip = ["sqlmodel[asyncio]", "aiosqlite"]async def setup(self):db_file = self.config.get("database", "")diff --git a/bbot/test/test_step_1/test_depsinstaller.py b/bbot/test/test_step_1/test_depsinstaller.pyindex 6d6ab8bee..c45abb2e2 100644--- a/bbot/test/test_step_1/test_depsinstaller.py+++ b/bbot/test/test_step_1/test_depsinstaller.py@@ -156,3 +156,35 @@ async def test_depsinstaller_stale_pip_cache(monkeypatch, bbot_scanner):for module_name in (missing_module, present_module):preloaded.pop(module_name, None)await scan._cleanup()+++def test_sql_modules_request_sqlalchemy_asyncio_extra():+ """SQLAlchemy 2.1 moved greenlet out of its default install and into the `asyncio` extra.++ The SQL output modules drive `sqlalchemy.ext.asyncio`, which hard-requires greenlet, so each+ one must ask for the extra explicitly. A bare `sqlmodel` resolves without greenlet and the+ module then hard-fails setup at scan time.+ """+ from bbot.core.modules import MODULE_LOADER++ MODULE_LOADER.preload()+ preloaded = MODULE_LOADER.preloaded()++ sqlmodel_modules = sorted(+ name+ for name, module in preloaded.items()+ if any(dep.split("[")[0].split("=")[0].split("~")[0].strip() == "sqlmodel" for dep in module["deps"]["pip"])+ )+ assert sqlmodel_modules, "expected to find modules depending on sqlmodel"++ for module_name in sqlmodel_modules:+ deps_pip = preloaded[module_name]["deps"]["pip"]+ provides_greenlet = any(+ (dep.startswith("sqlmodel[") and "asyncio" in dep.split("]")[0])+ or dep.split("=")[0].split("~")[0].split("<")[0].split(">")[0].strip() == "greenlet"+ for dep in deps_pip+ )+ assert provides_greenlet, (+ f"{module_name}.deps_pip must pull in greenlet "+ f"(via sqlmodel[asyncio] or an explicit greenlet dep), got {deps_pip}"+ )