Skip to content

Commit

Permalink
GT-3334: Changing how we resolve #1250 (fixes #1270).
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmkurtz committed Nov 21, 2019
1 parent 2f0b64a commit c5594d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Expand Up @@ -371,7 +371,7 @@ private void executeNormal() throws Exception {
}

@Override
protected DomainFolder getProjectRootFolder() {
public DomainFolder getProjectRootFolder() {
if (isRunningHeadless()) {
Project project = state.getProject();
ProjectData projectData = project.getProjectData();
Expand Down
Expand Up @@ -2473,7 +2473,7 @@ public void saveProgram(Program program, List<String> path) throws Exception {
* 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();
Expand Down
Expand Up @@ -69,11 +69,6 @@ public static GhidraPythonInterpreter get() {
// 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;
Expand Down Expand Up @@ -348,12 +343,16 @@ private void injectScriptHierarchy(PythonScript script) {
}
}

// 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);
}
Expand Down

0 comments on commit c5594d2

Please sign in to comment.