mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-13 05:07:38 +02:00
Code Analysis: Give pass to 'volatility3'
Also moves some code into a private method with a docstring in the visitor class.
This commit is contained in:
@@ -165,13 +165,16 @@ class ModuleVisitor(NodeVisitor):
|
||||
def violations(self):
|
||||
return self._violations
|
||||
|
||||
def enter_ImportFrom(self, node: ast.ImportFrom):
|
||||
if not node.module:
|
||||
return
|
||||
|
||||
def _check_vol3_import_from(self, node: ast.ImportFrom):
|
||||
"""
|
||||
Ensure that the only thing imported from a volatility3 module (apart
|
||||
from the root volatility3 module) are functions and modules. This
|
||||
prevents re-exporting of classes and variables from modules that use
|
||||
them.
|
||||
"""
|
||||
if (
|
||||
node.module
|
||||
and node.module.startswith("volatility3")
|
||||
and node.module.startswith("volatility3.") # Give a pass to volatility3 module
|
||||
and node.module != "volatility3.framework.constants._version" # make an exception for this
|
||||
):
|
||||
for name in node.names:
|
||||
@@ -198,6 +201,10 @@ class ModuleVisitor(NodeVisitor):
|
||||
)
|
||||
)
|
||||
|
||||
def enter_ImportFrom(self, node: ast.ImportFrom):
|
||||
self._check_vol3_import_from(node)
|
||||
|
||||
|
||||
def enter_ClassDef(self, node: ast.ClassDef) -> Any:
|
||||
logger.debug("Entering class %s", node.name)
|
||||
clazz = None
|
||||
|
||||
Reference in New Issue
Block a user