Core: Renable the import protection for volatility3.framework.plugins

In commit 21d916b (about 10 months ago) the logic for the warning about
volatility3.framework importing was disabled.  This re-enables it.

Also updates to support pyinstaller 5.10 function stack depth.

Closes #944
This commit is contained in:
Mike Auty
2023-04-30 09:02:40 +01:00
parent 900ab70452
commit 317f565685
+5 -2
View File
@@ -38,10 +38,13 @@ class WarningFindSpec(abc.MetaPathFinder):
"""Mock find_spec method that just checks the name, this must go
first."""
if fullname.startswith("volatility3.framework.plugins."):
warning = "Please do not use the volatility3.framework.plugins namespace directly, only use volatility3.plugins"
warning = f"Import {fullname}: Please do not use the volatility3.framework.plugins namespace directly, only use volatility3.plugins"
# Pyinstaller uses walk_packages/_collect_submodules to import, but needs to read the modules to figure out dependencies
# As such, we only print the warning when directly imported rather than from within walk_packages/_collect_submodules
if inspect.stack()[-2].function in ["walk_packages", "_collect_submodules"]:
if inspect.stack()[-2].function not in [
"walk_packages",
"_collect_submodules",
] and inspect.stack()[-3].function not in ["_collect_submodules"]:
raise Warning(warning)