Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6014: Setting minimum java version in OSGi bundles, and adding "Bundle Location ID" hidden column

Ryan Kurtzcca597318ee0
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
index 2045cafd90..6b11e7b968 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -396,6 +396,7 @@ public class BundleStatusTableModel
columnDescriptor.addVisibleColumn(new BuildSummaryColumn());
columnDescriptor.addHiddenColumn(new OSGiStatusColumn());
columnDescriptor.addHiddenColumn(new BundleTypeColumn());
+ columnDescriptor.addHiddenColumn(new BundleLocationId());
return columnDescriptor;
}
@@ -548,6 +549,27 @@ public class BundleStatusTableModel
}
}
+
+ private class BundleLocationId extends Column<String> {
+
+ BundleLocationId() {
+ super("Bundle Location ID");
+ }
+
+ @Override
+ public String getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
+ ServiceProvider serviceProvider0) throws IllegalArgumentException {
+ GhidraBundle bundle = bundleHost.getGhidraBundle(status.getFile());
+ if (bundle != null) {
+ String id = bundle.getLocationIdentifier();
+ if (id != null) {
+ return id;
+ }
+ }
+ return "";
+ }
+
+ }
private class BundleFileRenderer extends AbstractGColumnRenderer<ResourceFile> {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java
index b5ffdfdadc..7b02ecf671 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java
@@ -45,6 +45,8 @@ import aQute.bnd.osgi.Clazz.QUERY;
import generic.io.NullPrintWriter;
import generic.jar.ResourceFile;
import ghidra.app.script.*;
+import ghidra.framework.Application;
+import ghidra.framework.ApplicationProperties;
import ghidra.util.Msg;
import util.CollectionUtils;
import utilities.util.FileUtilities;
@@ -880,6 +882,13 @@ public class GhidraSourceBundle extends GhidraBundle {
analyzer.setProperty("Export-Package", "!*.private.*,!*.internal.*,*");
+ String minJava =
+ Application.getApplicationProperty(ApplicationProperties.APPLICATION_JAVA_MIN_PROPERTY);
+ if (minJava != null) {
+ analyzer.setProperty("Require-Capability",
+ "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version>=%s))\"".formatted(minJava));
+ }
+
try {
Manifest manifest;
try {