Skip to content

Commit c5594d2

Browse files
committed
GT-3334: Changing how we resolve NationalSecurityAgency#1250 (fixes NationalSecurityAgency#1270).
1 parent 2f0b64a commit c5594d2

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScript.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ private void executeNormal() throws Exception {
371371
}
372372

373373
@Override
374-
protected DomainFolder getProjectRootFolder() {
374+
public DomainFolder getProjectRootFolder() {
375375
if (isRunningHeadless()) {
376376
Project project = state.getProject();
377377
ProjectData projectData = project.getProjectData();

Ghidra/Features/Base/src/main/java/ghidra/program/flatapi/FlatProgramAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,7 @@ public void saveProgram(Program program, List<String> path) throws Exception {
24732473
* the root domain folder.
24742474
* @return the root domain folder of the current project
24752475
*/
2476-
protected DomainFolder getProjectRootFolder() {
2476+
public DomainFolder getProjectRootFolder() {
24772477
Project project = AppInfo.getActiveProject();
24782478
ProjectData projectData = project.getProjectData();
24792479
DomainFolder folder = projectData.getRootFolder();

Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ public static GhidraPythonInterpreter get() {
6969
// Setup python cache directory
7070
PythonUtils.setupPythonCacheDir(TaskMonitor.DUMMY);
7171

72-
// Enable protected java methods to be accessed from python sub-classes.
73-
// This is necessary to be able to call protected GhidraScript/FlatProgram API
74-
// methods from a python script.
75-
System.setProperty("python.security.respectJavaAccessibility", "false");
76-
7772
// Indicate that we've initialized the python environment, which should
7873
// only happen once.
7974
pythonInitialized = true;
@@ -348,12 +343,16 @@ private void injectScriptHierarchy(PythonScript script) {
348343
}
349344
}
350345

351-
// Add public and protected methods (only once). Ignore inner classes.
346+
// Add public methods (only once). Ignore inner classes.
347+
//
348+
// NOTE: We currently do not have a way to safely add protected methods. Disabling
349+
// python.security.respectJavaAccessibility and adding in protected methods in the below
350+
// loop caused an InaccessibleObjectException for some users (relating to core Java
351+
// modules, not the GhidraScript class hierarchy).
352352
if (!scriptMethodsInjected) {
353353
for (Method method : scriptClass.getDeclaredMethods()) {
354354
if (!method.getName().contains("$") &&
355-
(Modifier.isPublic(method.getModifiers()) ||
356-
Modifier.isProtected(method.getModifiers()))) {
355+
Modifier.isPublic(method.getModifiers())) {
357356
method.setAccessible(true);
358357
setMethod(script, method);
359358
}

0 commit comments

Comments
 (0)