Including imported modules and packages
To translate Python applications and prepare for a scan, OpenText SAST searches for any imported modules and packages used by the application. OpenText SAST does not respect the PYTHONPATH environment variable, which the Python runtime system uses to find imported modules and packages.
OpenText SAST searches for imported modules and packages using the list of directories in the following order:
The common root directory for all project source files. which OpenText SAST calculates automatically. For example, if there are two project directories
PrimaryDir/project1/*andPrimaryDir/project2/*, the common root directory isPrimaryDir.To remove the common root directory as a search target for imported modules and packages, include the
-python-no-auto-root-calculationoption in the translation command.The directories specified with the
-python-pathoption.OpenText SAST includes a subset of modules from the standard Python library (module "builtins", all modules originally written in C, and others) in the translation. OpenText SAST first searches for a standard Python library module in the set included with OpenText SAST and then in the paths specified with the
-python-pathoption. If your Python code imports any module that OpenText SAST cannot find, it produces a warning. To make sure that all modules of the standard Python library are found, add the path to your standard Python library in the-python-pathlist.The current directory that contains the file being translated. For example, when OpenText SAST translates a
PrimaryDir/project1/a.py, the directoryPrimaryDir/project1is added as the last directory to search for imported modules and packages.