PyPI / sqlalchemy / 2.1.4
sqlalchemy 2.1.4
- Source
- https://github.com/sqlalchemy/sqlalchemy
- Tag scanned
rel_2_1_4- Compared with
rel_2_1_3(0 signals introduced since)- Files
- 890 scanned, 17 skipped (binary, oversized, or unrecognised)
- Signals
- 2 critical · 0 warn · 44 info
- Scan time
- 36.1 s
- LLM review
- Reviewed by claude-haiku-5-5 (Anthropic): 42 of 42 warn and critical signals; 40 demoted to info.
- Disclude version
- 4.0.0
- Scanned (UTC)
- 2026-10-14 18:23
Signals
Ordered by severity, then signals introduced in this release. Hidden characters are shown as ⟨U+…⟩.
-
= =suspicious conftest loads and executes a bootstrap.py file at import time to set up the pytest plugin.Reasoning
Module-scope compile and exec of an external bootstrap file that imports the sqla_pytestplugin into the test namespace. This is an unusual, opaque loading pattern in conftest, but the file is a bundled project bootstrap, so the source is in-repo and readable. Benign-looking but worth a check of bootstrap.py.
-
= # noqasuspicious Module-level exec runs the bootstrap code, which then provides the pytest plugin star-import.Reasoning
Same pattern as the compile finding: exec of a bootstrap file at module scope, followed by a star-import. Executing code from a file in the repo on import is a dynamic loading pattern worth verifying against the bootstrap source, but it is not itself evidence of a payload.
-
passlikely benign Dynamic __import__ of a sibling package module by name in the performance examples.Reasoning
The import name is built from a loop variable inside a try/except ImportError, which is the usual pattern for optionally loading example or profiler modules. The import stays inside the package namespace and no untrusted input is evident in the snippet.
-
likely benign Dynamic import of a profiler module chosen by a CLI argument in the performance examples.
Reasoning
The module name is built from __name__ and args.name, where args comes from the example's own command-line parser. This is a developer-facing example runner selecting one of its own profiler modules, not a payload loader.
-
= . =likely benign Dynamic import of a SQLAlchemy dialect module by name.Reasoning
This is SQLAlchemy's standard dialect loader, importing sqlalchemy.dialects.<name> for a dialect name the library itself resolves. It is a documented plugin mechanism, not obfuscation.
-
= ..likely benign Dynamic import of a MySQL driver-specific module in the MariaDB dialect loader.Reasoning
The import path is a fixed package prefix plus a driver name chosen from a known set of MySQL DBAPI drivers. This is ordinary plugin loading in SQLAlchemy's dialect code.
-
info
critical→ info by reviewdynamic-importlib/sqlalchemy/dialects/mysql/mariadbconnector.py:210:32= ..likely benign Dynamic import of the MariaDB connector's constants module, derived from the loaded DBAPI's name.Reasoning
The import derives from the DBAPI module's own __name__ to reach its constants submodule, which is a standard way to locate driver constants. It is wrapped in a try block for optional support.
-
= ..likely benign Dynamic import of the mysqldb driver's constants module.Reasoning
This matches the MariaDB connector pattern: it derives the constants path from the loaded DBAPI's __name__ inside a try block. It is a normal driver-compatibility lookup.
-
passlikely benign Optional import of a package's provision submodule.Reasoning
The import of '<package>.provision' is guarded by ImportError and belongs to SQLAlchemy's testing/provisioning machinery, where the package name is a library-controlled identifier.
-
# establish pickle capability by adding it to this module =likely benign Registers a dynamically created event class in module globals so pickling works.Reasoning
The comment says this establishes pickle capability by registering the class in module globals, which is a known SQLAlchemy idiom for making dynamically generated classes picklable. No external input is involved.
-
=likely benign eval of a relationship argument string against the declarative class registry.Reasoning
SQLAlchemy's declarative registry evaluates developer-written string expressions in relationship and foreign-key arguments against the class registry. This is a documented feature, and the eval is scoped to a restricted dict, though it does run code from class definitions.
-
) =likely benign Registers a generated Annotated class in module globals by name.Reasoning
The name is built from the class name, and the generated annotated class is registered in globals so it can be pickled and referenced. This is ordinary metaprogramming in SQLAlchemy's annotation module.
-
= =likely benign Looks up and instantiates a coercion implementation class from module globals.Reasoning
The lookup checks globals for a name and instantiates the matching implementation class to populate a registry. This is internal dispatch over the module's own classes, not attacker-controlled reach.
-
= =likely benign exec of generated code to construct closure cells for lambda caching.Reasoning
The exec runs generated code that builds closure cells for SQLAlchemy's lambda statement caching, with the code generated internally from a fixed template and cell values passed as variables. It is a known performance technique, not a payload, though exec is inherently sensitive.
-
= yieldlikely benign Dynamic import of a SQLAlchemy dialect module in the testing engine helper.Reasoning
This is test-engine setup importing sqlalchemy.dialects.<name> for a dialect name from the test suite's own configuration. It is a plain dynamic module load in test utilities.
-
= . = =likely benign Reads the calling file's path via the call stack to build a directory for mypy test files.Reasoning
inspect.stack()[1].filename is used only to locate the caller's directory so test fixture files can be globbed relative to it. This is ordinary test-helper path resolution with no network, decoding, or execution involved.
-
# late = =likely benign Dynamically imports a module by name from test configuration and resolves its components.Reasoning
This is a dotted-path module loader for SQLAlchemy's test plugin. It imports a module name that comes from configuration and then walks attributes. Dynamic import is expected in a plugin system, and the snippet shows nothing hidden or encoded. The critical severity reflects the signal, not the context.
-
# in format_argpsec_plus() returnlikely benign Executes generated function source in a namespace and returns the resulting function.Reasoning
exec runs generated source for a function built from an argspec, which matches SQLAlchemy's known decorator-generation approach for preserving signatures. The code is produced by the library itself, not fetched from outside.
-
= passlikely benign Reads the calling module's __name__ through the frame's globals.Reasoning
sys._getframe(1).f_globals is used to read the caller's module name for a default value, guarded by exception handling. This is a common and benign way to get __name__ from the caller.
-
, , , =, -
, =, ) -
= = -
= = -
= =likely benign Compiles generated function source into a code object for later execution.Reasoning
compile turns generated function source into a code object, with the filename preserved and an entry added to linecache. This is the standard approach for generating functions with a correct traceback, and the source comes from the library's own templates.
-
=likely benign Executes compiled generated source in a local namespace to create a function.Reasoning
This exec follows the compile call and runs the generated code in a controlled env dict to produce the function. It is the same known generated-function pattern, not obfuscated payload delivery.
-
= =likely benign Lazily imports a module from a dotted path and fetches an attribute from it.Reasoning
This is a lazy-loader that imports a dotted module path and walks its attributes to obtain an object. It is a standard deferred-import helper in a large library, and nothing in the snippet is encoded or hidden.
-
= # being called from less than 3 (or given) stacklevels, weird,likely benign Fetches a caller frame at a given stack depth for warning attribution.Reasoning
sys._getframe(stacklevel) is used in a warning helper to find the caller frame for the stacklevel, with a ValueError fallback when the stack is shallow. The anti-analysis flag comes only from co-occurrence of exit or exec elsewhere in the file, which is a weak signal for this legitimate use.
-
= returnlikely benign Executes generated function source in a copied locals namespace and returns the resulting callable.Reasoning
exec runs generated source with a copy of locals to produce a set function, consistent with the library's other generated-function helpers. The source originates in the library, not from external input.
-
) and not in : = =likely benign Imports a module on demand and caches the result on the instance and globals.Reasoning
This is a lazy-module preloader that imports a module when it is first accessed and caches it on the instance and globals. Deferred importing is a well-known pattern for reducing import cost, and the module name is internal.
-
= =likely benign Caches a lazily imported module into globals and the instance dict by key.Reasoning
globals() is used for dictionary-based name caching immediately after the lazy import, which is the same deferred-loading mechanism. The reach-by-name pattern here is ordinary attribute caching, not hidden access.
-
= =likely benign Evaluates a string type annotation in the class namespace to resolve it.Reasoning
eval resolves string or forward-reference type annotations against the class namespace, which is required for typing support in SQLAlchemy. The expression is a type annotation from the library's own code or user declarations, not an external payload.
-
=likely benign Evaluates a string type annotation against base module globals to resolve it.Reasoning
This is the base-globals branch of the same annotation resolution with eval, and it is a standard way to resolve forward references. It is expected in a type-introspection utility.
-
= returnlikely benign Test helper executes generated source code into a scope dict to fetch variables.Reasoning
exec on a locally built code string in a test helper that builds a scope dict to extract typed names; a common test-generation idiom, with no network or obfuscated payload.
-
# test that repr() copies out all argumentslikely benign Test evals repr output of a MySQL type to check it reconstructs correctly.Reasoning
eval of a formatted repr string of a type instance in a test verifying repr round-trips. Standard test technique, no external input.
-
= ..likely benign Dynamically imports the psycopg errors module to get TransactionRollback for version compatibility.Reasoning
__import__ of the psycopg errors submodule based on the installed psycopg name, a standard version-dependent import. No obfuscation.
-
= ..likely benign Dynamically imports psycopg extensions for version-dependent exception class lookup.Reasoning
Same version-compatibility __import__ of psycopg extensions module, a routine test shim.
-
returnlikely benign Collects dialect modules by dynamically importing names from the package's own dialect list.Reasoning
Imports each SQLAlchemy dialect module by name from dialects.__all__ to collect them. Routine, sourced from a fixed in-package list.
-
):likely benign Test execs a generated import of a dialect module to check dialect resolution.Reasoning
exec builds a fixed template importing a dialect by name in a test verifying dialect loading. The name comes from test parameters, not external input.
-
likely benign Test execs generated comparison expressions over a fixed operator set.
Reasoning
Operator-driven exec of strings built from a fixed operator list in a test comparing proxy expressions. The 'decoder import' signal is a heuristic false positive since pickle is unrelated to this exec of local expression strings.
-
likely benign Test execs formatted comparison expression strings built from a fixed operator.
Reasoning
exec of an expression string formatted with a test-controlled operator, in a test of association proxy comparisons. Not external input.
-
likely benign Second exec of formatted comparison expression in the same association proxy test.
Reasoning
Same generated-expression exec over a fixed operator in a test; no external input or obfuscation.
-
return ,likely benign Test execs generated class source into a namespace to inspect the resulting class.Reasoning
exec of generated class source in a glbls namespace to build a test class for inspection. Standard metaprogramming in tests.
-
likely benign Perf script shells out to runsnake to visualize a profile file when enabled.
Reasoning
os.system runs a profiling tool (runsnake) on a filename in a perf script gated by a flag. Runtime shell invocation with a local filename, though it is not a payload; the filename is not externally sourced.
-
= =likely benign A test helper uses exec on generated source to build a lambda-statement function inside an isolated namespace dict.Reasoning
The exec call runs code inside a test helper with a controlled namespace dict. The snippet shows the code is a generated lambda-statement fixture, and the test then pulls a function out of the namespace. This is a common test pattern and not evidence of a dropper. The code variable's origin is not shown, which keeps confidence below the top band.
-
# the repr round tripslikely benign A SQLAlchemy test checks that a ForeignKey's repr round-trips through eval, in a file that also imports pickle.Reasoning
The file imports pickle, which triggers the decoder-import heuristic, and it also calls eval. The snippet shows eval(repr(fk)) inside a test that checks that a ForeignKey repr round-trips. That is ordinary unit-test code. The multi-stage payload shape is not present: nothing is decoded from an encoded blob and then executed.
-
# the repr round tripslikely benign eval is applied to the repr of a local ForeignKey object to verify that the repr round-trips in a test.Reasoning
The eval argument is repr(fk), the repr of a local ForeignKey object, and the result is compared against fk.target_tokens. This is a deliberate round-trip assertion in a test. The input is not attacker-controlled and no external data reaches eval.
Reproduce This Scan
Run disclude locally to verify. Add --format sarif for SARIF output. Add --llm (with an API key in the environment) to include the LLM review.
&&