mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-10-23 05:31:02 +00:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
d03a8a1b38
|
@ -302,6 +302,22 @@ public class BundleHost {
|
|||
return bundleMap.getBundleFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of currently managed enabled bundle files.
|
||||
*
|
||||
* @return all the enabled bundle files
|
||||
*/
|
||||
public Collection<ResourceFile> getEnabledBundleFiles() {
|
||||
List<ResourceFile> enabledList = new ArrayList<>();
|
||||
for (ResourceFile bundleFile : bundleMap.getBundleFiles()) {
|
||||
GhidraBundle bundle = bundleMap.get(bundleFile);
|
||||
if (bundle.isEnabled()) {
|
||||
enabledList.add(bundleFile);
|
||||
}
|
||||
}
|
||||
return enabledList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to resolve a list of BundleRequirements with active Bundle capabilities.
|
||||
*
|
||||
|
|
|
@ -123,6 +123,17 @@ public class GhidraScriptUtil {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the current enabled script directories.
|
||||
* @return a list of the current enabled script directories
|
||||
*/
|
||||
public static List<ResourceFile> getEnabledScriptSourceDirectories() {
|
||||
return bundleHost.getEnabledBundleFiles()
|
||||
.stream()
|
||||
.filter(ResourceFile::isDirectory)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the currently managed source directories for the given script file.
|
||||
*
|
||||
|
|
|
@ -121,8 +121,6 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||
|
||||
// Add __builtin__ module for code completion
|
||||
builtinModule = (PyModule) imp.load("__builtin__");
|
||||
|
||||
initializePythonPath();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,7 +132,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||
systemState.path.retainAll(defaultPythonPath);
|
||||
|
||||
// Add in Ghidra script source directories
|
||||
for (ResourceFile resourceFile : GhidraScriptUtil.getScriptSourceDirectories()) {
|
||||
for (ResourceFile resourceFile : GhidraScriptUtil.getEnabledScriptSourceDirectories()) {
|
||||
systemState.path.append(Py.newStringOrUnicode(resourceFile.getFile(false).getAbsolutePath()));
|
||||
}
|
||||
|
||||
|
@ -168,6 +166,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||
"Ghidra python interpreter has already been cleaned up.");
|
||||
}
|
||||
|
||||
initializePythonPath();
|
||||
injectScriptHierarchy(script);
|
||||
|
||||
if (buffer.length() > 0) {
|
||||
|
@ -207,6 +206,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||
"Ghidra python interpreter has already been cleaned up.");
|
||||
}
|
||||
|
||||
initializePythonPath();
|
||||
injectScriptHierarchy(script);
|
||||
|
||||
Py.getThreadState().tracefunc = interruptTraceFunction;
|
||||
|
|
Loading…
Reference in New Issue
Block a user