feat: Update version to 2.0.0-beta.1 and add API version check

- Update Java plugin version to v2.0.0-beta.1
- Add version identifier to bridge script
- Add API version check in bridge to verify plugin compatibility
- Bridge script will now check for API version 2 compatibility
This commit is contained in:
Teal Bauer 2025-04-14 21:28:50 +02:00
parent 6c28553c58
commit fedd2d0a55
2 changed files with 19 additions and 4 deletions

View File

@ -33,13 +33,17 @@ DEFAULT_GHIDRA_HOST = "localhost"
QUICK_DISCOVERY_RANGE = range(DEFAULT_GHIDRA_PORT, DEFAULT_GHIDRA_PORT+10) QUICK_DISCOVERY_RANGE = range(DEFAULT_GHIDRA_PORT, DEFAULT_GHIDRA_PORT+10)
FULL_DISCOVERY_RANGE = range(DEFAULT_GHIDRA_PORT, DEFAULT_GHIDRA_PORT+20) FULL_DISCOVERY_RANGE = range(DEFAULT_GHIDRA_PORT, DEFAULT_GHIDRA_PORT+20)
# Version information
BRIDGE_VERSION = "v2.0.0-beta.1"
REQUIRED_API_VERSION = 2
instructions = """ instructions = """
GhydraMCP allows interacting with multiple Ghidra SRE instances. Ghidra SRE is a tool for reverse engineering and analyzing binaries, e.g. malware. GhydraMCP allows interacting with multiple Ghidra SRE instances. Ghidra SRE is a tool for reverse engineering and analyzing binaries, e.g. malware.
First, run `discover_instances` to find open Ghidra instances. List tools to see what GhydraMCP can do. First, run `discover_instances` to find open Ghidra instances. List tools to see what GhydraMCP can do.
""" """
mcp = FastMCP("GhydraMCP", instructions=instructions) mcp = FastMCP("GhydraMCP", version=BRIDGE_VERSION, instructions=instructions)
ghidra_host = os.environ.get("GHIDRA_HYDRA_HOST", DEFAULT_GHIDRA_HOST) ghidra_host = os.environ.get("GHIDRA_HYDRA_HOST", DEFAULT_GHIDRA_HOST)
@ -391,8 +395,19 @@ def register_instance(port: int, url: str = None) -> str:
if "result" in version_data: if "result" in version_data:
result = version_data["result"] result = version_data["result"]
if isinstance(result, dict): if isinstance(result, dict):
project_info["plugin_version"] = result.get("plugin_version", "") plugin_version = result.get("plugin_version", "")
project_info["api_version"] = result.get("api_version", 0) api_version = result.get("api_version", 0)
project_info["plugin_version"] = plugin_version
project_info["api_version"] = api_version
# Verify API version compatibility
if api_version != REQUIRED_API_VERSION:
error_msg = f"API version mismatch: Plugin reports version {api_version}, but bridge requires version {REQUIRED_API_VERSION}"
print(error_msg, file=sys.stderr)
return error_msg
print(f"Connected to Ghidra plugin version {plugin_version} with API version {api_version}")
except Exception as e: except Exception as e:
print(f"Error parsing plugin version: {e}", file=sys.stderr) print(f"Error parsing plugin version: {e}", file=sys.stderr)

View File

@ -1,7 +1,7 @@
package eu.starsong.ghidra.api; package eu.starsong.ghidra.api;
public class ApiConstants { public class ApiConstants {
public static final String PLUGIN_VERSION = "v2.0.0"; public static final String PLUGIN_VERSION = "v2.0.0-beta.1";
public static final int API_VERSION = 2; public static final int API_VERSION = 2;
public static final int DEFAULT_PORT = 8192; public static final int DEFAULT_PORT = 8192;
public static final int MAX_PORT_ATTEMPTS = 10; public static final int MAX_PORT_ATTEMPTS = 10;