PyPI / sqlalchemy / 2.1.6
sqlalchemy 2.1.6
- Source
- https://github.com/sqlalchemy/sqlalchemy
- Tag scanned
rel_2_1_6- Compared with
rel_2_1_5(0 signals introduced since)- Files
- 887 scanned, 17 skipped (binary, oversized, or unrecognised)
- Signals
- 0 critical · 0 warn · 46 info
- Scan time
- 41.7 s
- LLM review
- Reviewed by claude-haiku-5-5 (Anthropic): 42 of 42 warn and critical signals; 42 demoted to info.
- Disclude version
- 4.1.0
- Scanned (UTC)
- 2026-10-22 09:14
Signals
Ordered by severity, then signals introduced in this release. Hidden characters are shown as ⟨U+…⟩.
-
passlikely benign Dynamic import of a sibling profiler module by name inside the examples package.Reasoning
The __import__ call builds a module path from the package's own __name__ and a name discovered within the package, inside a try/except ImportError. This is ordinary plugin discovery in a bundled example, with no network, shell or encoded payload involved.
-
likely benign Dynamic import of a profiler module selected by a command-line argument.
Reasoning
The module name is formed from __name__ and a command-line profiler name. It is a standard way to load a selected profiling target in an example script and carries no sign of malicious intent.
-
= . =likely benign Loads a SQLAlchemy database dialect module by name.Reasoning
This is SQLAlchemy's dialect loader, which imports sqlalchemy.dialects.<name> for a dialect name the user configured. The prefix is fixed and the name is restricted to dialect identifiers, so this is the expected plugin mechanism.
-
= ..likely benign Loads a MySQL/MariaDB driver-specific dialect module.Reasoning
The loader imports sqlalchemy.dialects.mysql.<driver> for a driver name, a standard MariaDB dialect selection routine in the library, not an attack pattern.
-
info
critical→ info by reviewdynamic-importlib/sqlalchemy/dialects/mysql/mariadbconnector.py:210:32= ..likely benign Imports the MariaDB connector's constants module to read client flags.Reasoning
It imports the DBAPI's own constants submodule using the DBAPI's __name__ and reads CLIENT flags, a compatibility lookup inside a try block with no outbound or encoded behaviour.
-
= ..likely benign Imports the mysqldb DBAPI's constants module to read client flags.Reasoning
This is the same DBAPI-constants lookup as the MariaDB connector, derived from the configured dbapi's __name__. It is routine compatibility code.
-
passlikely benign Optionally imports a package's provision module for test setup.Reasoning
It imports '<package>.provision' inside a try/except ImportError, the usual optional-test-provisioning hook in SQLAlchemy's testing machinery. The package name comes from the library's own test setup.
-
# establish pickle capability by adding it to this module =likely benign Registers a dynamically created event class in module globals for pickling.Reasoning
Assigning a class into module globals() is a known SQLAlchemy technique that makes dynamically created event classes picklable under their names. It is a legitimate metaprogramming idiom, not hidden behaviour.
-
=likely benign Evaluates a developer-supplied string expression against the ORM class registry.Reasoning
eval runs on a string argument of the ORM class registry, which evaluates expressions written by the developer in relationship declarations, with the registry dict as the namespace. This is a documented SQLAlchemy feature, though string eval is a risk if the input is untrusted.
-
) =likely benign Registers a generated Annotated class in module globals for pickling.Reasoning
This writes a generated 'Annotated<ClassName>' class into globals() so that annotated SQL element classes can be pickled. It is a standard internal naming pattern in SQLAlchemy.
-
= =likely benign Looks up and instantiates a coercion implementation class by name from globals.Reasoning
This looks up a name in globals() to pick a coercion implementation class and instantiates it. It is an internal registry lookup with no external input.
-
= =likely benign Executes generated helper code to construct closure cells for lambda SQL caching.Reasoning
exec runs generated source for a 'make_cells' helper that builds closure cells for SQL lambda caching. The code is produced internally from the library's templates, not from untrusted input, and the result is a closure factory.
-
= yieldlikely benign Dynamically imports a dialect module for test engine construction.Reasoning
This imports sqlalchemy.dialects.<name> in the test-engine helper to obtain a dialect for a named test configuration. It is test scaffolding with a fixed prefix.
-
= . = =likely benign Reads the caller's file path via the call stack to locate test fixture files.Reasoning
inspect.stack()[1] is used to find the caller's file path so a test fixture can locate sibling files. This is a common test-utility pattern with no network or execution behaviour.
-
# late = =likely benign Imports a test module by name and walks its attribute path.Reasoning
This imports a module name from the test plugin configuration and walks its attributes to reach the target. It is standard pytest/test-plugin loading code.
-
# in format_argpsec_plus() returnlikely benign Executes generated source to build a test function with a matching signature.Reasoning
exec compiles a generated function definition whose argument signature was formatted from an existing function, and returns the named function. This is a known approach for preserving signatures in test wrappers, with no external input.
-
= passlikely benign Reads the calling frame's __name__ to determine the module context.Reasoning
sys._getframe(1) is used to read the caller's module name for table/schema setup inside a testing helper, with the exception handled. This is a common, legitimate introspection pattern in Python libraries.
-
, , , =, -
, =, ) -
= = -
= = -
= =likely benign Compiles dynamically generated function source during decorator creation.Reasoning
compile() is applied to generated source text inside SQLAlchemy's decorator/function-generation helper (it caches entries in linecache), a known legitimate metaprogramming technique. The code is generated internally, not attacker-supplied.
-
=likely benign Executes generated wrapper source to build a function with a given signature.Reasoning
exec of the compiled generated code into a namespace env, followed by extracting the named function, is the standard generated-function pattern used by SQLAlchemy's langhelpers. Source is internally produced.
-
= =likely benign Lazily imports a module from a dotted path and walks its attributes.Reasoning
__import__ on a modulepath followed by attribute traversal is a lazy-loading helper for resolving dotted names, used for deferred imports. The module path is a library-internal argument, not untrusted input in this snippet.
-
= # being called from less than 3 (or given) stacklevels, weird,likely benign Retrieves a caller frame at a given stack level for diagnostics.Reasoning
sys._getframe with a stacklevel is used to find the caller for warning/deprecation reporting, with ValueError handling for shallow stacks. The anti-analysis label is driven only by the file also containing exit/exec calls, which is normal for this library.
-
= returnlikely benign Executes internally generated source to define a helper function.Reasoning
exec of code into a copied locals namespace returning env['set'] is a generated-source helper for producing a function, consistent with SQLAlchemy's internal code generation. No external input is evident.
-
) and not in : = =likely benign Lazily imports a module on first attribute access and caches it.Reasoning
This is a lazy module loader that imports a named module on first attribute access and caches it in __dict__ and globals. It is a standard deferred-import pattern and the module names are fixed in the library.
-
= =likely benign Caches the lazily imported module in the globals namespace.Reasoning
Reading globals()[key] after a lazy import is the caching step of the same preloading helper. It is a benign, well-understood Python idiom here.
-
= =likely benign Evaluates a string annotation in a class namespace to resolve its type.Reasoning
eval of a type annotation string with class and base namespaces is how SQLAlchemy resolves forward-reference annotations, as typing.get_type_hints does. The input is source annotations, not external data.
-
=likely benign Evaluates a string annotation against module globals as a fallback.Reasoning
Same annotation-resolution eval using base globals as a fallback, with exception wrapping into NameError. This is standard forward-ref resolution.
-
= returnlikely benign Test helper that executes a code snippet to extract named variables.Reasoning
exec in a test helper builds a scope from generated test code and returns a named variable. Test-only code with no sign of malicious use.
-
= =likely benign Loads and executes a repository bootstrap file to configure the test environment.Reasoning
The test conftest reads a bootstrap.py from the repository and compiles and execs it at import. This is unusual and runs on import, but the file is a local project file used to bootstrap the test plugin, so it is most likely a legitimate test setup pattern.
-
= # noqalikely benign Execs the bootstrap code at module scope to load the pytest plugin.Reasoning
Executes the bootstrap code into the conftest globals and then imports the pytest plugin, consistent with the compile at line 56. It is a project-local setup step, though running it at import time warrants a glance at the bootstrap file's contents.
-
# test that repr() copies out all argumentslikely benign Evaluates the repr of a MySQL type instance to verify round-tripping in a test.Reasoning
eval of a repr-generated string for a MySQL type in a test checks that repr copies all arguments. The input is the test's own type instance, so it is a benign test assertion.
-
= ..likely benign Dynamically imports the psycopg errors module to pick the rollback exception class.Reasoning
__import__ builds the psycopg errors submodule name from the installed driver's own __name__ to select the right exception class by version. This is a standard driver-compatibility shim in tests.
-
= ..likely benign Dynamically imports the psycopg extensions module for a version-specific exception class.Reasoning
Same psycopg compatibility import, here selecting the extensions module for the older driver version. The module name derives from the installed driver, so this is a benign test shim.
-
returnlikely benign Test helper that dynamically imports SQLAlchemy dialect submodules by name.Reasoning
Dynamic __import__ over a list of dialect names from the package's own __all__ inside a test helper. Benign test-suite dynamic loading of a trusted, local package; no network or encoded payload.
-
):likely benign Test code that execs a generated import statement to exercise dialect loading.Reasoning
exec builds a dialect import string from test-controlled names to verify a dialect loads. This is ordinary test scaffolding within SQLAlchemy's test suite, not an obfuscated or malicious payload.
-
likely benign Test code generating comparison expressions via exec for association proxy operator tests.
Reasoning
The pickle-plus-exec co-occurrence is a heuristic hit; the exec strings are formatted with a test-local comparison operator to generate expressions for testing association proxy operators. Legitimate test code, not a multi-stage payload.
-
likely benign Test exec of a formatted comparison expression for association proxy checks.
Reasoning
exec of a string formatted with a loop-controlled operator inside a test to check operator behavior. Dynamic code in tests of this kind is a normal pattern; no external input or obfuscation.
-
likely benign Second test exec of a formatted comparison expression for association proxy checks.
Reasoning
Same exec of a test-generated comparison string at the adjacent line. Benign test scaffolding within the SQLAlchemy test suite.
-
return ,likely benign Test helper that execs generated class source and returns the resulting class.Reasoning
exec of locally generated class source code into a namespace dict, then reads back the class. This is a common test technique for building classes dynamically; the code is not from untrusted input.
-
likely benign Perf script that shells out to runsnake to view a profile file.
Reasoning
os.system with a formatted filename for an optional profiling tool (runsnake) in a perf script. The command is built from a local filename argument, not remote data; shell injection risk is minor in a developer perf script and this is not a dropper.
-
= =likely benign Test code that execs generated source to build a lambda-statement helper.Reasoning
exec of a generated code string into a dict to produce a fake lambda module for testing lambda statement generation. Test-only dynamic code generation, no obfuscation.
-
# the repr round tripslikely benign Test that evals the repr of a ForeignKey to verify round-tripping.Reasoning
Heuristic co-occurrence of pickle import and eval; the eval is repr round-tripping of a ForeignKey in a test. Legitimate test of repr behavior, not a payload.
-
# the repr round tripslikely benign eval of a ForeignKey repr inside a round-trip test.Reasoning
eval of repr(fk) in a unit test checking that the repr round-trips. Trusted local object, standard test idiom.
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.
&&