43f27afe3c
Qualified names were often not fully qualified within their defined namespace. For example, modA.modB.ClassC.methD would be named modB.methD at best because we were not tracking the namespace as we traversed the AST nor were we determining the full qualified name of the module py file we are scanning. We improve this by making a eduated guess as the fully qualified name of a module based on the module path. See bandit.core.utils.get_module_qualname_by_path. We traverse the path from right to left. If the directory has a __init__.py we assume it is a parent module. Tests were added in tests_util.py. Since bandit could be used to scan files not in their final install location we also warn that the file is not in an install path and we may not get the proper fully qualified name. We also track the namespace as we traverse the AST. We use the module's FQ name as above as the module's base namespace. We add a Class node visitor which updates that namespace upon entering and leaving a Class definition. We do the same for Func nodes to deal with nested functions. Utility functions were added for managing namespace path that are similar to os.path.{join,split} Change-Id: I90c156eefb4801d7f75f6801343c2700b5421722 |
||
---|---|---|
.. | ||
core | ||
plugins | ||
__init__.py | ||
bandit.py |