mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-27 14:41:50 +00:00
GT-3334: Protected GhidraScript/FlatProgramAPI methods can now be called
from python (fixes #1250)
This commit is contained in:
parent
7cd82462e9
commit
4496e51b0b
@ -69,6 +69,11 @@ 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;
|
||||
@ -343,11 +348,12 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
||||
}
|
||||
}
|
||||
|
||||
// Add public methods only once. Ignore inner classes.
|
||||
// Add public and protected methods (only once). Ignore inner classes.
|
||||
if (!scriptMethodsInjected) {
|
||||
for (Method method : scriptClass.getDeclaredMethods()) {
|
||||
if (!method.getName().contains("$") &&
|
||||
Modifier.isPublic(method.getModifiers())) {
|
||||
(Modifier.isPublic(method.getModifiers()) ||
|
||||
Modifier.isProtected(method.getModifiers()))) {
|
||||
method.setAccessible(true);
|
||||
setMethod(script, method);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user