mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-4574 - Added support to create transient symbol tables from the
Symbol Tree, Symbol Table and other transient symbol tables
This commit is contained in:
@@ -24,8 +24,9 @@ import javax.swing.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import docking.ComponentProvider;
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.widgets.table.GTable;
|
||||
import docking.widgets.tree.GTree;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import generic.jar.ResourceFile;
|
||||
@@ -60,6 +61,11 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
d = waitForJDialog("New Script");
|
||||
pressButtonByText(d, "OK");
|
||||
|
||||
waitForSwing();
|
||||
|
||||
DialogComponentProvider dialog = waitForDialogComponent("Script Path Added/Enabled");
|
||||
close(dialog);
|
||||
|
||||
captureIsolatedProvider(GhidraScriptEditorComponentProvider.class, 597, 600);
|
||||
}
|
||||
|
||||
@@ -88,10 +94,8 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
@Test
|
||||
public void testAssign_Key_Binding() throws Exception {
|
||||
|
||||
ComponentProvider componentProvider = showProvider(GhidraScriptComponentProvider.class);
|
||||
JComponent component = componentProvider.getComponent();
|
||||
DraggableScriptTable scriptTable =
|
||||
(DraggableScriptTable) findComponentByName(component, "SCRIPT_TABLE");
|
||||
GhidraScriptComponentProvider provider = showProvider(GhidraScriptComponentProvider.class);
|
||||
GTable scriptTable = provider.getTable();
|
||||
selectRow(scriptTable, "HelloWorldScript.java");
|
||||
|
||||
performAction("Key Binding", "GhidraScriptMgrPlugin", false);
|
||||
@@ -101,10 +105,8 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
@Test
|
||||
public void testSelect_Font() throws Exception {
|
||||
|
||||
ComponentProvider componentProvider = showProvider(GhidraScriptComponentProvider.class);
|
||||
JComponent component = componentProvider.getComponent();
|
||||
DraggableScriptTable scriptTable =
|
||||
(DraggableScriptTable) findComponentByName(component, "SCRIPT_TABLE");
|
||||
GhidraScriptComponentProvider provider = showProvider(GhidraScriptComponentProvider.class);
|
||||
GTable scriptTable = provider.getTable();
|
||||
|
||||
selectRow(scriptTable, "HelloWorldScript.java");
|
||||
performAction("Edit", "GhidraScriptMgrPlugin", false);
|
||||
@@ -132,37 +134,26 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
@Test
|
||||
public void testEdit_Script() throws Exception {
|
||||
|
||||
ResourceFile newScript = createHelloWorldScript("MyHelloWorldScript");
|
||||
ComponentProvider componentProvider = showProvider(GhidraScriptComponentProvider.class);
|
||||
createHelloWorldScript("MyHelloWorldScript");
|
||||
GhidraScriptComponentProvider provider = showProvider(GhidraScriptComponentProvider.class);
|
||||
|
||||
JComponent component = componentProvider.getComponent();
|
||||
DraggableScriptTable scriptTable =
|
||||
(DraggableScriptTable) findComponentByName(component, "SCRIPT_TABLE");
|
||||
selectRow(scriptTable, newScript.getName());
|
||||
performAction("Edit", "GhidraScriptMgrPlugin", false);
|
||||
|
||||
waitForSwing();
|
||||
|
||||
GhidraScriptEditorComponentProvider provider =
|
||||
getProvider(GhidraScriptEditorComponentProvider.class);
|
||||
|
||||
moveProviderToFront(provider, 557, 378);
|
||||
captureProvider(provider);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScript_Manager() {
|
||||
ComponentProvider scriptManager = showProvider(GhidraScriptComponentProvider.class);
|
||||
JComponent component = scriptManager.getComponent();
|
||||
GhidraScriptComponentProvider provider = showProvider(GhidraScriptComponentProvider.class);
|
||||
JComponent component = provider.getComponent();
|
||||
final JSplitPane splitPane =
|
||||
(JSplitPane) findComponentByName(component, "dataDescriptionSplit");
|
||||
runSwing(() -> splitPane.setDividerLocation(0.63));
|
||||
|
||||
DraggableScriptTable scriptTable =
|
||||
(DraggableScriptTable) findComponentByName(component, "SCRIPT_TABLE");
|
||||
|
||||
GTree scriptCategoryTree = (GTree) findComponentByName(component, "CATEGORY_TREE");
|
||||
removeSuspectNodes(scriptCategoryTree);
|
||||
GTable scriptTable = provider.getTable();
|
||||
GTree scriptCategoryTree = provider.getTree();
|
||||
|
||||
selectPath(scriptCategoryTree, "Scripts", "Examples");
|
||||
collapse(scriptCategoryTree, "Examples");// don't open examples (silly JTree)
|
||||
@@ -170,8 +161,8 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
selectRow(scriptTable, "HelloWorldScript.java");
|
||||
scriptTable.scrollToSelectedRow();
|
||||
|
||||
moveProviderToFront(scriptManager, 1333, 570);
|
||||
captureProvider(scriptManager);
|
||||
moveProviderToFront(provider, 1333, 570);
|
||||
captureProvider(provider);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,10 +187,8 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
public void testDelete_Script_Confirm() throws Exception {
|
||||
createHelloWorldScript("FooScript");
|
||||
|
||||
ComponentProvider componentProvider = showProvider(GhidraScriptComponentProvider.class);
|
||||
JComponent component = componentProvider.getComponent();
|
||||
DraggableScriptTable scriptTable =
|
||||
(DraggableScriptTable) findComponentByName(component, "SCRIPT_TABLE");
|
||||
GhidraScriptComponentProvider provider = showProvider(GhidraScriptComponentProvider.class);
|
||||
GTable scriptTable = provider.getTable();
|
||||
selectRow(scriptTable, "FooScript.java");
|
||||
performAction("Delete", "GhidraScriptMgrPlugin", false);
|
||||
captureDialog();
|
||||
@@ -278,27 +267,6 @@ public class GhidraScriptMgrPluginScreenShots extends GhidraScreenShotGenerator
|
||||
});
|
||||
}
|
||||
|
||||
private void removeSuspectNodes(final GTree scriptCategoryTree) {
|
||||
List<String> accepted = new ArrayList<>(
|
||||
Arrays.asList("Examples", "Data Types", "Binary", "Functions", "Import", "Analysis"));
|
||||
|
||||
List<GTreeNode> toRemove = new ArrayList<>();
|
||||
final GTreeNode rootNode = scriptCategoryTree.getViewRoot();
|
||||
List<GTreeNode> children = rootNode.getChildren();
|
||||
for (GTreeNode child : children) {
|
||||
String name = child.getName();
|
||||
if (!accepted.contains(name)) {
|
||||
toRemove.add(child);
|
||||
}
|
||||
}
|
||||
|
||||
for (GTreeNode node : toRemove) {
|
||||
rootNode.removeNode(node);
|
||||
}
|
||||
|
||||
waitForTree(scriptCategoryTree);
|
||||
}
|
||||
|
||||
private ResourceFile createTempScriptFile(String name) {
|
||||
File userScriptsDir = new File(GhidraScriptUtil.USER_SCRIPTS_DIR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user