mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-29 23:55:40 +08:00
GP-6132: Fixed a bug in the the PyGhidra headless analyzer that resulted in the wrong exception being thrown when a script tries to import a module that isn't found
This commit is contained in:
@@ -18,7 +18,6 @@ package ghidra.pyghidra;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import ghidra.app.plugin.core.osgi.BundleHost;
|
||||
import ghidra.app.script.GhidraScriptUtil;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
@@ -35,14 +34,14 @@ public class PyGhidraPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
public void setUp() throws Exception {
|
||||
env = new TestEnv();
|
||||
PluginTool tool = env.getTool();
|
||||
GhidraScriptUtil.initialize(new BundleHost(), null);
|
||||
GhidraScriptUtil.acquireBundleHostReference();
|
||||
tool.addPlugin(PyGhidraPlugin.class.getName());
|
||||
env.getPlugin(PyGhidraPlugin.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
GhidraScriptUtil.dispose();
|
||||
GhidraScriptUtil.releaseBundleHostReference();
|
||||
env.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -26,7 +26,6 @@ import javax.swing.KeyStroke;
|
||||
import org.junit.*;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.plugin.core.osgi.BundleHost;
|
||||
import ghidra.app.script.GhidraScriptUtil;
|
||||
import ghidra.app.script.ScriptInfo;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
@@ -35,7 +34,7 @@ public class PythonScriptInfoTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
GhidraScriptUtil.initialize(new BundleHost(), null);
|
||||
GhidraScriptUtil.acquireBundleHostReference();
|
||||
Path userScriptDir = java.nio.file.Paths.get(GhidraScriptUtil.USER_SCRIPTS_DIR);
|
||||
if (Files.notExists(userScriptDir)) {
|
||||
Files.createDirectories(userScriptDir);
|
||||
@@ -44,7 +43,7 @@ public class PythonScriptInfoTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
GhidraScriptUtil.dispose();
|
||||
GhidraScriptUtil.releaseBundleHostReference();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user