GT-3334: Changing how we resolve #1250 (fixes #1270).

This commit is contained in:
Ryan Kurtz 2019-11-21 09:00:10 -05:00
parent 2f0b64a31a
commit c5594d2b91
3 changed files with 9 additions and 10 deletions

View File

@ -371,7 +371,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
}
@Override
protected DomainFolder getProjectRootFolder() {
public DomainFolder getProjectRootFolder() {
if (isRunningHeadless()) {
Project project = state.getProject();
ProjectData projectData = project.getProjectData();

View File

@ -2473,7 +2473,7 @@ public class FlatProgramAPI {
* the root domain folder.
* @return the root domain folder of the current project
*/
protected DomainFolder getProjectRootFolder() {
public DomainFolder getProjectRootFolder() {
Project project = AppInfo.getActiveProject();
ProjectData projectData = project.getProjectData();
DomainFolder folder = projectData.getRootFolder();

View File

@ -69,11 +69,6 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
// Setup python cache directory
PythonUtils.setupPythonCacheDir(TaskMonitor.DUMMY);
// Enable protected java methods to be accessed from python sub-classes.
// This is necessary to be able to call protected GhidraScript/FlatProgram API
// methods from a python script.
System.setProperty("python.security.respectJavaAccessibility", "false");
// Indicate that we've initialized the python environment, which should
// only happen once.
pythonInitialized = true;
@ -348,12 +343,16 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
}
}
// Add public and protected methods (only once). Ignore inner classes.
// Add public methods (only once). Ignore inner classes.
//
// NOTE: We currently do not have a way to safely add protected methods. Disabling
// python.security.respectJavaAccessibility and adding in protected methods in the below
// loop caused an InaccessibleObjectException for some users (relating to core Java
// modules, not the GhidraScript class hierarchy).
if (!scriptMethodsInjected) {
for (Method method : scriptClass.getDeclaredMethods()) {
if (!method.getName().contains("$") &&
(Modifier.isPublic(method.getModifiers()) ||
Modifier.isProtected(method.getModifiers()))) {
Modifier.isPublic(method.getModifiers())) {
method.setAccessible(true);
setMethod(script, method);
}