diff --git a/Ghidra/Features/PyGhidra/src/main/py/README.md b/Ghidra/Features/PyGhidra/src/main/py/README.md index b68c86131d..4550be5b4b 100644 --- a/Ghidra/Features/PyGhidra/src/main/py/README.md +++ b/Ghidra/Features/PyGhidra/src/main/py/README.md @@ -325,6 +325,11 @@ import pdb # imports Python's pdb import pdb_ # imports Ghidra's pdb ``` ## Change History +__2.2.1:__ +* PyGhidra now launches with the current working directory removed from `sys.path` to prevent + the potential for importing invalid modules from random `ghidra/` or `java/` directories that may + exist in the user's current working directory. + __2.2.0:__ * [`pyghidra.open_program()`](#pyghidraopen_program) and [`pyghidra.run_script()`](#pyghidrarun_script) now accept a `nested_project_location` parameter diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/__init__.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/__init__.py index c404603f10..acff535673 100644 --- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/__init__.py +++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ## -__version__ = "2.2.0" +__version__ = "2.2.1" # stub for documentation and typing # this is mostly to hide the function parameter diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py index a8864d65f1..1b8ed13bfc 100644 --- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py +++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py @@ -429,6 +429,10 @@ class PyGhidraLauncher: **jpype_kwargs ) + # Remove CWD from sys.path so we don't try to import from unintentional directories + # (i.e, an unrelated "ghidra" directory the user may have created) + sys.path.remove(os.getcwd()) + # Install hooks into python importlib sys.meta_path.append(_PyGhidraImportLoader()) sys.meta_path.append(_GhidraBundleFinder())