Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java packages overshadow Python modules when resolving imports #38

Closed
mike-hunhoff opened this issue Mar 28, 2023 · 3 comments · Fixed by #41
Closed

Java packages overshadow Python modules when resolving imports #38

mike-hunhoff opened this issue Mar 28, 2023 · 3 comments · Fixed by #41
Labels
bug Something isn't working

Comments

@mike-hunhoff
Copy link
Collaborator

mike-hunhoff commented Mar 28, 2023

Hi @0ddc0de - thank you for reaching out. TLDR; this unfortunately appears to be a bug in Ghidrathon. In theory, after fixing this bug what you are trying to do should work, although, I am uncertain without testing how dropping into a REPL may mess with headless execution flow.

Long winded explanation and notes:

Based on ImportError: java.lang.ClassNotFoundException: pdb.Pdb it appears Ghidra's ghidra.app.util.bin.format.pdb package is overshadowing Python's pdb module. This is likely due to Jep's import hook giving preference to Java over Python when resolving imports.

We should give preference to Python when executing Python code but still allow access to the overshadowed Java package. This likely requires wrapping Jep's ClassEnquirer as discussed here or modifying Jep's java_import_hook.py.

Originally posted by @mike-hunhoff in #37 (comment)

@mike-hunhoff
Copy link
Collaborator Author

mike-hunhoff commented Apr 21, 2023

Actual source of conflict from above is Ghidra's pdb plugin. It's unlikely that users want access to Ghidra's pdb from Python so we can simply give precedence to Python's pdb in this case. This may be as simple as adding pdb to the list of restricted package names.

@mike-hunhoff
Copy link
Collaborator Author

However, this doesn't solve the problem for other conflicts that may surface. We can check the full list of Java names checked by inspecting Jep's packageToClassMap and packageToSubPackageMap .

@mike-hunhoff
Copy link
Collaborator Author

Jep discussion here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant