Skip to content

Ghidra is a software reverse engineering (SRE) framework

a status is not a path

Jason P. Leasure15f46b7fae68
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleCompiler.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleCompiler.java
index f393d7f92e..df90f4b8d0 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleCompiler.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleCompiler.java
@@ -77,7 +77,6 @@ public class BundleCompiler {
options.add(System.getProperty("java.class.path") + File.pathSeparator + bindir.toString());
options.add("-proc:none");
- // final JavaFileManager rfm = new ResourceFileJavaFileManager(Collections.singletonList(bi.getSourceDir()));
final JavaFileManager rfm =
new ResourceFileJavaFileManager(Collections.singletonList(sb.getSourceDir()));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java
index 894ae00268..9772c00a61 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatus.java
@@ -19,13 +19,29 @@ import generic.jar.ResourceFile;
import generic.util.Path;
/**
- * The BundleStatus class represents the runtime state and user preferences for OSGi bundles in Ghidra.
+ * The BundleStatus class represents the runtime state and user preferences for OSGi bundles in Ghidra.
+ *
+ * XXX: this class relies on generic.util.Path solely for the parsing and formatting of USER_HOME and GHIDRA_HOME
*/
-public class BundleStatus extends Path {
+public class BundleStatus implements Comparable<BundleStatus> {
+ final Path path;
final GhidraBundle.Type type;
boolean active = false;
boolean busy = false;
+
+ public boolean isEnabled() {
+ return path.isEnabled();
+ }
+
+ public void setEnabled(boolean isEnabled) {
+ path.setEnabled(isEnabled);
+ }
+
+ public boolean isReadOnly() {
+ return path.isReadOnly();
+ }
+
String summary;
public GhidraBundle.Type getType() {
@@ -33,12 +49,12 @@ public class BundleStatus extends Path {
}
BundleStatus(String path, boolean enabled, boolean readonly) {
- super(path, enabled, false /*editable */, readonly);
+ this.path = new Path(path, enabled, false, readonly);
type = GhidraBundle.getType(getPath());
}
BundleStatus(ResourceFile path, boolean enabled, boolean readonly) {
- super(path, enabled, false /* editable */, readonly);
+ this.path = new Path(path, enabled, false, readonly);
type = GhidraBundle.getType(getPath());
}
@@ -50,11 +66,6 @@ public class BundleStatus extends Path {
return active;
}
- @Override
- public boolean isEditable() {
- return false;
- }
-
public void setActive(boolean b) {
active = b;
}
@@ -75,8 +86,21 @@ public class BundleStatus extends Path {
return summary;
}
+ public ResourceFile getPath() {
+ return path.getPath();
+ }
+
public boolean pathExists() {
- return exists();
+ return path.exists();
+ }
+
+ @Override
+ public int compareTo(BundleStatus o) {
+ return path.compareTo(o != null ? o.path : null);
+ }
+
+ public String getPathAsString() {
+ return path.getPathAsString();
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusModel.java
index 7aa7f9b6fa..4f8b98d4fa 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusModel.java
@@ -99,10 +99,10 @@ public class BundleStatusModel extends AbstractSortedTableModel<BundleStatus> {
}
};
- Column pathColumn = new Column("Path", String.class) {
+ Column pathColumn = new Column("Path", ResourceFile.class) {
@Override
Object getValue(BundleStatus status) {
- return status.getPath().toString();
+ return status.getPath();
}
};
Column summaryColumn = new Column("Summary", String.class) {
@@ -164,7 +164,7 @@ public class BundleStatusModel extends AbstractSortedTableModel<BundleStatus> {
// add user path
this.statuses.add(0,
new BundleStatus(GhidraScriptUtil.getUserScriptDirectory(), true, false));
-
+
computeCache();
bundleHost.addListener(bundleListener = new OSGiListener() {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusProvider.java
index e6d7cd0191..b4322718dc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusProvider.java
@@ -27,6 +27,7 @@ import javax.swing.table.TableColumn;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.table.*;
+import generic.jar.ResourceFile;
import ghidra.app.services.ConsoleService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.PluginTool;
@@ -182,8 +183,8 @@ public class BundleStatusProvider extends ComponentProviderAdapter {
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
JLabel c = (JLabel) super.getTableCellRendererComponent(data);
- BundleStatus status = (BundleStatus) data.getValue();
- if (!status.pathExists()) {
+ ResourceFile path = (ResourceFile) data.getValue();
+ if (!path.exists()) {
c.setForeground(Color.RED);
}
return c;